@vaadin/number-field 22.0.0-rc1 → 23.0.0-alpha2
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": "
|
|
3
|
+
"version": "23.0.0-alpha2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/component-base": "
|
|
36
|
-
"@vaadin/field-base": "
|
|
37
|
-
"@vaadin/input-container": "
|
|
38
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
39
|
-
"@vaadin/vaadin-material-styles": "
|
|
40
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
35
|
+
"@vaadin/component-base": "23.0.0-alpha2",
|
|
36
|
+
"@vaadin/field-base": "23.0.0-alpha2",
|
|
37
|
+
"@vaadin/input-container": "23.0.0-alpha2",
|
|
38
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
|
|
39
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha2",
|
|
40
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@esm-bundle/chai": "^4.3.4",
|
|
44
44
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
45
45
|
"sinon": "^9.2.1"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
|
|
48
48
|
}
|
|
@@ -8,6 +8,13 @@ import { InputFieldMixin } from '@vaadin/field-base/src/input-field-mixin.js';
|
|
|
8
8
|
import { SlotStylesMixin } from '@vaadin/field-base/src/slot-styles-mixin.js';
|
|
9
9
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Fired when the user commits a value change.
|
|
13
|
+
*/
|
|
14
|
+
export type NumberFieldChangeEvent = Event & {
|
|
15
|
+
target: NumberField;
|
|
16
|
+
};
|
|
17
|
+
|
|
11
18
|
/**
|
|
12
19
|
* Fired when the `invalid` property changes.
|
|
13
20
|
*/
|
|
@@ -24,7 +31,9 @@ export interface NumberFieldCustomEventMap {
|
|
|
24
31
|
'value-changed': NumberFieldValueChangedEvent;
|
|
25
32
|
}
|
|
26
33
|
|
|
27
|
-
export interface NumberFieldEventMap extends HTMLElementEventMap, NumberFieldCustomEventMap {
|
|
34
|
+
export interface NumberFieldEventMap extends HTMLElementEventMap, NumberFieldCustomEventMap {
|
|
35
|
+
change: NumberFieldChangeEvent;
|
|
36
|
+
}
|
|
28
37
|
|
|
29
38
|
/**
|
|
30
39
|
* `<vaadin-number-field>` is an input field web component that only accepts numeric input.
|
|
@@ -301,13 +301,11 @@ export class NumberField extends InputFieldMixin(SlotStylesMixin(ThemableMixin(E
|
|
|
301
301
|
value = this.max;
|
|
302
302
|
if (incr < 0) {
|
|
303
303
|
incr = 0;
|
|
304
|
-
} else {
|
|
304
|
+
} else if (this._getIncrement(1, value - this.step) > this.max) {
|
|
305
|
+
value -= 2 * this.step;
|
|
305
306
|
// FIXME(yuriy): find a proper solution to make correct step back
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
} else {
|
|
309
|
-
value -= this.step;
|
|
310
|
-
}
|
|
307
|
+
} else {
|
|
308
|
+
value -= this.step;
|
|
311
309
|
}
|
|
312
310
|
}
|
|
313
311
|
} else if (value < this.min) {
|
|
@@ -348,9 +346,8 @@ export class NumberField extends InputFieldMixin(SlotStylesMixin(ThemableMixin(E
|
|
|
348
346
|
return (currentValue - margin + step) / multiplier;
|
|
349
347
|
} else if (incr < 0) {
|
|
350
348
|
return (currentValue - (margin || step)) / multiplier;
|
|
351
|
-
} else {
|
|
352
|
-
return currentValue / multiplier;
|
|
353
349
|
}
|
|
350
|
+
return currentValue / multiplier;
|
|
354
351
|
}
|
|
355
352
|
|
|
356
353
|
/** @private */
|
|
@@ -363,7 +360,7 @@ export class NumberField extends InputFieldMixin(SlotStylesMixin(ThemableMixin(E
|
|
|
363
360
|
/** @private */
|
|
364
361
|
_getMultiplier(number) {
|
|
365
362
|
if (!isNaN(number)) {
|
|
366
|
-
return
|
|
363
|
+
return 10 ** this._getDecimalCount(number);
|
|
367
364
|
}
|
|
368
365
|
}
|
|
369
366
|
|
|
@@ -373,9 +370,8 @@ export class NumberField extends InputFieldMixin(SlotStylesMixin(ThemableMixin(E
|
|
|
373
370
|
return this.min == null || this._getIncrement(incr, value) >= this.min;
|
|
374
371
|
} else if (incr > 0) {
|
|
375
372
|
return this.max == null || this._getIncrement(incr, value) <= this.max;
|
|
376
|
-
} else {
|
|
377
|
-
return this._getIncrement(incr, value) <= this.max && this._getIncrement(incr, value) >= this.min;
|
|
378
373
|
}
|
|
374
|
+
return this._getIncrement(incr, value) <= this.max && this._getIncrement(incr, value) >= this.min;
|
|
379
375
|
}
|
|
380
376
|
|
|
381
377
|
/** @private */
|
|
@@ -470,9 +466,8 @@ export class NumberField extends InputFieldMixin(SlotStylesMixin(ThemableMixin(E
|
|
|
470
466
|
(this.required || this.min !== undefined || this.max !== undefined || this.__validateByStep)
|
|
471
467
|
) {
|
|
472
468
|
return this.inputElement.checkValidity();
|
|
473
|
-
} else {
|
|
474
|
-
return !this.invalid;
|
|
475
469
|
}
|
|
470
|
+
return !this.invalid;
|
|
476
471
|
}
|
|
477
472
|
}
|
|
478
473
|
|