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