@vaadin/field-base 25.2.0-alpha1 → 25.2.0-alpha11
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 +1141 -13
- package/package.json +7 -7
- package/src/checked-mixin.js +0 -5
- package/src/clear-button-mixin.js +0 -4
- package/src/error-controller.d.ts +2 -0
- package/src/field-mixin.js +1 -5
- package/src/helper-controller.d.ts +2 -0
- package/src/input-constraints-mixin.js +100 -104
- package/src/input-control-mixin.js +0 -21
- package/src/input-controller.d.ts +3 -1
- package/src/input-field-mixin.js +0 -3
- package/src/input-mixin.js +208 -209
- package/src/label-controller.d.ts +2 -0
- package/src/label-mixin.js +1 -3
- package/src/labelled-input-controller.d.ts +17 -1
- package/src/pattern-mixin.js +0 -3
- package/src/styles/button-base-styles.js +2 -2
- package/src/text-area-controller.d.ts +3 -1
- package/src/validate-mixin.js +86 -96
- package/src/virtual-keyboard-controller.d.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-base",
|
|
3
|
-
"version": "25.2.0-
|
|
3
|
+
"version": "25.2.0-alpha11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
|
-
"@vaadin/a11y-base": "25.2.0-
|
|
36
|
-
"@vaadin/component-base": "25.2.0-
|
|
35
|
+
"@vaadin/a11y-base": "25.2.0-alpha11",
|
|
36
|
+
"@vaadin/component-base": "25.2.0-alpha11",
|
|
37
37
|
"lit": "^3.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@vaadin/chai-plugins": "25.2.0-
|
|
41
|
-
"@vaadin/input-container": "25.2.0-
|
|
42
|
-
"@vaadin/test-runner-commands": "25.2.0-
|
|
40
|
+
"@vaadin/chai-plugins": "25.2.0-alpha11",
|
|
41
|
+
"@vaadin/input-container": "25.2.0-alpha11",
|
|
42
|
+
"@vaadin/test-runner-commands": "25.2.0-alpha11",
|
|
43
43
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
44
44
|
"sinon": "^21.0.2"
|
|
45
45
|
},
|
|
46
46
|
"customElements": "custom-elements.json",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "fdc37e932709f95491a027aeb2090911cb7528c6"
|
|
48
48
|
}
|
package/src/checked-mixin.js
CHANGED
|
@@ -9,11 +9,6 @@ import { InputMixin } from './input-mixin.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A mixin to manage the checked state.
|
|
12
|
-
*
|
|
13
|
-
* @polymerMixin
|
|
14
|
-
* @mixes DelegateStateMixin
|
|
15
|
-
* @mixes DisabledMixin
|
|
16
|
-
* @mixes InputMixin
|
|
17
12
|
*/
|
|
18
13
|
export const CheckedMixin = (superclass) =>
|
|
19
14
|
class CheckedMixinClass extends DelegateStateMixin(DisabledMixin(InputMixin(superclass))) {
|
|
@@ -10,10 +10,6 @@ import { InputMixin } from './input-mixin.js';
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A mixin that manages the clear button.
|
|
13
|
-
*
|
|
14
|
-
* @polymerMixin
|
|
15
|
-
* @mixes InputMixin
|
|
16
|
-
* @mixes KeyboardMixin
|
|
17
13
|
*/
|
|
18
14
|
export const ClearButtonMixin = (superclass) =>
|
|
19
15
|
class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
|
|
@@ -9,6 +9,8 @@ import { SlotChildObserveController } from '@vaadin/component-base/src/slot-chil
|
|
|
9
9
|
* A controller that manages the error message node content.
|
|
10
10
|
*/
|
|
11
11
|
export class ErrorController extends SlotChildObserveController {
|
|
12
|
+
constructor(host: HTMLElement);
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* String used for the error message text content.
|
|
14
16
|
*/
|
package/src/field-mixin.js
CHANGED
|
@@ -11,10 +11,6 @@ import { ValidateMixin } from './validate-mixin.js';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* A mixin to provide common field logic: label, error message and helper text.
|
|
14
|
-
*
|
|
15
|
-
* @polymerMixin
|
|
16
|
-
* @mixes LabelMixin
|
|
17
|
-
* @mixes ValidateMixin
|
|
18
14
|
*/
|
|
19
15
|
export const FieldMixin = (superclass) =>
|
|
20
16
|
class FieldMixinClass extends ValidateMixin(LabelMixin(superclass)) {
|
|
@@ -200,7 +196,7 @@ export const FieldMixin = (superclass) =>
|
|
|
200
196
|
// Otherwise assistive technologies would announce the error, even if we hide it.
|
|
201
197
|
if (invalid) {
|
|
202
198
|
const node = this._errorNode;
|
|
203
|
-
this._fieldAriaController.setErrorId(node
|
|
199
|
+
this._fieldAriaController.setErrorId(node?.id);
|
|
204
200
|
} else {
|
|
205
201
|
this._fieldAriaController.setErrorId(null);
|
|
206
202
|
}
|
|
@@ -9,6 +9,8 @@ import { SlotChildObserveController } from '@vaadin/component-base/src/slot-chil
|
|
|
9
9
|
* A controller that manages the helper node content.
|
|
10
10
|
*/
|
|
11
11
|
export class HelperController extends SlotChildObserveController {
|
|
12
|
+
constructor(host: HTMLElement);
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* String used for the helper text.
|
|
14
16
|
*/
|
|
@@ -10,122 +10,118 @@ import { ValidateMixin } from './validate-mixin.js';
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A mixin to combine multiple input validation constraints.
|
|
13
|
-
*
|
|
14
|
-
* @polymerMixin
|
|
15
|
-
* @mixes DelegateStateMixin
|
|
16
|
-
* @mixes InputMixin
|
|
17
|
-
* @mixes ValidateMixin
|
|
18
13
|
*/
|
|
19
|
-
|
|
20
|
-
(superclass)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
14
|
+
const InputConstraintsMixinImplementation = (superclass) => {
|
|
15
|
+
return class InputConstraintsMixinClass extends DelegateStateMixin(ValidateMixin(InputMixin(superclass))) {
|
|
16
|
+
/**
|
|
17
|
+
* An array of attributes which participate in the input validation.
|
|
18
|
+
* Changing these attributes will cause the input to re-validate.
|
|
19
|
+
*
|
|
20
|
+
* IMPORTANT: The attributes should be properly delegated to the input element
|
|
21
|
+
* from the host using `delegateAttrs` getter (see `DelegateStateMixin`).
|
|
22
|
+
* The `required` attribute is already delegated.
|
|
23
|
+
*/
|
|
24
|
+
static get constraints() {
|
|
25
|
+
return ['required'];
|
|
26
|
+
}
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
static get delegateAttrs() {
|
|
29
|
+
return [...super.delegateAttrs, 'required'];
|
|
30
|
+
}
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
/** @protected */
|
|
33
|
+
ready() {
|
|
34
|
+
super.ready();
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
this._createConstraintsObserver();
|
|
37
|
+
}
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
return !this.invalid;
|
|
39
|
+
/**
|
|
40
|
+
* Returns true if the current input value satisfies all constraints (if any).
|
|
41
|
+
* @return {boolean}
|
|
42
|
+
*/
|
|
43
|
+
checkValidity() {
|
|
44
|
+
if (this.inputElement && this._hasValidConstraints(this.constructor.constraints.map((c) => this[c]))) {
|
|
45
|
+
return this.inputElement.checkValidity();
|
|
54
46
|
}
|
|
47
|
+
return !this.invalid;
|
|
48
|
+
}
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if some of the provided set of constraints are valid.
|
|
52
|
+
* @param {Array} constraints
|
|
53
|
+
* @return {boolean}
|
|
54
|
+
* @protected
|
|
55
|
+
*/
|
|
56
|
+
_hasValidConstraints(constraints) {
|
|
57
|
+
return constraints.some((c) => this.__isValidConstraint(c));
|
|
58
|
+
}
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Override this method to customize setting up constraints observer.
|
|
62
|
+
* @protected
|
|
63
|
+
*/
|
|
64
|
+
_createConstraintsObserver() {
|
|
65
|
+
// This complex observer needs to be added dynamically instead of using `static get observers()`
|
|
66
|
+
// to make it possible to tweak this behavior in classes that apply this mixin.
|
|
67
|
+
this._createMethodObserver(`_constraintsChanged(stateTarget, ${this.constructor.constraints.join(', ')})`);
|
|
68
|
+
}
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const hasConstraints = this._hasValidConstraints(constraints);
|
|
90
|
-
const isLastConstraintRemoved = this.__previousHasConstraints && !hasConstraints;
|
|
91
|
-
|
|
92
|
-
if ((this._hasValue || this.invalid) && hasConstraints) {
|
|
93
|
-
this._requestValidation();
|
|
94
|
-
} else if (isLastConstraintRemoved && !this.manualValidation) {
|
|
95
|
-
this._setInvalid(false);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.__previousHasConstraints = hasConstraints;
|
|
70
|
+
/**
|
|
71
|
+
* Override this method to implement custom validation constraints.
|
|
72
|
+
* @param {HTMLElement | undefined} stateTarget
|
|
73
|
+
* @param {unknown[]} constraints
|
|
74
|
+
* @protected
|
|
75
|
+
*/
|
|
76
|
+
_constraintsChanged(stateTarget, ...constraints) {
|
|
77
|
+
// The input element's validity cannot be determined until
|
|
78
|
+
// all the necessary constraint attributes aren't set on it.
|
|
79
|
+
if (!stateTarget) {
|
|
80
|
+
return;
|
|
99
81
|
}
|
|
100
82
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* to capture native `change` event and make sure that
|
|
104
|
-
* a new one is dispatched after validation runs.
|
|
105
|
-
* @param {Event} event
|
|
106
|
-
* @protected
|
|
107
|
-
* @override
|
|
108
|
-
*/
|
|
109
|
-
_onChange(event) {
|
|
110
|
-
event.stopPropagation();
|
|
83
|
+
const hasConstraints = this._hasValidConstraints(constraints);
|
|
84
|
+
const isLastConstraintRemoved = this.__previousHasConstraints && !hasConstraints;
|
|
111
85
|
|
|
86
|
+
if ((this._hasValue || this.invalid) && hasConstraints) {
|
|
112
87
|
this._requestValidation();
|
|
113
|
-
|
|
114
|
-
this.
|
|
115
|
-
new CustomEvent('change', {
|
|
116
|
-
detail: {
|
|
117
|
-
sourceEvent: event,
|
|
118
|
-
},
|
|
119
|
-
bubbles: event.bubbles,
|
|
120
|
-
cancelable: event.cancelable,
|
|
121
|
-
}),
|
|
122
|
-
);
|
|
88
|
+
} else if (isLastConstraintRemoved && !this.manualValidation) {
|
|
89
|
+
this._setInvalid(false);
|
|
123
90
|
}
|
|
124
91
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
92
|
+
this.__previousHasConstraints = hasConstraints;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Override an event listener inherited from `InputMixin`
|
|
97
|
+
* to capture native `change` event and make sure that
|
|
98
|
+
* a new one is dispatched after validation runs.
|
|
99
|
+
* @param {Event} event
|
|
100
|
+
* @protected
|
|
101
|
+
* @override
|
|
102
|
+
*/
|
|
103
|
+
_onChange(event) {
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
|
|
106
|
+
this._requestValidation();
|
|
107
|
+
|
|
108
|
+
this.dispatchEvent(
|
|
109
|
+
new CustomEvent('change', {
|
|
110
|
+
detail: {
|
|
111
|
+
sourceEvent: event,
|
|
112
|
+
},
|
|
113
|
+
bubbles: event.bubbles,
|
|
114
|
+
cancelable: event.cancelable,
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @private */
|
|
120
|
+
__isValidConstraint(constraint) {
|
|
121
|
+
// 0 is valid for `minlength` and `maxlength`
|
|
122
|
+
return Boolean(constraint) || constraint === 0;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const InputConstraintsMixin = dedupeMixin(InputConstraintsMixinImplementation);
|
|
@@ -14,14 +14,6 @@ import { InputConstraintsMixin } from './input-constraints-mixin.js';
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A mixin to provide shared logic for the editable form input controls.
|
|
17
|
-
*
|
|
18
|
-
* @polymerMixin
|
|
19
|
-
* @mixes DelegateFocusMixin
|
|
20
|
-
* @mixes FieldMixin
|
|
21
|
-
* @mixes InputConstraintsMixin
|
|
22
|
-
* @mixes KeyboardMixin
|
|
23
|
-
* @mixes ClearButtonMixin
|
|
24
|
-
* @mixes SlotStylesMixin
|
|
25
17
|
*/
|
|
26
18
|
export const InputControlMixin = (superclass) =>
|
|
27
19
|
class InputControlMixinClass extends SlotStylesMixin(
|
|
@@ -250,17 +242,4 @@ export const InputControlMixin = (superclass) =>
|
|
|
250
242
|
}
|
|
251
243
|
}
|
|
252
244
|
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Fired when the user commits a value change.
|
|
256
|
-
*
|
|
257
|
-
* @event change
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Fired when the value is changed by the user: on every typing keystroke,
|
|
262
|
-
* and the value is cleared using the clear button.
|
|
263
|
-
*
|
|
264
|
-
* @event input
|
|
265
|
-
*/
|
|
266
245
|
};
|
|
@@ -8,4 +8,6 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* A controller to create and initialize slotted `<input>` element.
|
|
10
10
|
*/
|
|
11
|
-
export class InputController extends SlotController {
|
|
11
|
+
export class InputController extends SlotController {
|
|
12
|
+
constructor(host: HTMLElement, callback?: (node: HTMLInputElement) => void, options?: { uniqueIdPrefix?: string });
|
|
13
|
+
}
|
package/src/input-field-mixin.js
CHANGED
|
@@ -7,9 +7,6 @@ import { InputControlMixin } from './input-control-mixin.js';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A mixin to provide logic for vaadin-text-field and related components.
|
|
10
|
-
*
|
|
11
|
-
* @polymerMixin
|
|
12
|
-
* @mixes InputControlMixin
|
|
13
10
|
*/
|
|
14
11
|
export const InputFieldMixin = (superclass) =>
|
|
15
12
|
class InputFieldMixinClass extends InputControlMixin(superclass) {
|