@eturnity/eturnity_reusable_components 1.2.15 → 1.2.16-QA03-23092022.1
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.2.
|
|
3
|
+
"version": "1.2.16-QA03-23092022.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vue-cli-service serve",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"@vueform/slider": "1.0.5",
|
|
14
14
|
"core-js": "^3.6.5",
|
|
15
15
|
"vue": "^2.6.11",
|
|
16
|
-
"vue-styled-components": "^1.6.0"
|
|
16
|
+
"vue-styled-components": "^1.6.0",
|
|
17
|
+
"html-loader": "^0.5.5"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@storybook/addon-actions": "^6.2.8",
|
|
@@ -28,8 +29,7 @@
|
|
|
28
29
|
"babel-eslint": "^10.1.0",
|
|
29
30
|
"eslint": "^6.7.2",
|
|
30
31
|
"eslint-plugin-vue": "^6.2.2",
|
|
31
|
-
"vue-template-compiler": "^2.6.11"
|
|
32
|
-
"html-loader": "^0.5.5"
|
|
32
|
+
"vue-template-compiler": "^2.6.11"
|
|
33
33
|
},
|
|
34
34
|
"eslintConfig": {
|
|
35
35
|
"root": true,
|
package/src/App.vue
CHANGED
|
@@ -1,74 +1,14 @@
|
|
|
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
|
-
<br />
|
|
32
|
-
<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
|
-
<br />
|
|
43
4
|
<input-number
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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"
|
|
5
|
+
:value="num"
|
|
6
|
+
@input-change="num = $event"
|
|
7
|
+
unitName="t"
|
|
8
|
+
id="biebie"
|
|
9
|
+
test="koko"
|
|
10
|
+
@keydown="keydownHandler"
|
|
57
11
|
/>
|
|
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
12
|
</page-container>
|
|
73
13
|
</ThemeProvider>
|
|
74
14
|
</template>
|
|
@@ -77,17 +17,7 @@
|
|
|
77
17
|
import { ThemeProvider } from 'vue-styled-components'
|
|
78
18
|
import theme from './assets/theme'
|
|
79
19
|
import styled from 'vue-styled-components'
|
|
80
|
-
import MainTable from '@/components/tables/mainTable'
|
|
81
|
-
import ThreeDots from '@/components/threeDots'
|
|
82
|
-
import Toggle from '@/components/inputs/toggle'
|
|
83
20
|
import InputNumber from '@/components/inputs/inputNumber'
|
|
84
|
-
import Checkbox from '@/components/inputs/checkbox'
|
|
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'
|
|
90
|
-
// import TableDropdown from "@/components/tableDropdown"
|
|
91
21
|
|
|
92
22
|
const PageContainer = styled.div`
|
|
93
23
|
padding: 40px;
|
|
@@ -98,20 +28,12 @@ export default {
|
|
|
98
28
|
components: {
|
|
99
29
|
ThemeProvider,
|
|
100
30
|
PageContainer,
|
|
101
|
-
|
|
102
|
-
ThreeDots,
|
|
103
|
-
Toggle,
|
|
104
|
-
InputNumber,
|
|
105
|
-
PageSubtitle,
|
|
106
|
-
Spinner,
|
|
107
|
-
Checkbox,
|
|
108
|
-
ExternalButton,
|
|
109
|
-
collection,
|
|
110
|
-
icon
|
|
31
|
+
InputNumber
|
|
111
32
|
// TableDropdown,
|
|
112
33
|
},
|
|
113
34
|
data() {
|
|
114
35
|
return {
|
|
36
|
+
num: 42,
|
|
115
37
|
inputValue: null,
|
|
116
38
|
checkedOption: 'button_1',
|
|
117
39
|
question: {
|
|
@@ -170,6 +92,9 @@ export default {
|
|
|
170
92
|
}
|
|
171
93
|
},
|
|
172
94
|
methods: {
|
|
95
|
+
keydownHandler(e) {
|
|
96
|
+
console.log('test', e)
|
|
97
|
+
},
|
|
173
98
|
getTheme() {
|
|
174
99
|
return theme
|
|
175
100
|
},
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<wrapper :
|
|
2
|
+
<wrapper :size="size">
|
|
3
3
|
<icon-image
|
|
4
4
|
:size="size"
|
|
5
5
|
:color="color"
|
|
@@ -23,12 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
import styled from 'vue-styled-components'
|
|
25
25
|
|
|
26
|
-
const wrapperAttrs = {
|
|
26
|
+
const wrapperAttrs = { size: String }
|
|
27
27
|
const Wrapper = styled('div', wrapperAttrs)`
|
|
28
28
|
display: inline-block;
|
|
29
29
|
width: ${(props) => props.size};
|
|
30
30
|
height: ${(props) => props.size};
|
|
31
|
-
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
|
|
32
31
|
`
|
|
33
32
|
const IconImageProps = { color: String, hoveredColor: String, size: String }
|
|
34
33
|
const IconImage = styled('div', IconImageProps)`
|
|
@@ -37,7 +36,8 @@ const IconImage = styled('div', IconImageProps)`
|
|
|
37
36
|
height: ${(props) => props.size};
|
|
38
37
|
}
|
|
39
38
|
svg > path {
|
|
40
|
-
${(props) =>
|
|
39
|
+
${(props) =>
|
|
40
|
+
props.color && `fill: ${props.theme.colors[props.color] || props.color};`}
|
|
41
41
|
}
|
|
42
42
|
&:hover > svg > path {
|
|
43
43
|
${(props) => props.hoveredColor && `fill: ${props.hoveredColor};`}
|
|
@@ -51,10 +51,6 @@ export default {
|
|
|
51
51
|
IconImage
|
|
52
52
|
},
|
|
53
53
|
props: {
|
|
54
|
-
isDisabled: {
|
|
55
|
-
required: false,
|
|
56
|
-
default: false
|
|
57
|
-
},
|
|
58
54
|
name: {
|
|
59
55
|
required: true
|
|
60
56
|
},
|
|
@@ -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" 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};
|
|
74
|
+
`
|
|
75
|
+
const IconImg = styled('div', iconAttrs)`
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
height: ${(props) => props.size};
|
|
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: '14px'
|
|
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,15 +8,16 @@
|
|
|
8
8
|
v-if="labelInfoText"
|
|
9
9
|
:text="labelInfoText"
|
|
10
10
|
borderColor="#ccc"
|
|
11
|
-
size="
|
|
11
|
+
size="14px"
|
|
12
12
|
:alignText="labelInfoAlign"
|
|
13
13
|
/>
|
|
14
14
|
</label-wrapper>
|
|
15
15
|
<input-wrapper>
|
|
16
16
|
<input-container
|
|
17
|
+
v-bind="$attrs"
|
|
17
18
|
ref="inputField1"
|
|
18
19
|
:hasUnit="unitName && !!unitName.length"
|
|
19
|
-
:placeholder="
|
|
20
|
+
:placeholder="displayedPlaceholder"
|
|
20
21
|
:isError="isError"
|
|
21
22
|
:inputWidth="inputWidth"
|
|
22
23
|
:minWidth="minWidth"
|
|
@@ -30,9 +31,16 @@
|
|
|
30
31
|
:textAlign="textAlign"
|
|
31
32
|
:fontSize="fontSize"
|
|
32
33
|
:fontColor="fontColor"
|
|
34
|
+
:hasSlot="hasSlot"
|
|
35
|
+
:slotSize="slotSize"
|
|
36
|
+
v-on="$listeners"
|
|
33
37
|
/>
|
|
38
|
+
<slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
|
|
39
|
+
<slot></slot>
|
|
40
|
+
</slot-container>
|
|
41
|
+
|
|
34
42
|
<unit-container
|
|
35
|
-
v-if="unitName && showLinearUnitName"
|
|
43
|
+
v-if="unitName && showLinearUnitName && !hasSlot"
|
|
36
44
|
:hasLength="!!textInput.length"
|
|
37
45
|
:isError="isError"
|
|
38
46
|
>{{ unitName }}</unit-container
|
|
@@ -68,17 +76,12 @@
|
|
|
68
76
|
// :minNumber="0"
|
|
69
77
|
// fontColor="blue"
|
|
70
78
|
// />
|
|
71
|
-
import styled from
|
|
79
|
+
import styled from 'vue-styled-components'
|
|
72
80
|
import {
|
|
73
81
|
stringToNumber,
|
|
74
|
-
numberToString
|
|
75
|
-
} from
|
|
76
|
-
import InfoText from
|
|
77
|
-
|
|
78
|
-
const Container = styled.div`
|
|
79
|
-
width: 100%;
|
|
80
|
-
position: relative;
|
|
81
|
-
`
|
|
82
|
+
numberToString
|
|
83
|
+
} from '../../../helpers/numberConverter'
|
|
84
|
+
import InfoText from '../../infoText'
|
|
82
85
|
|
|
83
86
|
const inputProps = {
|
|
84
87
|
isError: Boolean,
|
|
@@ -90,30 +93,45 @@ const inputProps = {
|
|
|
90
93
|
textAlign: String,
|
|
91
94
|
fontSize: String,
|
|
92
95
|
fontColor: String,
|
|
96
|
+
hasSlot: Boolean,
|
|
97
|
+
slotSize: String
|
|
93
98
|
}
|
|
94
|
-
|
|
99
|
+
|
|
100
|
+
const Container = styled('div', inputProps)`
|
|
101
|
+
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
|
102
|
+
position: relative;
|
|
103
|
+
`
|
|
104
|
+
|
|
105
|
+
const InputContainer = styled('input', inputProps)`
|
|
95
106
|
border: ${(props) =>
|
|
96
107
|
props.isError
|
|
97
|
-
?
|
|
108
|
+
? '1px solid ' + props.theme.colors.red
|
|
98
109
|
: props.noBorder
|
|
99
|
-
?
|
|
100
|
-
:
|
|
101
|
-
padding:
|
|
102
|
-
|
|
110
|
+
? 'none'
|
|
111
|
+
: '1px solid ' + props.theme.colors.mediumGray};
|
|
112
|
+
padding-top: 11px;
|
|
113
|
+
padding-bottom: 11px;
|
|
114
|
+
padding-left: 10px;
|
|
115
|
+
padding-right: ${(props) =>
|
|
116
|
+
props.slotSize
|
|
117
|
+
? 'calc(' + props.slotSize + ' + 10px)'
|
|
118
|
+
: props.hasUnit
|
|
119
|
+
? '40px'
|
|
120
|
+
: '5px'};
|
|
103
121
|
border-radius: 4px;
|
|
104
122
|
text-align: ${(props) => props.textAlign};
|
|
105
|
-
cursor: ${(props) => (props.isDisabled ?
|
|
106
|
-
font-size: ${(props) => (props.fontSize ? props.fontSize :
|
|
123
|
+
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
|
|
124
|
+
font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
|
|
107
125
|
color: ${(props) =>
|
|
108
126
|
props.isError
|
|
109
127
|
? props.theme.colors.red
|
|
110
128
|
: props.fontColor
|
|
111
|
-
? props.fontColor +
|
|
129
|
+
? props.fontColor + ' !important'
|
|
112
130
|
: props.theme.colors.black};
|
|
113
|
-
width: ${(props) => (props.inputWidth ? props.inputWidth :
|
|
114
|
-
min-width: ${(props) => (props.minWidth ? props.minWidth :
|
|
131
|
+
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
|
132
|
+
min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
|
|
115
133
|
background-color: ${(props) =>
|
|
116
|
-
props.isDisabled ? props.theme.colors.grey5 :
|
|
134
|
+
props.isDisabled ? props.theme.colors.grey5 : '#fff'};
|
|
117
135
|
box-sizing: border-box;
|
|
118
136
|
|
|
119
137
|
&::placeholder {
|
|
@@ -130,7 +148,7 @@ const InputWrapper = styled.span`
|
|
|
130
148
|
position: relative;
|
|
131
149
|
`
|
|
132
150
|
|
|
133
|
-
const UnitContainer = styled(
|
|
151
|
+
const UnitContainer = styled('span', inputProps)`
|
|
134
152
|
border-left: 1px solid
|
|
135
153
|
${(props) =>
|
|
136
154
|
props.isError
|
|
@@ -142,6 +160,7 @@ const UnitContainer = styled("span", inputProps)`
|
|
|
142
160
|
right: 10px;
|
|
143
161
|
top: 0;
|
|
144
162
|
padding-left: 10px;
|
|
163
|
+
text-align: right;
|
|
145
164
|
color: ${(props) =>
|
|
146
165
|
props.isError
|
|
147
166
|
? props.theme.colors.red
|
|
@@ -150,6 +169,28 @@ const UnitContainer = styled("span", inputProps)`
|
|
|
150
169
|
: props.theme.colors.mediumGray};
|
|
151
170
|
`
|
|
152
171
|
|
|
172
|
+
const SlotContainer = styled('span', inputProps)`
|
|
173
|
+
text-align: right;
|
|
174
|
+
border-left: 1px solid
|
|
175
|
+
${(props) =>
|
|
176
|
+
props.isError
|
|
177
|
+
? props.theme.colors.red
|
|
178
|
+
: props.hasLength
|
|
179
|
+
? props.theme.colors.black
|
|
180
|
+
: props.theme.colors.mediumGray};
|
|
181
|
+
position: absolute;
|
|
182
|
+
width: ${(props) =>
|
|
183
|
+
props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
|
|
184
|
+
right: 10px;
|
|
185
|
+
top: 0;
|
|
186
|
+
padding-left: 10px;
|
|
187
|
+
color: ${(props) =>
|
|
188
|
+
props.isError
|
|
189
|
+
? props.theme.colors.red
|
|
190
|
+
: props.hasLength
|
|
191
|
+
? props.theme.colors.black
|
|
192
|
+
: props.theme.colors.mediumGray};
|
|
193
|
+
`
|
|
153
194
|
const ErrorMessage = styled.div`
|
|
154
195
|
font-size: 14px;
|
|
155
196
|
color: ${(props) => props.theme.colors.red};
|
|
@@ -169,7 +210,7 @@ const LabelText = styled.div`
|
|
|
169
210
|
`
|
|
170
211
|
|
|
171
212
|
export default {
|
|
172
|
-
name:
|
|
213
|
+
name: 'input-number',
|
|
173
214
|
components: {
|
|
174
215
|
Container,
|
|
175
216
|
InputContainer,
|
|
@@ -178,131 +219,148 @@ export default {
|
|
|
178
219
|
ErrorMessage,
|
|
179
220
|
LabelWrapper,
|
|
180
221
|
LabelText,
|
|
181
|
-
|
|
222
|
+
SlotContainer,
|
|
223
|
+
InfoText
|
|
182
224
|
},
|
|
225
|
+
inheritAttrs: false,
|
|
183
226
|
data() {
|
|
184
227
|
return {
|
|
185
|
-
textInput:
|
|
186
|
-
isFocused: false
|
|
228
|
+
textInput: '',
|
|
229
|
+
isFocused: false
|
|
187
230
|
}
|
|
188
231
|
},
|
|
189
232
|
props: {
|
|
190
233
|
placeholder: {
|
|
191
234
|
required: false,
|
|
192
|
-
default:
|
|
235
|
+
default: ''
|
|
193
236
|
},
|
|
194
237
|
isError: {
|
|
195
238
|
required: false,
|
|
196
|
-
default: false
|
|
239
|
+
default: false
|
|
197
240
|
},
|
|
198
241
|
inputWidth: {
|
|
199
242
|
required: false,
|
|
200
|
-
default: null
|
|
243
|
+
default: null
|
|
201
244
|
},
|
|
202
245
|
minWidth: {
|
|
203
246
|
required: false,
|
|
204
|
-
default: null
|
|
247
|
+
default: null
|
|
205
248
|
},
|
|
206
249
|
value: {
|
|
207
250
|
required: true,
|
|
208
|
-
default: null
|
|
251
|
+
default: null
|
|
209
252
|
},
|
|
210
253
|
clearInput: {
|
|
211
254
|
required: false,
|
|
212
|
-
default: false
|
|
255
|
+
default: false
|
|
213
256
|
},
|
|
214
257
|
errorMessage: {
|
|
215
258
|
required: false,
|
|
216
|
-
default:
|
|
259
|
+
default: 'Please insert a correct number'
|
|
217
260
|
},
|
|
218
261
|
numberPrecision: {
|
|
219
262
|
required: false,
|
|
220
|
-
default: 0
|
|
263
|
+
default: 0
|
|
221
264
|
},
|
|
222
265
|
unitName: {
|
|
223
266
|
required: false,
|
|
224
|
-
default:
|
|
267
|
+
default: ''
|
|
225
268
|
},
|
|
226
269
|
showLinearUnitName: {
|
|
227
270
|
required: false,
|
|
228
|
-
default: false
|
|
271
|
+
default: false
|
|
229
272
|
},
|
|
230
273
|
disabled: {
|
|
231
274
|
required: false,
|
|
232
|
-
default: false
|
|
275
|
+
default: false
|
|
233
276
|
},
|
|
234
277
|
noBorder: {
|
|
235
278
|
required: false,
|
|
236
|
-
default: false
|
|
279
|
+
default: false
|
|
237
280
|
},
|
|
238
281
|
textAlign: {
|
|
239
282
|
required: false,
|
|
240
|
-
default:
|
|
283
|
+
default: 'left'
|
|
241
284
|
},
|
|
242
285
|
fontSize: {
|
|
243
286
|
required: false,
|
|
244
|
-
default:
|
|
287
|
+
default: '13px'
|
|
245
288
|
},
|
|
246
289
|
labelText: {
|
|
247
290
|
required: false,
|
|
248
|
-
default: null
|
|
291
|
+
default: null
|
|
249
292
|
},
|
|
250
293
|
labelInfoText: {
|
|
251
294
|
required: false,
|
|
252
|
-
default: null
|
|
295
|
+
default: null
|
|
253
296
|
},
|
|
254
297
|
labelInfoAlign: {
|
|
255
298
|
required: false,
|
|
256
|
-
default:
|
|
299
|
+
default: 'right'
|
|
257
300
|
},
|
|
258
301
|
minNumber: {
|
|
259
302
|
required: false,
|
|
260
|
-
default: null
|
|
303
|
+
default: null
|
|
261
304
|
},
|
|
262
305
|
fontColor: {
|
|
263
306
|
required: false,
|
|
264
|
-
default: null
|
|
307
|
+
default: null
|
|
265
308
|
},
|
|
266
309
|
numberToStringEnabled: {
|
|
267
310
|
required: false,
|
|
268
|
-
default: true
|
|
311
|
+
default: true
|
|
312
|
+
},
|
|
313
|
+
slotSize: {
|
|
314
|
+
required: false
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
computed: {
|
|
318
|
+
hasSlot() {
|
|
319
|
+
console.log(this.$slots.default)
|
|
320
|
+
return !!this.$slots.default
|
|
321
|
+
},
|
|
322
|
+
computedSlotSize() {
|
|
323
|
+
return this.slotSize || this.$slots['default'][0].elm.clientWidth
|
|
269
324
|
},
|
|
325
|
+
displayedPlaceholder() {
|
|
326
|
+
if (this.placeholder) return this.placeholder
|
|
327
|
+
return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
|
|
270
328
|
},
|
|
271
329
|
methods: {
|
|
272
330
|
onChangeHandler(event) {
|
|
273
331
|
if (isNaN(event)) {
|
|
274
332
|
event = this.minNumber || this.minNumber === 0 ? this.minNumber : event
|
|
275
333
|
}
|
|
276
|
-
this.$emit(
|
|
334
|
+
this.$emit('input-change', event)
|
|
277
335
|
},
|
|
278
336
|
onEvaluateCode(val) {
|
|
279
337
|
// function to perform math on the code
|
|
280
338
|
// filter the string in case of any malicious content
|
|
281
|
-
let filtered = val.replace(/[^-()\d/*+.,]/g,
|
|
339
|
+
let filtered = val.replace(/[^-()\d/*+.,]/g, '')
|
|
282
340
|
filtered = filtered.split(/([-+*/()])/)
|
|
283
341
|
let formatted = filtered.map((item) => {
|
|
284
342
|
if (
|
|
285
|
-
item ===
|
|
286
|
-
item ===
|
|
287
|
-
item ===
|
|
288
|
-
item ===
|
|
289
|
-
item ===
|
|
290
|
-
item ===
|
|
291
|
-
item ===
|
|
343
|
+
item === '+' ||
|
|
344
|
+
item === '-' ||
|
|
345
|
+
item === '*' ||
|
|
346
|
+
item === '/' ||
|
|
347
|
+
item === '(' ||
|
|
348
|
+
item === ')' ||
|
|
349
|
+
item === ''
|
|
292
350
|
) {
|
|
293
351
|
return item
|
|
294
352
|
} else {
|
|
295
353
|
let num = stringToNumber({
|
|
296
354
|
value: item,
|
|
297
|
-
numberPrecision: false
|
|
355
|
+
numberPrecision: false
|
|
298
356
|
})
|
|
299
357
|
return num
|
|
300
358
|
}
|
|
301
359
|
})
|
|
302
|
-
let evaluated = eval(formatted.join(
|
|
360
|
+
let evaluated = eval(formatted.join('')) || ''
|
|
303
361
|
evaluated = stringToNumber({
|
|
304
362
|
value: evaluated,
|
|
305
|
-
numberPrecision: this.numberPrecision
|
|
363
|
+
numberPrecision: this.numberPrecision
|
|
306
364
|
})
|
|
307
365
|
return evaluated
|
|
308
366
|
},
|
|
@@ -315,7 +373,7 @@ export default {
|
|
|
315
373
|
this.textInput = numberToString({
|
|
316
374
|
value:
|
|
317
375
|
evaluatedInput && value.length ? evaluatedInput : this.minNumber,
|
|
318
|
-
numberPrecision: this.numberPrecision
|
|
376
|
+
numberPrecision: this.numberPrecision
|
|
319
377
|
})
|
|
320
378
|
}
|
|
321
379
|
let adjustedMinValue =
|
|
@@ -323,8 +381,8 @@ export default {
|
|
|
323
381
|
? value
|
|
324
382
|
: this.minNumber || this.minNumber === 0
|
|
325
383
|
? this.minNumber
|
|
326
|
-
:
|
|
327
|
-
this.$emit(
|
|
384
|
+
: ''
|
|
385
|
+
this.$emit('input-blur', adjustedMinValue)
|
|
328
386
|
},
|
|
329
387
|
focusInput() {
|
|
330
388
|
if (this.disabled) {
|
|
@@ -341,38 +399,38 @@ export default {
|
|
|
341
399
|
? value
|
|
342
400
|
: this.minNumber || this.minNumber === 0
|
|
343
401
|
? this.minNumber
|
|
344
|
-
:
|
|
402
|
+
: ''
|
|
345
403
|
if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
|
|
346
404
|
let input = this.numberToStringEnabled
|
|
347
405
|
? numberToString({
|
|
348
406
|
value: adjustedMinValue,
|
|
349
|
-
numberPrecision: this.numberPrecision
|
|
407
|
+
numberPrecision: this.numberPrecision
|
|
350
408
|
})
|
|
351
409
|
: adjustedMinValue
|
|
352
|
-
let unit = this.showLinearUnitName ?
|
|
353
|
-
return input +
|
|
410
|
+
let unit = this.showLinearUnitName ? '' : this.unitName
|
|
411
|
+
return input + ' ' + unit
|
|
354
412
|
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
|
355
|
-
return
|
|
413
|
+
return ''
|
|
356
414
|
} else {
|
|
357
415
|
return this.numberToStringEnabled
|
|
358
416
|
? numberToString({
|
|
359
417
|
value: adjustedMinValue,
|
|
360
|
-
numberPrecision: this.numberPrecision
|
|
418
|
+
numberPrecision: this.numberPrecision
|
|
361
419
|
})
|
|
362
420
|
: adjustedMinValue
|
|
363
421
|
}
|
|
364
|
-
}
|
|
422
|
+
}
|
|
365
423
|
},
|
|
366
424
|
created() {
|
|
367
425
|
if (this.value) {
|
|
368
426
|
this.textInput = numberToString({
|
|
369
427
|
value: this.value,
|
|
370
|
-
numberPrecision: this.numberPrecision
|
|
428
|
+
numberPrecision: this.numberPrecision
|
|
371
429
|
})
|
|
372
430
|
} else if (this.minNumber !== null) {
|
|
373
431
|
this.textInput = numberToString({
|
|
374
432
|
value: this.minNumber,
|
|
375
|
-
numberPrecision: this.numberPrecision
|
|
433
|
+
numberPrecision: this.numberPrecision
|
|
376
434
|
})
|
|
377
435
|
}
|
|
378
436
|
},
|
|
@@ -380,9 +438,9 @@ export default {
|
|
|
380
438
|
clearInput: function (value) {
|
|
381
439
|
if (value) {
|
|
382
440
|
// If the value is typed, then we should clear the textInput on Continue
|
|
383
|
-
this.textInput =
|
|
441
|
+
this.textInput = ''
|
|
384
442
|
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
387
445
|
}
|
|
388
|
-
</script>
|
|
446
|
+
</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
|