@vaadin/number-field 24.2.0-alpha1 → 24.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/number-field",
3
- "version": "24.2.0-alpha1",
3
+ "version": "24.2.0-alpha11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,23 +38,23 @@
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
40
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/a11y-base": "24.2.0-alpha1",
42
- "@vaadin/component-base": "24.2.0-alpha1",
43
- "@vaadin/field-base": "24.2.0-alpha1",
44
- "@vaadin/input-container": "24.2.0-alpha1",
45
- "@vaadin/vaadin-lumo-styles": "24.2.0-alpha1",
46
- "@vaadin/vaadin-material-styles": "24.2.0-alpha1",
47
- "@vaadin/vaadin-themable-mixin": "24.2.0-alpha1",
41
+ "@vaadin/a11y-base": "24.2.0-alpha11",
42
+ "@vaadin/component-base": "24.2.0-alpha11",
43
+ "@vaadin/field-base": "24.2.0-alpha11",
44
+ "@vaadin/input-container": "24.2.0-alpha11",
45
+ "@vaadin/vaadin-lumo-styles": "24.2.0-alpha11",
46
+ "@vaadin/vaadin-material-styles": "24.2.0-alpha11",
47
+ "@vaadin/vaadin-themable-mixin": "24.2.0-alpha11",
48
48
  "lit": "^2.0.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@esm-bundle/chai": "^4.3.4",
52
- "@vaadin/testing-helpers": "^0.4.2",
52
+ "@vaadin/testing-helpers": "^0.5.0",
53
53
  "sinon": "^13.0.2"
54
54
  },
55
55
  "web-types": [
56
56
  "web-types.json",
57
57
  "web-types.lit.json"
58
58
  ],
59
- "gitHead": "0dbb118320203ab6c0c07450a3e718815367589f"
59
+ "gitHead": "a958207d5f6a09ca0e2dcf9f62194b3f92c8766a"
60
60
  }
@@ -10,6 +10,7 @@ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
10
10
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
11
11
  import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
12
12
  import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
13
+ import type { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
13
14
  import type { ClearButtonMixinClass } from '@vaadin/field-base/src/clear-button-mixin.js';
14
15
  import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
15
16
  import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
@@ -17,7 +18,6 @@ import type { InputControlMixinClass } from '@vaadin/field-base/src/input-contro
17
18
  import type { InputFieldMixinClass } from '@vaadin/field-base/src/input-field-mixin.js';
18
19
  import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
19
20
  import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
20
- import type { SlotStylesMixinClass } from '@vaadin/field-base/src/slot-styles-mixin.js';
21
21
  import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
22
22
 
23
23
  /**
@@ -66,6 +66,7 @@ export const NumberFieldMixin = (superClass) =>
66
66
  constructor() {
67
67
  super();
68
68
  this._setType('number');
69
+ this.__onWheel = this.__onWheel.bind(this);
69
70
  }
70
71
 
71
72
  /** @protected */
@@ -134,6 +135,50 @@ export const NumberFieldMixin = (superClass) =>
134
135
  return !this.invalid;
135
136
  }
136
137
 
138
+ /**
139
+ * Override the method from `InputMixin` to add
140
+ * a wheel event listener to the input element.
141
+ *
142
+ * @param {HTMLElement} input
143
+ * @override
144
+ * @protected
145
+ */
146
+ _addInputListeners(input) {
147
+ super._addInputListeners(input);
148
+ input.addEventListener('wheel', this.__onWheel);
149
+ }
150
+
151
+ /**
152
+ * Override the method from `InputMixin` to remove
153
+ * the wheel event listener from the input element.
154
+ *
155
+ * @param {HTMLElement} input
156
+ * @override
157
+ * @protected
158
+ */
159
+ _removeInputListeners(input) {
160
+ super._removeInputListeners(input);
161
+ input.removeEventListener('wheel', this.__onWheel);
162
+ }
163
+
164
+ /**
165
+ * Prevents default browser behavior for wheel events on the input element
166
+ * when it's focused. More precisely, this prevents the browser from attempting
167
+ * to increment or decrement the value when the mouse wheel is used within
168
+ * the input element.
169
+ *
170
+ * CAVEAT: As a side-effect, this also prevents page scrolling when
171
+ * the pointer is positioned over the field and the field is focused.
172
+ *
173
+ * @param {WheelEvent} event
174
+ * @private
175
+ */
176
+ __onWheel(event) {
177
+ if (this.hasAttribute('focused')) {
178
+ event.preventDefault();
179
+ }
180
+ }
181
+
137
182
  /** @protected */
138
183
  _onDecreaseButtonTouchend(e) {
139
184
  // Cancel the following click and focus events
@@ -20,6 +20,11 @@ export type NumberFieldChangeEvent = Event & {
20
20
  */
21
21
  export type NumberFieldInvalidChangedEvent = CustomEvent<{ value: boolean }>;
22
22
 
23
+ /**
24
+ * Fired when the `dirty` property changes.
25
+ */
26
+ export type NumberFieldDirtyChangedEvent = CustomEvent<{ value: boolean }>;
27
+
23
28
  /**
24
29
  * Fired when the `value` property changes.
25
30
  */
@@ -33,6 +38,8 @@ export type NumberFieldValidatedEvent = CustomEvent<{ valid: boolean }>;
33
38
  export interface NumberFieldCustomEventMap {
34
39
  'invalid-changed': NumberFieldInvalidChangedEvent;
35
40
 
41
+ 'dirty-changed': NumberFieldDirtyChangedEvent;
42
+
36
43
  'value-changed': NumberFieldValueChangedEvent;
37
44
 
38
45
  validated: NumberFieldValidatedEvent;
@@ -66,6 +73,7 @@ export interface NumberFieldEventMap extends HTMLElementEventMap, NumberFieldCus
66
73
  * @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
67
74
  * @fires {Event} change - Fired when the user commits a value change.
68
75
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
76
+ * @fires {CustomEvent} dirty-changed - Fired when the `dirty` property changes.
69
77
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
70
78
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
71
79
  */
@@ -114,6 +114,7 @@ export class NumberField extends NumberFieldMixin(ThemableMixin(ElementMixin(Pol
114
114
  this._tooltipController = new TooltipController(this);
115
115
  this.addController(this._tooltipController);
116
116
  this._tooltipController.setPosition('top');
117
+ this._tooltipController.setAriaTarget(this.inputElement);
117
118
  }
118
119
  }
119
120
 
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/number-field",
4
- "version": "24.2.0-alpha1",
4
+ "version": "24.2.0-alpha11",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-number-field",
11
- "description": "`<vaadin-number-field>` is an input field web component that only accepts numeric input.\n\n```html\n<vaadin-number-field label=\"Balance\"></vaadin-number-field>\n```\n\n### Styling\n\n`<vaadin-number-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n------------------|-------------------------\n`increase-button` | Increase (\"plus\") button\n`decrease-button` | Decrease (\"minus\") button\n\nNote, the `input-prevented` state attribute is only supported when `allowedCharPattern` is set.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
11
+ "description": "`<vaadin-number-field>` is an input field web component that only accepts numeric input.\n\n```html\n<vaadin-number-field label=\"Balance\"></vaadin-number-field>\n```\n\n### Styling\n\n`<vaadin-number-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha11/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n------------------|-------------------------\n`increase-button` | Increase (\"plus\") button\n`decrease-button` | Decrease (\"minus\") button\n\nNote, the `input-prevented` state attribute is only supported when `allowedCharPattern` is set.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "disabled",
@@ -120,6 +120,17 @@
120
120
  ]
121
121
  }
122
122
  },
123
+ {
124
+ "name": "dirty",
125
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\nan `input` or `change` event. Additionally, the field can be manually\nmarked as dirty by setting the property to `true`.",
126
+ "value": {
127
+ "type": [
128
+ "boolean",
129
+ "null",
130
+ "undefined"
131
+ ]
132
+ }
133
+ },
123
134
  {
124
135
  "name": "clear-button-visible",
125
136
  "description": "Set to true to display the clear icon which clears the input.\n\nIt is up to the component to choose where to place the clear icon:\nin the Shadow DOM or in the light DOM. In any way, a reference to\nthe clear icon element should be provided via the `clearElement` getter.",
@@ -396,6 +407,17 @@
396
407
  ]
397
408
  }
398
409
  },
410
+ {
411
+ "name": "dirty",
412
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\nan `input` or `change` event. Additionally, the field can be manually\nmarked as dirty by setting the property to `true`.",
413
+ "value": {
414
+ "type": [
415
+ "boolean",
416
+ "null",
417
+ "undefined"
418
+ ]
419
+ }
420
+ },
399
421
  {
400
422
  "name": "clearButtonVisible",
401
423
  "description": "Set to true to display the clear icon which clears the input.\n\nIt is up to the component to choose where to place the clear icon:\nin the Shadow DOM or in the light DOM. In any way, a reference to\nthe clear icon element should be provided via the `clearElement` getter.",
@@ -569,6 +591,10 @@
569
591
  {
570
592
  "name": "value-changed",
571
593
  "description": "Fired when the `value` property changes."
594
+ },
595
+ {
596
+ "name": "dirty-changed",
597
+ "description": "Fired when the `dirty` property changes."
572
598
  }
573
599
  ]
574
600
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/number-field",
4
- "version": "24.2.0-alpha1",
4
+ "version": "24.2.0-alpha11",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-number-field",
19
- "description": "`<vaadin-number-field>` is an input field web component that only accepts numeric input.\n\n```html\n<vaadin-number-field label=\"Balance\"></vaadin-number-field>\n```\n\n### Styling\n\n`<vaadin-number-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n------------------|-------------------------\n`increase-button` | Increase (\"plus\") button\n`decrease-button` | Decrease (\"minus\") button\n\nNote, the `input-prevented` state attribute is only supported when `allowedCharPattern` is set.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
19
+ "description": "`<vaadin-number-field>` is an input field web component that only accepts numeric input.\n\n```html\n<vaadin-number-field label=\"Balance\"></vaadin-number-field>\n```\n\n### Styling\n\n`<vaadin-number-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha11/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n------------------|-------------------------\n`increase-button` | Increase (\"plus\") button\n`decrease-button` | Decrease (\"minus\") button\n\nNote, the `input-prevented` state attribute is only supported when `allowedCharPattern` is set.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -47,6 +47,13 @@
47
47
  "kind": "expression"
48
48
  }
49
49
  },
50
+ {
51
+ "name": "?dirty",
52
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\nan `input` or `change` event. Additionally, the field can be manually\nmarked as dirty by setting the property to `true`.",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ },
50
57
  {
51
58
  "name": "?clearButtonVisible",
52
59
  "description": "Set to true to display the clear icon which clears the input.\n\nIt is up to the component to choose where to place the clear icon:\nin the Shadow DOM or in the light DOM. In any way, a reference to\nthe clear icon element should be provided via the `clearElement` getter.",
@@ -221,6 +228,13 @@
221
228
  "value": {
222
229
  "kind": "expression"
223
230
  }
231
+ },
232
+ {
233
+ "name": "@dirty-changed",
234
+ "description": "Fired when the `dirty` property changes.",
235
+ "value": {
236
+ "kind": "expression"
237
+ }
224
238
  }
225
239
  ]
226
240
  }