@fluid-topics/ft-number-field 1.3.51 → 1.3.52
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.
|
@@ -6,6 +6,7 @@ export declare class FtNumberField extends FtLitElement implements FtNumberField
|
|
|
6
6
|
static styles: import("lit").CSSResult;
|
|
7
7
|
label?: string;
|
|
8
8
|
value?: number;
|
|
9
|
+
integer: boolean;
|
|
9
10
|
helper: string;
|
|
10
11
|
outlined: boolean;
|
|
11
12
|
disabled: boolean;
|
|
@@ -18,6 +19,7 @@ export declare class FtNumberField extends FtLitElement implements FtNumberField
|
|
|
18
19
|
protected update(changedProperties: PropertyValues): void;
|
|
19
20
|
lowerBound(value: number): number;
|
|
20
21
|
upperBound(value: number): number;
|
|
22
|
+
round(value: number): number;
|
|
21
23
|
private onChange;
|
|
22
24
|
private setValue;
|
|
23
25
|
private onFocus;
|
package/build/ft-number-field.js
CHANGED
|
@@ -15,6 +15,7 @@ import { FtTypography } from "@fluid-topics/ft-typography";
|
|
|
15
15
|
class FtNumberField extends FtLitElement {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(...arguments);
|
|
18
|
+
this.integer = false;
|
|
18
19
|
this.helper = "";
|
|
19
20
|
this.outlined = false;
|
|
20
21
|
this.disabled = false;
|
|
@@ -75,6 +76,9 @@ class FtNumberField extends FtLitElement {
|
|
|
75
76
|
upperBound(value) {
|
|
76
77
|
return this.max != undefined ? Math.min(this.max, value) : value;
|
|
77
78
|
}
|
|
79
|
+
round(value) {
|
|
80
|
+
return this.integer ? Math.floor(value) : value;
|
|
81
|
+
}
|
|
78
82
|
onChange(event) {
|
|
79
83
|
event.preventDefault();
|
|
80
84
|
event.stopPropagation();
|
|
@@ -83,7 +87,7 @@ class FtNumberField extends FtLitElement {
|
|
|
83
87
|
setValue(value) {
|
|
84
88
|
const oldValue = this.value;
|
|
85
89
|
this.value = value;
|
|
86
|
-
const boundedValue = this.value == undefined ? undefined : this.lowerBound(this.upperBound(this.value));
|
|
90
|
+
const boundedValue = this.value == undefined ? undefined : this.round(this.lowerBound(this.upperBound(this.value)));
|
|
87
91
|
setTimeout(() => {
|
|
88
92
|
this.value = boundedValue;
|
|
89
93
|
if (oldValue !== boundedValue) {
|
|
@@ -113,6 +117,9 @@ __decorate([
|
|
|
113
117
|
__decorate([
|
|
114
118
|
numberProperty()
|
|
115
119
|
], FtNumberField.prototype, "value", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
property({ type: Boolean })
|
|
122
|
+
], FtNumberField.prototype, "integer", void 0);
|
|
116
123
|
__decorate([
|
|
117
124
|
property({ type: String })
|
|
118
125
|
], FtNumberField.prototype, "helper", void 0);
|