@vaadin/number-field 24.0.0-alpha1 → 24.0.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.0.0-alpha1",
3
+ "version": "24.0.0-alpha11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,12 +35,12 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/component-base": "24.0.0-alpha1",
39
- "@vaadin/field-base": "24.0.0-alpha1",
40
- "@vaadin/input-container": "24.0.0-alpha1",
41
- "@vaadin/vaadin-lumo-styles": "24.0.0-alpha1",
42
- "@vaadin/vaadin-material-styles": "24.0.0-alpha1",
43
- "@vaadin/vaadin-themable-mixin": "24.0.0-alpha1"
38
+ "@vaadin/component-base": "24.0.0-alpha11",
39
+ "@vaadin/field-base": "24.0.0-alpha11",
40
+ "@vaadin/input-container": "24.0.0-alpha11",
41
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha11",
42
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha11",
43
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha11"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@esm-bundle/chai": "^4.3.4",
@@ -51,5 +51,5 @@
51
51
  "web-types.json",
52
52
  "web-types.lit.json"
53
53
  ],
54
- "gitHead": "427527c27c4b27822d61fd41d38d7b170134770b"
54
+ "gitHead": "641b3d96ceeb3e503a093682ebe686afdd8c3a68"
55
55
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
@@ -70,10 +70,10 @@ export interface NumberFieldEventMap extends HTMLElementEventMap, NumberFieldCus
70
70
  */
71
71
  declare class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(HTMLElement))) {
72
72
  /**
73
- * Set to true to display value increase/decrease controls.
74
- * @attr {boolean} has-controls
73
+ * Set to true to show increase/decrease buttons.
74
+ * @attr {boolean} step-buttons-visible
75
75
  */
76
- hasControls: boolean;
76
+ stepButtonsVisible: boolean;
77
77
 
78
78
  /**
79
79
  * The minimum value of the field.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 '@vaadin/input-container/src/vaadin-input-container.js';
@@ -100,7 +100,7 @@ export class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(Poly
100
100
  part="decrease-button"
101
101
  on-click="_decreaseValue"
102
102
  on-touchend="_decreaseButtonTouchend"
103
- hidden$="[[!hasControls]]"
103
+ hidden$="[[!stepButtonsVisible]]"
104
104
  aria-hidden="true"
105
105
  slot="prefix"
106
106
  ></div>
@@ -113,7 +113,7 @@ export class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(Poly
113
113
  part="increase-button"
114
114
  on-click="_increaseValue"
115
115
  on-touchend="_increaseButtonTouchend"
116
- hidden$="[[!hasControls]]"
116
+ hidden$="[[!stepButtonsVisible]]"
117
117
  aria-hidden="true"
118
118
  slot="suffix"
119
119
  ></div>
@@ -135,10 +135,10 @@ export class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(Poly
135
135
  static get properties() {
136
136
  return {
137
137
  /**
138
- * Set to true to display value increase/decrease controls.
139
- * @attr {boolean} has-controls
138
+ * Set to true to show increase/decrease buttons.
139
+ * @attr {boolean} step-buttons-visible
140
140
  */
141
- hasControls: {
141
+ stepButtonsVisible: {
142
142
  type: Boolean,
143
143
  value: false,
144
144
  reflectToAttribute: true,
@@ -205,7 +205,7 @@ export class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(Poly
205
205
  direction: rtl;
206
206
  }
207
207
 
208
- ${tag}[dir='rtl']:not([has-controls]) input[type="number"]::placeholder {
208
+ ${tag}[dir='rtl']:not([step-buttons-visible]) input[type="number"]::placeholder {
209
209
  text-align: left;
210
210
  }
211
211
  `,
@@ -241,17 +241,19 @@ export class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(Poly
241
241
  }
242
242
 
243
243
  /**
244
- * Override a method from `InputConstraintsMixin`
245
- * to additionally check for bad user input.
244
+ * Override the method from `InputConstraintsMixin`
245
+ * to enforce HTML constraint validation even if
246
+ * the user didn't add any constraints explicitly:
247
+ * the field has to be regardless checked for bad input.
246
248
  *
247
249
  * @override
248
250
  */
249
251
  checkValidity() {
250
- if (this.inputElement && this.inputElement.validity.badInput) {
251
- return false;
252
+ if (this.inputElement) {
253
+ return this.inputElement.checkValidity();
252
254
  }
253
255
 
254
- return super.checkValidity();
256
+ return !this.invalid;
255
257
  }
256
258
 
257
259
  /** @private */
@@ -429,6 +431,22 @@ export class NumberField extends InputFieldMixin(ThemableMixin(ElementMixin(Poly
429
431
 
430
432
  super._onKeyDown(event);
431
433
  }
434
+
435
+ /**
436
+ * Native [type=number] inputs don't update their value
437
+ * when you are entering input that the browser is unable to parse
438
+ * e.g. "--5", hence we have to override this method from `InputMixin`
439
+ * so that, when value is empty, it would additionally check
440
+ * for bad input based on the native `validity.badInput` property.
441
+ *
442
+ * @param {InputEvent} event
443
+ * @protected
444
+ * @override
445
+ */
446
+ _setHasInputValue(event) {
447
+ const target = event.composedPath()[0];
448
+ this._hasInputValue = target.value.length > 0 || target.validity.badInput;
449
+ }
432
450
  }
433
451
 
434
452
  customElements.define(NumberField.is, NumberField);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 '@vaadin/vaadin-lumo-styles/sizing.js';
@@ -9,11 +9,7 @@ import { inputFieldShared } from '@vaadin/vaadin-lumo-styles/mixins/input-field-
9
9
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
10
 
11
11
  const numberField = css`
12
- :host {
13
- width: 8em;
14
- }
15
-
16
- :host([has-controls]:not([theme~='align-right'])) ::slotted(input) {
12
+ :host([step-buttons-visible]:not([theme~='align-right'])) ::slotted(input) {
17
13
  text-align: center;
18
14
  }
19
15
 
@@ -21,7 +17,7 @@ const numberField = css`
21
17
  opacity: 0.2;
22
18
  }
23
19
 
24
- :host([has-controls]) [part='input-field'] {
20
+ :host([step-buttons-visible]) [part='input-field'] {
25
21
  padding: 0;
26
22
  }
27
23
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 '@vaadin/input-container/theme/lumo/vaadin-input-container.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { fieldButton } from '@vaadin/vaadin-material-styles/mixins/field-button.js';
@@ -8,11 +8,7 @@ import { inputFieldShared } from '@vaadin/vaadin-material-styles/mixins/input-fi
8
8
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
9
 
10
10
  const numberField = css`
11
- :host {
12
- width: 8em;
13
- }
14
-
15
- :host([has-controls]) ::slotted(input) {
11
+ :host([step-buttons-visible]) ::slotted(input) {
16
12
  text-align: center;
17
13
  }
18
14
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 '@vaadin/input-container/theme/material/vaadin-input-container.js';
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.0.0-alpha1",
4
+ "version": "24.0.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.0.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/custom-theme/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.0.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/custom-theme/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "disabled",
@@ -209,8 +209,8 @@
209
209
  }
210
210
  },
211
211
  {
212
- "name": "has-controls",
213
- "description": "Set to true to display value increase/decrease controls.",
212
+ "name": "step-buttons-visible",
213
+ "description": "Set to true to show increase/decrease buttons.",
214
214
  "value": {
215
215
  "type": [
216
216
  "boolean",
@@ -463,8 +463,8 @@
463
463
  }
464
464
  },
465
465
  {
466
- "name": "hasControls",
467
- "description": "Set to true to display value increase/decrease controls.",
466
+ "name": "stepButtonsVisible",
467
+ "description": "Set to true to show increase/decrease buttons.",
468
468
  "value": {
469
469
  "type": [
470
470
  "boolean",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/number-field",
4
- "version": "24.0.0-alpha1",
4
+ "version": "24.0.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.0.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/custom-theme/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.0.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/custom-theme/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -69,8 +69,8 @@
69
69
  }
70
70
  },
71
71
  {
72
- "name": "?hasControls",
73
- "description": "Set to true to display value increase/decrease controls.",
72
+ "name": "?stepButtonsVisible",
73
+ "description": "Set to true to show increase/decrease buttons.",
74
74
  "value": {
75
75
  "kind": "expression"
76
76
  }