@eturnity/eturnity_reusable_components 1.1.27 → 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.27",
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
@@ -6,7 +6,7 @@
6
6
  ref="dropdownItem"
7
7
  :disabled="disabled"
8
8
  >
9
- <component-container :colSpan="colSpan" class="table-dropdown">
9
+ <component-container :colSpan="colSpan - 1" class="table-dropdown">
10
10
  <component-item v-for="(item, index) in tableItems" :key="index">
11
11
  <template-button
12
12
  @click.stop="onTemplateClick(item.row)"
@@ -161,7 +161,7 @@ const ComponentItem = styled.div`
161
161
  const containerAttrs = { colSpan: Number }
162
162
  const ComponentContainer = styled("div", containerAttrs)`
163
163
  display: grid;
164
- grid-template-columns: repeat(${(props) => props.colSpan}, minmax(0, 1fr)) auto;
164
+ grid-template-columns: 1fr repeat(${(props) => props.colSpan}, auto) auto;
165
165
  grid-gap: 12px;
166
166
  align-items: center;
167
167
  background-color: ${(props) => props.theme.colors.white};
@@ -217,7 +217,7 @@ const OptionsWrapper = styled.div`
217
217
 
218
218
  const OptionsItem = styled("div", containerAttrs)`
219
219
  display: grid;
220
- grid-template-columns: repeat(${(props) => props.colSpan}, minmax(0, 1fr));
220
+ grid-template-columns: 1fr repeat(${(props) => props.colSpan}, auto);
221
221
  grid-gap: 12px;
222
222
  padding: 10px;
223
223
  height: max-content;
@@ -1,43 +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"
7
+ selectedLang === 'de-DE' ||
8
+ selectedLang === 'it-CH' ||
9
+ selectedLang === 'no-no' ||
10
+ selectedLang === 'da-dk' ||
11
+ selectedLang === 'de'
11
12
  ) {
12
13
  // replace commas with a dot, and dots with blank
13
- newVal = newVal
14
- .replace(/[^\d.,']/g, "")
15
- .replace(/[.\s]/g, "")
16
- .replace(/[,\s]/, ".")
17
- } 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') {
18
26
  // replace commas with blank
19
- 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
+ }
20
32
  } else if (
21
- selectedLang === "de-ch" ||
22
- selectedLang === "fr-ch" ||
23
- selectedLang === "it-ch"
33
+ selectedLang === 'de-ch' ||
34
+ selectedLang === 'fr-ch' ||
35
+ selectedLang === 'it-ch'
24
36
  ) {
25
37
  // replace ' with blank
26
- 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
+ }
27
43
  } else if (
28
- selectedLang === "fr-fr" ||
29
- selectedLang === "fr" ||
30
- selectedLang === "sv-se"
44
+ selectedLang === 'fr-fr' ||
45
+ selectedLang === 'fr' ||
46
+ selectedLang === 'sv-se'
31
47
  ) {
32
48
  // replace space with blank, and commas with dot
33
- 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
+ }
34
54
  } else {
35
55
  // en-US as default
36
- 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
+ }
37
61
  }
38
62
  newVal = parseFloat(newVal).toFixed(numberPrecision)
39
63
  return parseFloat(newVal)
40
- }
64
+ },
41
65
 
42
66
  export const numberToString = ({ value, numberPrecision }) => {
43
67
  let selectedLang = localStorage.getItem("lang")