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