@vonage/vivid 4.14.2 → 4.14.3

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