@eturnity/eturnity_reusable_components 1.1.28 → 1.1.31
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 +1 -1
- package/src/App.vue +10 -1
- package/src/helpers/numberConverter.js +34 -10
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -37,6 +37,13 @@
|
|
|
37
37
|
labelAlign="right"
|
|
38
38
|
:disabled="true"
|
|
39
39
|
/>
|
|
40
|
+
<br />
|
|
41
|
+
<input-number
|
|
42
|
+
placeholder="Enter distance"
|
|
43
|
+
:numberPrecision="2"
|
|
44
|
+
:value="inputValue"
|
|
45
|
+
@input-change="onInputChange($event)"
|
|
46
|
+
/>
|
|
40
47
|
</page-container>
|
|
41
48
|
</ThemeProvider>
|
|
42
49
|
</template>
|
|
@@ -48,6 +55,7 @@ import styled from "vue-styled-components"
|
|
|
48
55
|
import MainTable from "@/components/tables/mainTable"
|
|
49
56
|
import ThreeDots from "@/components/threeDots"
|
|
50
57
|
import Toggle from "@/components/inputs/toggle"
|
|
58
|
+
import InputNumber from "@/components/inputs/inputNumber"
|
|
51
59
|
// import TableDropdown from "@/components/tableDropdown"
|
|
52
60
|
|
|
53
61
|
const PageContainer = styled.div`
|
|
@@ -62,6 +70,7 @@ export default {
|
|
|
62
70
|
MainTable,
|
|
63
71
|
ThreeDots,
|
|
64
72
|
Toggle,
|
|
73
|
+
InputNumber,
|
|
65
74
|
// TableDropdown,
|
|
66
75
|
},
|
|
67
76
|
data() {
|
|
@@ -128,7 +137,7 @@ export default {
|
|
|
128
137
|
return theme
|
|
129
138
|
},
|
|
130
139
|
onInputChange(event) {
|
|
131
|
-
this.
|
|
140
|
+
this.inputValue = event
|
|
132
141
|
},
|
|
133
142
|
isDropdownOpen() {
|
|
134
143
|
return this.dropdownOpen
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const stringToNumber = ({ value, numberPrecision }) => {
|
|
1
|
+
export const stringToNumber = ({ value, numberPrecision, allowNegative }) => {
|
|
2
2
|
// This is for saving. It converts our input string to a readable number
|
|
3
3
|
let newVal = value.toString()
|
|
4
4
|
const selectedLang = localStorage.getItem("lang")
|
|
@@ -7,33 +7,57 @@ export const stringToNumber = ({ value, numberPrecision }) => {
|
|
|
7
7
|
selectedLang === "de-DE" ||
|
|
8
8
|
selectedLang === "it-CH" ||
|
|
9
9
|
selectedLang === "no-no" ||
|
|
10
|
-
selectedLang === "da-dk"
|
|
10
|
+
selectedLang === "da-dk" ||
|
|
11
|
+
selectedLang === "de"
|
|
11
12
|
) {
|
|
12
13
|
// replace commas with a dot, and dots with blank
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (allowNegative) {
|
|
15
|
+
newVal = newVal
|
|
16
|
+
.replace(/[^\d-.,']/g, "")
|
|
17
|
+
.replace(/[.\s]/g, "")
|
|
18
|
+
.replace(/[,\s]/, ".")
|
|
19
|
+
} else {
|
|
20
|
+
newVal = newVal
|
|
21
|
+
.replace(/[^\d.,']/g, "")
|
|
22
|
+
.replace(/[.\s]/g, "")
|
|
23
|
+
.replace(/[,\s]/, ".")
|
|
24
|
+
}
|
|
17
25
|
} else if (selectedLang === "en-us") {
|
|
18
26
|
// replace commas with blank
|
|
19
|
-
|
|
27
|
+
if (allowNegative) {
|
|
28
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/[,\s]/g, "")
|
|
29
|
+
} else {
|
|
30
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, "")
|
|
31
|
+
}
|
|
20
32
|
} else if (
|
|
21
33
|
selectedLang === "de-ch" ||
|
|
22
34
|
selectedLang === "fr-ch" ||
|
|
23
35
|
selectedLang === "it-ch"
|
|
24
36
|
) {
|
|
25
37
|
// replace ' with blank
|
|
26
|
-
|
|
38
|
+
if (allowNegative) {
|
|
39
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/['\s]/g, "")
|
|
40
|
+
} else {
|
|
41
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/['\s]/g, "")
|
|
42
|
+
}
|
|
27
43
|
} else if (
|
|
28
44
|
selectedLang === "fr-fr" ||
|
|
29
45
|
selectedLang === "fr" ||
|
|
30
46
|
selectedLang === "sv-se"
|
|
31
47
|
) {
|
|
32
48
|
// replace space with blank, and commas with dot
|
|
33
|
-
|
|
49
|
+
if (allowNegative) {
|
|
50
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/[,\s]/g, ".")
|
|
51
|
+
} else {
|
|
52
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, ".")
|
|
53
|
+
}
|
|
34
54
|
} else {
|
|
35
55
|
// en-US as default
|
|
36
|
-
|
|
56
|
+
if (allowNegative) {
|
|
57
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/[,\s]/g, "")
|
|
58
|
+
} else {
|
|
59
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, "")
|
|
60
|
+
}
|
|
37
61
|
}
|
|
38
62
|
newVal = parseFloat(newVal).toFixed(numberPrecision)
|
|
39
63
|
return parseFloat(newVal)
|