@eturnity/eturnity_reusable_components 1.2.14 → 1.2.15-0
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
|
@@ -1,74 +1,38 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ThemeProvider :theme="getTheme()" :style="{ height: '100%' }">
|
|
3
3
|
<page-container>
|
|
4
|
-
<main-table titleText="My Table">
|
|
5
|
-
<thead>
|
|
6
|
-
<tr>
|
|
7
|
-
<th>Column 1</th>
|
|
8
|
-
<th>Column 2</th>
|
|
9
|
-
<th>Column 3</th>
|
|
10
|
-
<div />
|
|
11
|
-
</tr>
|
|
12
|
-
</thead>
|
|
13
|
-
<tbody>
|
|
14
|
-
<tr>
|
|
15
|
-
<!-- <table-dropdown
|
|
16
|
-
:colSpan="3"
|
|
17
|
-
:tableItems="getDropdownValues()"
|
|
18
|
-
@toggle-dropdown-open="toggleDropdownOpen()"
|
|
19
|
-
@item-selected="onItemSelected({ item: $event, index })"
|
|
20
|
-
:isOpen="isDropdownOpen()"
|
|
21
|
-
:optionItems="itemOptions"
|
|
22
|
-
:optionsDisplay="['display_name', 'company_item_number', 'model']"
|
|
23
|
-
/> -->
|
|
24
|
-
<td>Test</td>
|
|
25
|
-
<div class="icons-container">
|
|
26
|
-
<three-dots :options="listOptions" :isLoading="false" />
|
|
27
|
-
</div>
|
|
28
|
-
</tr>
|
|
29
|
-
</tbody>
|
|
30
|
-
</main-table>
|
|
31
4
|
<br />
|
|
5
|
+
<input-number
|
|
6
|
+
:value="inputValue"
|
|
7
|
+
@input-change="inputValue = $event"
|
|
8
|
+
inputWidth="250px"
|
|
9
|
+
slotSize="50%"
|
|
10
|
+
><InputAnnexContainer>
|
|
11
|
+
<span>123m2</span>
|
|
12
|
+
<info-text size="10" text="infoText ceci est le text"></info-text>
|
|
13
|
+
</InputAnnexContainer>
|
|
14
|
+
</input-number>
|
|
15
|
+
<input-number
|
|
16
|
+
:value="inputValue"
|
|
17
|
+
@input-change="inputValue = $event"
|
|
18
|
+
inputWidth="250px"
|
|
19
|
+
slotSize="50%"
|
|
20
|
+
:isError="true"
|
|
21
|
+
><InputAnnexContainer>
|
|
22
|
+
<span>123m2</span>
|
|
23
|
+
<info-text size="15" text="infoText ceci est le text"></info-text>
|
|
24
|
+
</InputAnnexContainer>
|
|
25
|
+
</input-number>
|
|
32
26
|
<br />
|
|
33
|
-
<toggle
|
|
34
|
-
@on-toggle-change="onInputChange($event)"
|
|
35
|
-
:isChecked="inputValue"
|
|
36
|
-
label="My Label Text"
|
|
37
|
-
infoTextMessage="This is my test message"
|
|
38
|
-
infoTextAlign="right"
|
|
39
|
-
labelAlign="right"
|
|
40
|
-
:disabled="false"
|
|
41
|
-
/>
|
|
42
27
|
<br />
|
|
43
28
|
<input-number
|
|
44
29
|
placeholder="Enter distance"
|
|
45
30
|
:numberPrecision="2"
|
|
46
31
|
:value="inputValue"
|
|
47
32
|
@input-change="onInputChange($event)"
|
|
48
|
-
|
|
33
|
+
>unit</input-number
|
|
34
|
+
>
|
|
49
35
|
<br />
|
|
50
|
-
<page-subtitle text="My Subtitle" infoText="My info Text" />
|
|
51
|
-
<spinner size="30px" />
|
|
52
|
-
<checkbox
|
|
53
|
-
label="Do you accept the Terms?"
|
|
54
|
-
:isChecked="true"
|
|
55
|
-
size="small"
|
|
56
|
-
:isDisabled="false"
|
|
57
|
-
/>
|
|
58
|
-
<external-button text="Click me!" minWidth="500px" />
|
|
59
|
-
<icon name="Battery" />
|
|
60
|
-
<icon name="Bubble" color="red" hoveredColor="blue" size="60px" />
|
|
61
|
-
<icon name="Call" color="red" hoveredColor="blue" size="60px" />
|
|
62
|
-
<icon name="Camera" color="yellow" hoveredColor="green" size="60px" />
|
|
63
|
-
<icon name="House" color="red" hoveredColor="blue" size="20px" />
|
|
64
|
-
<icon name="House" color="red" hoveredColor="blue" size="40px" />
|
|
65
|
-
<icon name="House" color="red" hoveredColor="blue" size="80px" />
|
|
66
|
-
<icon name="House" color="red" hoveredColor="blue" size="120px" />
|
|
67
|
-
<icon name="Area_Active" color="red" hoveredColor="blue" size="150px" />
|
|
68
|
-
<icon name="Area_Active" color="red" hoveredColor="blue" size="120px" />
|
|
69
|
-
<icon name="Area_Active" color="red" hoveredColor="blue" size="80px" />
|
|
70
|
-
<icon name="Area_Active" color="red" hoveredColor="blue" size="40px" />
|
|
71
|
-
<collection />
|
|
72
36
|
</page-container>
|
|
73
37
|
</ThemeProvider>
|
|
74
38
|
</template>
|
|
@@ -77,17 +41,15 @@
|
|
|
77
41
|
import { ThemeProvider } from 'vue-styled-components'
|
|
78
42
|
import theme from './assets/theme'
|
|
79
43
|
import styled from 'vue-styled-components'
|
|
80
|
-
|
|
81
|
-
import ThreeDots from '@/components/threeDots'
|
|
82
|
-
import Toggle from '@/components/inputs/toggle'
|
|
44
|
+
|
|
83
45
|
import InputNumber from '@/components/inputs/inputNumber'
|
|
84
|
-
import
|
|
85
|
-
import PageSubtitle from '@/components/pageSubtitle'
|
|
86
|
-
import Spinner from '@/components/spinner'
|
|
87
|
-
import ExternalButton from '@/components/buttons/externalButton'
|
|
88
|
-
import icon from '@/components/icon'
|
|
89
|
-
import collection from '@/components/icons/iconCollection'
|
|
46
|
+
import infoText from '@/components/infoText'
|
|
90
47
|
// import TableDropdown from "@/components/tableDropdown"
|
|
48
|
+
const InputAnnexContainer = styled.div`
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: auto auto;
|
|
51
|
+
grid-gap: 10px;
|
|
52
|
+
`
|
|
91
53
|
|
|
92
54
|
const PageContainer = styled.div`
|
|
93
55
|
padding: 40px;
|
|
@@ -98,16 +60,9 @@ export default {
|
|
|
98
60
|
components: {
|
|
99
61
|
ThemeProvider,
|
|
100
62
|
PageContainer,
|
|
101
|
-
MainTable,
|
|
102
|
-
ThreeDots,
|
|
103
|
-
Toggle,
|
|
104
63
|
InputNumber,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
Checkbox,
|
|
108
|
-
ExternalButton,
|
|
109
|
-
collection,
|
|
110
|
-
icon
|
|
64
|
+
infoText,
|
|
65
|
+
InputAnnexContainer
|
|
111
66
|
// TableDropdown,
|
|
112
67
|
},
|
|
113
68
|
data() {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M12 -1.04907e-06C14.3734 -8.41587e-07 16.6934 0.703787 18.6668 2.02236C20.6402 3.34094 22.1783 5.21509 23.0865 7.4078C23.9948 9.60051 24.2324 12.0133 23.7694 14.3411C23.3064 16.6689 22.1635 18.8071 20.4853 20.4853C18.807 22.1635 16.6688 23.3064 14.3411 23.7694C12.0133 24.2324 9.6005 23.9948 7.40779 23.0866C5.21508 22.1783 3.34093 20.6402 2.02236 18.6668C0.703782 16.6935 -6.97861e-06 14.3734 -6.77112e-06 12C-6.49289e-06 8.8174 1.26428 5.76515 3.51471 3.51472C5.76515 1.26428 8.8174 -1.32731e-06 12 -1.04907e-06ZM9.74999 19.81L14.25 19.81L14.25 10.81L9.74999 10.81L9.74999 19.81ZM12 8.69C12.445 8.69 12.88 8.55804 13.25 8.31081C13.62 8.06357 13.9084 7.71217 14.0787 7.30104C14.249 6.8899 14.2936 6.4375 14.2068 6.00105C14.1199 5.56459 13.9057 5.16368 13.591 4.84901C13.2763 4.53434 12.8754 4.32005 12.4389 4.23323C12.0025 4.14642 11.5501 4.19097 11.139 4.36127C10.7278 4.53157 10.3764 4.81996 10.1292 5.18997C9.88195 5.55998 9.74999 5.99499 9.74999 6.44C9.75079 7.03649 9.98809 7.60833 10.4099 8.03011C10.8317 8.4519 11.4035 8.68921 12 8.69Z" fill="#B2B9C5"/>
|
|
3
|
+
</svg>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<component-wrapper>
|
|
3
|
-
<icon-wrapper>
|
|
3
|
+
<icon-wrapper :size="size">
|
|
4
4
|
<icon-img
|
|
5
5
|
:isActive="showInfo"
|
|
6
6
|
:size="size"
|
|
@@ -9,20 +9,7 @@
|
|
|
9
9
|
@mouseenter="toggleShowInfo()"
|
|
10
10
|
@mouseleave="toggleShowInfo()"
|
|
11
11
|
>
|
|
12
|
-
<
|
|
13
|
-
class="img-icon"
|
|
14
|
-
:width="size"
|
|
15
|
-
:height="size"
|
|
16
|
-
viewBox="0 0 24 24"
|
|
17
|
-
fill="none"
|
|
18
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
19
|
-
>
|
|
20
|
-
<path
|
|
21
|
-
class="img-icon"
|
|
22
|
-
d="M20.4853 3.51469C18.2188 1.24823 15.2053 0 12 0C8.79469 0 5.78123 1.24823 3.51469 3.51469C1.24823 5.78123 0 8.79469 0 12C0 15.2053 1.24823 18.2188 3.51469 20.4853C5.78123 22.7518 8.79469 24 12 24C15.2053 24 18.2188 22.7518 20.4853 20.4853C22.7518 18.2188 24 15.2053 24 12C24 8.79469 22.7518 5.78123 20.4853 3.51469ZM12 3.28125C13.4216 3.28125 14.5781 4.4378 14.5781 5.85938C14.5781 7.28095 13.4216 8.4375 12 8.4375C10.5784 8.4375 9.42188 7.28095 9.42188 5.85938C9.42188 4.4378 10.5784 3.28125 12 3.28125ZM15.2812 19.6875H8.71875V18.2812H10.125V11.9167H8.71875V10.5104H13.875V18.2812H15.2812V19.6875Z"
|
|
23
|
-
fill="#D5D5D5"
|
|
24
|
-
/>
|
|
25
|
-
</svg>
|
|
12
|
+
<icon :size="size + 'px'" name="info" :color="iconColor" />
|
|
26
13
|
</icon-img>
|
|
27
14
|
<text-overlay
|
|
28
15
|
v-if="showInfo"
|
|
@@ -44,19 +31,16 @@
|
|
|
44
31
|
// size="20"
|
|
45
32
|
// alignText="right" // default is left
|
|
46
33
|
// />
|
|
47
|
-
|
|
48
|
-
import styled from
|
|
49
|
-
|
|
50
|
-
const IconWrapper = styled.div`
|
|
51
|
-
position: relative;
|
|
52
|
-
`
|
|
34
|
+
import theme from '@/assets/theme.js'
|
|
35
|
+
import styled from 'vue-styled-components'
|
|
36
|
+
import icon from '../icon'
|
|
53
37
|
|
|
54
38
|
const textAttrs = { borderColor: String, alignText: String }
|
|
55
|
-
const TextOverlay = styled(
|
|
39
|
+
const TextOverlay = styled('div', textAttrs)`
|
|
56
40
|
position: absolute;
|
|
57
41
|
top: 26px;
|
|
58
|
-
right: ${(props) => (props.alignText ===
|
|
59
|
-
left: ${(props) => (props.alignText ===
|
|
42
|
+
right: ${(props) => (props.alignText === 'left' ? '-10px' : 'inherit')};
|
|
43
|
+
left: ${(props) => (props.alignText === 'left' ? 'inherit' : '-10px')};
|
|
60
44
|
background: ${(props) => props.theme.colors.black};
|
|
61
45
|
padding: 10px;
|
|
62
46
|
width: max-content;
|
|
@@ -68,12 +52,12 @@ const TextOverlay = styled("div", textAttrs)`
|
|
|
68
52
|
color: ${(props) => props.theme.colors.white};
|
|
69
53
|
|
|
70
54
|
:before {
|
|
71
|
-
content:
|
|
55
|
+
content: '';
|
|
72
56
|
background-color: ${(props) => props.theme.colors.black};
|
|
73
57
|
position: absolute;
|
|
74
58
|
top: 2px;
|
|
75
|
-
right: ${(props) => (props.alignText ===
|
|
76
|
-
left: ${(props) => (props.alignText ===
|
|
59
|
+
right: ${(props) => (props.alignText === 'left' ? '-12px' : 'inherit')};
|
|
60
|
+
left: ${(props) => (props.alignText === 'left' ? 'inherit' : '40px')};
|
|
77
61
|
height: 8px;
|
|
78
62
|
width: 8px;
|
|
79
63
|
transform-origin: center center;
|
|
@@ -82,18 +66,15 @@ const TextOverlay = styled("div", textAttrs)`
|
|
|
82
66
|
`
|
|
83
67
|
|
|
84
68
|
const iconAttrs = { isActive: Boolean, size: String, borderColor: String }
|
|
85
|
-
const IconImg = styled("div", iconAttrs)`
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
height: ${(props) => props.size + "px"};
|
|
88
69
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
70
|
+
const IconWrapper = styled('div', iconAttrs)`
|
|
71
|
+
position: relative;
|
|
72
|
+
top: 1px;
|
|
73
|
+
height: ${(props) => props.size}px;
|
|
74
|
+
`
|
|
75
|
+
const IconImg = styled('div', iconAttrs)`
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
height: ${(props) => props.size}px;
|
|
97
78
|
`
|
|
98
79
|
|
|
99
80
|
const ComponentWrapper = styled.div`
|
|
@@ -101,38 +82,39 @@ const ComponentWrapper = styled.div`
|
|
|
101
82
|
`
|
|
102
83
|
|
|
103
84
|
export default {
|
|
104
|
-
name:
|
|
85
|
+
name: 'info-text',
|
|
105
86
|
components: {
|
|
106
87
|
IconWrapper,
|
|
107
88
|
TextOverlay,
|
|
108
89
|
ComponentWrapper,
|
|
109
90
|
IconImg,
|
|
91
|
+
icon
|
|
110
92
|
},
|
|
111
93
|
props: {
|
|
112
94
|
text: {
|
|
113
|
-
required: true
|
|
95
|
+
required: true
|
|
114
96
|
},
|
|
115
97
|
borderColor: {
|
|
116
98
|
required: false,
|
|
117
|
-
default: null
|
|
99
|
+
default: null
|
|
118
100
|
},
|
|
119
101
|
size: {
|
|
120
102
|
required: false,
|
|
121
|
-
default:
|
|
103
|
+
default: '14'
|
|
122
104
|
},
|
|
123
105
|
alignText: {
|
|
124
106
|
required: false,
|
|
125
|
-
default:
|
|
126
|
-
}
|
|
107
|
+
default: 'left' // "left" or "right"
|
|
108
|
+
}
|
|
127
109
|
},
|
|
128
110
|
methods: {
|
|
129
111
|
toggleShowInfo() {
|
|
130
112
|
this.showInfo = !this.showInfo
|
|
131
113
|
|
|
132
114
|
if (this.showInfo) {
|
|
133
|
-
document.addEventListener(
|
|
115
|
+
document.addEventListener('click', this.clickOutside)
|
|
134
116
|
} else {
|
|
135
|
-
document.removeEventListener(
|
|
117
|
+
document.removeEventListener('click', this.clickOutside)
|
|
136
118
|
}
|
|
137
119
|
},
|
|
138
120
|
clickOutside(event) {
|
|
@@ -140,12 +122,21 @@ export default {
|
|
|
140
122
|
return
|
|
141
123
|
}
|
|
142
124
|
this.toggleShowInfo()
|
|
143
|
-
}
|
|
125
|
+
}
|
|
144
126
|
},
|
|
145
127
|
data() {
|
|
146
128
|
return {
|
|
147
|
-
showInfo: false
|
|
129
|
+
showInfo: false
|
|
148
130
|
}
|
|
149
131
|
},
|
|
132
|
+
computed: {
|
|
133
|
+
iconColor() {
|
|
134
|
+
return this.isActive
|
|
135
|
+
? this.borderColor
|
|
136
|
+
? this.borderColor
|
|
137
|
+
: theme.colors.secondary
|
|
138
|
+
: theme.colors.mediumGray
|
|
139
|
+
}
|
|
140
|
+
}
|
|
150
141
|
}
|
|
151
|
-
</script>
|
|
142
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<container>
|
|
2
|
+
<container :inputWidth="inputWidth">
|
|
3
3
|
<label-wrapper v-if="labelText">
|
|
4
4
|
<label-text>
|
|
5
5
|
{{ labelText }}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
v-if="labelInfoText"
|
|
9
9
|
:text="labelInfoText"
|
|
10
10
|
borderColor="#ccc"
|
|
11
|
-
size="
|
|
11
|
+
size="14"
|
|
12
12
|
:alignText="labelInfoAlign"
|
|
13
13
|
/>
|
|
14
14
|
</label-wrapper>
|
|
@@ -30,9 +30,15 @@
|
|
|
30
30
|
:textAlign="textAlign"
|
|
31
31
|
:fontSize="fontSize"
|
|
32
32
|
:fontColor="fontColor"
|
|
33
|
+
:hasSlot="hasSlot"
|
|
34
|
+
:slotSize="slotSize"
|
|
33
35
|
/>
|
|
36
|
+
<slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
|
|
37
|
+
<slot></slot>
|
|
38
|
+
</slot-container>
|
|
39
|
+
|
|
34
40
|
<unit-container
|
|
35
|
-
v-if="unitName && showLinearUnitName"
|
|
41
|
+
v-if="unitName && showLinearUnitName && !hasSlot"
|
|
36
42
|
:hasLength="!!textInput.length"
|
|
37
43
|
:isError="isError"
|
|
38
44
|
>{{ unitName }}</unit-container
|
|
@@ -68,17 +74,12 @@
|
|
|
68
74
|
// :minNumber="0"
|
|
69
75
|
// fontColor="blue"
|
|
70
76
|
// />
|
|
71
|
-
import styled from
|
|
77
|
+
import styled from 'vue-styled-components'
|
|
72
78
|
import {
|
|
73
79
|
stringToNumber,
|
|
74
|
-
numberToString
|
|
75
|
-
} from
|
|
76
|
-
import InfoText from
|
|
77
|
-
|
|
78
|
-
const Container = styled.div`
|
|
79
|
-
width: 100%;
|
|
80
|
-
position: relative;
|
|
81
|
-
`
|
|
80
|
+
numberToString
|
|
81
|
+
} from '../../../helpers/numberConverter'
|
|
82
|
+
import InfoText from '../../infoText'
|
|
82
83
|
|
|
83
84
|
const inputProps = {
|
|
84
85
|
isError: Boolean,
|
|
@@ -90,30 +91,45 @@ const inputProps = {
|
|
|
90
91
|
textAlign: String,
|
|
91
92
|
fontSize: String,
|
|
92
93
|
fontColor: String,
|
|
94
|
+
hasSlot: Boolean,
|
|
95
|
+
slotSize: String
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
|
|
98
|
+
const Container = styled('div', inputProps)`
|
|
99
|
+
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
|
100
|
+
position: relative;
|
|
101
|
+
`
|
|
102
|
+
|
|
103
|
+
const InputContainer = styled('input', inputProps)`
|
|
95
104
|
border: ${(props) =>
|
|
96
105
|
props.isError
|
|
97
|
-
?
|
|
106
|
+
? '1px solid ' + props.theme.colors.red
|
|
98
107
|
: props.noBorder
|
|
99
|
-
?
|
|
100
|
-
:
|
|
101
|
-
padding:
|
|
102
|
-
|
|
108
|
+
? 'none'
|
|
109
|
+
: '1px solid ' + props.theme.colors.mediumGray};
|
|
110
|
+
padding-top: 11px;
|
|
111
|
+
padding-bottom: 11px;
|
|
112
|
+
padding-left: 10px;
|
|
113
|
+
padding-right: ${(props) =>
|
|
114
|
+
props.slotSize
|
|
115
|
+
? 'calc(' + props.slotSize + ' + 10px)'
|
|
116
|
+
: props.hasUnit
|
|
117
|
+
? '40px'
|
|
118
|
+
: '5px'};
|
|
103
119
|
border-radius: 4px;
|
|
104
120
|
text-align: ${(props) => props.textAlign};
|
|
105
|
-
cursor: ${(props) => (props.isDisabled ?
|
|
106
|
-
font-size: ${(props) => (props.fontSize ? props.fontSize :
|
|
121
|
+
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
|
|
122
|
+
font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
|
|
107
123
|
color: ${(props) =>
|
|
108
124
|
props.isError
|
|
109
125
|
? props.theme.colors.red
|
|
110
126
|
: props.fontColor
|
|
111
|
-
? props.fontColor +
|
|
127
|
+
? props.fontColor + ' !important'
|
|
112
128
|
: props.theme.colors.black};
|
|
113
|
-
width: ${(props) => (props.inputWidth ? props.inputWidth :
|
|
114
|
-
min-width: ${(props) => (props.minWidth ? props.minWidth :
|
|
129
|
+
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
|
130
|
+
min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
|
|
115
131
|
background-color: ${(props) =>
|
|
116
|
-
props.isDisabled ? props.theme.colors.grey5 :
|
|
132
|
+
props.isDisabled ? props.theme.colors.grey5 : '#fff'};
|
|
117
133
|
box-sizing: border-box;
|
|
118
134
|
|
|
119
135
|
&::placeholder {
|
|
@@ -130,7 +146,7 @@ const InputWrapper = styled.span`
|
|
|
130
146
|
position: relative;
|
|
131
147
|
`
|
|
132
148
|
|
|
133
|
-
const UnitContainer = styled(
|
|
149
|
+
const UnitContainer = styled('span', inputProps)`
|
|
134
150
|
border-left: 1px solid
|
|
135
151
|
${(props) =>
|
|
136
152
|
props.isError
|
|
@@ -142,6 +158,7 @@ const UnitContainer = styled("span", inputProps)`
|
|
|
142
158
|
right: 10px;
|
|
143
159
|
top: 0;
|
|
144
160
|
padding-left: 10px;
|
|
161
|
+
text-align: right;
|
|
145
162
|
color: ${(props) =>
|
|
146
163
|
props.isError
|
|
147
164
|
? props.theme.colors.red
|
|
@@ -150,6 +167,28 @@ const UnitContainer = styled("span", inputProps)`
|
|
|
150
167
|
: props.theme.colors.mediumGray};
|
|
151
168
|
`
|
|
152
169
|
|
|
170
|
+
const SlotContainer = styled('span', inputProps)`
|
|
171
|
+
text-align: right;
|
|
172
|
+
border-left: 1px solid
|
|
173
|
+
${(props) =>
|
|
174
|
+
props.isError
|
|
175
|
+
? props.theme.colors.red
|
|
176
|
+
: props.hasLength
|
|
177
|
+
? props.theme.colors.black
|
|
178
|
+
: props.theme.colors.mediumGray};
|
|
179
|
+
position: absolute;
|
|
180
|
+
width: ${(props) =>
|
|
181
|
+
props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
|
|
182
|
+
right: 10px;
|
|
183
|
+
top: 0;
|
|
184
|
+
padding-left: 10px;
|
|
185
|
+
color: ${(props) =>
|
|
186
|
+
props.isError
|
|
187
|
+
? props.theme.colors.red
|
|
188
|
+
: props.hasLength
|
|
189
|
+
? props.theme.colors.black
|
|
190
|
+
: props.theme.colors.mediumGray};
|
|
191
|
+
`
|
|
153
192
|
const ErrorMessage = styled.div`
|
|
154
193
|
font-size: 14px;
|
|
155
194
|
color: ${(props) => props.theme.colors.red};
|
|
@@ -169,7 +208,7 @@ const LabelText = styled.div`
|
|
|
169
208
|
`
|
|
170
209
|
|
|
171
210
|
export default {
|
|
172
|
-
name:
|
|
211
|
+
name: 'input-number',
|
|
173
212
|
components: {
|
|
174
213
|
Container,
|
|
175
214
|
InputContainer,
|
|
@@ -178,131 +217,144 @@ export default {
|
|
|
178
217
|
ErrorMessage,
|
|
179
218
|
LabelWrapper,
|
|
180
219
|
LabelText,
|
|
181
|
-
|
|
220
|
+
SlotContainer,
|
|
221
|
+
InfoText
|
|
182
222
|
},
|
|
183
223
|
data() {
|
|
184
224
|
return {
|
|
185
|
-
textInput:
|
|
186
|
-
isFocused: false
|
|
225
|
+
textInput: '',
|
|
226
|
+
isFocused: false
|
|
187
227
|
}
|
|
188
228
|
},
|
|
189
229
|
props: {
|
|
190
230
|
placeholder: {
|
|
191
231
|
required: false,
|
|
192
|
-
default:
|
|
232
|
+
default: ''
|
|
193
233
|
},
|
|
194
234
|
isError: {
|
|
195
235
|
required: false,
|
|
196
|
-
default: false
|
|
236
|
+
default: false
|
|
197
237
|
},
|
|
198
238
|
inputWidth: {
|
|
199
239
|
required: false,
|
|
200
|
-
default: null
|
|
240
|
+
default: null
|
|
201
241
|
},
|
|
202
242
|
minWidth: {
|
|
203
243
|
required: false,
|
|
204
|
-
default: null
|
|
244
|
+
default: null
|
|
205
245
|
},
|
|
206
246
|
value: {
|
|
207
247
|
required: true,
|
|
208
|
-
default: null
|
|
248
|
+
default: null
|
|
209
249
|
},
|
|
210
250
|
clearInput: {
|
|
211
251
|
required: false,
|
|
212
|
-
default: false
|
|
252
|
+
default: false
|
|
213
253
|
},
|
|
214
254
|
errorMessage: {
|
|
215
255
|
required: false,
|
|
216
|
-
default:
|
|
256
|
+
default: 'Please insert a correct number'
|
|
217
257
|
},
|
|
218
258
|
numberPrecision: {
|
|
219
259
|
required: false,
|
|
220
|
-
default: 0
|
|
260
|
+
default: 0
|
|
221
261
|
},
|
|
222
262
|
unitName: {
|
|
223
263
|
required: false,
|
|
224
|
-
default:
|
|
264
|
+
default: ''
|
|
225
265
|
},
|
|
226
266
|
showLinearUnitName: {
|
|
227
267
|
required: false,
|
|
228
|
-
default: false
|
|
268
|
+
default: false
|
|
229
269
|
},
|
|
230
270
|
disabled: {
|
|
231
271
|
required: false,
|
|
232
|
-
default: false
|
|
272
|
+
default: false
|
|
233
273
|
},
|
|
234
274
|
noBorder: {
|
|
235
275
|
required: false,
|
|
236
|
-
default: false
|
|
276
|
+
default: false
|
|
237
277
|
},
|
|
238
278
|
textAlign: {
|
|
239
279
|
required: false,
|
|
240
|
-
default:
|
|
280
|
+
default: 'left'
|
|
241
281
|
},
|
|
242
282
|
fontSize: {
|
|
243
283
|
required: false,
|
|
244
|
-
default:
|
|
284
|
+
default: '13px'
|
|
245
285
|
},
|
|
246
286
|
labelText: {
|
|
247
287
|
required: false,
|
|
248
|
-
default: null
|
|
288
|
+
default: null
|
|
249
289
|
},
|
|
250
290
|
labelInfoText: {
|
|
251
291
|
required: false,
|
|
252
|
-
default: null
|
|
292
|
+
default: null
|
|
253
293
|
},
|
|
254
294
|
labelInfoAlign: {
|
|
255
295
|
required: false,
|
|
256
|
-
default:
|
|
296
|
+
default: 'right'
|
|
257
297
|
},
|
|
258
298
|
minNumber: {
|
|
259
299
|
required: false,
|
|
260
|
-
default: null
|
|
300
|
+
default: null
|
|
261
301
|
},
|
|
262
302
|
fontColor: {
|
|
263
303
|
required: false,
|
|
264
|
-
default: null
|
|
304
|
+
default: null
|
|
265
305
|
},
|
|
266
306
|
numberToStringEnabled: {
|
|
267
307
|
required: false,
|
|
268
|
-
default: true
|
|
308
|
+
default: true
|
|
309
|
+
},
|
|
310
|
+
slotSize: {
|
|
311
|
+
required: false
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
computed: {
|
|
315
|
+
hasSlot() {
|
|
316
|
+
console.log(this.$slots.default)
|
|
317
|
+
return !!this.$slots.default
|
|
269
318
|
},
|
|
319
|
+
computedSlotSize() {
|
|
320
|
+
return this.slotSize || this.$slots['default'][0].elm.clientWidth
|
|
321
|
+
}
|
|
270
322
|
},
|
|
271
323
|
methods: {
|
|
272
324
|
onChangeHandler(event) {
|
|
273
325
|
if (isNaN(event)) {
|
|
274
326
|
event = this.minNumber || this.minNumber === 0 ? this.minNumber : event
|
|
275
327
|
}
|
|
276
|
-
this.$emit(
|
|
328
|
+
this.$emit('input-change', event)
|
|
277
329
|
},
|
|
278
330
|
onEvaluateCode(val) {
|
|
279
331
|
// function to perform math on the code
|
|
280
332
|
// filter the string in case of any malicious content
|
|
281
|
-
let filtered = val.replace(/[^-()\d/*+.,]/g,
|
|
333
|
+
let filtered = val.replace(/[^-()\d/*+.,]/g, '')
|
|
282
334
|
filtered = filtered.split(/([-+*/()])/)
|
|
283
335
|
let formatted = filtered.map((item) => {
|
|
284
336
|
if (
|
|
285
|
-
item ===
|
|
286
|
-
item ===
|
|
287
|
-
item ===
|
|
288
|
-
item ===
|
|
289
|
-
item ===
|
|
290
|
-
item ===
|
|
291
|
-
item ===
|
|
337
|
+
item === '+' ||
|
|
338
|
+
item === '-' ||
|
|
339
|
+
item === '*' ||
|
|
340
|
+
item === '/' ||
|
|
341
|
+
item === '(' ||
|
|
342
|
+
item === ')' ||
|
|
343
|
+
item === ''
|
|
292
344
|
) {
|
|
293
345
|
return item
|
|
294
346
|
} else {
|
|
295
347
|
let num = stringToNumber({
|
|
296
348
|
value: item,
|
|
297
|
-
numberPrecision: false
|
|
349
|
+
numberPrecision: false
|
|
298
350
|
})
|
|
299
351
|
return num
|
|
300
352
|
}
|
|
301
353
|
})
|
|
302
|
-
let evaluated = eval(formatted.join(
|
|
354
|
+
let evaluated = eval(formatted.join(''))
|
|
303
355
|
evaluated = stringToNumber({
|
|
304
356
|
value: evaluated,
|
|
305
|
-
numberPrecision: this.numberPrecision
|
|
357
|
+
numberPrecision: this.numberPrecision
|
|
306
358
|
})
|
|
307
359
|
return evaluated
|
|
308
360
|
},
|
|
@@ -315,7 +367,7 @@ export default {
|
|
|
315
367
|
this.textInput = numberToString({
|
|
316
368
|
value:
|
|
317
369
|
evaluatedInput && value.length ? evaluatedInput : this.minNumber,
|
|
318
|
-
numberPrecision: this.numberPrecision
|
|
370
|
+
numberPrecision: this.numberPrecision
|
|
319
371
|
})
|
|
320
372
|
}
|
|
321
373
|
let adjustedMinValue =
|
|
@@ -323,8 +375,8 @@ export default {
|
|
|
323
375
|
? value
|
|
324
376
|
: this.minNumber || this.minNumber === 0
|
|
325
377
|
? this.minNumber
|
|
326
|
-
:
|
|
327
|
-
this.$emit(
|
|
378
|
+
: ''
|
|
379
|
+
this.$emit('input-blur', adjustedMinValue)
|
|
328
380
|
},
|
|
329
381
|
focusInput() {
|
|
330
382
|
if (this.disabled) {
|
|
@@ -341,38 +393,38 @@ export default {
|
|
|
341
393
|
? value
|
|
342
394
|
: this.minNumber || this.minNumber === 0
|
|
343
395
|
? this.minNumber
|
|
344
|
-
:
|
|
396
|
+
: ''
|
|
345
397
|
if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
|
|
346
398
|
let input = this.numberToStringEnabled
|
|
347
399
|
? numberToString({
|
|
348
400
|
value: adjustedMinValue,
|
|
349
|
-
numberPrecision: this.numberPrecision
|
|
401
|
+
numberPrecision: this.numberPrecision
|
|
350
402
|
})
|
|
351
403
|
: adjustedMinValue
|
|
352
|
-
let unit = this.showLinearUnitName ?
|
|
353
|
-
return input +
|
|
404
|
+
let unit = this.showLinearUnitName ? '' : this.unitName
|
|
405
|
+
return input + ' ' + unit
|
|
354
406
|
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
|
355
|
-
return
|
|
407
|
+
return ''
|
|
356
408
|
} else {
|
|
357
409
|
return this.numberToStringEnabled
|
|
358
410
|
? numberToString({
|
|
359
411
|
value: adjustedMinValue,
|
|
360
|
-
numberPrecision: this.numberPrecision
|
|
412
|
+
numberPrecision: this.numberPrecision
|
|
361
413
|
})
|
|
362
414
|
: adjustedMinValue
|
|
363
415
|
}
|
|
364
|
-
}
|
|
416
|
+
}
|
|
365
417
|
},
|
|
366
418
|
created() {
|
|
367
419
|
if (this.value) {
|
|
368
420
|
this.textInput = numberToString({
|
|
369
421
|
value: this.value,
|
|
370
|
-
numberPrecision: this.numberPrecision
|
|
422
|
+
numberPrecision: this.numberPrecision
|
|
371
423
|
})
|
|
372
424
|
} else if (this.minNumber !== null) {
|
|
373
425
|
this.textInput = numberToString({
|
|
374
426
|
value: this.minNumber,
|
|
375
|
-
numberPrecision: this.numberPrecision
|
|
427
|
+
numberPrecision: this.numberPrecision
|
|
376
428
|
})
|
|
377
429
|
}
|
|
378
430
|
},
|
|
@@ -380,9 +432,9 @@ export default {
|
|
|
380
432
|
clearInput: function (value) {
|
|
381
433
|
if (value) {
|
|
382
434
|
// If the value is typed, then we should clear the textInput on Continue
|
|
383
|
-
this.textInput =
|
|
435
|
+
this.textInput = ''
|
|
384
436
|
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
387
439
|
}
|
|
388
|
-
</script>
|
|
440
|
+
</script>
|
|
@@ -4,6 +4,9 @@ export const stringToNumber = ({
|
|
|
4
4
|
allowNegative
|
|
5
5
|
}) => {
|
|
6
6
|
// This is for saving. It converts our input string to a readable number
|
|
7
|
+
if (value === undefined) {
|
|
8
|
+
value = ''
|
|
9
|
+
}
|
|
7
10
|
let newVal = value.toString()
|
|
8
11
|
const selectedLang = localStorage.getItem('lang')
|
|
9
12
|
// The first replace will replace not allowed characters with a blank
|