@vaadin/field-base 23.2.16 → 23.2.18
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/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +4 -4
- package/src/checked-mixin.d.ts +2 -2
- package/src/checked-mixin.js +2 -2
- package/src/delegate-focus-mixin.d.ts +48 -0
- package/src/delegate-focus-mixin.js +228 -0
- package/src/delegate-state-mixin.d.ts +20 -0
- package/src/delegate-state-mixin.js +125 -0
- package/src/error-controller.d.ts +8 -3
- package/src/error-controller.js +65 -53
- package/src/field-aria-controller.d.ts +1 -1
- package/src/field-aria-controller.js +11 -11
- package/src/field-mixin.d.ts +1 -1
- package/src/field-mixin.js +28 -24
- package/src/helper-controller.d.ts +5 -3
- package/src/helper-controller.js +147 -47
- package/src/input-constraints-mixin.d.ts +4 -2
- package/src/input-constraints-mixin.js +2 -2
- package/src/input-control-mixin.d.ts +3 -3
- package/src/input-control-mixin.js +4 -4
- package/src/input-controller.d.ts +1 -1
- package/src/input-controller.js +8 -5
- package/src/input-field-mixin.d.ts +3 -3
- package/src/input-field-mixin.js +10 -10
- package/src/input-mixin.d.ts +3 -5
- package/src/input-mixin.js +10 -26
- package/src/label-controller.d.ts +8 -3
- package/src/label-controller.js +149 -45
- package/src/label-mixin.d.ts +1 -1
- package/src/label-mixin.js +8 -13
- package/src/labelled-input-controller.d.ts +1 -1
- package/src/labelled-input-controller.js +2 -2
- package/src/pattern-mixin.d.ts +13 -3
- package/src/pattern-mixin.js +50 -2
- package/src/shadow-focus-mixin.d.ts +23 -0
- package/src/shadow-focus-mixin.js +97 -0
- package/src/slot-styles-mixin.d.ts +1 -1
- package/src/slot-styles-mixin.js +1 -1
- package/src/slot-target-controller.d.ts +31 -0
- package/src/slot-target-controller.js +123 -0
- package/src/styles/clear-button-styles.d.ts +1 -1
- package/src/styles/clear-button-styles.js +2 -2
- package/src/styles/field-shared-styles.d.ts +1 -1
- package/src/styles/field-shared-styles.js +1 -1
- package/src/styles/input-field-container-styles.d.ts +1 -1
- package/src/styles/input-field-container-styles.js +1 -1
- package/src/styles/input-field-shared-styles.d.ts +1 -1
- package/src/styles/input-field-shared-styles.js +1 -1
- package/src/text-area-controller.d.ts +1 -1
- package/src/text-area-controller.js +8 -5
- package/src/validate-mixin.d.ts +1 -1
- package/src/validate-mixin.js +1 -1
- package/src/virtual-keyboard-controller.d.ts +1 -1
- package/src/virtual-keyboard-controller.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { CheckedMixin } from './src/checked-mixin.js';
|
|
2
|
+
export { DelegateFocusMixin } from './src/delegate-focus-mixin.js';
|
|
3
|
+
export { DelegateStateMixin } from './src/delegate-state-mixin.js';
|
|
2
4
|
export { FieldAriaController } from './src/field-aria-controller.js';
|
|
3
5
|
export { FieldMixin } from './src/field-mixin.js';
|
|
4
6
|
export { InputController } from './src/input-controller.js';
|
|
@@ -8,6 +10,7 @@ export { InputMixin } from './src/input-mixin.js';
|
|
|
8
10
|
export { LabelledInputController } from './src/labelled-input-controller.js';
|
|
9
11
|
export { LabelMixin } from './src/label-mixin.js';
|
|
10
12
|
export { PatternMixin } from './src/pattern-mixin.js';
|
|
13
|
+
export { ShadowFocusMixin } from './src/shadow-focus-mixin.js';
|
|
11
14
|
export { SlotStylesMixin } from './src/slot-styles-mixin.js';
|
|
12
15
|
export { TextAreaController } from './src/text-area-controller.js';
|
|
13
16
|
export { ValidateMixin } from './src/validate-mixin.js';
|
package/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { CheckedMixin } from './src/checked-mixin.js';
|
|
2
|
+
export { DelegateFocusMixin } from './src/delegate-focus-mixin.js';
|
|
3
|
+
export { DelegateStateMixin } from './src/delegate-state-mixin.js';
|
|
2
4
|
export { FieldAriaController } from './src/field-aria-controller.js';
|
|
3
5
|
export { FieldMixin } from './src/field-mixin.js';
|
|
4
6
|
export { InputController } from './src/input-controller.js';
|
|
@@ -8,6 +10,7 @@ export { InputMixin } from './src/input-mixin.js';
|
|
|
8
10
|
export { LabelledInputController } from './src/labelled-input-controller.js';
|
|
9
11
|
export { LabelMixin } from './src/label-mixin.js';
|
|
10
12
|
export { PatternMixin } from './src/pattern-mixin.js';
|
|
13
|
+
export { ShadowFocusMixin } from './src/shadow-focus-mixin.js';
|
|
11
14
|
export { SlotStylesMixin } from './src/slot-styles-mixin.js';
|
|
12
15
|
export { TextAreaController } from './src/text-area-controller.js';
|
|
13
16
|
export { ValidateMixin } from './src/validate-mixin.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-base",
|
|
3
|
-
"version": "23.2.
|
|
3
|
+
"version": "23.2.18",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
34
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/component-base": "~23.2.
|
|
35
|
+
"@vaadin/component-base": "~23.2.18",
|
|
36
36
|
"lit": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@esm-bundle/chai": "^4.3.4",
|
|
40
|
-
"@vaadin/testing-helpers": "^0.
|
|
40
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
41
41
|
"sinon": "^13.0.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "0633266344f3b8eaae21f5c1365b682f163dd0cb"
|
|
44
44
|
}
|
package/src/checked-mixin.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
-
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
8
7
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
+
import type { DelegateStateMixinClass } from './delegate-state-mixin.js';
|
|
9
9
|
import type { InputMixinClass } from './input-mixin.js';
|
|
10
10
|
|
|
11
11
|
/**
|
package/src/checked-mixin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
8
7
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
9
8
|
import { isElementFocused } from '@vaadin/component-base/src/focus-utils.js';
|
|
9
|
+
import { DelegateStateMixin } from './delegate-state-mixin.js';
|
|
10
10
|
import { InputMixin } from './input-mixin.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
+
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
9
|
+
import type { TabindexMixinClass } from '@vaadin/component-base/src/tabindex-mixin.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A mixin to forward focus to an element in the light DOM.
|
|
13
|
+
*/
|
|
14
|
+
export declare function DelegateFocusMixin<T extends Constructor<HTMLElement>>(
|
|
15
|
+
base: T,
|
|
16
|
+
): Constructor<DelegateFocusMixinClass> &
|
|
17
|
+
Constructor<DisabledMixinClass> &
|
|
18
|
+
Constructor<FocusMixinClass> &
|
|
19
|
+
Constructor<TabindexMixinClass> &
|
|
20
|
+
T;
|
|
21
|
+
|
|
22
|
+
export declare class DelegateFocusMixinClass {
|
|
23
|
+
/**
|
|
24
|
+
* Specify that this control should have input focus when the page loads.
|
|
25
|
+
*/
|
|
26
|
+
autofocus: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A reference to the focusable element controlled by the mixin.
|
|
30
|
+
* It can be an input, textarea, button or any element with tabindex > -1.
|
|
31
|
+
*
|
|
32
|
+
* Any component implementing this mixin is expected to provide it
|
|
33
|
+
* by using `this._setFocusElement(input)` Polymer API.
|
|
34
|
+
*/
|
|
35
|
+
readonly focusElement: HTMLElement | null | undefined;
|
|
36
|
+
|
|
37
|
+
protected _addFocusListeners(element: HTMLElement): void;
|
|
38
|
+
|
|
39
|
+
protected _removeFocusListeners(element: HTMLElement): void;
|
|
40
|
+
|
|
41
|
+
protected _focusElementChanged(element: HTMLElement, oldElement: HTMLElement): void;
|
|
42
|
+
|
|
43
|
+
protected _onBlur(event: FocusEvent): void;
|
|
44
|
+
|
|
45
|
+
protected _onFocus(event: FocusEvent): void;
|
|
46
|
+
|
|
47
|
+
protected _setFocusElement(element: HTMLElement): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
+
import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
|
|
8
|
+
import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A mixin to forward focus to an element in the light DOM.
|
|
12
|
+
*
|
|
13
|
+
* @polymerMixin
|
|
14
|
+
* @mixes FocusMixin
|
|
15
|
+
* @mixes TabindexMixin
|
|
16
|
+
*/
|
|
17
|
+
export const DelegateFocusMixin = dedupingMixin(
|
|
18
|
+
(superclass) =>
|
|
19
|
+
class DelegateFocusMixinClass extends FocusMixin(TabindexMixin(superclass)) {
|
|
20
|
+
static get properties() {
|
|
21
|
+
return {
|
|
22
|
+
/**
|
|
23
|
+
* Specify that this control should have input focus when the page loads.
|
|
24
|
+
*/
|
|
25
|
+
autofocus: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A reference to the focusable element controlled by the mixin.
|
|
31
|
+
* It can be an input, textarea, button or any element with tabindex > -1.
|
|
32
|
+
*
|
|
33
|
+
* Any component implementing this mixin is expected to provide it
|
|
34
|
+
* by using `this._setFocusElement(input)` Polymer API.
|
|
35
|
+
*
|
|
36
|
+
* Toggling `tabindex` attribute on the host element propagates its value to `focusElement`.
|
|
37
|
+
*
|
|
38
|
+
* @protected
|
|
39
|
+
* @type {!HTMLElement}
|
|
40
|
+
*/
|
|
41
|
+
focusElement: {
|
|
42
|
+
type: Object,
|
|
43
|
+
readOnly: true,
|
|
44
|
+
observer: '_focusElementChanged',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Override the property from `TabIndexMixin`
|
|
49
|
+
* to ensure the `tabindex` attribute of the focus element
|
|
50
|
+
* will be restored to `0` after re-enabling the element.
|
|
51
|
+
*
|
|
52
|
+
* @protected
|
|
53
|
+
* @override
|
|
54
|
+
*/
|
|
55
|
+
_lastTabIndex: {
|
|
56
|
+
value: 0,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
constructor() {
|
|
62
|
+
super();
|
|
63
|
+
|
|
64
|
+
this._boundOnBlur = this._onBlur.bind(this);
|
|
65
|
+
this._boundOnFocus = this._onFocus.bind(this);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** @protected */
|
|
69
|
+
ready() {
|
|
70
|
+
super.ready();
|
|
71
|
+
|
|
72
|
+
if (this.autofocus && !this.disabled) {
|
|
73
|
+
requestAnimationFrame(() => {
|
|
74
|
+
this.focus();
|
|
75
|
+
this.setAttribute('focus-ring', '');
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @protected
|
|
82
|
+
* @override
|
|
83
|
+
*/
|
|
84
|
+
focus() {
|
|
85
|
+
if (!this.focusElement || this.disabled) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.focusElement.focus();
|
|
90
|
+
this._setFocused(true);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @protected
|
|
95
|
+
* @override
|
|
96
|
+
*/
|
|
97
|
+
blur() {
|
|
98
|
+
if (!this.focusElement) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.focusElement.blur();
|
|
102
|
+
this._setFocused(false);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @protected
|
|
107
|
+
* @override
|
|
108
|
+
*/
|
|
109
|
+
click() {
|
|
110
|
+
if (this.focusElement && !this.disabled) {
|
|
111
|
+
this.focusElement.click();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** @protected */
|
|
116
|
+
_focusElementChanged(element, oldElement) {
|
|
117
|
+
if (element) {
|
|
118
|
+
element.disabled = this.disabled;
|
|
119
|
+
this._addFocusListeners(element);
|
|
120
|
+
this.__forwardTabIndex(this.tabindex);
|
|
121
|
+
} else if (oldElement) {
|
|
122
|
+
this._removeFocusListeners(oldElement);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {HTMLElement} element
|
|
128
|
+
* @protected
|
|
129
|
+
*/
|
|
130
|
+
_addFocusListeners(element) {
|
|
131
|
+
element.addEventListener('blur', this._boundOnBlur);
|
|
132
|
+
element.addEventListener('focus', this._boundOnFocus);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @param {HTMLElement} element
|
|
137
|
+
* @protected
|
|
138
|
+
*/
|
|
139
|
+
_removeFocusListeners(element) {
|
|
140
|
+
element.removeEventListener('blur', this._boundOnBlur);
|
|
141
|
+
element.removeEventListener('focus', this._boundOnFocus);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Focus event does not bubble, so we dispatch it manually
|
|
146
|
+
* on the host element to support adding focus listeners
|
|
147
|
+
* when the focusable element is placed in light DOM.
|
|
148
|
+
* @param {FocusEvent} event
|
|
149
|
+
* @protected
|
|
150
|
+
*/
|
|
151
|
+
_onFocus(event) {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
this.dispatchEvent(new Event('focus'));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Blur event does not bubble, so we dispatch it manually
|
|
158
|
+
* on the host element to support adding blur listeners
|
|
159
|
+
* when the focusable element is placed in light DOM.
|
|
160
|
+
* @param {FocusEvent} event
|
|
161
|
+
* @protected
|
|
162
|
+
*/
|
|
163
|
+
_onBlur(event) {
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
this.dispatchEvent(new Event('blur'));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @param {Event} event
|
|
170
|
+
* @return {boolean}
|
|
171
|
+
* @protected
|
|
172
|
+
* @override
|
|
173
|
+
*/
|
|
174
|
+
_shouldSetFocus(event) {
|
|
175
|
+
return event.target === this.focusElement;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @param {boolean} disabled
|
|
180
|
+
* @param {boolean} oldDisabled
|
|
181
|
+
* @protected
|
|
182
|
+
* @override
|
|
183
|
+
*/
|
|
184
|
+
_disabledChanged(disabled, oldDisabled) {
|
|
185
|
+
super._disabledChanged(disabled, oldDisabled);
|
|
186
|
+
|
|
187
|
+
if (this.focusElement) {
|
|
188
|
+
this.focusElement.disabled = disabled;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (disabled) {
|
|
192
|
+
this.blur();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Override an observer from `TabindexMixin`.
|
|
198
|
+
* Do not call super to remove tabindex attribute
|
|
199
|
+
* from the host after it has been forwarded.
|
|
200
|
+
* @param {string} tabindex
|
|
201
|
+
* @protected
|
|
202
|
+
* @override
|
|
203
|
+
*/
|
|
204
|
+
_tabindexChanged(tabindex) {
|
|
205
|
+
this.__forwardTabIndex(tabindex);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** @private */
|
|
209
|
+
__forwardTabIndex(tabindex) {
|
|
210
|
+
if (tabindex !== undefined && this.focusElement) {
|
|
211
|
+
this.focusElement.tabIndex = tabindex;
|
|
212
|
+
|
|
213
|
+
// Preserve tabindex="-1" on the host element
|
|
214
|
+
if (tabindex !== -1) {
|
|
215
|
+
this.tabindex = undefined;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (this.disabled && tabindex) {
|
|
220
|
+
// If tabindex attribute was changed while component was disabled
|
|
221
|
+
if (tabindex !== -1) {
|
|
222
|
+
this._lastTabIndex = tabindex;
|
|
223
|
+
}
|
|
224
|
+
this.tabindex = undefined;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A mixin to delegate properties and attributes to a target element.
|
|
10
|
+
*/
|
|
11
|
+
export declare function DelegateStateMixin<T extends Constructor<HTMLElement>>(
|
|
12
|
+
base: T,
|
|
13
|
+
): Constructor<DelegateStateMixinClass> & T;
|
|
14
|
+
|
|
15
|
+
export declare class DelegateStateMixinClass {
|
|
16
|
+
/**
|
|
17
|
+
* A target element to which attributes and properties are delegated.
|
|
18
|
+
*/
|
|
19
|
+
stateTarget: HTMLElement | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A mixin to delegate properties and attributes to a target element.
|
|
10
|
+
*
|
|
11
|
+
* @polymerMixin
|
|
12
|
+
*/
|
|
13
|
+
export const DelegateStateMixin = dedupingMixin(
|
|
14
|
+
(superclass) =>
|
|
15
|
+
class DelegateStateMixinClass extends superclass {
|
|
16
|
+
static get properties() {
|
|
17
|
+
return {
|
|
18
|
+
/**
|
|
19
|
+
* A target element to which attributes and properties are delegated.
|
|
20
|
+
* @protected
|
|
21
|
+
*/
|
|
22
|
+
stateTarget: {
|
|
23
|
+
type: Object,
|
|
24
|
+
observer: '_stateTargetChanged',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An array of the host attributes to delegate to the target element.
|
|
31
|
+
*/
|
|
32
|
+
static get delegateAttrs() {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An array of the host properties to delegate to the target element.
|
|
38
|
+
*/
|
|
39
|
+
static get delegateProps() {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @protected */
|
|
44
|
+
ready() {
|
|
45
|
+
super.ready();
|
|
46
|
+
|
|
47
|
+
this._createDelegateAttrsObserver();
|
|
48
|
+
this._createDelegatePropsObserver();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @protected */
|
|
52
|
+
_stateTargetChanged(target) {
|
|
53
|
+
if (target) {
|
|
54
|
+
this._ensureAttrsDelegated();
|
|
55
|
+
this._ensurePropsDelegated();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @protected */
|
|
60
|
+
_createDelegateAttrsObserver() {
|
|
61
|
+
this._createMethodObserver(`_delegateAttrsChanged(${this.constructor.delegateAttrs.join(', ')})`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @protected */
|
|
65
|
+
_createDelegatePropsObserver() {
|
|
66
|
+
this._createMethodObserver(`_delegatePropsChanged(${this.constructor.delegateProps.join(', ')})`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** @protected */
|
|
70
|
+
_ensureAttrsDelegated() {
|
|
71
|
+
this.constructor.delegateAttrs.forEach((name) => {
|
|
72
|
+
this._delegateAttribute(name, this[name]);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @protected */
|
|
77
|
+
_ensurePropsDelegated() {
|
|
78
|
+
this.constructor.delegateProps.forEach((name) => {
|
|
79
|
+
this._delegateProperty(name, this[name]);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** @protected */
|
|
84
|
+
_delegateAttrsChanged(...values) {
|
|
85
|
+
this.constructor.delegateAttrs.forEach((name, index) => {
|
|
86
|
+
this._delegateAttribute(name, values[index]);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @protected */
|
|
91
|
+
_delegatePropsChanged(...values) {
|
|
92
|
+
this.constructor.delegateProps.forEach((name, index) => {
|
|
93
|
+
this._delegateProperty(name, values[index]);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @protected */
|
|
98
|
+
_delegateAttribute(name, value) {
|
|
99
|
+
if (!this.stateTarget) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (name === 'invalid') {
|
|
104
|
+
this._delegateAttribute('aria-invalid', value ? 'true' : false);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (typeof value === 'boolean') {
|
|
108
|
+
this.stateTarget.toggleAttribute(name, value);
|
|
109
|
+
} else if (value) {
|
|
110
|
+
this.stateTarget.setAttribute(name, value);
|
|
111
|
+
} else {
|
|
112
|
+
this.stateTarget.removeAttribute(name);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @protected */
|
|
117
|
+
_delegateProperty(name, value) {
|
|
118
|
+
if (!this.stateTarget) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.stateTarget[name] = value;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
);
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A controller that manages the error message node content.
|
|
10
10
|
*/
|
|
11
|
-
export class ErrorController extends
|
|
11
|
+
export class ErrorController extends SlotController {
|
|
12
|
+
/**
|
|
13
|
+
* ID attribute value set on the error message element.
|
|
14
|
+
*/
|
|
15
|
+
readonly errorId: string;
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
* String used for the error message text content.
|
|
14
19
|
*/
|