@eturnity/eturnity_reusable_components 1.1.29 → 1.1.32
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
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
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
:placeholder="placeholder"
|
|
19
19
|
:isError="isError"
|
|
20
20
|
:inputWidth="inputWidth"
|
|
21
|
+
:minWidth="minWidth"
|
|
21
22
|
:value="formatWithCurrency(value)"
|
|
22
23
|
:hasLength="!!value && !!value.length"
|
|
23
24
|
@blur="onInputBlur($event)"
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
// placeholder="Enter distance"
|
|
49
50
|
// :isError="false" //default is false
|
|
50
51
|
// inputWidth="150px" //by default, this is 100%
|
|
52
|
+
// minWidth="100px"
|
|
51
53
|
// :numberPrecision="3"
|
|
52
54
|
// unitName="pc"
|
|
53
55
|
// :value="inputValue" //required -- String
|
|
@@ -79,6 +81,7 @@ const inputProps = {
|
|
|
79
81
|
isError: Boolean,
|
|
80
82
|
hasUnit: Boolean,
|
|
81
83
|
inputWidth: String,
|
|
84
|
+
minWidth: String,
|
|
82
85
|
hasLength: Boolean,
|
|
83
86
|
isDisabled: Boolean,
|
|
84
87
|
noBorder: Boolean,
|
|
@@ -103,6 +106,7 @@ const InputContainer = styled("input", inputProps)`
|
|
|
103
106
|
color: ${(props) =>
|
|
104
107
|
props.isError ? props.theme.colors.red : props.theme.colors.black};
|
|
105
108
|
width: ${(props) => (props.inputWidth ? props.inputWidth : "100%")};
|
|
109
|
+
min-width: ${(props) => (props.minWidth ? props.minWidth : "unset")};
|
|
106
110
|
background-color: ${(props) =>
|
|
107
111
|
props.isDisabled ? props.theme.colors.grey5 : "#fff"};
|
|
108
112
|
box-sizing: border-box;
|
|
@@ -189,6 +193,10 @@ export default {
|
|
|
189
193
|
required: false,
|
|
190
194
|
default: null,
|
|
191
195
|
},
|
|
196
|
+
minWidth: {
|
|
197
|
+
required: false,
|
|
198
|
+
default: null,
|
|
199
|
+
},
|
|
192
200
|
value: {
|
|
193
201
|
required: true,
|
|
194
202
|
default: null,
|
|
@@ -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")
|
|
@@ -11,30 +11,53 @@ export const stringToNumber = ({ value, numberPrecision }) => {
|
|
|
11
11
|
selectedLang === "de"
|
|
12
12
|
) {
|
|
13
13
|
// replace commas with a dot, and dots with blank
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|
|
18
25
|
} else if (selectedLang === "en-us") {
|
|
19
26
|
// replace commas with blank
|
|
20
|
-
|
|
27
|
+
if (allowNegative) {
|
|
28
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/[,\s]/g, "")
|
|
29
|
+
} else {
|
|
30
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, "")
|
|
31
|
+
}
|
|
21
32
|
} else if (
|
|
22
33
|
selectedLang === "de-ch" ||
|
|
23
34
|
selectedLang === "fr-ch" ||
|
|
24
35
|
selectedLang === "it-ch"
|
|
25
36
|
) {
|
|
26
37
|
// replace ' with blank
|
|
27
|
-
|
|
38
|
+
if (allowNegative) {
|
|
39
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/['\s]/g, "")
|
|
40
|
+
} else {
|
|
41
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/['\s]/g, "")
|
|
42
|
+
}
|
|
28
43
|
} else if (
|
|
29
44
|
selectedLang === "fr-fr" ||
|
|
30
45
|
selectedLang === "fr" ||
|
|
31
46
|
selectedLang === "sv-se"
|
|
32
47
|
) {
|
|
33
48
|
// replace space with blank, and commas with dot
|
|
34
|
-
|
|
49
|
+
if (allowNegative) {
|
|
50
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/[,\s]/g, ".")
|
|
51
|
+
} else {
|
|
52
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, ".")
|
|
53
|
+
}
|
|
35
54
|
} else {
|
|
36
55
|
// en-US as default
|
|
37
|
-
|
|
56
|
+
if (allowNegative) {
|
|
57
|
+
newVal = newVal.replace(/[^\d-.,']/g, "").replace(/[,\s]/g, "")
|
|
58
|
+
} else {
|
|
59
|
+
newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, "")
|
|
60
|
+
}
|
|
38
61
|
}
|
|
39
62
|
newVal = parseFloat(newVal).toFixed(numberPrecision)
|
|
40
63
|
return parseFloat(newVal)
|