@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.
- package/custom-elements.json +1361 -1017
- package/index.cjs +1 -0
- package/index.js +1 -1
- package/lib/accordion/definition.d.ts +5 -1
- package/lib/combobox/combobox.d.ts +5 -1
- package/lib/file-picker/file-picker.d.ts +1 -0
- package/lib/menu-item/definition.d.ts +1 -1
- package/lib/menu-item/menu-item-role.d.ts +7 -0
- package/lib/menu-item/menu-item.d.ts +1 -7
- package/lib/number-field/number-field.d.ts +1 -1
- package/lib/option/option.d.ts +6 -0
- package/lib/radio/radio.d.ts +2 -2
- package/lib/searchable-select/option-tag.d.ts +2 -2
- package/lib/select/select.form-associated.d.ts +1 -1
- package/lib/switch/switch.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +5 -1
- package/lib/text-anchor/text-anchor.d.ts +1 -1
- package/lib/tree-item/tree-item.d.ts +1 -1
- package/lib/tree-view/tree-view.d.ts +1 -1
- package/package.json +1 -1
- package/shared/applyMixinsWithObservables.cjs +1 -1
- package/shared/applyMixinsWithObservables.js +1 -1
- package/shared/definition11.cjs +1 -1
- package/shared/definition11.js +1 -1
- package/shared/definition16.cjs +63 -30
- package/shared/definition16.js +61 -28
- package/shared/definition17.cjs +2 -2
- package/shared/definition17.js +2 -2
- package/shared/definition2.cjs +11 -6
- package/shared/definition2.js +11 -7
- package/shared/definition25.cjs +25 -18
- package/shared/definition25.js +26 -19
- package/shared/definition29.cjs +12 -33
- package/shared/definition29.js +12 -33
- package/shared/definition33.cjs +1 -1
- package/shared/definition33.js +1 -1
- package/shared/definition34.cjs +4 -294
- package/shared/definition34.js +4 -294
- package/shared/definition41.cjs +1 -1
- package/shared/definition41.js +1 -1
- package/shared/definition42.cjs +1 -2
- package/shared/definition42.js +1 -2
- package/shared/definition43.cjs +1 -2
- package/shared/definition43.js +1 -2
- package/shared/definition46.cjs +2 -2
- package/shared/definition46.js +3 -3
- package/shared/definition48.cjs +22 -15
- package/shared/definition48.js +22 -15
- package/shared/definition5.cjs +4 -3
- package/shared/definition5.js +4 -3
- package/shared/definition51.cjs +11 -402
- package/shared/definition51.js +17 -408
- package/shared/definition54.js +1 -1
- package/shared/definition56.js +1 -1
- package/shared/direction.cjs +2 -16
- package/shared/direction.js +3 -17
- package/shared/foundation/utilities/direction.d.ts +2 -0
- package/shared/listbox.cjs +1 -1
- package/shared/listbox.js +1 -1
- package/shared/text-anchor.cjs +1 -1
- package/shared/text-anchor.js +1 -1
- package/shared/text-field2.js +1 -1
- package/shared/vivid-element.cjs +0 -2
- package/shared/vivid-element.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/vivid.api.json +70 -3
- package/shared/apply-mixins2.cjs +0 -25
- package/shared/apply-mixins2.js +0 -23
- package/shared/form-associated2.cjs +0 -383
- package/shared/form-associated2.js +0 -381
- package/shared/foundation-element.cjs +0 -1417
- package/shared/foundation-element.js +0 -1414
- package/shared/key-codes2.cjs +0 -96
- package/shared/key-codes2.js +0 -88
- package/shared/start-end.cjs +0 -52
- package/shared/start-end.js +0 -50
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Do not edit directly
|
|
3
|
-
* Generated on Tue,
|
|
3
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Do not edit directly
|
|
7
|
-
* Generated on Tue,
|
|
7
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Do not edit directly
|
|
11
|
-
* Generated on Tue,
|
|
11
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* Do not edit directly
|
|
15
|
-
* Generated on Tue,
|
|
15
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 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,
|
|
3
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Do not edit directly
|
|
7
|
-
* Generated on Tue,
|
|
7
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Do not edit directly
|
|
11
|
-
* Generated on Tue,
|
|
11
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* Do not edit directly
|
|
15
|
-
* Generated on Tue,
|
|
15
|
+
* Generated on Tue, 04 Feb 2025 16:43:13 GMT
|
|
16
16
|
*/
|
|
17
17
|
@property --vvd-size-density {
|
|
18
18
|
syntax: "<integer>";
|
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
|
|
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",
|
package/shared/apply-mixins2.cjs
DELETED
|
@@ -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;
|
package/shared/apply-mixins2.js
DELETED
|
@@ -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;
|