@eturnity/eturnity_reusable_components 1.1.29 → 1.1.30

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": "@eturnity/eturnity_reusable_components",
3
- "version": "1.1.29",
3
+ "version": "1.1.30",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
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.isChecked = event
140
+ this.inputValue = event
132
141
  },
133
142
  isDropdownOpen() {
134
143
  return this.dropdownOpen
@@ -1,44 +1,67 @@
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
- const selectedLang = localStorage.getItem("lang")
4
+ const selectedLang = localStorage.getItem('lang')
5
5
  // The first replace will replace not allowed characters with a blank
6
6
  if (
7
- selectedLang === "de-DE" ||
8
- selectedLang === "it-CH" ||
9
- selectedLang === "no-no" ||
10
- selectedLang === "da-dk" ||
11
- selectedLang === "de"
7
+ selectedLang === 'de-DE' ||
8
+ selectedLang === 'it-CH' ||
9
+ selectedLang === 'no-no' ||
10
+ selectedLang === 'da-dk' ||
11
+ selectedLang === 'de'
12
12
  ) {
13
13
  // replace commas with a dot, and dots with blank
14
- newVal = newVal
15
- .replace(/[^\d.,']/g, "")
16
- .replace(/[.\s]/g, "")
17
- .replace(/[,\s]/, ".")
18
- } else if (selectedLang === "en-us") {
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
+ }
25
+ } else if (selectedLang === 'en-us') {
19
26
  // replace commas with blank
20
- newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, "")
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
- selectedLang === "de-ch" ||
23
- selectedLang === "fr-ch" ||
24
- selectedLang === "it-ch"
33
+ selectedLang === 'de-ch' ||
34
+ selectedLang === 'fr-ch' ||
35
+ selectedLang === 'it-ch'
25
36
  ) {
26
37
  // replace ' with blank
27
- newVal = newVal.replace(/[^\d.,']/g, "").replace(/['\s]/g, "")
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
- selectedLang === "fr-fr" ||
30
- selectedLang === "fr" ||
31
- selectedLang === "sv-se"
44
+ selectedLang === 'fr-fr' ||
45
+ selectedLang === 'fr' ||
46
+ selectedLang === 'sv-se'
32
47
  ) {
33
48
  // replace space with blank, and commas with dot
34
- newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, ".")
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
- newVal = newVal.replace(/[^\d.,']/g, "").replace(/[,\s]/g, "")
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)
41
- }
64
+ },
42
65
 
43
66
  export const numberToString = ({ value, numberPrecision }) => {
44
67
  let selectedLang = localStorage.getItem("lang")