@vaadin/number-field 22.0.2 → 23.0.0-alpha4

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": "22.0.2",
3
+ "version": "23.0.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "main": "vaadin-number-field.js",
20
20
  "module": "vaadin-number-field.js",
21
+ "type": "module",
21
22
  "files": [
22
23
  "src",
23
24
  "theme",
@@ -32,17 +33,17 @@
32
33
  ],
33
34
  "dependencies": {
34
35
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/component-base": "^22.0.2",
36
- "@vaadin/field-base": "^22.0.2",
37
- "@vaadin/input-container": "^22.0.2",
38
- "@vaadin/vaadin-lumo-styles": "^22.0.2",
39
- "@vaadin/vaadin-material-styles": "^22.0.2",
40
- "@vaadin/vaadin-themable-mixin": "^22.0.2"
36
+ "@vaadin/component-base": "23.0.0-alpha4",
37
+ "@vaadin/field-base": "23.0.0-alpha4",
38
+ "@vaadin/input-container": "23.0.0-alpha4",
39
+ "@vaadin/vaadin-lumo-styles": "23.0.0-alpha4",
40
+ "@vaadin/vaadin-material-styles": "23.0.0-alpha4",
41
+ "@vaadin/vaadin-themable-mixin": "23.0.0-alpha4"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@esm-bundle/chai": "^4.3.4",
44
45
  "@vaadin/testing-helpers": "^0.3.2",
45
46
  "sinon": "^9.2.1"
46
47
  },
47
- "gitHead": "df21370c4a655a38eac11f79686021ab3b0887ad"
48
+ "gitHead": "81e2deee5147bb7c1f4884760f4598613306f1fb"
48
49
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 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';
@@ -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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 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';
@@ -233,7 +233,7 @@ export class NumberField extends InputFieldMixin(SlotStylesMixin(ThemableMixin(E
233
233
  this.ariaTarget = input;
234
234
  })
235
235
  );
236
- this.addController(new LabelledInputController(this.inputElement, this._labelNode));
236
+ this.addController(new LabelledInputController(this.inputElement, this._labelController));
237
237
  }
238
238
 
239
239
  /** @private */
@@ -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
- if (this._getIncrement(1, value - this.step) > this.max) {
307
- value -= 2 * this.step;
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 Math.pow(10, this._getDecimalCount(number));
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
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 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 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 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';