@vaadin/field-base 23.2.0-alpha3 → 23.2.0-alpha6
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/package.json +3 -3
- package/src/checked-mixin.d.ts +3 -3
- package/src/checked-mixin.js +11 -1
- package/src/delegate-focus-mixin.d.ts +3 -3
- package/src/delegate-state-mixin.d.ts +1 -1
- package/src/field-aria-controller.js +1 -1
- package/src/field-mixin.d.ts +3 -3
- package/src/field-mixin.js +1 -1
- package/src/input-constraints-mixin.d.ts +3 -3
- package/src/input-control-mixin.d.ts +3 -3
- package/src/input-field-mixin.d.ts +5 -5
- package/src/input-field-mixin.js +17 -9
- package/src/input-mixin.d.ts +1 -1
- package/src/input-mixin.js +43 -8
- package/src/label-mixin.d.ts +1 -1
- package/src/pattern-mixin.d.ts +3 -3
- package/src/pattern-mixin.js +1 -0
- package/src/shadow-focus-mixin.d.ts +3 -3
- package/src/slot-styles-mixin.d.ts +1 -1
- package/src/validate-mixin.d.ts +1 -1
- package/src/virtual-keyboard-controller.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-base",
|
|
3
|
-
"version": "23.2.0-
|
|
3
|
+
"version": "23.2.0-alpha6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,7 +32,7 @@
|
|
|
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.0-
|
|
35
|
+
"@vaadin/component-base": "23.2.0-alpha6",
|
|
36
36
|
"lit": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
41
41
|
"sinon": "^13.0.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "61f1fb56953434e97d34a8819640064301dd3d8a"
|
|
44
44
|
}
|
package/src/checked-mixin.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ import type { InputMixinClass } from './input-mixin.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function CheckedMixin<T extends Constructor<object>>(
|
|
15
15
|
base: T,
|
|
16
|
-
):
|
|
17
|
-
Constructor<CheckedMixinClass> &
|
|
16
|
+
): Constructor<CheckedMixinClass> &
|
|
18
17
|
Constructor<DelegateStateMixinClass> &
|
|
19
18
|
Constructor<DisabledMixinClass> &
|
|
20
|
-
Constructor<InputMixinClass
|
|
19
|
+
Constructor<InputMixinClass> &
|
|
20
|
+
T;
|
|
21
21
|
|
|
22
22
|
export declare class CheckedMixinClass {
|
|
23
23
|
/**
|
package/src/checked-mixin.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
7
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
+
import { isElementFocused } from '@vaadin/component-base/src/focus-utils.js';
|
|
8
9
|
import { DelegateStateMixin } from './delegate-state-mixin.js';
|
|
9
10
|
import { InputMixin } from './input-mixin.js';
|
|
10
11
|
|
|
@@ -39,11 +40,20 @@ export const CheckedMixin = dedupingMixin(
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
43
|
+
* @param {Event} event
|
|
42
44
|
* @protected
|
|
43
45
|
* @override
|
|
44
46
|
*/
|
|
45
47
|
_onChange(event) {
|
|
46
|
-
|
|
48
|
+
const input = event.target;
|
|
49
|
+
|
|
50
|
+
this._toggleChecked(input.checked);
|
|
51
|
+
|
|
52
|
+
// Clicking the checkbox or radio-button in Safari
|
|
53
|
+
// does not make it focused, so we do it manually.
|
|
54
|
+
if (!isElementFocused(input)) {
|
|
55
|
+
input.focus();
|
|
56
|
+
}
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
/** @protected */
|
|
@@ -13,11 +13,11 @@ import type { TabindexMixinClass } from '@vaadin/component-base/src/tabindex-mix
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function DelegateFocusMixin<T extends Constructor<HTMLElement>>(
|
|
15
15
|
base: T,
|
|
16
|
-
):
|
|
17
|
-
Constructor<DelegateFocusMixinClass> &
|
|
16
|
+
): Constructor<DelegateFocusMixinClass> &
|
|
18
17
|
Constructor<DisabledMixinClass> &
|
|
19
18
|
Constructor<FocusMixinClass> &
|
|
20
|
-
Constructor<TabindexMixinClass
|
|
19
|
+
Constructor<TabindexMixinClass> &
|
|
20
|
+
T;
|
|
21
21
|
|
|
22
22
|
export declare class DelegateFocusMixinClass {
|
|
23
23
|
/**
|
|
@@ -10,7 +10,7 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function DelegateStateMixin<T extends Constructor<HTMLElement>>(
|
|
12
12
|
base: T,
|
|
13
|
-
):
|
|
13
|
+
): Constructor<DelegateStateMixinClass> & T;
|
|
14
14
|
|
|
15
15
|
export declare class DelegateStateMixinClass {
|
|
16
16
|
/**
|
package/src/field-mixin.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function FieldMixin<T extends Constructor<HTMLElement>>(
|
|
15
15
|
superclass: T,
|
|
16
|
-
):
|
|
17
|
-
Constructor<ControllerMixinClass> &
|
|
16
|
+
): Constructor<ControllerMixinClass> &
|
|
18
17
|
Constructor<FieldMixinClass> &
|
|
19
18
|
Constructor<LabelMixinClass> &
|
|
20
|
-
Constructor<ValidateMixinClass
|
|
19
|
+
Constructor<ValidateMixinClass> &
|
|
20
|
+
T;
|
|
21
21
|
|
|
22
22
|
export declare class FieldMixinClass {
|
|
23
23
|
/**
|
package/src/field-mixin.js
CHANGED
|
@@ -14,12 +14,12 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function InputConstraintsMixin<T extends Constructor<HTMLElement>>(
|
|
16
16
|
base: T,
|
|
17
|
-
):
|
|
18
|
-
Constructor<DelegateStateMixinClass> &
|
|
17
|
+
): Constructor<DelegateStateMixinClass> &
|
|
19
18
|
Constructor<DisabledMixinClass> &
|
|
20
19
|
Constructor<InputConstraintsMixinClass> &
|
|
21
20
|
Constructor<InputMixinClass> &
|
|
22
|
-
Constructor<ValidateMixinClass
|
|
21
|
+
Constructor<ValidateMixinClass> &
|
|
22
|
+
T;
|
|
23
23
|
|
|
24
24
|
export declare class InputConstraintsMixinClass {
|
|
25
25
|
/**
|
|
@@ -21,8 +21,7 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function InputControlMixin<T extends Constructor<HTMLElement>>(
|
|
23
23
|
base: T,
|
|
24
|
-
):
|
|
25
|
-
Constructor<ControllerMixinClass> &
|
|
24
|
+
): Constructor<ControllerMixinClass> &
|
|
26
25
|
Constructor<DelegateFocusMixinClass> &
|
|
27
26
|
Constructor<DelegateStateMixinClass> &
|
|
28
27
|
Constructor<DisabledMixinClass> &
|
|
@@ -33,7 +32,8 @@ export declare function InputControlMixin<T extends Constructor<HTMLElement>>(
|
|
|
33
32
|
Constructor<InputMixinClass> &
|
|
34
33
|
Constructor<KeyboardMixinClass> &
|
|
35
34
|
Constructor<LabelMixinClass> &
|
|
36
|
-
Constructor<ValidateMixinClass
|
|
35
|
+
Constructor<ValidateMixinClass> &
|
|
36
|
+
T;
|
|
37
37
|
|
|
38
38
|
export declare class InputControlMixinClass {
|
|
39
39
|
/**
|
|
@@ -22,8 +22,7 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function InputFieldMixin<T extends Constructor<HTMLElement>>(
|
|
24
24
|
base: T,
|
|
25
|
-
):
|
|
26
|
-
Constructor<ControllerMixinClass> &
|
|
25
|
+
): Constructor<ControllerMixinClass> &
|
|
27
26
|
Constructor<DelegateFocusMixinClass> &
|
|
28
27
|
Constructor<DelegateStateMixinClass> &
|
|
29
28
|
Constructor<DisabledMixinClass> &
|
|
@@ -35,7 +34,8 @@ export declare function InputFieldMixin<T extends Constructor<HTMLElement>>(
|
|
|
35
34
|
Constructor<InputMixinClass> &
|
|
36
35
|
Constructor<KeyboardMixinClass> &
|
|
37
36
|
Constructor<LabelMixinClass> &
|
|
38
|
-
Constructor<ValidateMixinClass
|
|
37
|
+
Constructor<ValidateMixinClass> &
|
|
38
|
+
T;
|
|
39
39
|
|
|
40
40
|
export declare class InputFieldMixinClass {
|
|
41
41
|
/**
|
|
@@ -52,7 +52,7 @@ export declare class InputFieldMixinClass {
|
|
|
52
52
|
* on: Enable autocorrection.
|
|
53
53
|
* off: Disable autocorrection.
|
|
54
54
|
*/
|
|
55
|
-
autocorrect: '
|
|
55
|
+
autocorrect: 'off' | 'on' | undefined;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* This is a property supported by Safari and Chrome that is used to control whether
|
|
@@ -63,5 +63,5 @@ export declare class InputFieldMixinClass {
|
|
|
63
63
|
* sentences: Sentences capitalization.
|
|
64
64
|
* none: No capitalization.
|
|
65
65
|
*/
|
|
66
|
-
autocapitalize: '
|
|
66
|
+
autocapitalize: 'characters' | 'none' | 'off' | 'on' | 'sentences' | 'words' | undefined;
|
|
67
67
|
}
|
package/src/input-field-mixin.js
CHANGED
|
@@ -85,15 +85,17 @@ export const InputFieldMixin = (superclass) =>
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
* Override an event listener from `
|
|
89
|
-
* @param {
|
|
88
|
+
* Override an event listener from `FocusMixin`.
|
|
89
|
+
* @param {boolean} focused
|
|
90
90
|
* @protected
|
|
91
91
|
* @override
|
|
92
92
|
*/
|
|
93
|
-
|
|
94
|
-
super.
|
|
93
|
+
_setFocused(focused) {
|
|
94
|
+
super._setFocused(focused);
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
if (!focused) {
|
|
97
|
+
this.validate();
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -112,14 +114,20 @@ export const InputFieldMixin = (superclass) =>
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/**
|
|
115
|
-
* Override
|
|
117
|
+
* Override an observer from `InputMixin` to validate the field
|
|
116
118
|
* when a new value is set programmatically.
|
|
117
|
-
*
|
|
119
|
+
*
|
|
120
|
+
* @param {string | undefined} newValue
|
|
121
|
+
* @param {string | undefined} oldValue
|
|
118
122
|
* @protected
|
|
119
123
|
* @override
|
|
120
124
|
*/
|
|
121
|
-
|
|
122
|
-
super.
|
|
125
|
+
_valueChanged(newValue, oldValue) {
|
|
126
|
+
super._valueChanged(newValue, oldValue);
|
|
127
|
+
|
|
128
|
+
if (oldValue === undefined) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
123
131
|
|
|
124
132
|
if (this.invalid) {
|
|
125
133
|
this.validate();
|
package/src/input-mixin.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
9
9
|
* A mixin to store the reference to an input element
|
|
10
10
|
* and add input and change event listeners to it.
|
|
11
11
|
*/
|
|
12
|
-
export declare function InputMixin<T extends Constructor<HTMLElement>>(base: T):
|
|
12
|
+
export declare function InputMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<InputMixinClass> & T;
|
|
13
13
|
|
|
14
14
|
export declare class InputMixinClass {
|
|
15
15
|
/**
|
package/src/input-mixin.js
CHANGED
|
@@ -52,6 +52,16 @@ export const InputMixin = dedupingMixin(
|
|
|
52
52
|
observer: '_valueChanged',
|
|
53
53
|
notify: true,
|
|
54
54
|
},
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* When true, the input element has a non-empty value entered by the user.
|
|
58
|
+
* @protected
|
|
59
|
+
*/
|
|
60
|
+
_hasInputValue: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
value: false,
|
|
63
|
+
observer: '_hasInputValueChanged',
|
|
64
|
+
},
|
|
55
65
|
};
|
|
56
66
|
}
|
|
57
67
|
|
|
@@ -59,7 +69,7 @@ export const InputMixin = dedupingMixin(
|
|
|
59
69
|
super();
|
|
60
70
|
|
|
61
71
|
this._boundOnInput = this._onInput.bind(this);
|
|
62
|
-
this._boundOnChange = this.
|
|
72
|
+
this._boundOnChange = this.__onChange.bind(this);
|
|
63
73
|
}
|
|
64
74
|
|
|
65
75
|
/**
|
|
@@ -73,6 +83,7 @@ export const InputMixin = dedupingMixin(
|
|
|
73
83
|
* Add event listeners to the input element instance.
|
|
74
84
|
* Override this method to add custom listeners.
|
|
75
85
|
* @param {!HTMLElement} input
|
|
86
|
+
* @protected
|
|
76
87
|
*/
|
|
77
88
|
_addInputListeners(input) {
|
|
78
89
|
input.addEventListener('input', this._boundOnInput);
|
|
@@ -82,6 +93,7 @@ export const InputMixin = dedupingMixin(
|
|
|
82
93
|
/**
|
|
83
94
|
* Remove event listeners from the input element instance.
|
|
84
95
|
* @param {!HTMLElement} input
|
|
96
|
+
* @protected
|
|
85
97
|
*/
|
|
86
98
|
_removeInputListeners(input) {
|
|
87
99
|
input.removeEventListener('input', this._boundOnInput);
|
|
@@ -95,7 +107,6 @@ export const InputMixin = dedupingMixin(
|
|
|
95
107
|
* for example to skip this in certain conditions.
|
|
96
108
|
* @param {string} value
|
|
97
109
|
* @protected
|
|
98
|
-
* @override
|
|
99
110
|
*/
|
|
100
111
|
_forwardInputValue(value) {
|
|
101
112
|
// Value might be set before an input element is initialized.
|
|
@@ -112,7 +123,11 @@ export const InputMixin = dedupingMixin(
|
|
|
112
123
|
}
|
|
113
124
|
}
|
|
114
125
|
|
|
115
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* @param {HTMLElement | undefined} input
|
|
128
|
+
* @param {HTMLElement | undefined} oldInput
|
|
129
|
+
* @protected
|
|
130
|
+
*/
|
|
116
131
|
_inputElementChanged(input, oldInput) {
|
|
117
132
|
if (input) {
|
|
118
133
|
this._addInputListeners(input);
|
|
@@ -121,12 +136,22 @@ export const InputMixin = dedupingMixin(
|
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Observer to notify about the change of private property.
|
|
141
|
+
*
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
_hasInputValueChanged(hasValue, oldHasValue) {
|
|
145
|
+
if (hasValue || oldHasValue) {
|
|
146
|
+
this.dispatchEvent(new CustomEvent('has-input-value-changed'));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
124
150
|
/**
|
|
125
151
|
* An input event listener used to update the field value.
|
|
126
|
-
*
|
|
127
|
-
* @param {Event}
|
|
152
|
+
*
|
|
153
|
+
* @param {Event} event
|
|
128
154
|
* @protected
|
|
129
|
-
* @override
|
|
130
155
|
*/
|
|
131
156
|
_onInput(event) {
|
|
132
157
|
// Ignore fake input events e.g. used by clear button.
|
|
@@ -140,10 +165,21 @@ export const InputMixin = dedupingMixin(
|
|
|
140
165
|
* Override this method with an actual implementation.
|
|
141
166
|
* @param {Event} _event
|
|
142
167
|
* @protected
|
|
143
|
-
* @override
|
|
144
168
|
*/
|
|
145
169
|
_onChange(_event) {}
|
|
146
170
|
|
|
171
|
+
/**
|
|
172
|
+
* A change event listener used to update `_hasInputValue` property.
|
|
173
|
+
* Do not override this method.
|
|
174
|
+
*
|
|
175
|
+
* @param {Event} event
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
__onChange(event) {
|
|
179
|
+
this._hasInputValue = event.target.value.length > 0;
|
|
180
|
+
this._onChange(event);
|
|
181
|
+
}
|
|
182
|
+
|
|
147
183
|
/**
|
|
148
184
|
* Toggle the has-value attribute based on the value property.
|
|
149
185
|
* @param {boolean} hasValue
|
|
@@ -158,7 +194,6 @@ export const InputMixin = dedupingMixin(
|
|
|
158
194
|
* @param {string | undefined} newVal
|
|
159
195
|
* @param {string | undefined} oldVal
|
|
160
196
|
* @protected
|
|
161
|
-
* @override
|
|
162
197
|
*/
|
|
163
198
|
_valueChanged(newVal, oldVal) {
|
|
164
199
|
this._toggleHasValue(newVal !== '' && newVal != null);
|
package/src/label-mixin.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { LabelController } from './label-controller.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* A mixin to provide label via corresponding property or named slot.
|
|
11
11
|
*/
|
|
12
|
-
export declare function LabelMixin<T extends Constructor<HTMLElement>>(base: T):
|
|
12
|
+
export declare function LabelMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<LabelMixinClass> & T;
|
|
13
13
|
|
|
14
14
|
export declare class LabelMixinClass {
|
|
15
15
|
/**
|
package/src/pattern-mixin.d.ts
CHANGED
|
@@ -15,13 +15,13 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function PatternMixin<T extends Constructor<HTMLElement>>(
|
|
17
17
|
base: T,
|
|
18
|
-
):
|
|
19
|
-
Constructor<DelegateStateMixinClass> &
|
|
18
|
+
): Constructor<DelegateStateMixinClass> &
|
|
20
19
|
Constructor<DisabledMixinClass> &
|
|
21
20
|
Constructor<InputConstraintsMixinClass> &
|
|
22
21
|
Constructor<InputMixinClass> &
|
|
23
22
|
Constructor<PatternMixinClass> &
|
|
24
|
-
Constructor<ValidateMixinClass
|
|
23
|
+
Constructor<ValidateMixinClass> &
|
|
24
|
+
T;
|
|
25
25
|
|
|
26
26
|
export declare class PatternMixinClass {
|
|
27
27
|
/**
|
package/src/pattern-mixin.js
CHANGED
|
@@ -15,9 +15,9 @@ import type { DelegateFocusMixinClass } from './delegate-focus-mixin.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function ShadowFocusMixin<T extends Constructor<HTMLElement>>(
|
|
17
17
|
base: T,
|
|
18
|
-
):
|
|
19
|
-
Constructor<DelegateFocusMixinClass> &
|
|
18
|
+
): Constructor<DelegateFocusMixinClass> &
|
|
20
19
|
Constructor<DisabledMixinClass> &
|
|
21
20
|
Constructor<FocusMixinClass> &
|
|
22
21
|
Constructor<KeyboardMixinClass> &
|
|
23
|
-
Constructor<TabindexMixinClass
|
|
22
|
+
Constructor<TabindexMixinClass> &
|
|
23
|
+
T;
|
|
@@ -11,7 +11,7 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function SlotStylesMixin<T extends Constructor<HTMLElement>>(
|
|
13
13
|
base: T,
|
|
14
|
-
):
|
|
14
|
+
): Constructor<SlotStylesMixinClass> & T;
|
|
15
15
|
|
|
16
16
|
export declare class SlotStylesMixinClass {
|
|
17
17
|
/**
|
package/src/validate-mixin.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
8
8
|
/**
|
|
9
9
|
* A mixin to provide required state and validation logic.
|
|
10
10
|
*/
|
|
11
|
-
export declare function ValidateMixin<T extends Constructor<HTMLElement>>(base: T):
|
|
11
|
+
export declare function ValidateMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<ValidateMixinClass> & T;
|
|
12
12
|
|
|
13
13
|
export declare class ValidateMixinClass {
|
|
14
14
|
/**
|
|
@@ -10,5 +10,5 @@ import type { ReactiveController } from 'lit';
|
|
|
10
10
|
* when the field's overlay is closed.
|
|
11
11
|
*/
|
|
12
12
|
export class VirtualKeyboardController implements ReactiveController {
|
|
13
|
-
constructor(host: { inputElement?: HTMLElement; opened: boolean }
|
|
13
|
+
constructor(host: HTMLElement & { inputElement?: HTMLElement; opened: boolean });
|
|
14
14
|
}
|