@vonage/vivid 4.12.0 → 4.13.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 (124) hide show
  1. package/custom-elements.json +2339 -288
  2. package/lib/accordion/accordion.d.ts +21 -2
  3. package/lib/accordion-item/accordion-item.d.ts +6 -2
  4. package/lib/calendar/calendar.d.ts +1 -1
  5. package/lib/date-picker/date-picker.d.ts +1 -0
  6. package/lib/file-picker/file-picker.d.ts +6 -0
  7. package/lib/menu/menu.d.ts +16 -3
  8. package/lib/menu-item/menu-item.d.ts +10 -2
  9. package/lib/option/option.d.ts +27 -7
  10. package/lib/radio/radio.d.ts +12 -2
  11. package/lib/radio/radio.form-associated.d.ts +10 -0
  12. package/lib/radio-group/radio-group.d.ts +20 -2
  13. package/lib/switch/switch.d.ts +5 -2
  14. package/lib/switch/switch.form-associated.d.ts +10 -0
  15. package/lib/tab/tab.d.ts +3 -2
  16. package/lib/tab-panel/tab-panel.d.ts +2 -2
  17. package/lib/tabs/tabs.d.ts +33 -11
  18. package/lib/text-area/text-area.d.ts +25 -3
  19. package/lib/text-area/text-field.form-associated.d.ts +10 -0
  20. package/lib/text-field/text-field.d.ts +28 -3
  21. package/lib/text-field/text-field.form-associated.d.ts +10 -0
  22. package/package.json +1 -1
  23. package/shared/date-picker/date-picker-base.d.ts +1 -0
  24. package/shared/definition.cjs +29 -72
  25. package/shared/definition.js +30 -73
  26. package/shared/definition11.cjs +1 -1
  27. package/shared/definition11.js +1 -1
  28. package/shared/definition16.cjs +1 -2
  29. package/shared/definition16.js +1 -2
  30. package/shared/definition17.cjs +3 -3
  31. package/shared/definition17.js +3 -3
  32. package/shared/definition18.cjs +6 -1
  33. package/shared/definition18.js +6 -1
  34. package/shared/definition19.cjs +17 -8
  35. package/shared/definition19.js +17 -8
  36. package/shared/definition2.cjs +154 -187
  37. package/shared/definition2.js +157 -190
  38. package/shared/definition20.cjs +3 -2
  39. package/shared/definition20.js +3 -2
  40. package/shared/definition21.cjs +1 -1
  41. package/shared/definition21.js +1 -1
  42. package/shared/definition24.cjs +1 -1
  43. package/shared/definition24.js +1 -1
  44. package/shared/definition25.cjs +24 -3
  45. package/shared/definition25.js +24 -3
  46. package/shared/definition29.cjs +358 -559
  47. package/shared/definition29.js +359 -560
  48. package/shared/definition30.cjs +2 -0
  49. package/shared/definition30.js +2 -0
  50. package/shared/definition35.cjs +223 -3
  51. package/shared/definition35.js +223 -3
  52. package/shared/definition36.cjs +149 -14
  53. package/shared/definition36.js +150 -15
  54. package/shared/definition40.cjs +226 -399
  55. package/shared/definition40.js +229 -402
  56. package/shared/definition42.cjs +3 -2
  57. package/shared/definition42.js +3 -2
  58. package/shared/definition43.cjs +1 -0
  59. package/shared/definition43.js +1 -0
  60. package/shared/definition44.cjs +1 -1
  61. package/shared/definition44.js +1 -1
  62. package/shared/definition46.cjs +1 -1
  63. package/shared/definition46.js +1 -1
  64. package/shared/definition47.cjs +8 -16
  65. package/shared/definition47.js +4 -12
  66. package/shared/definition49.cjs +64 -89
  67. package/shared/definition49.js +66 -91
  68. package/shared/definition5.cjs +1 -1
  69. package/shared/definition5.js +1 -1
  70. package/shared/definition50.cjs +1 -11
  71. package/shared/definition50.js +1 -11
  72. package/shared/definition51.cjs +5 -15
  73. package/shared/definition51.js +6 -16
  74. package/shared/definition52.cjs +284 -20
  75. package/shared/definition52.js +288 -24
  76. package/shared/definition55.cjs +160 -180
  77. package/shared/definition55.js +160 -180
  78. package/shared/definition56.cjs +3 -307
  79. package/shared/definition56.js +5 -309
  80. package/shared/definition57.cjs +34 -11
  81. package/shared/definition57.js +30 -7
  82. package/shared/definition61.cjs +1 -1
  83. package/shared/definition61.js +1 -1
  84. package/shared/definition62.cjs +17 -8
  85. package/shared/definition62.js +17 -8
  86. package/shared/definition64.cjs +18 -7
  87. package/shared/definition64.js +19 -8
  88. package/shared/form-associated.cjs +1 -1
  89. package/shared/form-associated.js +1 -1
  90. package/shared/icon.cjs +1 -1
  91. package/shared/icon.js +1 -1
  92. package/shared/index.cjs +1 -0
  93. package/shared/index.js +1 -1
  94. package/shared/key-codes.cjs +1 -94
  95. package/shared/key-codes.js +2 -89
  96. package/shared/key-codes2.cjs +87 -1
  97. package/shared/key-codes2.js +83 -2
  98. package/shared/listbox.cjs +204 -10
  99. package/shared/listbox.js +200 -6
  100. package/shared/{direction.cjs → localization.cjs} +12 -3
  101. package/shared/{direction.js → localization.js} +12 -3
  102. package/shared/numbers.cjs +0 -12
  103. package/shared/numbers.js +1 -12
  104. package/shared/presentationDate.cjs +22 -8
  105. package/shared/presentationDate.js +16 -2
  106. package/shared/radio.cjs +92 -117
  107. package/shared/radio.js +93 -118
  108. package/shared/slider.template.cjs +2 -15
  109. package/shared/slider.template.js +2 -14
  110. package/shared/strings.cjs +26 -0
  111. package/shared/strings.js +25 -1
  112. package/shared/text-field2.cjs +538 -194
  113. package/shared/text-field2.js +539 -195
  114. package/styles/core/all.css +21 -1
  115. package/styles/core/theme.css +21 -1
  116. package/styles/core/typography.css +1 -1
  117. package/styles/tokens/theme-dark.css +4 -4
  118. package/styles/tokens/theme-light.css +4 -4
  119. package/styles/tokens/vivid-2-compat.css +1 -1
  120. package/vivid.api.json +44 -0
  121. package/shared/Reflector.cjs +0 -71
  122. package/shared/Reflector.js +0 -69
  123. package/shared/listbox-option.cjs +0 -204
  124. package/shared/listbox-option.js +0 -201
@@ -1,225 +1,569 @@
1
- import { F as FoundationElement, D as DOM, _ as __decorate, a as attr, n as nullableNumberConverter, o as observable } from './index.js';
2
- import { a as applyMixins } from './apply-mixins.js';
1
+ import { O as Observable, D as DOM, F as FoundationElement, a as attr, n as nullableNumberConverter, o as observable } from './index.js';
2
+ import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
3
3
  import { F as FormAssociated } from './form-associated.js';
4
- import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
5
- import { S as StartEnd } from './start-end.js';
4
+ import { m as memoizeWith } from './icon.js';
5
+ import { A as ARIAGlobalStatesAndProperties } from './aria-global2.js';
6
+ import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, b as FormElementCharCount } from './form-elements.js';
7
+ import { a as applyMixins } from './apply-mixins.js';
8
+ import { A as AffixIcon } from './affix.js';
9
+
10
+ const byteToHex = [];
11
+ for (let i = 0; i < 256; ++i) {
12
+ byteToHex.push((i + 0x100).toString(16).slice(1));
13
+ }
14
+ function unsafeStringify(arr, offset = 0) {
15
+ return (byteToHex[arr[offset + 0]] +
16
+ byteToHex[arr[offset + 1]] +
17
+ byteToHex[arr[offset + 2]] +
18
+ byteToHex[arr[offset + 3]] +
19
+ '-' +
20
+ byteToHex[arr[offset + 4]] +
21
+ byteToHex[arr[offset + 5]] +
22
+ '-' +
23
+ byteToHex[arr[offset + 6]] +
24
+ byteToHex[arr[offset + 7]] +
25
+ '-' +
26
+ byteToHex[arr[offset + 8]] +
27
+ byteToHex[arr[offset + 9]] +
28
+ '-' +
29
+ byteToHex[arr[offset + 10]] +
30
+ byteToHex[arr[offset + 11]] +
31
+ byteToHex[arr[offset + 12]] +
32
+ byteToHex[arr[offset + 13]] +
33
+ byteToHex[arr[offset + 14]] +
34
+ byteToHex[arr[offset + 15]]).toLowerCase();
35
+ }
36
+
37
+ let getRandomValues;
38
+ const rnds8 = new Uint8Array(16);
39
+ function rng() {
40
+ if (!getRandomValues) {
41
+ if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
42
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
43
+ }
44
+ getRandomValues = crypto.getRandomValues.bind(crypto);
45
+ }
46
+ return getRandomValues(rnds8);
47
+ }
48
+
49
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
50
+ const native = { randomUUID };
51
+
52
+ function v4(options, buf, offset) {
53
+ if (native.randomUUID && !buf && !options) {
54
+ return native.randomUUID();
55
+ }
56
+ options = options || {};
57
+ const rnds = options.random || (options.rng || rng)();
58
+ rnds[6] = (rnds[6] & 0x0f) | 0x40;
59
+ rnds[8] = (rnds[8] & 0x3f) | 0x80;
60
+ return unsafeStringify(rnds);
61
+ }
62
+
63
+ const generateRandomId = () => v4();
64
+
65
+ class Reflector {
66
+ #reflectedProperties = /* @__PURE__ */ new Map();
67
+ #source;
68
+ #target;
69
+ constructor(source, target) {
70
+ this.#source = source;
71
+ this.#target = target;
72
+ }
73
+ attribute(propertyName, attributeName) {
74
+ this.#addReflectedProperty(propertyName, {
75
+ type: "attribute",
76
+ destination: attributeName
77
+ });
78
+ }
79
+ booleanAttribute(propertyName, attributeName) {
80
+ this.#addReflectedProperty(propertyName, {
81
+ type: "boolean-attribute",
82
+ destination: attributeName
83
+ });
84
+ }
85
+ property(propertyName, targetProperty, skipIfEqual = false) {
86
+ this.#addReflectedProperty(propertyName, {
87
+ type: "property",
88
+ destination: targetProperty,
89
+ skipIfEqual
90
+ });
91
+ }
92
+ destroy() {
93
+ const notifier = Observable.getNotifier(this.#source);
94
+ for (const prop of this.#reflectedProperties.keys()) {
95
+ notifier.unsubscribe(this.#propertyChangeHandler, prop);
96
+ }
97
+ this.#reflectedProperties.clear();
98
+ }
99
+ #addReflectedProperty(name, reflected) {
100
+ this.#reflectedProperties.set(name, reflected);
101
+ const notifier = Observable.getNotifier(this.#source);
102
+ notifier.subscribe(this.#propertyChangeHandler, name);
103
+ this.#propertyChangeHandler.handleChange(this.#source, name);
104
+ }
105
+ #propertyChangeHandler = {
106
+ handleChange: (source, propertyName) => {
107
+ const reflectedProperty = this.#reflectedProperties.get(propertyName);
108
+ const value = source[propertyName];
109
+ switch (reflectedProperty.type) {
110
+ case "boolean-attribute":
111
+ DOM.setBooleanAttribute(
112
+ this.#target,
113
+ reflectedProperty.destination,
114
+ Boolean(value)
115
+ );
116
+ break;
117
+ case "attribute":
118
+ DOM.setAttribute(this.#target, reflectedProperty.destination, value);
119
+ break;
120
+ case "property":
121
+ if (reflectedProperty.skipIfEqual && this.#target[reflectedProperty.destination] === value) {
122
+ return;
123
+ }
124
+ this.#target[reflectedProperty.destination] = value;
125
+ break;
126
+ }
127
+ }
128
+ };
129
+ }
6
130
 
7
131
  class _TextField extends FoundationElement {
8
132
  }
9
- /**
10
- * A form-associated base class for the {@link @microsoft/fast-foundation#(TextField:class)} component.
11
- *
12
- * @internal
13
- */
14
133
  class FormAssociatedTextField extends FormAssociated(_TextField) {
15
- constructor() {
16
- super(...arguments);
17
- this.proxy = document.createElement("input");
18
- }
134
+ constructor() {
135
+ super(...arguments);
136
+ this.proxy = document.createElement("input");
137
+ }
19
138
  }
20
139
 
21
- /**
22
- * Text field sub-types
23
- * @public
24
- */
140
+ var __defProp = Object.defineProperty;
141
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
142
+ var __typeError = (msg) => {
143
+ throw TypeError(msg);
144
+ };
145
+ var __decorateClass = (decorators, target, key, kind) => {
146
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
147
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
148
+ if (decorator = decorators[i])
149
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
150
+ if (kind && result) __defProp(target, key, result);
151
+ return result;
152
+ };
153
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
154
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
155
+ 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);
156
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
157
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
158
+ var _TextField_instances, handleLabelChange_fn, _reflectToInput, _helperTextMirrorEl, _helperTextSlotMutationObserver, updateHelperTextMutationObserver_fn, updateMirroredHelperText_fn;
25
159
  const TextFieldType = {
160
+ /**
161
+ * An email TextField
162
+ */
163
+ email: "email",
164
+ /**
165
+ * A password TextField
166
+ */
167
+ password: "password",
168
+ /**
169
+ * A telephone TextField
170
+ */
171
+ tel: "tel",
172
+ /**
173
+ * A text TextField
174
+ */
175
+ text: "text",
176
+ /**
177
+ * A URL TextField
178
+ */
179
+ url: "url"
180
+ };
181
+ const safariWorkaroundClassName = "_vvd-3-text-field-safari-workaround";
182
+ const getSafariWorkaroundStyleSheet = memoizeWith(
183
+ () => "",
184
+ () => {
185
+ const styleSheet = new CSSStyleSheet();
186
+ const supportsReplaceSync = "replaceSync" in styleSheet;
187
+ if (supportsReplaceSync) {
188
+ styleSheet.replaceSync(`
189
+ .${safariWorkaroundClassName}::placeholder {
190
+ opacity: 1 !important;
191
+ -webkit-text-fill-color: var(--_low-ink-color) !important;
192
+ }`);
193
+ }
194
+ return styleSheet;
195
+ }
196
+ );
197
+ const installSafariWorkaroundStyle = (forElement) => {
198
+ const root = forElement.getRootNode();
199
+ const workaroundStyleSheet = getSafariWorkaroundStyleSheet();
200
+ const supportsAdoptedStyleSheets = "adoptedStyleSheets" in root;
201
+ if (!supportsAdoptedStyleSheets) {
202
+ return;
203
+ }
204
+ if (!root.adoptedStyleSheets.includes(workaroundStyleSheet)) {
205
+ root.adoptedStyleSheets = [
206
+ ...root.adoptedStyleSheets,
207
+ workaroundStyleSheet
208
+ ];
209
+ }
210
+ };
211
+ let TextField = class extends FormAssociatedTextField {
212
+ constructor() {
213
+ super(...arguments);
214
+ __privateAdd(this, _TextField_instances);
215
+ // eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
216
+ this.type = TextFieldType.text;
26
217
  /**
27
- * An email TextField
28
- */
29
- email: "email",
30
- /**
31
- * A password TextField
32
- */
33
- password: "password",
34
- /**
35
- * A telephone TextField
36
- */
37
- tel: "tel",
38
- /**
39
- * A text TextField
40
- */
41
- text: "text",
42
- /**
43
- * A URL TextField
218
+ * @internal
44
219
  */
45
- url: "url",
46
- };
47
-
48
- /**
49
- * A Text Field Custom HTML Element.
50
- * Based largely on the {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text | <input type="text" /> element }.
51
- *
52
- * @slot start - Content which can be provided before the number field input
53
- * @slot end - Content which can be provided after the number field input
54
- * @slot - The default slot for the label
55
- * @csspart label - The label
56
- * @csspart root - The element wrapping the control, including start and end slots
57
- * @csspart control - The text field element
58
- * @fires change - Fires a custom 'change' event when the value has changed
59
- *
60
- * @public
61
- */
62
- let TextField$1 = class TextField extends FormAssociatedTextField {
63
- constructor() {
64
- super(...arguments);
65
- /**
66
- * Allows setting a type or mode of text.
67
- * @public
68
- * @remarks
69
- * HTML Attribute: type
70
- */
71
- this.type = TextFieldType.text;
72
- }
73
- readOnlyChanged() {
74
- if (this.proxy instanceof HTMLInputElement) {
75
- this.proxy.readOnly = this.readOnly;
76
- this.validate();
77
- }
220
+ this._labelEl = null;
221
+ __privateAdd(this, _reflectToInput);
222
+ __privateAdd(this, _helperTextMirrorEl);
223
+ __privateAdd(this, _helperTextSlotMutationObserver);
224
+ }
225
+ /**
226
+ * @internal
227
+ */
228
+ readOnlyChanged() {
229
+ if (this.proxy instanceof HTMLInputElement) {
230
+ this.proxy.readOnly = this.readOnly;
231
+ this.validate();
78
232
  }
79
- autofocusChanged() {
80
- if (this.proxy instanceof HTMLInputElement) {
81
- this.proxy.autofocus = this.autofocus;
82
- this.validate();
83
- }
233
+ }
234
+ /**
235
+ * @internal
236
+ */
237
+ autofocusChanged() {
238
+ if (this.proxy instanceof HTMLInputElement) {
239
+ this.proxy.autofocus = this.autofocus;
240
+ this.validate();
84
241
  }
85
- placeholderChanged() {
86
- if (this.proxy instanceof HTMLInputElement) {
87
- this.proxy.placeholder = this.placeholder;
88
- }
242
+ }
243
+ /**
244
+ * @internal
245
+ */
246
+ placeholderChanged() {
247
+ if (this.proxy instanceof HTMLInputElement) {
248
+ this.proxy.placeholder = this.placeholder;
89
249
  }
90
- typeChanged() {
91
- if (this.proxy instanceof HTMLInputElement) {
92
- this.proxy.type = this.type;
93
- this.validate();
94
- }
250
+ }
251
+ /**
252
+ * @internal
253
+ */
254
+ typeChanged() {
255
+ if (this.proxy instanceof HTMLInputElement) {
256
+ this.proxy.type = this.type;
257
+ this.validate();
95
258
  }
96
- listChanged() {
97
- if (this.proxy instanceof HTMLInputElement) {
98
- this.proxy.setAttribute("list", this.list);
99
- this.validate();
100
- }
259
+ }
260
+ /**
261
+ * @internal
262
+ */
263
+ listChanged() {
264
+ if (this.proxy instanceof HTMLInputElement) {
265
+ this.proxy.setAttribute("list", this.list);
266
+ this.validate();
101
267
  }
102
- maxlengthChanged() {
103
- if (this.proxy instanceof HTMLInputElement) {
104
- this.proxy.maxLength = this.maxlength;
105
- this.validate();
106
- }
268
+ }
269
+ /**
270
+ * @internal
271
+ */
272
+ maxlengthChanged() {
273
+ if (this.proxy instanceof HTMLInputElement) {
274
+ this.proxy.maxLength = this.maxlength;
275
+ this.validate();
107
276
  }
108
- minlengthChanged() {
109
- if (this.proxy instanceof HTMLInputElement) {
110
- this.proxy.minLength = this.minlength;
111
- this.validate();
112
- }
277
+ }
278
+ /**
279
+ * @internal
280
+ */
281
+ minlengthChanged() {
282
+ if (this.proxy instanceof HTMLInputElement) {
283
+ this.proxy.minLength = this.minlength;
284
+ this.validate();
113
285
  }
114
- patternChanged() {
115
- if (this.proxy instanceof HTMLInputElement) {
116
- this.proxy.pattern = this.pattern;
117
- this.validate();
118
- }
286
+ }
287
+ /**
288
+ * @internal
289
+ */
290
+ patternChanged() {
291
+ if (this.proxy instanceof HTMLInputElement) {
292
+ this.proxy.pattern = this.pattern;
293
+ this.validate();
119
294
  }
120
- sizeChanged() {
121
- if (this.proxy instanceof HTMLInputElement) {
122
- this.proxy.size = this.size;
123
- }
295
+ }
296
+ /**
297
+ * @internal
298
+ */
299
+ sizeChanged() {
300
+ if (this.proxy instanceof HTMLInputElement) {
301
+ this.proxy.size = this.size;
124
302
  }
125
- spellcheckChanged() {
126
- if (this.proxy instanceof HTMLInputElement) {
127
- this.proxy.spellcheck = this.spellcheck;
128
- }
303
+ }
304
+ /**
305
+ * @internal
306
+ */
307
+ spellcheckChanged() {
308
+ if (this.proxy instanceof HTMLInputElement) {
309
+ this.proxy.spellcheck = this.spellcheck;
129
310
  }
130
- /**
131
- * @internal
132
- */
133
- connectedCallback() {
134
- super.connectedCallback();
135
- this.proxy.setAttribute("type", this.type);
136
- this.validate();
137
- if (this.autofocus) {
138
- DOM.queueUpdate(() => {
139
- this.focus();
140
- });
141
- }
311
+ }
312
+ /**
313
+ * Selects all the text in the text field
314
+ *
315
+ * @public
316
+ */
317
+ select() {
318
+ this.control.select();
319
+ }
320
+ /**
321
+ * Handles the internal control's `input` event
322
+ * @internal
323
+ */
324
+ handleTextInput() {
325
+ this.value = this.control.value;
326
+ }
327
+ /**
328
+ * Change event handler for inner control.
329
+ * @remarks
330
+ * "Change" events are not `composable` so they will not
331
+ * permeate the shadow DOM boundary. This fn effectively proxies
332
+ * the change event, emitting a `change` event whenever the internal
333
+ * control emits a `change` event
334
+ * @internal
335
+ */
336
+ handleChange() {
337
+ this.$emit("change");
338
+ }
339
+ /** {@inheritDoc (FormAssociated:interface).validate} */
340
+ validate() {
341
+ super.validate(this.control);
342
+ }
343
+ /**
344
+ * @internal
345
+ */
346
+ labelChanged() {
347
+ if (this._labelEl) {
348
+ __privateMethod(this, _TextField_instances, handleLabelChange_fn).call(this, this._labelEl);
142
349
  }
143
- /**
144
- * Selects all the text in the text field
145
- *
146
- * @public
147
- */
148
- select() {
149
- this.control.select();
150
- /**
151
- * The select event does not permeate the shadow DOM boundary.
152
- * This fn effectively proxies the select event,
153
- * emitting a `select` event whenever the internal
154
- * control emits a `select` event
155
- */
156
- this.$emit("select");
350
+ }
351
+ connectedCallback() {
352
+ super.connectedCallback();
353
+ this.proxy.setAttribute("type", this.type);
354
+ this.validate();
355
+ if (this.autofocus) {
356
+ DOM.queueUpdate(() => {
357
+ this.focus();
358
+ });
157
359
  }
158
- /**
159
- * Handles the internal control's `input` event
160
- * @internal
161
- */
162
- handleTextInput() {
163
- this.value = this.control.value;
360
+ if (!this.control) {
361
+ const uniqueId = this.id || generateRandomId();
362
+ const controlId = `vvd-text-field-control-${uniqueId}`;
363
+ const helperTextId = `vvd-text-field-helper-text-${uniqueId}`;
364
+ const input = document.createElement("input");
365
+ input.slot = "_control";
366
+ input.id = controlId;
367
+ input.className = safariWorkaroundClassName;
368
+ this.control = input;
369
+ input.addEventListener("input", () => {
370
+ this.handleTextInput();
371
+ });
372
+ input.addEventListener("change", () => {
373
+ this.handleChange();
374
+ });
375
+ input.addEventListener("blur", () => {
376
+ this.$emit("blur", void 0, { bubbles: false });
377
+ });
378
+ input.addEventListener("focus", () => {
379
+ this.$emit("focus", void 0, { bubbles: false });
380
+ });
381
+ this.appendChild(input);
382
+ const label = document.createElement("label");
383
+ label.slot = "_label";
384
+ label.htmlFor = controlId;
385
+ this._labelEl = label;
386
+ __privateMethod(this, _TextField_instances, handleLabelChange_fn).call(this, label);
387
+ __privateSet(this, _helperTextMirrorEl, document.createElement("div"));
388
+ __privateGet(this, _helperTextMirrorEl).id = helperTextId;
389
+ __privateGet(this, _helperTextMirrorEl).slot = "_mirrored-helper-text";
390
+ __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
391
+ this.appendChild(__privateGet(this, _helperTextMirrorEl));
392
+ installSafariWorkaroundStyle(this);
164
393
  }
165
- /**
166
- * Change event handler for inner control.
167
- * @remarks
168
- * "Change" events are not `composable` so they will not
169
- * permeate the shadow DOM boundary. This fn effectively proxies
170
- * the change event, emitting a `change` event whenever the internal
171
- * control emits a `change` event
172
- * @internal
173
- */
174
- handleChange() {
175
- this.$emit("change");
394
+ __privateSet(this, _reflectToInput, new Reflector(this, this.control));
395
+ __privateGet(this, _reflectToInput).booleanAttribute("autofocus", "autofocus");
396
+ __privateGet(this, _reflectToInput).booleanAttribute("disabled", "disabled");
397
+ __privateGet(this, _reflectToInput).booleanAttribute("readOnly", "readonly");
398
+ __privateGet(this, _reflectToInput).booleanAttribute("required", "required");
399
+ __privateGet(this, _reflectToInput).booleanAttribute("spellcheck", "spellcheck");
400
+ __privateGet(this, _reflectToInput).attribute("list", "list");
401
+ __privateGet(this, _reflectToInput).attribute("maxlength", "maxlength");
402
+ __privateGet(this, _reflectToInput).attribute("minlength", "minlength");
403
+ __privateGet(this, _reflectToInput).attribute("pattern", "pattern");
404
+ __privateGet(this, _reflectToInput).attribute("placeholder", "placeholder");
405
+ __privateGet(this, _reflectToInput).attribute("size", "size");
406
+ __privateGet(this, _reflectToInput).attribute("autoComplete", "autocomplete");
407
+ __privateGet(this, _reflectToInput).attribute("type", "type");
408
+ __privateGet(this, _reflectToInput).attribute("inputMode", "inputmode");
409
+ __privateGet(this, _reflectToInput).attribute("ariaAtomic", "aria-atomic");
410
+ __privateGet(this, _reflectToInput).attribute("ariaBusy", "aria-busy");
411
+ __privateGet(this, _reflectToInput).attribute("ariaCurrent", "aria-current");
412
+ __privateGet(this, _reflectToInput).attribute("ariaDetails", "aria-details");
413
+ __privateGet(this, _reflectToInput).attribute("ariaDisabled", "aria-disabled");
414
+ __privateGet(this, _reflectToInput).attribute("ariaHaspopup", "aria-haspopup");
415
+ __privateGet(this, _reflectToInput).attribute("ariaHidden", "aria-hidden");
416
+ __privateGet(this, _reflectToInput).attribute("ariaInvalid", "aria-invalid");
417
+ __privateGet(this, _reflectToInput).attribute("ariaKeyshortcuts", "aria-keyshortcuts");
418
+ __privateGet(this, _reflectToInput).attribute("ariaLabel", "aria-label");
419
+ __privateGet(this, _reflectToInput).attribute("ariaLive", "aria-live");
420
+ __privateGet(this, _reflectToInput).attribute("ariaRelevant", "aria-relevant");
421
+ __privateGet(this, _reflectToInput).attribute(
422
+ "ariaRoledescription",
423
+ "aria-roledescription"
424
+ );
425
+ __privateGet(this, _reflectToInput).property("value", "value", true);
426
+ __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
427
+ }
428
+ disconnectedCallback() {
429
+ super.disconnectedCallback();
430
+ __privateGet(this, _reflectToInput).destroy();
431
+ __privateSet(this, _reflectToInput, void 0);
432
+ __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
433
+ }
434
+ focus() {
435
+ this.control?.focus();
436
+ }
437
+ /**
438
+ * @internal
439
+ */
440
+ helperTextChanged() {
441
+ __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
442
+ }
443
+ /**
444
+ * @internal
445
+ */
446
+ _helperTextSlottedContentChanged() {
447
+ __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
448
+ __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
449
+ }
450
+ };
451
+ _TextField_instances = new WeakSet();
452
+ handleLabelChange_fn = function(labelEl) {
453
+ if (!this.label) {
454
+ labelEl.remove();
455
+ } else {
456
+ labelEl.textContent = this.label;
457
+ if (!labelEl.isConnected) {
458
+ this.appendChild(labelEl);
176
459
  }
177
- /** {@inheritDoc (FormAssociated:interface).validate} */
178
- validate() {
179
- super.validate(this.control);
460
+ }
461
+ };
462
+ _reflectToInput = new WeakMap();
463
+ _helperTextMirrorEl = new WeakMap();
464
+ _helperTextSlotMutationObserver = new WeakMap();
465
+ updateHelperTextMutationObserver_fn = function() {
466
+ const usesHelperTextSlot = this._helperTextSlottedContent.length;
467
+ const shouldHaveMutationObserver = usesHelperTextSlot && this.isConnected;
468
+ if (shouldHaveMutationObserver && !__privateGet(this, _helperTextSlotMutationObserver)) {
469
+ __privateSet(this, _helperTextSlotMutationObserver, new MutationObserver((records) => {
470
+ if (records.some((record) => record.target !== __privateGet(this, _helperTextMirrorEl))) {
471
+ __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
472
+ }
473
+ }));
474
+ __privateGet(this, _helperTextSlotMutationObserver).observe(this, {
475
+ subtree: true,
476
+ childList: true,
477
+ characterData: true
478
+ });
479
+ }
480
+ if (!shouldHaveMutationObserver && __privateGet(this, _helperTextSlotMutationObserver)) {
481
+ __privateGet(this, _helperTextSlotMutationObserver).disconnect();
482
+ __privateSet(this, _helperTextSlotMutationObserver, void 0);
483
+ }
484
+ };
485
+ updateMirroredHelperText_fn = function() {
486
+ let helperText = this.helperText ?? "";
487
+ if (this._helperTextSlottedContent?.length) {
488
+ helperText = this._helperTextSlottedContent.map((node) => node.innerText).join(" ");
489
+ }
490
+ if (__privateGet(this, _helperTextMirrorEl)) {
491
+ __privateGet(this, _helperTextMirrorEl).textContent = helperText;
492
+ if (helperText) {
493
+ this.control.setAttribute(
494
+ "aria-describedby",
495
+ __privateGet(this, _helperTextMirrorEl).id
496
+ );
497
+ } else {
498
+ this.control.removeAttribute("aria-describedby");
180
499
  }
500
+ }
181
501
  };
182
- __decorate([
183
- attr({ attribute: "readonly", mode: "boolean" })
184
- ], TextField$1.prototype, "readOnly", void 0);
185
- __decorate([
186
- attr({ mode: "boolean" })
187
- ], TextField$1.prototype, "autofocus", void 0);
188
- __decorate([
189
- attr
190
- ], TextField$1.prototype, "placeholder", void 0);
191
- __decorate([
192
- attr
193
- ], TextField$1.prototype, "type", void 0);
194
- __decorate([
195
- attr
196
- ], TextField$1.prototype, "list", void 0);
197
- __decorate([
198
- attr({ converter: nullableNumberConverter })
199
- ], TextField$1.prototype, "maxlength", void 0);
200
- __decorate([
201
- attr({ converter: nullableNumberConverter })
202
- ], TextField$1.prototype, "minlength", void 0);
203
- __decorate([
204
- attr
205
- ], TextField$1.prototype, "pattern", void 0);
206
- __decorate([
207
- attr({ converter: nullableNumberConverter })
208
- ], TextField$1.prototype, "size", void 0);
209
- __decorate([
210
- attr({ mode: "boolean" })
211
- ], TextField$1.prototype, "spellcheck", void 0);
212
- __decorate([
213
- observable
214
- ], TextField$1.prototype, "defaultSlottedNodes", void 0);
215
- /**
216
- * Includes ARIA states and properties relating to the ARIA textbox role
217
- *
218
- * @public
219
- */
502
+ __decorateClass([
503
+ attr({ attribute: "readonly", mode: "boolean" })
504
+ ], TextField.prototype, "readOnly", 2);
505
+ __decorateClass([
506
+ attr({ mode: "boolean" })
507
+ ], TextField.prototype, "autofocus", 2);
508
+ __decorateClass([
509
+ attr
510
+ ], TextField.prototype, "placeholder", 2);
511
+ __decorateClass([
512
+ attr
513
+ ], TextField.prototype, "type", 2);
514
+ __decorateClass([
515
+ attr
516
+ ], TextField.prototype, "list", 2);
517
+ __decorateClass([
518
+ attr({ converter: nullableNumberConverter })
519
+ ], TextField.prototype, "maxlength", 2);
520
+ __decorateClass([
521
+ attr({ converter: nullableNumberConverter })
522
+ ], TextField.prototype, "minlength", 2);
523
+ __decorateClass([
524
+ attr
525
+ ], TextField.prototype, "pattern", 2);
526
+ __decorateClass([
527
+ attr({ converter: nullableNumberConverter })
528
+ ], TextField.prototype, "size", 2);
529
+ __decorateClass([
530
+ attr({ mode: "boolean" })
531
+ ], TextField.prototype, "spellcheck", 2);
532
+ __decorateClass([
533
+ attr
534
+ ], TextField.prototype, "appearance", 2);
535
+ __decorateClass([
536
+ attr
537
+ ], TextField.prototype, "shape", 2);
538
+ __decorateClass([
539
+ attr
540
+ ], TextField.prototype, "autoComplete", 2);
541
+ __decorateClass([
542
+ attr()
543
+ ], TextField.prototype, "scale", 2);
544
+ __decorateClass([
545
+ attr({ attribute: "inputmode" })
546
+ ], TextField.prototype, "inputMode", 2);
547
+ __decorateClass([
548
+ observable
549
+ ], TextField.prototype, "actionItemsSlottedContent", 2);
550
+ __decorateClass([
551
+ observable
552
+ ], TextField.prototype, "leadingActionItemsSlottedContent", 2);
553
+ TextField = __decorateClass([
554
+ errorText,
555
+ formElements
556
+ ], TextField);
220
557
  class DelegatesARIATextbox {
221
558
  }
222
559
  applyMixins(DelegatesARIATextbox, ARIAGlobalStatesAndProperties);
223
- applyMixins(TextField$1, StartEnd, DelegatesARIATextbox);
560
+ applyMixinsWithObservables(
561
+ TextField,
562
+ AffixIcon,
563
+ FormElementCharCount,
564
+ FormElementHelperText,
565
+ FormElementSuccessText,
566
+ DelegatesARIATextbox
567
+ );
224
568
 
225
- export { DelegatesARIATextbox as D, TextField$1 as T };
569
+ export { DelegatesARIATextbox as D, Reflector as R, TextField as T };