@vaadin/field-base 25.2.0-alpha8 → 25.2.0-beta1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/field-base",
3
- "version": "25.2.0-alpha8",
3
+ "version": "25.2.0-beta1",
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-alpha8",
36
- "@vaadin/component-base": "25.2.0-alpha8",
35
+ "@vaadin/a11y-base": "25.2.0-beta1",
36
+ "@vaadin/component-base": "25.2.0-beta1",
37
37
  "lit": "^3.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@vaadin/chai-plugins": "25.2.0-alpha8",
41
- "@vaadin/input-container": "25.2.0-alpha8",
42
- "@vaadin/test-runner-commands": "25.2.0-alpha8",
40
+ "@vaadin/chai-plugins": "25.2.0-beta1",
41
+ "@vaadin/input-container": "25.2.0-beta1",
42
+ "@vaadin/test-runner-commands": "25.2.0-beta1",
43
43
  "@vaadin/testing-helpers": "^2.0.0",
44
44
  "sinon": "^21.0.2"
45
45
  },
46
46
  "customElements": "custom-elements.json",
47
- "gitHead": "2b82e20cdfc605b1187e9a24ae42869e1500ab68"
47
+ "gitHead": "471a23f60d1eb725f98a33f62cb9664d9c0a4163"
48
48
  }
@@ -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
  */
@@ -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 && node.id);
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
- export const InputConstraintsMixin = dedupeMixin(
20
- (superclass) =>
21
- class InputConstraintsMixinClass extends DelegateStateMixin(ValidateMixin(InputMixin(superclass))) {
22
- /**
23
- * An array of attributes which participate in the input validation.
24
- * Changing these attributes will cause the input to re-validate.
25
- *
26
- * IMPORTANT: The attributes should be properly delegated to the input element
27
- * from the host using `delegateAttrs` getter (see `DelegateStateMixin`).
28
- * The `required` attribute is already delegated.
29
- */
30
- static get constraints() {
31
- return ['required'];
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
- static get delegateAttrs() {
35
- return [...super.delegateAttrs, 'required'];
36
- }
28
+ static get delegateAttrs() {
29
+ return [...super.delegateAttrs, 'required'];
30
+ }
37
31
 
38
- /** @protected */
39
- ready() {
40
- super.ready();
32
+ /** @protected */
33
+ ready() {
34
+ super.ready();
41
35
 
42
- this._createConstraintsObserver();
43
- }
36
+ this._createConstraintsObserver();
37
+ }
44
38
 
45
- /**
46
- * Returns true if the current input value satisfies all constraints (if any).
47
- * @return {boolean}
48
- */
49
- checkValidity() {
50
- if (this.inputElement && this._hasValidConstraints(this.constructor.constraints.map((c) => this[c]))) {
51
- return this.inputElement.checkValidity();
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
- * Returns true if some of the provided set of constraints are valid.
58
- * @param {Array} constraints
59
- * @return {boolean}
60
- * @protected
61
- */
62
- _hasValidConstraints(constraints) {
63
- return constraints.some((c) => this.__isValidConstraint(c));
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
- * Override this method to customize setting up constraints observer.
68
- * @protected
69
- */
70
- _createConstraintsObserver() {
71
- // This complex observer needs to be added dynamically instead of using `static get observers()`
72
- // to make it possible to tweak this behavior in classes that apply this mixin.
73
- this._createMethodObserver(`_constraintsChanged(stateTarget, ${this.constructor.constraints.join(', ')})`);
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
- * Override this method to implement custom validation constraints.
78
- * @param {HTMLElement | undefined} stateTarget
79
- * @param {unknown[]} constraints
80
- * @protected
81
- */
82
- _constraintsChanged(stateTarget, ...constraints) {
83
- // The input element's validity cannot be determined until
84
- // all the necessary constraint attributes aren't set on it.
85
- if (!stateTarget) {
86
- return;
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
- * Override an event listener inherited from `InputMixin`
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.dispatchEvent(
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
- /** @private */
126
- __isValidConstraint(constraint) {
127
- // 0 is valid for `minlength` and `maxlength`
128
- return Boolean(constraint) || constraint === 0;
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
+ }
@@ -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) {