@vaadin/number-field 24.7.0-alpha2 → 24.7.0-alpha3
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 +11 -11
- package/src/vaadin-number-field-mixin.js +25 -18
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/number-field",
|
|
3
|
-
"version": "24.7.0-
|
|
3
|
+
"version": "24.7.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/a11y-base": "24.7.0-
|
|
40
|
-
"@vaadin/component-base": "24.7.0-
|
|
41
|
-
"@vaadin/field-base": "24.7.0-
|
|
42
|
-
"@vaadin/input-container": "24.7.0-
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "24.7.0-
|
|
44
|
-
"@vaadin/vaadin-material-styles": "24.7.0-
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "24.7.0-
|
|
39
|
+
"@vaadin/a11y-base": "24.7.0-alpha3",
|
|
40
|
+
"@vaadin/component-base": "24.7.0-alpha3",
|
|
41
|
+
"@vaadin/field-base": "24.7.0-alpha3",
|
|
42
|
+
"@vaadin/input-container": "24.7.0-alpha3",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "24.7.0-alpha3",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "24.7.0-alpha3",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "24.7.0-alpha3",
|
|
46
46
|
"lit": "^3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@vaadin/chai-plugins": "24.7.0-
|
|
50
|
-
"@vaadin/testing-helpers": "^1.
|
|
49
|
+
"@vaadin/chai-plugins": "24.7.0-alpha3",
|
|
50
|
+
"@vaadin/testing-helpers": "^1.1.0",
|
|
51
51
|
"sinon": "^18.0.0"
|
|
52
52
|
},
|
|
53
53
|
"web-types": [
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "dd5cfad6c9b54e676f5b10dffba2233775378f40"
|
|
58
58
|
}
|
|
@@ -4,11 +4,20 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { getDeepActiveElement } from '@vaadin/a11y-base/src/focus-utils.js';
|
|
7
|
-
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller';
|
|
7
|
+
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
8
8
|
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
9
9
|
import { InputFieldMixin } from '@vaadin/field-base/src/input-field-mixin.js';
|
|
10
10
|
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
11
11
|
|
|
12
|
+
// [type=number] value returns an empty string for invalid numbers,
|
|
13
|
+
// while valueAsNumber returns NaN for empty strings, which makes
|
|
14
|
+
// invalid and empty values indistinguishable. It's only possible
|
|
15
|
+
// to detect unparsable input by checking the validity.badInput
|
|
16
|
+
// boolean property. This string is used in _inputElementValue
|
|
17
|
+
// as a marker to help Flow detect and clear unparsable values
|
|
18
|
+
// through that property.
|
|
19
|
+
const BAD_INPUT_STRING = 'NaN';
|
|
20
|
+
|
|
12
21
|
/**
|
|
13
22
|
* A mixin providing common number field functionality.
|
|
14
23
|
*
|
|
@@ -111,7 +120,7 @@ export const NumberFieldMixin = (superClass) =>
|
|
|
111
120
|
* @private
|
|
112
121
|
*/
|
|
113
122
|
get __hasUnparsableValue() {
|
|
114
|
-
return this.
|
|
123
|
+
return this._inputElementValue === BAD_INPUT_STRING;
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
/** @protected */
|
|
@@ -405,22 +414,6 @@ export const NumberFieldMixin = (superClass) =>
|
|
|
405
414
|
super._onKeyDown(event);
|
|
406
415
|
}
|
|
407
416
|
|
|
408
|
-
/**
|
|
409
|
-
* Native [type=number] inputs don't update their value
|
|
410
|
-
* when you are entering input that the browser is unable to parse
|
|
411
|
-
* e.g. "--5", hence we have to override this method from `InputMixin`
|
|
412
|
-
* so that, when value is empty, it would additionally check
|
|
413
|
-
* for bad input based on the native `validity.badInput` property.
|
|
414
|
-
*
|
|
415
|
-
* @param {InputEvent} event
|
|
416
|
-
* @protected
|
|
417
|
-
* @override
|
|
418
|
-
*/
|
|
419
|
-
_setHasInputValue(event) {
|
|
420
|
-
const target = event.composedPath()[0];
|
|
421
|
-
this._hasInputValue = target.value.length > 0 || this.__hasUnparsableValue;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
417
|
/**
|
|
425
418
|
* Override this method from `InputMixin` to prevent
|
|
426
419
|
* the value change caused by user input from being treated
|
|
@@ -527,4 +520,18 @@ export const NumberFieldMixin = (superClass) =>
|
|
|
527
520
|
this.__committedValue = this.value;
|
|
528
521
|
this.__committedUnparsableValueStatus = this.__hasUnparsableValue;
|
|
529
522
|
}
|
|
523
|
+
|
|
524
|
+
/** @override */
|
|
525
|
+
get _inputElementValue() {
|
|
526
|
+
if (this.inputElement && this.inputElement.validity.badInput) {
|
|
527
|
+
return BAD_INPUT_STRING;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return super._inputElementValue;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** @override */
|
|
534
|
+
set _inputElementValue(value) {
|
|
535
|
+
super._inputElementValue = value;
|
|
536
|
+
}
|
|
530
537
|
};
|
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.7.0-
|
|
4
|
+
"version": "24.7.0-alpha3",
|
|
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.7.0-
|
|
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.7.0-alpha3/#/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.\n\n### Change events\n\nDepending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,\nthe component can fire either a `change` event or an `unparsable-change` event:\n\nValue change | Event\n:------------------------|:------------------\nempty => parsable | change\nempty => unparsable | unparsable-change\nparsable => empty | change\nparsable => parsable | change\nparsable => unparsable | change\nunparsable => empty | unparsable-change\nunparsable => parsable | change\nunparsable => unparsable | -\n\nNote, there is currently no way to detect unparsable => unparsable changes because the browser\ndoesn't provide access to unparsable values of native [type=number] inputs.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/number-field",
|
|
4
|
-
"version": "24.7.0-
|
|
4
|
+
"version": "24.7.0-alpha3",
|
|
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.7.0-
|
|
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.7.0-alpha3/#/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.\n\n### Change events\n\nDepending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,\nthe component can fire either a `change` event or an `unparsable-change` event:\n\nValue change | Event\n:------------------------|:------------------\nempty => parsable | change\nempty => unparsable | unparsable-change\nparsable => empty | change\nparsable => parsable | change\nparsable => unparsable | change\nunparsable => empty | unparsable-change\nunparsable => parsable | change\nunparsable => unparsable | -\n\nNote, there is currently no way to detect unparsable => unparsable changes because the browser\ndoesn't provide access to unparsable values of native [type=number] inputs.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|