@vonage/vivid 4.14.2 → 4.14.4

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 (81) hide show
  1. package/custom-elements.json +1361 -1017
  2. package/index.cjs +1 -0
  3. package/index.js +1 -1
  4. package/lib/accordion/definition.d.ts +5 -1
  5. package/lib/combobox/combobox.d.ts +5 -1
  6. package/lib/file-picker/file-picker.d.ts +1 -0
  7. package/lib/menu-item/definition.d.ts +1 -1
  8. package/lib/menu-item/menu-item-role.d.ts +7 -0
  9. package/lib/menu-item/menu-item.d.ts +1 -7
  10. package/lib/number-field/number-field.d.ts +1 -1
  11. package/lib/option/option.d.ts +6 -0
  12. package/lib/radio/radio.d.ts +2 -2
  13. package/lib/searchable-select/option-tag.d.ts +2 -2
  14. package/lib/select/select.form-associated.d.ts +1 -1
  15. package/lib/switch/switch.d.ts +1 -0
  16. package/lib/tabs/tabs.d.ts +5 -1
  17. package/lib/text-anchor/text-anchor.d.ts +1 -1
  18. package/lib/tree-item/tree-item.d.ts +1 -1
  19. package/lib/tree-view/tree-view.d.ts +1 -1
  20. package/package.json +1 -1
  21. package/shared/applyMixinsWithObservables.cjs +1 -1
  22. package/shared/applyMixinsWithObservables.js +1 -1
  23. package/shared/definition11.cjs +1 -1
  24. package/shared/definition11.js +1 -1
  25. package/shared/definition16.cjs +63 -30
  26. package/shared/definition16.js +61 -28
  27. package/shared/definition17.cjs +2 -2
  28. package/shared/definition17.js +2 -2
  29. package/shared/definition2.cjs +11 -6
  30. package/shared/definition2.js +11 -7
  31. package/shared/definition25.cjs +25 -18
  32. package/shared/definition25.js +26 -19
  33. package/shared/definition29.cjs +12 -33
  34. package/shared/definition29.js +12 -33
  35. package/shared/definition33.cjs +1 -1
  36. package/shared/definition33.js +1 -1
  37. package/shared/definition34.cjs +4 -294
  38. package/shared/definition34.js +4 -294
  39. package/shared/definition41.cjs +1 -1
  40. package/shared/definition41.js +1 -1
  41. package/shared/definition42.cjs +1 -2
  42. package/shared/definition42.js +1 -2
  43. package/shared/definition43.cjs +1 -2
  44. package/shared/definition43.js +1 -2
  45. package/shared/definition46.cjs +2 -2
  46. package/shared/definition46.js +3 -3
  47. package/shared/definition48.cjs +22 -15
  48. package/shared/definition48.js +22 -15
  49. package/shared/definition5.cjs +4 -3
  50. package/shared/definition5.js +4 -3
  51. package/shared/definition51.cjs +11 -402
  52. package/shared/definition51.js +17 -408
  53. package/shared/definition54.js +1 -1
  54. package/shared/definition56.js +1 -1
  55. package/shared/direction.cjs +2 -16
  56. package/shared/direction.js +3 -17
  57. package/shared/foundation/utilities/direction.d.ts +2 -0
  58. package/shared/listbox.cjs +1 -1
  59. package/shared/listbox.js +1 -1
  60. package/shared/text-anchor.cjs +1 -1
  61. package/shared/text-anchor.js +1 -1
  62. package/shared/text-field2.js +1 -1
  63. package/shared/vivid-element.cjs +0 -2
  64. package/shared/vivid-element.js +1 -1
  65. package/styles/core/all.css +1 -1
  66. package/styles/core/theme.css +1 -1
  67. package/styles/core/typography.css +1 -1
  68. package/styles/tokens/theme-dark.css +4 -4
  69. package/styles/tokens/theme-light.css +4 -4
  70. package/styles/tokens/vivid-2-compat.css +1 -1
  71. package/vivid.api.json +70 -3
  72. package/shared/apply-mixins2.cjs +0 -25
  73. package/shared/apply-mixins2.js +0 -23
  74. package/shared/form-associated2.cjs +0 -383
  75. package/shared/form-associated2.js +0 -381
  76. package/shared/foundation-element.cjs +0 -1417
  77. package/shared/foundation-element.js +0 -1414
  78. package/shared/key-codes2.cjs +0 -96
  79. package/shared/key-codes2.js +0 -88
  80. package/shared/start-end.cjs +0 -52
  81. package/shared/start-end.js +0 -50
@@ -1,381 +0,0 @@
1
- import { a as attr, o as observable, e as emptyArray, D as DOM } from './vivid-element.js';
2
- import { k as keyEnter } from './key-codes2.js';
3
-
4
- const proxySlotName = "form-associated-proxy";
5
- const ElementInternalsKey = "ElementInternals";
6
- /**
7
- * @alpha
8
- */
9
- const supportsElementInternals = ElementInternalsKey in window &&
10
- "setFormValue" in window[ElementInternalsKey].prototype;
11
- const InternalsMap = new WeakMap();
12
- /**
13
- * Base function for providing Custom Element Form Association.
14
- *
15
- * @alpha
16
- */
17
- function FormAssociated(BaseCtor) {
18
- const C = class extends BaseCtor {
19
- constructor(...args) {
20
- super(...args);
21
- /**
22
- * Track whether the value has been changed from the initial value
23
- */
24
- this.dirtyValue = false;
25
- /**
26
- * Sets the element's disabled state. A disabled element will not be included during form submission.
27
- *
28
- * @remarks
29
- * HTML Attribute: disabled
30
- */
31
- this.disabled = false;
32
- /**
33
- * These are events that are still fired by the proxy
34
- * element based on user / programmatic interaction.
35
- *
36
- * The proxy implementation should be transparent to
37
- * the app author, so block these events from emitting.
38
- */
39
- this.proxyEventsToBlock = ["change", "click"];
40
- this.proxyInitialized = false;
41
- this.required = false;
42
- this.initialValue = this.initialValue || "";
43
- if (!this.elementInternals) {
44
- // When elementInternals is not supported, formResetCallback is
45
- // bound to an event listener, so ensure the handler's `this`
46
- // context is correct.
47
- this.formResetCallback = this.formResetCallback.bind(this);
48
- }
49
- }
50
- /**
51
- * Must evaluate to true to enable elementInternals.
52
- * Feature detects API support and resolve respectively
53
- *
54
- * @internal
55
- */
56
- static get formAssociated() {
57
- return supportsElementInternals;
58
- }
59
- /**
60
- * Returns the validity state of the element
61
- *
62
- * @alpha
63
- */
64
- get validity() {
65
- return this.elementInternals
66
- ? this.elementInternals.validity
67
- : this.proxy.validity;
68
- }
69
- /**
70
- * Retrieve a reference to the associated form.
71
- * Returns null if not associated to any form.
72
- *
73
- * @alpha
74
- */
75
- get form() {
76
- return this.elementInternals ? this.elementInternals.form : this.proxy.form;
77
- }
78
- /**
79
- * Retrieve the localized validation message,
80
- * or custom validation message if set.
81
- *
82
- * @alpha
83
- */
84
- get validationMessage() {
85
- return this.elementInternals
86
- ? this.elementInternals.validationMessage
87
- : this.proxy.validationMessage;
88
- }
89
- /**
90
- * Whether the element will be validated when the
91
- * form is submitted
92
- */
93
- get willValidate() {
94
- return this.elementInternals
95
- ? this.elementInternals.willValidate
96
- : this.proxy.willValidate;
97
- }
98
- /**
99
- * A reference to all associated label elements
100
- */
101
- get labels() {
102
- if (this.elementInternals) {
103
- return Object.freeze(Array.from(this.elementInternals.labels));
104
- }
105
- else if (this.proxy instanceof HTMLElement &&
106
- this.proxy.ownerDocument &&
107
- this.id) {
108
- // Labels associated by wrapping the element: <label><custom-element></custom-element></label>
109
- const parentLabels = this.proxy.labels;
110
- // Labels associated using the `for` attribute
111
- const forLabels = Array.from(this.proxy.getRootNode().querySelectorAll(`[for='${this.id}']`));
112
- const labels = parentLabels
113
- ? forLabels.concat(Array.from(parentLabels))
114
- : forLabels;
115
- return Object.freeze(labels);
116
- }
117
- else {
118
- return emptyArray;
119
- }
120
- }
121
- /**
122
- * Invoked when the `value` property changes
123
- * @param previous - the previous value
124
- * @param next - the new value
125
- *
126
- * @remarks
127
- * If elements extending `FormAssociated` implement a `valueChanged` method
128
- * They must be sure to invoke `super.valueChanged(previous, next)` to ensure
129
- * proper functioning of `FormAssociated`
130
- */
131
- valueChanged(previous, next) {
132
- this.dirtyValue = true;
133
- if (this.proxy instanceof HTMLElement) {
134
- this.proxy.value = this.value;
135
- }
136
- this.currentValue = this.value;
137
- this.setFormValue(this.value);
138
- this.validate();
139
- }
140
- currentValueChanged() {
141
- this.value = this.currentValue;
142
- }
143
- /**
144
- * Invoked when the `initialValue` property changes
145
- *
146
- * @param previous - the previous value
147
- * @param next - the new value
148
- *
149
- * @remarks
150
- * If elements extending `FormAssociated` implement a `initialValueChanged` method
151
- * They must be sure to invoke `super.initialValueChanged(previous, next)` to ensure
152
- * proper functioning of `FormAssociated`
153
- */
154
- initialValueChanged(previous, next) {
155
- // If the value is clean and the component is connected to the DOM
156
- // then set value equal to the attribute value.
157
- if (!this.dirtyValue) {
158
- this.value = this.initialValue;
159
- this.dirtyValue = false;
160
- }
161
- }
162
- /**
163
- * Invoked when the `disabled` property changes
164
- *
165
- * @param previous - the previous value
166
- * @param next - the new value
167
- *
168
- * @remarks
169
- * If elements extending `FormAssociated` implement a `disabledChanged` method
170
- * They must be sure to invoke `super.disabledChanged(previous, next)` to ensure
171
- * proper functioning of `FormAssociated`
172
- */
173
- disabledChanged(previous, next) {
174
- if (this.proxy instanceof HTMLElement) {
175
- this.proxy.disabled = this.disabled;
176
- }
177
- DOM.queueUpdate(() => this.classList.toggle("disabled", this.disabled));
178
- }
179
- /**
180
- * Invoked when the `name` property changes
181
- *
182
- * @param previous - the previous value
183
- * @param next - the new value
184
- *
185
- * @remarks
186
- * If elements extending `FormAssociated` implement a `nameChanged` method
187
- * They must be sure to invoke `super.nameChanged(previous, next)` to ensure
188
- * proper functioning of `FormAssociated`
189
- */
190
- nameChanged(previous, next) {
191
- if (this.proxy instanceof HTMLElement) {
192
- this.proxy.name = this.name;
193
- }
194
- }
195
- /**
196
- * Invoked when the `required` property changes
197
- *
198
- * @param previous - the previous value
199
- * @param next - the new value
200
- *
201
- * @remarks
202
- * If elements extending `FormAssociated` implement a `requiredChanged` method
203
- * They must be sure to invoke `super.requiredChanged(previous, next)` to ensure
204
- * proper functioning of `FormAssociated`
205
- */
206
- requiredChanged(prev, next) {
207
- if (this.proxy instanceof HTMLElement) {
208
- this.proxy.required = this.required;
209
- }
210
- DOM.queueUpdate(() => this.classList.toggle("required", this.required));
211
- this.validate();
212
- }
213
- /**
214
- * The element internals object. Will only exist
215
- * in browsers supporting the attachInternals API
216
- */
217
- get elementInternals() {
218
- if (!supportsElementInternals) {
219
- return null;
220
- }
221
- let internals = InternalsMap.get(this);
222
- if (!internals) {
223
- internals = this.attachInternals();
224
- InternalsMap.set(this, internals);
225
- }
226
- return internals;
227
- }
228
- /**
229
- * @internal
230
- */
231
- connectedCallback() {
232
- super.connectedCallback();
233
- this.addEventListener("keypress", this._keypressHandler);
234
- if (!this.value) {
235
- this.value = this.initialValue;
236
- this.dirtyValue = false;
237
- }
238
- if (!this.elementInternals) {
239
- this.attachProxy();
240
- if (this.form) {
241
- this.form.addEventListener("reset", this.formResetCallback);
242
- }
243
- }
244
- }
245
- /**
246
- * @internal
247
- */
248
- disconnectedCallback() {
249
- super.disconnectedCallback();
250
- this.proxyEventsToBlock.forEach(name => this.proxy.removeEventListener(name, this.stopPropagation));
251
- if (!this.elementInternals && this.form) {
252
- this.form.removeEventListener("reset", this.formResetCallback);
253
- }
254
- }
255
- /**
256
- * Return the current validity of the element.
257
- */
258
- checkValidity() {
259
- return this.elementInternals
260
- ? this.elementInternals.checkValidity()
261
- : this.proxy.checkValidity();
262
- }
263
- /**
264
- * Return the current validity of the element.
265
- * If false, fires an invalid event at the element.
266
- */
267
- reportValidity() {
268
- return this.elementInternals
269
- ? this.elementInternals.reportValidity()
270
- : this.proxy.reportValidity();
271
- }
272
- /**
273
- * Set the validity of the control. In cases when the elementInternals object is not
274
- * available (and the proxy element is used to report validity), this function will
275
- * do nothing unless a message is provided, at which point the setCustomValidity method
276
- * of the proxy element will be invoked with the provided message.
277
- * @param flags - Validity flags
278
- * @param message - Optional message to supply
279
- * @param anchor - Optional element used by UA to display an interactive validation UI
280
- */
281
- setValidity(flags, message, anchor) {
282
- if (this.elementInternals) {
283
- this.elementInternals.setValidity(flags, message, anchor);
284
- }
285
- else if (typeof message === "string") {
286
- this.proxy.setCustomValidity(message);
287
- }
288
- }
289
- /**
290
- * Invoked when a connected component's form or fieldset has its disabled
291
- * state changed.
292
- * @param disabled - the disabled value of the form / fieldset
293
- */
294
- formDisabledCallback(disabled) {
295
- this.disabled = disabled;
296
- }
297
- formResetCallback() {
298
- this.value = this.initialValue;
299
- this.dirtyValue = false;
300
- }
301
- /**
302
- * Attach the proxy element to the DOM
303
- */
304
- attachProxy() {
305
- var _a;
306
- if (!this.proxyInitialized) {
307
- this.proxyInitialized = true;
308
- this.proxy.style.display = "none";
309
- this.proxyEventsToBlock.forEach(name => this.proxy.addEventListener(name, this.stopPropagation));
310
- // These are typically mapped to the proxy during
311
- // property change callbacks, but during initialization
312
- // on the initial call of the callback, the proxy is
313
- // still undefined. We should find a better way to address this.
314
- this.proxy.disabled = this.disabled;
315
- this.proxy.required = this.required;
316
- if (typeof this.name === "string") {
317
- this.proxy.name = this.name;
318
- }
319
- if (typeof this.value === "string") {
320
- this.proxy.value = this.value;
321
- }
322
- this.proxy.setAttribute("slot", proxySlotName);
323
- this.proxySlot = document.createElement("slot");
324
- this.proxySlot.setAttribute("name", proxySlotName);
325
- }
326
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(this.proxySlot);
327
- this.appendChild(this.proxy);
328
- }
329
- /**
330
- * Detach the proxy element from the DOM
331
- */
332
- detachProxy() {
333
- var _a;
334
- this.removeChild(this.proxy);
335
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeChild(this.proxySlot);
336
- }
337
- /** {@inheritDoc (FormAssociated:interface).validate} */
338
- validate(anchor) {
339
- if (this.proxy instanceof HTMLElement) {
340
- this.setValidity(this.proxy.validity, this.proxy.validationMessage, anchor);
341
- }
342
- }
343
- /**
344
- * Associates the provided value (and optional state) with the parent form.
345
- * @param value - The value to set
346
- * @param state - The state object provided to during session restores and when autofilling.
347
- */
348
- setFormValue(value, state) {
349
- if (this.elementInternals) {
350
- this.elementInternals.setFormValue(value, state || value);
351
- }
352
- }
353
- _keypressHandler(e) {
354
- switch (e.key) {
355
- case keyEnter:
356
- if (this.form instanceof HTMLFormElement) {
357
- // Implicit submission
358
- const defaultButton = this.form.querySelector("[type=submit]");
359
- defaultButton === null || defaultButton === void 0 ? void 0 : defaultButton.click();
360
- }
361
- break;
362
- }
363
- }
364
- /**
365
- * Used to stop propagation of proxy element events
366
- * @param e - Event object
367
- */
368
- stopPropagation(e) {
369
- e.stopPropagation();
370
- }
371
- };
372
- attr({ mode: "boolean" })(C.prototype, "disabled");
373
- attr({ mode: "fromView", attribute: "value" })(C.prototype, "initialValue");
374
- attr({ attribute: "current-value" })(C.prototype, "currentValue");
375
- attr(C.prototype, "name");
376
- attr({ mode: "boolean" })(C.prototype, "required");
377
- observable(C.prototype, "value");
378
- return C;
379
- }
380
-
381
- export { FormAssociated as F };