@vonage/vivid 3.39.0 → 3.40.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 (147) hide show
  1. package/accordion/index.js +1 -1
  2. package/accordion-item/index.js +1 -1
  3. package/alert/index.js +3 -2
  4. package/banner/index.js +2 -1
  5. package/breadcrumb-item/index.js +1 -1
  6. package/button/index.js +2 -1
  7. package/card/index.js +1 -1
  8. package/checkbox/index.js +1 -1
  9. package/combobox/index.js +5 -3
  10. package/custom-elements.json +512 -0
  11. package/data-grid/index.js +1 -0
  12. package/date-picker/index.js +6 -4
  13. package/date-range-picker/index.js +5 -3
  14. package/dialog/index.js +6 -2
  15. package/elevation/index.js +1 -1
  16. package/fab/index.js +1 -1
  17. package/file-picker/index.js +2 -1
  18. package/focus/index.js +1 -1
  19. package/header/index.js +1 -1
  20. package/index.js +23 -19
  21. package/lib/checkbox/checkbox.d.ts +1 -0
  22. package/lib/components.d.ts +1 -0
  23. package/lib/dialog/dialog.d.ts +4 -0
  24. package/lib/dialog/locale.d.ts +3 -0
  25. package/lib/menu/menu.d.ts +1 -0
  26. package/lib/number-field/locale.d.ts +4 -0
  27. package/lib/number-field/number-field.d.ts +4 -2
  28. package/lib/progress/progress.d.ts +1 -0
  29. package/lib/progress-ring/progress-ring.d.ts +1 -0
  30. package/lib/radio/radio.d.ts +1 -0
  31. package/lib/selectable-box/definition.d.ts +3 -0
  32. package/lib/selectable-box/selectable-box.d.ts +13 -0
  33. package/lib/selectable-box/selectable-box.template.d.ts +4 -0
  34. package/lib/slider/definition.d.ts +1 -0
  35. package/lib/slider/slider.d.ts +5 -0
  36. package/lib/text-area/text-area.d.ts +3 -0
  37. package/lib/text-field/text-field.d.ts +5 -2
  38. package/listbox/index.js +3 -2
  39. package/locales/en-GB.js +7 -0
  40. package/locales/en-US.js +7 -0
  41. package/locales/ja-JP.js +7 -0
  42. package/locales/zh-CN.js +7 -0
  43. package/menu/index.js +4 -3
  44. package/menu-item/index.js +1 -1
  45. package/nav-disclosure/index.js +1 -1
  46. package/nav-item/index.js +1 -1
  47. package/number-field/index.js +3 -1
  48. package/option/index.js +1 -1
  49. package/package.json +1 -1
  50. package/pagination/index.js +2 -1
  51. package/popup/index.js +4 -3
  52. package/radio/index.js +1 -1
  53. package/select/index.js +5 -3
  54. package/selectable-box/index.js +23 -0
  55. package/shared/Reflector.js +65 -0
  56. package/shared/date-picker/calendar/segment.d.ts +21 -0
  57. package/shared/date-picker/date-picker-base.d.ts +1 -0
  58. package/shared/definition.js +2 -2
  59. package/shared/definition10.js +4 -73
  60. package/shared/definition11.js +1 -1
  61. package/shared/definition12.js +1 -1
  62. package/shared/definition13.js +2 -2
  63. package/shared/definition14.js +12 -5
  64. package/shared/definition15.js +3 -3
  65. package/shared/definition16.js +22 -8
  66. package/shared/definition17.js +5 -5
  67. package/shared/definition18.js +15 -8
  68. package/shared/definition19.js +18 -10
  69. package/shared/definition2.js +2 -2
  70. package/shared/definition20.js +1 -1
  71. package/shared/definition21.js +1 -1
  72. package/shared/definition22.js +2 -2
  73. package/shared/definition23.js +4 -3
  74. package/shared/definition24.js +2 -2
  75. package/shared/definition27.js +13 -4
  76. package/shared/definition28.js +2 -2
  77. package/shared/definition29.js +2 -2
  78. package/shared/definition3.js +1 -1
  79. package/shared/definition30.js +2 -2
  80. package/shared/definition32.js +1 -1
  81. package/shared/definition33.js +19 -4
  82. package/shared/definition34.js +2 -2
  83. package/shared/definition35.js +3 -2
  84. package/shared/definition36.js +11 -3
  85. package/shared/definition37.js +13 -9
  86. package/shared/definition38.js +2 -2
  87. package/shared/definition39.js +5 -4
  88. package/shared/definition4.js +4 -3
  89. package/shared/definition40.js +4 -4
  90. package/shared/definition41.js +111 -76
  91. package/shared/definition42.js +77 -557
  92. package/shared/definition43.js +568 -102
  93. package/shared/definition44.js +104 -135
  94. package/shared/definition45.js +153 -17
  95. package/shared/definition46.js +16 -79
  96. package/shared/definition47.js +53 -475
  97. package/shared/definition48.js +493 -25
  98. package/shared/definition49.js +22 -121
  99. package/shared/definition5.js +1 -1
  100. package/shared/definition50.js +114 -261
  101. package/shared/definition51.js +258 -119
  102. package/shared/definition52.js +258 -109
  103. package/shared/definition53.js +84 -74
  104. package/shared/definition54.js +114 -69
  105. package/shared/definition55.js +81 -292
  106. package/shared/definition56.js +302 -13
  107. package/shared/definition57.js +11 -41
  108. package/shared/definition58.js +20 -154
  109. package/shared/definition59.js +181 -0
  110. package/shared/definition6.js +1 -1
  111. package/shared/definition7.js +3 -2
  112. package/shared/definition8.js +2 -2
  113. package/shared/enums.js +71 -0
  114. package/shared/icon.js +1 -1
  115. package/shared/index2.js +28 -1
  116. package/shared/key-codes.js +1 -1
  117. package/shared/key-codes2.js +9 -0
  118. package/shared/listbox.js +2 -7
  119. package/shared/localization/Locale.d.ts +4 -0
  120. package/shared/presentationDate.js +194 -141
  121. package/shared/radio.js +7 -0
  122. package/shared/text-field.js +1 -1
  123. package/shared/utils/Reflector.d.ts +8 -0
  124. package/shared/utils/randomId.d.ts +1 -0
  125. package/side-drawer/index.js +1 -1
  126. package/slider/index.js +2 -2
  127. package/split-button/index.js +2 -2
  128. package/style.css +686 -559
  129. package/styles/core/all.css +1 -1
  130. package/styles/core/theme.css +1 -1
  131. package/styles/core/typography.css +1 -1
  132. package/styles/tokens/theme-dark.css +4 -4
  133. package/styles/tokens/theme-light.css +4 -4
  134. package/styles/tokens/vivid-2-compat.css +1 -1
  135. package/switch/index.js +2 -2
  136. package/tab/index.js +2 -2
  137. package/tab-panel/index.js +1 -1
  138. package/tabs/index.js +4 -4
  139. package/tag/index.js +2 -2
  140. package/tag-group/index.js +1 -1
  141. package/text-area/index.js +3 -2
  142. package/text-field/index.js +3 -2
  143. package/toggletip/index.js +5 -4
  144. package/tooltip/index.js +5 -4
  145. package/tree-item/index.js +2 -2
  146. package/tree-view/index.js +1 -1
  147. package/vivid.api.json +141 -0
@@ -1,9 +1,83 @@
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';
1
+ import { a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { f as focusRegistries } from './definition57.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 { R as Reflector } from './Reflector.js';
7
+ import { T as TextField$1 } from './text-field2.js';
8
+ import { a as applyMixins } from './apply-mixins.js';
9
+ import { s as styles } from './text-field.js';
10
+ import { f as focusTemplateFactory } from './focus2.js';
3
11
  import { w as when } from './when.js';
12
+ import { s as slotted } from './slotted.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, 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}";
15
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
16
+ // require the crypto API and do not support built-in fallback to lower quality random number
17
+ // generators (like Math.random()).
18
+ let getRandomValues;
19
+ const rnds8 = new Uint8Array(16);
20
+ function rng() {
21
+ // lazy load so that environments that need to polyfill have a chance to do so
22
+ if (!getRandomValues) {
23
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
24
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
25
+
26
+ if (!getRandomValues) {
27
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
28
+ }
29
+ }
30
+
31
+ return getRandomValues(rnds8);
32
+ }
33
+
34
+ /**
35
+ * Convert array of 16 byte values to UUID string format of the form:
36
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
37
+ */
38
+
39
+ const byteToHex = [];
40
+
41
+ for (let i = 0; i < 256; ++i) {
42
+ byteToHex.push((i + 0x100).toString(16).slice(1));
43
+ }
44
+
45
+ function unsafeStringify(arr, offset = 0) {
46
+ // Note: Be careful editing this code! It's been tuned for performance
47
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
48
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
49
+ }
50
+
51
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
52
+ const native = {
53
+ randomUUID
54
+ };
55
+
56
+ function v4(options, buf, offset) {
57
+ if (native.randomUUID && !buf && !options) {
58
+ return native.randomUUID();
59
+ }
60
+
61
+ options = options || {};
62
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
63
+
64
+ rnds[6] = rnds[6] & 0x0f | 0x40;
65
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
66
+
67
+ if (buf) {
68
+ offset = offset || 0;
69
+
70
+ for (let i = 0; i < 16; ++i) {
71
+ buf[offset + i] = rnds[i];
72
+ }
73
+
74
+ return buf;
75
+ }
76
+
77
+ return unsafeStringify(rnds);
78
+ }
79
+
80
+ const generateRandomId = () => v4();
7
81
 
8
82
  var __defProp = Object.defineProperty;
9
83
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16,135 +90,210 @@ var __decorateClass = (decorators, target, key, kind) => {
16
90
  __defProp(target, key, result);
17
91
  return result;
18
92
  };
19
- class Toggletip extends FoundationElement {
93
+ const safariWorkaroundClassName = "_vvd-3-text-field-safari-workaround";
94
+ const safariWorkaroundStyleSheet = new CSSStyleSheet();
95
+ safariWorkaroundStyleSheet.replaceSync(`
96
+ .${safariWorkaroundClassName}::placeholder {
97
+ opacity: 1 !important;
98
+ -webkit-text-fill-color: var(--_low-ink-color) !important;
99
+ }`);
100
+ const installSafariWorkaroundStyle = (forElement) => {
101
+ const root = forElement.getRootNode();
102
+ if (!root.adoptedStyleSheets.includes(safariWorkaroundStyleSheet)) {
103
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, safariWorkaroundStyleSheet];
104
+ }
105
+ };
106
+ let TextField = class extends TextField$1 {
20
107
  constructor() {
21
108
  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
- };
109
+ /**
110
+ * @internal
111
+ */
112
+ this._labelEl = null;
52
113
  }
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);
114
+ /**
115
+ * @internal
116
+ */
117
+ labelChanged() {
118
+ if (this._labelEl) {
119
+ this.#handleLabelChange(this._labelEl);
66
120
  }
67
121
  }
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");
122
+ #handleLabelChange(labelEl) {
123
+ if (!this.label) {
124
+ labelEl.remove();
75
125
  } else {
76
- document.removeEventListener("click", this.#closeOnClickOutside);
77
- document.removeEventListener("keydown", this.#closeOnEscape);
78
- this.removeAttribute("role");
126
+ labelEl.textContent = this.label;
127
+ if (!labelEl.isConnected) {
128
+ this.appendChild(labelEl);
129
+ }
79
130
  }
80
- if (this.#anchorEl) {
81
- this.#anchorEl.ariaExpanded = this.open.toString();
131
+ }
132
+ #reflectToInput;
133
+ connectedCallback() {
134
+ super.connectedCallback();
135
+ if (!this.control) {
136
+ const uniqueId = this.id || generateRandomId();
137
+ const controlId = `vvd-text-field-control-${uniqueId}`;
138
+ const input = document.createElement("input");
139
+ input.slot = "_control";
140
+ input.id = controlId;
141
+ input.className = safariWorkaroundClassName;
142
+ this.control = input;
143
+ this.#reflectToInput = new Reflector(this, input);
144
+ this.#reflectToInput.booleanAttribute("autofocus", "autofocus");
145
+ this.#reflectToInput.booleanAttribute("disabled", "disabled");
146
+ this.#reflectToInput.booleanAttribute("readOnly", "readonly");
147
+ this.#reflectToInput.booleanAttribute("required", "required");
148
+ this.#reflectToInput.booleanAttribute("spellcheck", "spellcheck");
149
+ this.#reflectToInput.attribute("list", "list");
150
+ this.#reflectToInput.attribute("maxlength", "maxlength");
151
+ this.#reflectToInput.attribute("minlength", "minlength");
152
+ this.#reflectToInput.attribute("pattern", "pattern");
153
+ this.#reflectToInput.attribute("placeholder", "placeholder");
154
+ this.#reflectToInput.attribute("size", "size");
155
+ this.#reflectToInput.attribute("autoComplete", "autocomplete");
156
+ this.#reflectToInput.attribute("type", "type");
157
+ this.#reflectToInput.attribute("ariaAtomic", "aria-atomic");
158
+ this.#reflectToInput.attribute("ariaBusy", "aria-busy");
159
+ this.#reflectToInput.attribute("ariaControls", "aria-controls");
160
+ this.#reflectToInput.attribute("ariaCurrent", "aria-current");
161
+ this.#reflectToInput.attribute("ariaDescribedby", "aria-describedby");
162
+ this.#reflectToInput.attribute("ariaDetails", "aria-details");
163
+ this.#reflectToInput.attribute("ariaDisabled", "aria-disabled");
164
+ this.#reflectToInput.attribute("ariaErrormessage", "aria-errormessage");
165
+ this.#reflectToInput.attribute("ariaFlowto", "aria-flowto");
166
+ this.#reflectToInput.attribute("ariaHaspopup", "aria-haspopup");
167
+ this.#reflectToInput.attribute("ariaHidden", "aria-hidden");
168
+ this.#reflectToInput.attribute("ariaInvalid", "aria-invalid");
169
+ this.#reflectToInput.attribute("ariaKeyshortcuts", "aria-keyshortcuts");
170
+ this.#reflectToInput.attribute("ariaLabel", "aria-label");
171
+ this.#reflectToInput.attribute("ariaLabelledby", "aria-labelledby");
172
+ this.#reflectToInput.attribute("ariaLive", "aria-live");
173
+ this.#reflectToInput.attribute("ariaOwns", "aria-owns");
174
+ this.#reflectToInput.attribute("ariaRelevant", "aria-relevant");
175
+ this.#reflectToInput.attribute("ariaRoledescription", "aria-roledescription");
176
+ this.#reflectToInput.property("value", "value", true);
177
+ input.addEventListener("input", () => {
178
+ this.handleTextInput();
179
+ });
180
+ input.addEventListener("change", () => {
181
+ this.handleChange();
182
+ });
183
+ input.addEventListener("blur", () => {
184
+ this.$emit("blur");
185
+ });
186
+ input.addEventListener("focus", () => {
187
+ this.$emit("focus");
188
+ });
189
+ this.appendChild(input);
190
+ const label = document.createElement("label");
191
+ label.slot = "_label";
192
+ label.htmlFor = controlId;
193
+ this._labelEl = label;
194
+ this.#handleLabelChange(label);
195
+ installSafariWorkaroundStyle(this);
82
196
  }
83
197
  }
84
198
  disconnectedCallback() {
85
199
  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;
200
+ this.#reflectToInput.destroy();
94
201
  }
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, "");
202
+ focus() {
203
+ this.control?.focus();
99
204
  }
100
- #openIfClosed;
101
- #closeOnClickOutside;
102
- #closeOnEscape;
103
- }
205
+ };
104
206
  __decorateClass([
105
207
  attr
106
- ], Toggletip.prototype, "headline", 2);
208
+ ], TextField.prototype, "appearance", 2);
107
209
  __decorateClass([
108
- attr({ mode: "boolean" })
109
- ], Toggletip.prototype, "alternate", 2);
210
+ attr
211
+ ], TextField.prototype, "shape", 2);
110
212
  __decorateClass([
111
- attr({ mode: "fromView" })
112
- ], Toggletip.prototype, "placement", 2);
213
+ attr
214
+ ], TextField.prototype, "autoComplete", 2);
113
215
  __decorateClass([
114
- attr({ mode: "fromView" })
115
- ], Toggletip.prototype, "anchor", 2);
216
+ observable
217
+ ], TextField.prototype, "actionItemsSlottedContent", 2);
116
218
  __decorateClass([
117
- attr({ mode: "boolean" })
118
- ], Toggletip.prototype, "open", 2);
219
+ observable
220
+ ], TextField.prototype, "leadingActionItemsSlottedContent", 2);
221
+ TextField = __decorateClass([
222
+ errorText,
223
+ formElements
224
+ ], TextField);
225
+ applyMixins(TextField, AffixIcon, FormElementCharCount, FormElementHelperText, FormElementSuccessText);
119
226
 
120
- const getClasses = (_) => classNames("control");
121
- const ToggletipTemplate = (context) => {
122
- const popup = context.tagFor(Popup);
227
+ const getStateClasses = ({
228
+ errorValidationMessage,
229
+ disabled,
230
+ value,
231
+ readOnly,
232
+ placeholder,
233
+ appearance,
234
+ shape,
235
+ label,
236
+ successText,
237
+ actionItemsSlottedContent,
238
+ leadingActionItemsSlottedContent,
239
+ icon
240
+ }) => classNames(
241
+ ["error connotation-alert", Boolean(errorValidationMessage)],
242
+ ["disabled", disabled],
243
+ ["has-value", Boolean(value)],
244
+ ["readonly", readOnly],
245
+ ["placeholder", Boolean(placeholder)],
246
+ [`appearance-${appearance}`, Boolean(appearance)],
247
+ [`shape-${shape}`, Boolean(shape)],
248
+ ["no-label", !label],
249
+ ["has-icon", !!icon],
250
+ ["success connotation-success", Boolean(successText)],
251
+ ["action-items", !!actionItemsSlottedContent?.length],
252
+ ["leading-action-items", !!leadingActionItemsSlottedContent?.length],
253
+ ["no-leading", !(leadingActionItemsSlottedContent?.length || icon)]
254
+ );
255
+ function renderCharCount() {
123
256
  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}>
257
+ <span class="char-count">${(x) => x.value ? x.value.length : 0} / ${(x) => x.maxlength}</span>
139
258
  `;
259
+ }
260
+ const TextfieldTemplate = (context) => {
261
+ const affixIconTemplate = affixIconTemplateFactory(context);
262
+ const focusTemplate = focusTemplateFactory(context);
263
+ return html`
264
+ <div class="base ${getStateClasses}">
265
+ ${when((x) => x.charCount && x.maxlength, renderCharCount())}
266
+ <slot class="label" name="_label"></slot>
267
+ <div class="fieldset">
268
+ <div class="leading-items-wrapper">
269
+ <slot name="leading-action-items" ${slotted("leadingActionItemsSlottedContent")}></slot>
270
+ ${(x) => affixIconTemplate(x.icon)}
271
+ </div>
272
+
273
+ <div class="wrapper">
274
+ <slot class="control" name="_control"></slot>
275
+ ${() => focusTemplate}
276
+ </div>
277
+ <div class="action-items-wrapper">
278
+ <slot name="action-items" ${slotted("actionItemsSlottedContent")}></slot>
279
+ </div>
280
+
281
+ </div>
282
+ ${when((x) => !x.successText && !x.errorValidationMessage && x.helperText?.length, getFeedbackTemplate("helper", context))}
283
+ ${when((x) => !x.successText && x.errorValidationMessage, getFeedbackTemplate("error", context))}
284
+ ${when((x) => x.successText, getFeedbackTemplate("success", context))}
285
+ </div>`;
140
286
  };
141
287
 
142
- const toggletipDefinition = Toggletip.compose({
143
- baseName: "toggletip",
144
- template: ToggletipTemplate,
145
- styles
288
+ const textFieldDefinition = TextField.compose({
289
+ baseName: "text-field",
290
+ template: TextfieldTemplate,
291
+ styles,
292
+ shadowOptions: {
293
+ delegatesFocus: true
294
+ }
146
295
  });
147
- const toggletipRegistries = [toggletipDefinition(), ...popupRegistries];
148
- const registerToggletip = registerFactory(toggletipRegistries);
296
+ const textFieldRegistries = [textFieldDefinition(), ...iconRegistries, ...focusRegistries];
297
+ const registerTextField = registerFactory(textFieldRegistries);
149
298
 
150
- export { toggletipRegistries as a, registerToggletip as r, toggletipDefinition as t };
299
+ 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 './definition58.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 './definition59.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, 17 Oct 2023 15:27:52 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 Wed, 01 Nov 2023 12:16:28 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 };