@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
@@ -2,318 +2,14 @@
2
2
 
3
3
  const index = require('./index.cjs');
4
4
  const definition = require('./definition27.cjs');
5
- const Reflector = require('./Reflector.cjs');
6
- const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
7
- const icon = require('./icon.cjs');
8
5
  const textField = require('./text-field2.cjs');
9
- const formElements = require('./form-elements.cjs');
10
- const affix = require('./affix.cjs');
11
6
  const textField$1 = require('./text-field.cjs');
7
+ const affix = require('./affix.cjs');
12
8
  const when = require('./when.cjs');
13
9
  const slotted = require('./slotted.cjs');
10
+ const formElements = require('./form-elements.cjs');
14
11
  const classNames = require('./class-names.cjs');
15
12
 
16
- const byteToHex = [];
17
- for (let i = 0; i < 256; ++i) {
18
- byteToHex.push((i + 0x100).toString(16).slice(1));
19
- }
20
- function unsafeStringify(arr, offset = 0) {
21
- return (byteToHex[arr[offset + 0]] +
22
- byteToHex[arr[offset + 1]] +
23
- byteToHex[arr[offset + 2]] +
24
- byteToHex[arr[offset + 3]] +
25
- '-' +
26
- byteToHex[arr[offset + 4]] +
27
- byteToHex[arr[offset + 5]] +
28
- '-' +
29
- byteToHex[arr[offset + 6]] +
30
- byteToHex[arr[offset + 7]] +
31
- '-' +
32
- byteToHex[arr[offset + 8]] +
33
- byteToHex[arr[offset + 9]] +
34
- '-' +
35
- byteToHex[arr[offset + 10]] +
36
- byteToHex[arr[offset + 11]] +
37
- byteToHex[arr[offset + 12]] +
38
- byteToHex[arr[offset + 13]] +
39
- byteToHex[arr[offset + 14]] +
40
- byteToHex[arr[offset + 15]]).toLowerCase();
41
- }
42
-
43
- let getRandomValues;
44
- const rnds8 = new Uint8Array(16);
45
- function rng() {
46
- if (!getRandomValues) {
47
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
48
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
49
- }
50
- getRandomValues = crypto.getRandomValues.bind(crypto);
51
- }
52
- return getRandomValues(rnds8);
53
- }
54
-
55
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
56
- const native = { randomUUID };
57
-
58
- function v4(options, buf, offset) {
59
- if (native.randomUUID && !buf && !options) {
60
- return native.randomUUID();
61
- }
62
- options = options || {};
63
- const rnds = options.random || (options.rng || rng)();
64
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
65
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
66
- return unsafeStringify(rnds);
67
- }
68
-
69
- const generateRandomId = () => v4();
70
-
71
- var __defProp = Object.defineProperty;
72
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
73
- var __typeError = (msg) => {
74
- throw TypeError(msg);
75
- };
76
- var __decorateClass = (decorators, target, key, kind) => {
77
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
78
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
79
- if (decorator = decorators[i])
80
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
81
- if (kind && result) __defProp(target, key, result);
82
- return result;
83
- };
84
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
85
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
86
- 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);
87
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
88
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
89
- var _TextField_instances, handleLabelChange_fn, _reflectToInput, _helperTextMirrorEl, _helperTextSlotMutationObserver, updateHelperTextMutationObserver_fn, updateMirroredHelperText_fn;
90
- const safariWorkaroundClassName = "_vvd-3-text-field-safari-workaround";
91
- const getSafariWorkaroundStyleSheet = icon.memoizeWith(
92
- () => "",
93
- () => {
94
- const styleSheet = new CSSStyleSheet();
95
- const supportsReplaceSync = "replaceSync" in styleSheet;
96
- if (supportsReplaceSync) {
97
- styleSheet.replaceSync(`
98
- .${safariWorkaroundClassName}::placeholder {
99
- opacity: 1 !important;
100
- -webkit-text-fill-color: var(--_low-ink-color) !important;
101
- }`);
102
- }
103
- return styleSheet;
104
- }
105
- );
106
- const installSafariWorkaroundStyle = (forElement) => {
107
- const root = forElement.getRootNode();
108
- const workaroundStyleSheet = getSafariWorkaroundStyleSheet();
109
- const supportsAdoptedStyleSheets = "adoptedStyleSheets" in root;
110
- if (!supportsAdoptedStyleSheets) {
111
- return;
112
- }
113
- if (!root.adoptedStyleSheets.includes(workaroundStyleSheet)) {
114
- root.adoptedStyleSheets = [
115
- ...root.adoptedStyleSheets,
116
- workaroundStyleSheet
117
- ];
118
- }
119
- };
120
- exports.TextField = class TextField extends textField.TextField {
121
- constructor() {
122
- super(...arguments);
123
- __privateAdd(this, _TextField_instances);
124
- /**
125
- * @internal
126
- */
127
- this._labelEl = null;
128
- __privateAdd(this, _reflectToInput);
129
- __privateAdd(this, _helperTextMirrorEl);
130
- __privateAdd(this, _helperTextSlotMutationObserver);
131
- }
132
- /**
133
- * @internal
134
- */
135
- labelChanged() {
136
- if (this._labelEl) {
137
- __privateMethod(this, _TextField_instances, handleLabelChange_fn).call(this, this._labelEl);
138
- }
139
- }
140
- connectedCallback() {
141
- super.connectedCallback();
142
- if (!this.control) {
143
- const uniqueId = this.id || generateRandomId();
144
- const controlId = `vvd-text-field-control-${uniqueId}`;
145
- const helperTextId = `vvd-text-field-helper-text-${uniqueId}`;
146
- const input = document.createElement("input");
147
- input.slot = "_control";
148
- input.id = controlId;
149
- input.className = safariWorkaroundClassName;
150
- this.control = input;
151
- input.addEventListener("input", () => {
152
- this.handleTextInput();
153
- });
154
- input.addEventListener("change", () => {
155
- this.handleChange();
156
- });
157
- input.addEventListener("blur", () => {
158
- this.$emit("blur", void 0, { bubbles: false });
159
- });
160
- input.addEventListener("focus", () => {
161
- this.$emit("focus", void 0, { bubbles: false });
162
- });
163
- this.appendChild(input);
164
- const label = document.createElement("label");
165
- label.slot = "_label";
166
- label.htmlFor = controlId;
167
- this._labelEl = label;
168
- __privateMethod(this, _TextField_instances, handleLabelChange_fn).call(this, label);
169
- __privateSet(this, _helperTextMirrorEl, document.createElement("div"));
170
- __privateGet(this, _helperTextMirrorEl).id = helperTextId;
171
- __privateGet(this, _helperTextMirrorEl).slot = "_mirrored-helper-text";
172
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
173
- this.appendChild(__privateGet(this, _helperTextMirrorEl));
174
- installSafariWorkaroundStyle(this);
175
- }
176
- __privateSet(this, _reflectToInput, new Reflector.Reflector(this, this.control));
177
- __privateGet(this, _reflectToInput).booleanAttribute("autofocus", "autofocus");
178
- __privateGet(this, _reflectToInput).booleanAttribute("disabled", "disabled");
179
- __privateGet(this, _reflectToInput).booleanAttribute("readOnly", "readonly");
180
- __privateGet(this, _reflectToInput).booleanAttribute("required", "required");
181
- __privateGet(this, _reflectToInput).booleanAttribute("spellcheck", "spellcheck");
182
- __privateGet(this, _reflectToInput).attribute("list", "list");
183
- __privateGet(this, _reflectToInput).attribute("maxlength", "maxlength");
184
- __privateGet(this, _reflectToInput).attribute("minlength", "minlength");
185
- __privateGet(this, _reflectToInput).attribute("pattern", "pattern");
186
- __privateGet(this, _reflectToInput).attribute("placeholder", "placeholder");
187
- __privateGet(this, _reflectToInput).attribute("size", "size");
188
- __privateGet(this, _reflectToInput).attribute("autoComplete", "autocomplete");
189
- __privateGet(this, _reflectToInput).attribute("type", "type");
190
- __privateGet(this, _reflectToInput).attribute("inputMode", "inputmode");
191
- __privateGet(this, _reflectToInput).attribute("ariaAtomic", "aria-atomic");
192
- __privateGet(this, _reflectToInput).attribute("ariaBusy", "aria-busy");
193
- __privateGet(this, _reflectToInput).attribute("ariaCurrent", "aria-current");
194
- __privateGet(this, _reflectToInput).attribute("ariaDetails", "aria-details");
195
- __privateGet(this, _reflectToInput).attribute("ariaDisabled", "aria-disabled");
196
- __privateGet(this, _reflectToInput).attribute("ariaHaspopup", "aria-haspopup");
197
- __privateGet(this, _reflectToInput).attribute("ariaHidden", "aria-hidden");
198
- __privateGet(this, _reflectToInput).attribute("ariaInvalid", "aria-invalid");
199
- __privateGet(this, _reflectToInput).attribute("ariaKeyshortcuts", "aria-keyshortcuts");
200
- __privateGet(this, _reflectToInput).attribute("ariaLabel", "aria-label");
201
- __privateGet(this, _reflectToInput).attribute("ariaLive", "aria-live");
202
- __privateGet(this, _reflectToInput).attribute("ariaRelevant", "aria-relevant");
203
- __privateGet(this, _reflectToInput).attribute(
204
- "ariaRoledescription",
205
- "aria-roledescription"
206
- );
207
- __privateGet(this, _reflectToInput).property("value", "value", true);
208
- __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
209
- }
210
- disconnectedCallback() {
211
- super.disconnectedCallback();
212
- __privateGet(this, _reflectToInput).destroy();
213
- __privateSet(this, _reflectToInput, void 0);
214
- __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
215
- }
216
- focus() {
217
- this.control?.focus();
218
- }
219
- /**
220
- * @internal
221
- */
222
- helperTextChanged() {
223
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
224
- }
225
- /**
226
- * @internal
227
- */
228
- _helperTextSlottedContentChanged() {
229
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
230
- __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
231
- }
232
- };
233
- _TextField_instances = new WeakSet();
234
- handleLabelChange_fn = function(labelEl) {
235
- if (!this.label) {
236
- labelEl.remove();
237
- } else {
238
- labelEl.textContent = this.label;
239
- if (!labelEl.isConnected) {
240
- this.appendChild(labelEl);
241
- }
242
- }
243
- };
244
- _reflectToInput = new WeakMap();
245
- _helperTextMirrorEl = new WeakMap();
246
- _helperTextSlotMutationObserver = new WeakMap();
247
- updateHelperTextMutationObserver_fn = function() {
248
- const usesHelperTextSlot = this._helperTextSlottedContent.length;
249
- const shouldHaveMutationObserver = usesHelperTextSlot && this.isConnected;
250
- if (shouldHaveMutationObserver && !__privateGet(this, _helperTextSlotMutationObserver)) {
251
- __privateSet(this, _helperTextSlotMutationObserver, new MutationObserver((records) => {
252
- if (records.some((record) => record.target !== __privateGet(this, _helperTextMirrorEl))) {
253
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
254
- }
255
- }));
256
- __privateGet(this, _helperTextSlotMutationObserver).observe(this, {
257
- subtree: true,
258
- childList: true,
259
- characterData: true
260
- });
261
- }
262
- if (!shouldHaveMutationObserver && __privateGet(this, _helperTextSlotMutationObserver)) {
263
- __privateGet(this, _helperTextSlotMutationObserver).disconnect();
264
- __privateSet(this, _helperTextSlotMutationObserver, void 0);
265
- }
266
- };
267
- updateMirroredHelperText_fn = function() {
268
- let helperText = this.helperText ?? "";
269
- if (this._helperTextSlottedContent?.length) {
270
- helperText = this._helperTextSlottedContent.map((node) => node.innerText).join(" ");
271
- }
272
- if (__privateGet(this, _helperTextMirrorEl)) {
273
- __privateGet(this, _helperTextMirrorEl).textContent = helperText;
274
- if (helperText) {
275
- this.control.setAttribute(
276
- "aria-describedby",
277
- __privateGet(this, _helperTextMirrorEl).id
278
- );
279
- } else {
280
- this.control.removeAttribute("aria-describedby");
281
- }
282
- }
283
- };
284
- __decorateClass([
285
- index.attr
286
- ], exports.TextField.prototype, "appearance", 2);
287
- __decorateClass([
288
- index.attr
289
- ], exports.TextField.prototype, "shape", 2);
290
- __decorateClass([
291
- index.attr
292
- ], exports.TextField.prototype, "autoComplete", 2);
293
- __decorateClass([
294
- index.attr()
295
- ], exports.TextField.prototype, "scale", 2);
296
- __decorateClass([
297
- index.attr({ attribute: "inputmode" })
298
- ], exports.TextField.prototype, "inputMode", 2);
299
- __decorateClass([
300
- index.observable
301
- ], exports.TextField.prototype, "actionItemsSlottedContent", 2);
302
- __decorateClass([
303
- index.observable
304
- ], exports.TextField.prototype, "leadingActionItemsSlottedContent", 2);
305
- exports.TextField = __decorateClass([
306
- formElements.errorText,
307
- formElements.formElements
308
- ], exports.TextField);
309
- applyMixinsWithObservables.applyMixinsWithObservables(
310
- exports.TextField,
311
- affix.AffixIcon,
312
- formElements.FormElementCharCount,
313
- formElements.FormElementHelperText,
314
- formElements.FormElementSuccessText
315
- );
316
-
317
13
  const getStateClasses = ({
318
14
  errorValidationMessage,
319
15
  disabled,
@@ -380,7 +76,7 @@ const TextfieldTemplate = (context) => {
380
76
  <slot name="_mirrored-helper-text"></slot>`;
381
77
  };
382
78
 
383
- const textFieldDefinition = exports.TextField.compose({
79
+ const textFieldDefinition = textField.TextField.compose({
384
80
  baseName: "text-field",
385
81
  template: TextfieldTemplate,
386
82
  styles: textField$1.styles,
@@ -1,317 +1,13 @@
1
- import { a as attr, o as observable, h as html, r as registerFactory } from './index.js';
1
+ import { h as html, r as registerFactory } from './index.js';
2
2
  import { a as iconRegistries } from './definition27.js';
3
- import { R as Reflector } from './Reflector.js';
4
- import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
5
- import { m as memoizeWith } from './icon.js';
6
- import { T as TextField$1 } from './text-field2.js';
7
- import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, b as FormElementCharCount, g as getFeedbackTemplate } from './form-elements.js';
8
- import { A as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
3
+ import { T as TextField } from './text-field2.js';
9
4
  import { s as styles } from './text-field.js';
5
+ import { a as affixIconTemplateFactory } from './affix.js';
10
6
  import { w as when } from './when.js';
11
7
  import { s as slotted } from './slotted.js';
8
+ import { g as getFeedbackTemplate } from './form-elements.js';
12
9
  import { c as classNames } from './class-names.js';
13
10
 
14
- const byteToHex = [];
15
- for (let i = 0; i < 256; ++i) {
16
- byteToHex.push((i + 0x100).toString(16).slice(1));
17
- }
18
- function unsafeStringify(arr, offset = 0) {
19
- return (byteToHex[arr[offset + 0]] +
20
- byteToHex[arr[offset + 1]] +
21
- byteToHex[arr[offset + 2]] +
22
- byteToHex[arr[offset + 3]] +
23
- '-' +
24
- byteToHex[arr[offset + 4]] +
25
- byteToHex[arr[offset + 5]] +
26
- '-' +
27
- byteToHex[arr[offset + 6]] +
28
- byteToHex[arr[offset + 7]] +
29
- '-' +
30
- byteToHex[arr[offset + 8]] +
31
- byteToHex[arr[offset + 9]] +
32
- '-' +
33
- byteToHex[arr[offset + 10]] +
34
- byteToHex[arr[offset + 11]] +
35
- byteToHex[arr[offset + 12]] +
36
- byteToHex[arr[offset + 13]] +
37
- byteToHex[arr[offset + 14]] +
38
- byteToHex[arr[offset + 15]]).toLowerCase();
39
- }
40
-
41
- let getRandomValues;
42
- const rnds8 = new Uint8Array(16);
43
- function rng() {
44
- if (!getRandomValues) {
45
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
46
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
47
- }
48
- getRandomValues = crypto.getRandomValues.bind(crypto);
49
- }
50
- return getRandomValues(rnds8);
51
- }
52
-
53
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
54
- const native = { randomUUID };
55
-
56
- function v4(options, buf, offset) {
57
- if (native.randomUUID && !buf && !options) {
58
- return native.randomUUID();
59
- }
60
- options = options || {};
61
- const rnds = options.random || (options.rng || rng)();
62
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
63
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
64
- return unsafeStringify(rnds);
65
- }
66
-
67
- const generateRandomId = () => v4();
68
-
69
- var __defProp = Object.defineProperty;
70
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
71
- var __typeError = (msg) => {
72
- throw TypeError(msg);
73
- };
74
- var __decorateClass = (decorators, target, key, kind) => {
75
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
76
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
77
- if (decorator = decorators[i])
78
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
79
- if (kind && result) __defProp(target, key, result);
80
- return result;
81
- };
82
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
83
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
84
- 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);
85
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
86
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
87
- var _TextField_instances, handleLabelChange_fn, _reflectToInput, _helperTextMirrorEl, _helperTextSlotMutationObserver, updateHelperTextMutationObserver_fn, updateMirroredHelperText_fn;
88
- const safariWorkaroundClassName = "_vvd-3-text-field-safari-workaround";
89
- const getSafariWorkaroundStyleSheet = memoizeWith(
90
- () => "",
91
- () => {
92
- const styleSheet = new CSSStyleSheet();
93
- const supportsReplaceSync = "replaceSync" in styleSheet;
94
- if (supportsReplaceSync) {
95
- styleSheet.replaceSync(`
96
- .${safariWorkaroundClassName}::placeholder {
97
- opacity: 1 !important;
98
- -webkit-text-fill-color: var(--_low-ink-color) !important;
99
- }`);
100
- }
101
- return styleSheet;
102
- }
103
- );
104
- const installSafariWorkaroundStyle = (forElement) => {
105
- const root = forElement.getRootNode();
106
- const workaroundStyleSheet = getSafariWorkaroundStyleSheet();
107
- const supportsAdoptedStyleSheets = "adoptedStyleSheets" in root;
108
- if (!supportsAdoptedStyleSheets) {
109
- return;
110
- }
111
- if (!root.adoptedStyleSheets.includes(workaroundStyleSheet)) {
112
- root.adoptedStyleSheets = [
113
- ...root.adoptedStyleSheets,
114
- workaroundStyleSheet
115
- ];
116
- }
117
- };
118
- let TextField = class extends TextField$1 {
119
- constructor() {
120
- super(...arguments);
121
- __privateAdd(this, _TextField_instances);
122
- /**
123
- * @internal
124
- */
125
- this._labelEl = null;
126
- __privateAdd(this, _reflectToInput);
127
- __privateAdd(this, _helperTextMirrorEl);
128
- __privateAdd(this, _helperTextSlotMutationObserver);
129
- }
130
- /**
131
- * @internal
132
- */
133
- labelChanged() {
134
- if (this._labelEl) {
135
- __privateMethod(this, _TextField_instances, handleLabelChange_fn).call(this, this._labelEl);
136
- }
137
- }
138
- connectedCallback() {
139
- super.connectedCallback();
140
- if (!this.control) {
141
- const uniqueId = this.id || generateRandomId();
142
- const controlId = `vvd-text-field-control-${uniqueId}`;
143
- const helperTextId = `vvd-text-field-helper-text-${uniqueId}`;
144
- const input = document.createElement("input");
145
- input.slot = "_control";
146
- input.id = controlId;
147
- input.className = safariWorkaroundClassName;
148
- this.control = input;
149
- input.addEventListener("input", () => {
150
- this.handleTextInput();
151
- });
152
- input.addEventListener("change", () => {
153
- this.handleChange();
154
- });
155
- input.addEventListener("blur", () => {
156
- this.$emit("blur", void 0, { bubbles: false });
157
- });
158
- input.addEventListener("focus", () => {
159
- this.$emit("focus", void 0, { bubbles: false });
160
- });
161
- this.appendChild(input);
162
- const label = document.createElement("label");
163
- label.slot = "_label";
164
- label.htmlFor = controlId;
165
- this._labelEl = label;
166
- __privateMethod(this, _TextField_instances, handleLabelChange_fn).call(this, label);
167
- __privateSet(this, _helperTextMirrorEl, document.createElement("div"));
168
- __privateGet(this, _helperTextMirrorEl).id = helperTextId;
169
- __privateGet(this, _helperTextMirrorEl).slot = "_mirrored-helper-text";
170
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
171
- this.appendChild(__privateGet(this, _helperTextMirrorEl));
172
- installSafariWorkaroundStyle(this);
173
- }
174
- __privateSet(this, _reflectToInput, new Reflector(this, this.control));
175
- __privateGet(this, _reflectToInput).booleanAttribute("autofocus", "autofocus");
176
- __privateGet(this, _reflectToInput).booleanAttribute("disabled", "disabled");
177
- __privateGet(this, _reflectToInput).booleanAttribute("readOnly", "readonly");
178
- __privateGet(this, _reflectToInput).booleanAttribute("required", "required");
179
- __privateGet(this, _reflectToInput).booleanAttribute("spellcheck", "spellcheck");
180
- __privateGet(this, _reflectToInput).attribute("list", "list");
181
- __privateGet(this, _reflectToInput).attribute("maxlength", "maxlength");
182
- __privateGet(this, _reflectToInput).attribute("minlength", "minlength");
183
- __privateGet(this, _reflectToInput).attribute("pattern", "pattern");
184
- __privateGet(this, _reflectToInput).attribute("placeholder", "placeholder");
185
- __privateGet(this, _reflectToInput).attribute("size", "size");
186
- __privateGet(this, _reflectToInput).attribute("autoComplete", "autocomplete");
187
- __privateGet(this, _reflectToInput).attribute("type", "type");
188
- __privateGet(this, _reflectToInput).attribute("inputMode", "inputmode");
189
- __privateGet(this, _reflectToInput).attribute("ariaAtomic", "aria-atomic");
190
- __privateGet(this, _reflectToInput).attribute("ariaBusy", "aria-busy");
191
- __privateGet(this, _reflectToInput).attribute("ariaCurrent", "aria-current");
192
- __privateGet(this, _reflectToInput).attribute("ariaDetails", "aria-details");
193
- __privateGet(this, _reflectToInput).attribute("ariaDisabled", "aria-disabled");
194
- __privateGet(this, _reflectToInput).attribute("ariaHaspopup", "aria-haspopup");
195
- __privateGet(this, _reflectToInput).attribute("ariaHidden", "aria-hidden");
196
- __privateGet(this, _reflectToInput).attribute("ariaInvalid", "aria-invalid");
197
- __privateGet(this, _reflectToInput).attribute("ariaKeyshortcuts", "aria-keyshortcuts");
198
- __privateGet(this, _reflectToInput).attribute("ariaLabel", "aria-label");
199
- __privateGet(this, _reflectToInput).attribute("ariaLive", "aria-live");
200
- __privateGet(this, _reflectToInput).attribute("ariaRelevant", "aria-relevant");
201
- __privateGet(this, _reflectToInput).attribute(
202
- "ariaRoledescription",
203
- "aria-roledescription"
204
- );
205
- __privateGet(this, _reflectToInput).property("value", "value", true);
206
- __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
207
- }
208
- disconnectedCallback() {
209
- super.disconnectedCallback();
210
- __privateGet(this, _reflectToInput).destroy();
211
- __privateSet(this, _reflectToInput, void 0);
212
- __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
213
- }
214
- focus() {
215
- this.control?.focus();
216
- }
217
- /**
218
- * @internal
219
- */
220
- helperTextChanged() {
221
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
222
- }
223
- /**
224
- * @internal
225
- */
226
- _helperTextSlottedContentChanged() {
227
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
228
- __privateMethod(this, _TextField_instances, updateHelperTextMutationObserver_fn).call(this);
229
- }
230
- };
231
- _TextField_instances = new WeakSet();
232
- handleLabelChange_fn = function(labelEl) {
233
- if (!this.label) {
234
- labelEl.remove();
235
- } else {
236
- labelEl.textContent = this.label;
237
- if (!labelEl.isConnected) {
238
- this.appendChild(labelEl);
239
- }
240
- }
241
- };
242
- _reflectToInput = new WeakMap();
243
- _helperTextMirrorEl = new WeakMap();
244
- _helperTextSlotMutationObserver = new WeakMap();
245
- updateHelperTextMutationObserver_fn = function() {
246
- const usesHelperTextSlot = this._helperTextSlottedContent.length;
247
- const shouldHaveMutationObserver = usesHelperTextSlot && this.isConnected;
248
- if (shouldHaveMutationObserver && !__privateGet(this, _helperTextSlotMutationObserver)) {
249
- __privateSet(this, _helperTextSlotMutationObserver, new MutationObserver((records) => {
250
- if (records.some((record) => record.target !== __privateGet(this, _helperTextMirrorEl))) {
251
- __privateMethod(this, _TextField_instances, updateMirroredHelperText_fn).call(this);
252
- }
253
- }));
254
- __privateGet(this, _helperTextSlotMutationObserver).observe(this, {
255
- subtree: true,
256
- childList: true,
257
- characterData: true
258
- });
259
- }
260
- if (!shouldHaveMutationObserver && __privateGet(this, _helperTextSlotMutationObserver)) {
261
- __privateGet(this, _helperTextSlotMutationObserver).disconnect();
262
- __privateSet(this, _helperTextSlotMutationObserver, void 0);
263
- }
264
- };
265
- updateMirroredHelperText_fn = function() {
266
- let helperText = this.helperText ?? "";
267
- if (this._helperTextSlottedContent?.length) {
268
- helperText = this._helperTextSlottedContent.map((node) => node.innerText).join(" ");
269
- }
270
- if (__privateGet(this, _helperTextMirrorEl)) {
271
- __privateGet(this, _helperTextMirrorEl).textContent = helperText;
272
- if (helperText) {
273
- this.control.setAttribute(
274
- "aria-describedby",
275
- __privateGet(this, _helperTextMirrorEl).id
276
- );
277
- } else {
278
- this.control.removeAttribute("aria-describedby");
279
- }
280
- }
281
- };
282
- __decorateClass([
283
- attr
284
- ], TextField.prototype, "appearance", 2);
285
- __decorateClass([
286
- attr
287
- ], TextField.prototype, "shape", 2);
288
- __decorateClass([
289
- attr
290
- ], TextField.prototype, "autoComplete", 2);
291
- __decorateClass([
292
- attr()
293
- ], TextField.prototype, "scale", 2);
294
- __decorateClass([
295
- attr({ attribute: "inputmode" })
296
- ], TextField.prototype, "inputMode", 2);
297
- __decorateClass([
298
- observable
299
- ], TextField.prototype, "actionItemsSlottedContent", 2);
300
- __decorateClass([
301
- observable
302
- ], TextField.prototype, "leadingActionItemsSlottedContent", 2);
303
- TextField = __decorateClass([
304
- errorText,
305
- formElements
306
- ], TextField);
307
- applyMixinsWithObservables(
308
- TextField,
309
- AffixIcon,
310
- FormElementCharCount,
311
- FormElementHelperText,
312
- FormElementSuccessText
313
- );
314
-
315
11
  const getStateClasses = ({
316
12
  errorValidationMessage,
317
13
  disabled,
@@ -389,4 +85,4 @@ const textFieldDefinition = TextField.compose({
389
85
  const textFieldRegistries = [textFieldDefinition(), ...iconRegistries];
390
86
  const registerTextField = registerFactory(textFieldRegistries);
391
87
 
392
- export { TextField as T, textFieldRegistries as a, registerTextField as r, textFieldDefinition as t };
88
+ export { textFieldRegistries as a, registerTextField as r, textFieldDefinition as t };