@eturnity/eturnity_reusable_components 7.24.3-EPDM-11320.0 → 7.24.3-EPDM-11143.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/.prettierrc +7 -0
- package/package.json +20 -6
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/App.vue +70 -75
- package/src/assets/svgIcons/copy.svg +10 -0
- package/src/components/addNewButton/index.vue +27 -24
- package/src/components/banner/actionBanner/index.vue +30 -32
- package/src/components/banner/banner/index.vue +80 -88
- package/src/components/banner/infoBanner/index.vue +44 -36
- package/src/components/buttons/buttonIcon/index.vue +78 -83
- package/src/components/buttons/closeButton/index.vue +26 -26
- package/src/components/buttons/mainButton/index.vue +76 -80
- package/src/components/card/index.vue +52 -56
- package/src/components/collapsableInfoText/index.vue +76 -81
- package/src/components/deleteIcon/index.vue +28 -31
- package/src/components/draggableInputHandle/index.vue +17 -20
- package/src/components/dropdown/Dropdown.stories.js +8 -8
- package/src/components/dropdown/index.vue +72 -75
- package/src/components/errorMessage/index.vue +23 -23
- package/src/components/filter/filterSettings.vue +329 -349
- package/src/components/filter/index.vue +130 -130
- package/src/components/filter/parentDropdown.vue +40 -43
- package/src/components/icon/Icons.stories.js +4 -4
- package/src/components/icon/iconCache.js +1 -1
- package/src/components/icon/iconCollection.vue +37 -40
- package/src/components/icon/index.vue +65 -72
- package/src/components/iconWrapper/index.vue +118 -122
- package/src/components/infoCard/index.vue +17 -20
- package/src/components/infoText/index.vue +82 -88
- package/src/components/inputs/checkbox/index.vue +94 -91
- package/src/components/inputs/inputNumber/index.vue +488 -508
- package/src/components/inputs/inputNumberQuestion/index.vue +124 -127
- package/src/components/inputs/inputText/index.vue +252 -265
- package/src/components/inputs/radioButton/index.vue +120 -135
- package/src/components/inputs/searchInput/index.vue +81 -84
- package/src/components/inputs/select/index.vue +631 -644
- package/src/components/inputs/select/option/index.vue +91 -91
- package/src/components/inputs/select/select.stories.js +7 -7
- package/src/components/inputs/slider/index.vue +46 -46
- package/src/components/inputs/switchField/index.vue +152 -159
- package/src/components/inputs/textAreaInput/index.vue +113 -120
- package/src/components/inputs/toggle/index.vue +127 -137
- package/src/components/label/index.vue +61 -64
- package/src/components/markerItem/index.vue +40 -40
- package/src/components/modals/actionModal/index.vue +29 -32
- package/src/components/modals/infoModal/index.vue +27 -34
- package/src/components/modals/modal/index.vue +80 -88
- package/src/components/navigationTabs/index.vue +47 -50
- package/src/components/pageSubtitle/index.vue +29 -33
- package/src/components/pageTitle/index.vue +39 -47
- package/src/components/pagination/index.vue +62 -64
- package/src/components/progressBar/index.vue +67 -70
- package/src/components/projectMarker/index.vue +163 -172
- package/src/components/rangeSlider/Slider.vue +449 -449
- package/src/components/rangeSlider/index.vue +270 -282
- package/src/components/rangeSlider/utils/dom.js +3 -3
- package/src/components/selectedOptions/index.vue +51 -51
- package/src/components/sideMenu/index.vue +109 -117
- package/src/components/spinner/index.vue +34 -37
- package/src/components/tableDropdown/index.vue +326 -343
- package/src/components/tables/mainTable/index.vue +106 -109
- package/src/components/tables/viewTable/index.vue +92 -105
- package/src/components/threeDots/index.vue +171 -174
- package/src/components/videoThumbnail/index.vue +59 -67
- package/src/components/videoThumbnail/videoThumbnail.stories.js +6 -6
- package/.eslintrc.js +0 -125
@@ -1,94 +1,74 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
3
|
-
|
4
|
-
:input-width="inputWidth"
|
5
|
-
>
|
6
|
-
<LabelSlotWrapper
|
2
|
+
<container :inputWidth="inputWidth" :alignItems="alignItems">
|
3
|
+
<label-slot-wrapper
|
7
4
|
v-if="hasLabelSlot"
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
5
|
+
:isInteractive="isInteractive"
|
6
|
+
:alignItems="alignItems"
|
7
|
+
:noBorder="noBorder"
|
8
|
+
:isError="isError"
|
9
|
+
:borderColor="borderColor"
|
13
10
|
@mousedown="initInteraction"
|
14
11
|
>
|
15
12
|
<slot name="label"></slot>
|
16
|
-
</
|
13
|
+
</label-slot-wrapper>
|
17
14
|
|
18
|
-
<
|
19
|
-
<
|
20
|
-
:data-id="labelDataId"
|
21
|
-
:label-font-color="labelFontColor"
|
22
|
-
>
|
15
|
+
<label-wrapper v-if="labelText">
|
16
|
+
<label-text :labelFontColor="labelFontColor" :data-id="labelDataId">
|
23
17
|
{{ labelText }}
|
24
|
-
</
|
18
|
+
</label-text>
|
25
19
|
|
26
|
-
<
|
20
|
+
<info-text
|
27
21
|
v-if="labelInfoText"
|
28
|
-
:align-arrow="labelInfoAlign"
|
29
22
|
:text="labelInfoText"
|
23
|
+
:alignArrow="labelInfoAlign"
|
30
24
|
/>
|
31
|
-
</
|
32
|
-
<
|
33
|
-
<
|
25
|
+
</label-wrapper>
|
26
|
+
<input-wrapper>
|
27
|
+
<input-container
|
34
28
|
v-bind="$attrs"
|
35
|
-
ref="inputField1"
|
36
|
-
:
|
37
|
-
:background-color="backgroundColor"
|
38
|
-
:border-color="borderColor"
|
39
|
-
:data-id="inputDataId"
|
40
|
-
:disabled="disabled"
|
41
|
-
:font-color="fontColor"
|
42
|
-
:font-size="fontSize"
|
43
|
-
:has-label-slot="hasLabelSlot"
|
44
|
-
:has-slot="hasSlot"
|
45
|
-
:has-unit="unitName && !!unitName.length"
|
46
|
-
:input-height="inputHeight"
|
47
|
-
:is-disabled="disabled"
|
48
|
-
:is-error="isError"
|
49
|
-
:is-interactive="isInteractive"
|
50
|
-
:min-width="minWidth"
|
51
|
-
:no-border="noBorder"
|
29
|
+
ref="inputField1"
|
30
|
+
:hasUnit="unitName && !!unitName.length"
|
52
31
|
:placeholder="displayedPlaceholder"
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
32
|
+
:isError="isError"
|
33
|
+
:inputHeight="inputHeight"
|
34
|
+
:minWidth="minWidth"
|
35
|
+
:isInteractive="isInteractive"
|
56
36
|
:value="formatWithCurrency(value)"
|
57
37
|
@blur="onInputBlur($event)"
|
58
38
|
@focus="focusInput()"
|
59
|
-
@input="onInput($event)"
|
60
39
|
@keyup.enter="onEnterPress"
|
40
|
+
@input="onInput($event)"
|
41
|
+
:disabled="disabled"
|
42
|
+
:isDisabled="disabled"
|
43
|
+
:alignItems="alignItems"
|
44
|
+
:noBorder="noBorder"
|
45
|
+
:borderColor="borderColor"
|
46
|
+
:textAlign="textAlign"
|
47
|
+
:fontSize="fontSize"
|
48
|
+
:fontColor="fontColor"
|
49
|
+
:backgroundColor="backgroundColor"
|
50
|
+
:hasSlot="hasSlot"
|
51
|
+
:hasLabelSlot="hasLabelSlot"
|
52
|
+
:slotSize="slotSize"
|
53
|
+
:showLinearUnitName="showLinearUnitName"
|
54
|
+
:data-id="inputDataId"
|
61
55
|
/>
|
62
|
-
<
|
63
|
-
v-if="hasSlot"
|
64
|
-
:is-error="isError"
|
65
|
-
:slot-size="slotSize"
|
66
|
-
>
|
56
|
+
<slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
|
67
57
|
<slot></slot>
|
68
|
-
</
|
58
|
+
</slot-container>
|
69
59
|
|
70
|
-
<
|
60
|
+
<unit-container
|
71
61
|
v-if="unitName && showLinearUnitName && !hasSlot"
|
72
|
-
:
|
73
|
-
:
|
62
|
+
:hasLength="!!textInput.length"
|
63
|
+
:isError="isError"
|
64
|
+
>{{ unitName }}</unit-container
|
74
65
|
>
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<Icon
|
82
|
-
cursor="default"
|
83
|
-
name="warning"
|
84
|
-
size="16px"
|
85
|
-
/>
|
86
|
-
</IconWrapper>
|
87
|
-
</InputWrapper>
|
88
|
-
<ErrorMessage v-if="isError">
|
89
|
-
{{ errorMessage }}
|
90
|
-
</ErrorMessage>
|
91
|
-
</Container>
|
66
|
+
<icon-wrapper v-if="isError && !showLinearUnitName" size="16px">
|
67
|
+
<icon name="warning" size="16px" cursor="default" />
|
68
|
+
</icon-wrapper>
|
69
|
+
</input-wrapper>
|
70
|
+
<error-message v-if="isError">{{ errorMessage }}</error-message>
|
71
|
+
</container>
|
92
72
|
</template>
|
93
73
|
|
94
74
|
<script>
|
@@ -120,47 +100,47 @@
|
|
120
100
|
// >
|
121
101
|
//<template name=label><img>....</template>
|
122
102
|
//</inputNumber>
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
103
|
+
import styled from 'vue3-styled-components'
|
104
|
+
import {
|
105
|
+
stringToNumber,
|
106
|
+
numberToString
|
107
|
+
} from '../../../helpers/numberConverter'
|
108
|
+
import InfoText from '../../infoText'
|
109
|
+
import ErrorMessage from '../../errorMessage'
|
110
|
+
import warningIcon from '../../../assets/icons/error_icon.png'
|
111
|
+
import Icon from '../../icon'
|
132
112
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
113
|
+
const inputProps = {
|
114
|
+
isError: Boolean,
|
115
|
+
hasUnit: Boolean,
|
116
|
+
inputWidth: String,
|
117
|
+
minWidth: String,
|
118
|
+
isDisabled: Boolean,
|
119
|
+
noBorder: Boolean,
|
120
|
+
textAlign: String,
|
121
|
+
fontSize: String,
|
122
|
+
fontColor: String,
|
123
|
+
backgroundColor: String,
|
124
|
+
hasSlot: Boolean,
|
125
|
+
hasLabelSlot: Boolean,
|
126
|
+
slotSize: String,
|
127
|
+
inputHeight: String,
|
128
|
+
isInteractive: Boolean,
|
129
|
+
alignItems: String,
|
130
|
+
labelFontColor: String,
|
131
|
+
borderColor: String,
|
132
|
+
showLinearUnitName: Boolean
|
133
|
+
}
|
154
134
|
|
155
|
-
|
135
|
+
const Container = styled('div', inputProps)`
|
156
136
|
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
157
137
|
position: relative;
|
158
138
|
display: grid;
|
159
139
|
grid-template-columns: ${(props) =>
|
160
|
-
|
140
|
+
props.alignItems === 'vertical' ? '1fr' : 'auto 1fr'};
|
161
141
|
`
|
162
142
|
|
163
|
-
|
143
|
+
const InputContainer = styled('input', inputProps)`
|
164
144
|
border: ${(props) =>
|
165
145
|
props.isError
|
166
146
|
? '1px solid ' + props.theme.colors.red
|
@@ -170,7 +150,7 @@
|
|
170
150
|
? props.theme.colors[props.borderColor]
|
171
151
|
? '1px solid ' + props.theme.colors[props.borderColor]
|
172
152
|
: '1px solid ' + props.borderColor
|
173
|
-
|
153
|
+
: '1px solid ' + props.theme.colors.grey4};
|
174
154
|
height: ${(props) => props.inputHeight};
|
175
155
|
max-height: ${(props) => props.inputHeight};
|
176
156
|
padding: 0 10px;
|
@@ -181,11 +161,11 @@
|
|
181
161
|
: 'calc(' + slotSize + ' + 10px)'
|
182
162
|
: isError && !showLinearUnitName
|
183
163
|
? '24px'
|
184
|
-
|
164
|
+
: '5px'};
|
185
165
|
border-radius: ${(props) =>
|
186
166
|
props.isInteractive && props.alignItems != 'vertical'
|
187
167
|
? '0 4px 4px 0'
|
188
|
-
|
168
|
+
: '4px'};
|
189
169
|
text-align: ${(props) => props.textAlign};
|
190
170
|
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
|
191
171
|
font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
|
@@ -196,16 +176,16 @@
|
|
196
176
|
? props.theme.colors.grey2
|
197
177
|
: props.fontColor
|
198
178
|
? props.fontColor + ' !important'
|
199
|
-
|
179
|
+
: props.theme.colors.black};
|
200
180
|
background-color: ${(props) =>
|
201
181
|
props.backgroundColor
|
202
182
|
? props.backgroundColor + ' !important'
|
203
|
-
|
183
|
+
: props.theme.colors.white};
|
204
184
|
width: ${(props) =>
|
205
|
-
|
185
|
+
props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
|
206
186
|
min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
|
207
187
|
background-color: ${(props) =>
|
208
|
-
|
188
|
+
props.isDisabled ? props.theme.colors.grey5 : '#fff'};
|
209
189
|
box-sizing: border-box;
|
210
190
|
|
211
191
|
&::placeholder {
|
@@ -217,18 +197,18 @@
|
|
217
197
|
}
|
218
198
|
`
|
219
199
|
|
220
|
-
|
200
|
+
const InputWrapper = styled.span`
|
221
201
|
position: relative;
|
222
202
|
`
|
223
203
|
|
224
|
-
|
204
|
+
const UnitContainer = styled('span', inputProps)`
|
225
205
|
border-left: 1px solid
|
226
206
|
${(props) =>
|
227
207
|
props.isError
|
228
208
|
? props.theme.colors.red
|
229
209
|
: props.hasLength
|
230
210
|
? props.theme.colors.black
|
231
|
-
|
211
|
+
: props.theme.colors.mediumGray};
|
232
212
|
position: absolute;
|
233
213
|
right: 10px;
|
234
214
|
top: 10px;
|
@@ -239,10 +219,10 @@
|
|
239
219
|
? props.theme.colors.red
|
240
220
|
: props.hasLength
|
241
221
|
? props.theme.colors.black
|
242
|
-
|
222
|
+
: props.theme.colors.mediumGray};
|
243
223
|
`
|
244
224
|
|
245
|
-
|
225
|
+
const SlotContainer = styled('span', inputProps)`
|
246
226
|
text-align: right;
|
247
227
|
border-left: 1px solid
|
248
228
|
${(props) =>
|
@@ -250,10 +230,10 @@
|
|
250
230
|
? props.theme.colors.red
|
251
231
|
: props.hasLength
|
252
232
|
? props.theme.colors.black
|
253
|
-
|
233
|
+
: props.theme.colors.mediumGray};
|
254
234
|
position: absolute;
|
255
235
|
width: ${(props) =>
|
256
|
-
|
236
|
+
props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
|
257
237
|
right: 10px;
|
258
238
|
top: 10px;
|
259
239
|
padding-left: 10px;
|
@@ -262,17 +242,17 @@
|
|
262
242
|
? props.theme.colors.red
|
263
243
|
: props.hasLength
|
264
244
|
? props.theme.colors.black
|
265
|
-
|
245
|
+
: props.theme.colors.mediumGray};
|
266
246
|
`
|
267
247
|
|
268
|
-
|
248
|
+
const LabelWrapper = styled('div', inputProps)`
|
269
249
|
display: flex;
|
270
250
|
align-items: center;
|
271
251
|
gap: 10px;
|
272
252
|
margin-bottom: 8px;
|
273
253
|
cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
|
274
254
|
`
|
275
|
-
|
255
|
+
const LabelSlotWrapper = styled('div', inputProps)`
|
276
256
|
display: flex;
|
277
257
|
gap: 10px;
|
278
258
|
align-items: center;
|
@@ -288,22 +268,22 @@
|
|
288
268
|
? props.theme.colors[props.borderColor]
|
289
269
|
? '1px solid ' + props.theme.colors[props.borderColor]
|
290
270
|
: '1px solid ' + props.borderColor
|
291
|
-
|
271
|
+
: '1px solid ' + props.theme.colors.grey4};
|
292
272
|
border-radius: 4px 0 0 4px;
|
293
273
|
border-right: none;
|
294
274
|
`
|
295
275
|
|
296
|
-
|
276
|
+
const LabelText = styled('div', inputProps)`
|
297
277
|
font-size: 13px;
|
298
278
|
color: ${(props) =>
|
299
279
|
props.theme.colors[props.labelFontColor]
|
300
280
|
? props.theme.colors[props.labelFontColor]
|
301
|
-
|
281
|
+
: props.labelFontColor};
|
302
282
|
font-weight: 700;
|
303
283
|
`
|
304
284
|
|
305
|
-
|
306
|
-
|
285
|
+
const IconAttrs = { size: String }
|
286
|
+
const IconWrapper = styled('div', IconAttrs)`
|
307
287
|
position: absolute;
|
308
288
|
top: 0;
|
309
289
|
bottom: 0;
|
@@ -312,419 +292,419 @@
|
|
312
292
|
height: ${(props) => (props.size ? props.size : 'auto')};
|
313
293
|
`
|
314
294
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
default: null
|
419
|
-
},
|
420
|
-
labelInfoAlign: {
|
421
|
-
required: false,
|
422
|
-
default: 'left'
|
423
|
-
},
|
424
|
-
defaultNumber: {
|
425
|
-
required: false,
|
426
|
-
default: null
|
427
|
-
},
|
428
|
-
minNumber: {
|
429
|
-
required: false,
|
430
|
-
default: null
|
431
|
-
},
|
432
|
-
fontColor: {
|
433
|
-
required: false,
|
434
|
-
default: null
|
435
|
-
},
|
436
|
-
backgroundColor: {
|
437
|
-
required: false,
|
438
|
-
default: null
|
439
|
-
},
|
440
|
-
numberToStringEnabled: {
|
441
|
-
required: false,
|
442
|
-
default: true
|
443
|
-
},
|
444
|
-
allowNegative: {
|
445
|
-
required: false,
|
446
|
-
default: true
|
447
|
-
},
|
448
|
-
slotSize: {
|
449
|
-
required: false
|
450
|
-
},
|
451
|
-
labelFontColor: {
|
452
|
-
required: false,
|
453
|
-
default: 'eturnityGrey'
|
454
|
-
},
|
455
|
-
focus: {
|
456
|
-
required: false,
|
457
|
-
default: false
|
458
|
-
},
|
459
|
-
labelDataId: {
|
460
|
-
required: false,
|
461
|
-
default: ''
|
462
|
-
},
|
463
|
-
inputDataId: {
|
464
|
-
required: false,
|
465
|
-
default: ''
|
466
|
-
}
|
295
|
+
export default {
|
296
|
+
name: 'input-number',
|
297
|
+
components: {
|
298
|
+
Container,
|
299
|
+
InputContainer,
|
300
|
+
InputWrapper,
|
301
|
+
UnitContainer,
|
302
|
+
ErrorMessage,
|
303
|
+
LabelWrapper,
|
304
|
+
LabelSlotWrapper,
|
305
|
+
LabelText,
|
306
|
+
InfoText,
|
307
|
+
Icon,
|
308
|
+
SlotContainer,
|
309
|
+
IconWrapper
|
310
|
+
},
|
311
|
+
inheritAttrs: false,
|
312
|
+
data() {
|
313
|
+
return {
|
314
|
+
textInput: '',
|
315
|
+
isFocused: false,
|
316
|
+
warningIcon: warningIcon
|
317
|
+
}
|
318
|
+
},
|
319
|
+
props: {
|
320
|
+
placeholder: {
|
321
|
+
required: false,
|
322
|
+
default: ''
|
323
|
+
},
|
324
|
+
isError: {
|
325
|
+
required: false,
|
326
|
+
default: false
|
327
|
+
},
|
328
|
+
inputWidth: {
|
329
|
+
required: false,
|
330
|
+
default: null
|
331
|
+
},
|
332
|
+
minWidth: {
|
333
|
+
required: false,
|
334
|
+
default: null
|
335
|
+
},
|
336
|
+
inputHeight: {
|
337
|
+
required: false,
|
338
|
+
default: '40px'
|
339
|
+
},
|
340
|
+
value: {
|
341
|
+
required: true,
|
342
|
+
default: null
|
343
|
+
},
|
344
|
+
clearInput: {
|
345
|
+
required: false,
|
346
|
+
default: false
|
347
|
+
},
|
348
|
+
alignItems: {
|
349
|
+
required: false,
|
350
|
+
default: 'vertical'
|
351
|
+
},
|
352
|
+
errorMessage: {
|
353
|
+
required: false,
|
354
|
+
default: 'Please insert a correct number'
|
355
|
+
},
|
356
|
+
numberPrecision: {
|
357
|
+
required: false,
|
358
|
+
default: 0
|
359
|
+
},
|
360
|
+
minDecimals: {
|
361
|
+
required: false,
|
362
|
+
default: 0
|
363
|
+
},
|
364
|
+
unitName: {
|
365
|
+
required: false,
|
366
|
+
default: ''
|
367
|
+
},
|
368
|
+
showLinearUnitName: {
|
369
|
+
required: false,
|
370
|
+
default: false
|
371
|
+
},
|
372
|
+
disabled: {
|
373
|
+
required: false,
|
374
|
+
default: false
|
375
|
+
},
|
376
|
+
noBorder: {
|
377
|
+
required: false,
|
378
|
+
default: false
|
379
|
+
},
|
380
|
+
borderColor: {
|
381
|
+
required: false
|
382
|
+
},
|
383
|
+
textAlign: {
|
384
|
+
required: false,
|
385
|
+
default: 'left'
|
386
|
+
},
|
387
|
+
fontSize: {
|
388
|
+
required: false,
|
389
|
+
default: '13px'
|
390
|
+
},
|
391
|
+
isInteractive: {
|
392
|
+
required: false,
|
393
|
+
default: false
|
394
|
+
},
|
395
|
+
interactionStep: {
|
396
|
+
required: false,
|
397
|
+
default: 1
|
467
398
|
},
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
399
|
+
labelText: {
|
400
|
+
required: false,
|
401
|
+
default: null
|
402
|
+
},
|
403
|
+
labelInfoText: {
|
404
|
+
required: false,
|
405
|
+
default: null
|
406
|
+
},
|
407
|
+
labelInfoAlign: {
|
408
|
+
required: false,
|
409
|
+
default: 'left'
|
410
|
+
},
|
411
|
+
defaultNumber: {
|
412
|
+
required: false,
|
413
|
+
default: null
|
414
|
+
},
|
415
|
+
minNumber: {
|
416
|
+
required: false,
|
417
|
+
default: null
|
418
|
+
},
|
419
|
+
fontColor: {
|
420
|
+
required: false,
|
421
|
+
default: null
|
422
|
+
},
|
423
|
+
backgroundColor: {
|
424
|
+
required: false,
|
425
|
+
default: null
|
426
|
+
},
|
427
|
+
numberToStringEnabled: {
|
428
|
+
required: false,
|
429
|
+
default: true
|
430
|
+
},
|
431
|
+
allowNegative: {
|
432
|
+
required: false,
|
433
|
+
default: true
|
434
|
+
},
|
435
|
+
slotSize: {
|
436
|
+
required: false
|
437
|
+
},
|
438
|
+
labelFontColor: {
|
439
|
+
required: false,
|
440
|
+
default: 'eturnityGrey'
|
441
|
+
},
|
442
|
+
focus: {
|
443
|
+
required: false,
|
444
|
+
default: false
|
445
|
+
},
|
446
|
+
labelDataId: {
|
447
|
+
required: false,
|
448
|
+
default: ''
|
449
|
+
},
|
450
|
+
inputDataId: {
|
451
|
+
required: false,
|
452
|
+
default: ''
|
453
|
+
}
|
454
|
+
},
|
455
|
+
computed: {
|
456
|
+
displayedPlaceholder() {
|
457
|
+
if (this.placeholder) return this.placeholder
|
458
|
+
if (this.defaultNumber)
|
459
|
+
return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
|
460
|
+
return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
|
461
|
+
},
|
462
|
+
hasSlot() {
|
463
|
+
return !!this.$slots.default
|
464
|
+
},
|
465
|
+
hasLabelSlot() {
|
466
|
+
return !!this.$slots.label
|
467
|
+
}
|
468
|
+
},
|
469
|
+
methods: {
|
470
|
+
onEnterPress() {
|
471
|
+
this.$emit('on-enter-click')
|
472
|
+
this.$refs.inputField1.$el.blur()
|
473
|
+
},
|
474
|
+
onChangeHandler(event) {
|
475
|
+
if (isNaN(event) || event === '') {
|
476
|
+
event = this.defaultNumber
|
477
|
+
? this.defaultNumber
|
478
|
+
: this.minNumber || this.minNumber === 0
|
479
|
+
? this.minNumber
|
480
|
+
: event
|
473
481
|
}
|
482
|
+
if (!this.allowNegative) {
|
483
|
+
event = Math.abs(event)
|
484
|
+
}
|
485
|
+
event = parseFloat(event)
|
486
|
+
// Need to return an integer rather than a string
|
487
|
+
this.$emit('input-change', event)
|
474
488
|
},
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
489
|
+
onEvaluateCode(event) {
|
490
|
+
// function to perform math on the code
|
491
|
+
// filter the string in case of any malicious content
|
492
|
+
const val = event.target.value
|
493
|
+
let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
494
|
+
filtered = filtered.split(/([-+*/()])/)
|
495
|
+
let formatted = filtered.map((item) => {
|
496
|
+
if (
|
497
|
+
item === '+' ||
|
498
|
+
item === '-' ||
|
499
|
+
item === '*' ||
|
500
|
+
item === '/' ||
|
501
|
+
item === '(' ||
|
502
|
+
item === ')' ||
|
503
|
+
item === ''
|
504
|
+
) {
|
505
|
+
return item
|
506
|
+
} else {
|
507
|
+
let num = stringToNumber({
|
508
|
+
value: item,
|
509
|
+
numberPrecision: false,
|
510
|
+
minDecimals: this.minDecimals
|
511
|
+
})
|
512
|
+
return num
|
513
|
+
}
|
514
|
+
})
|
515
|
+
let evaluated
|
516
|
+
formatted = this.removeStringItemsAfterLastNumber(formatted)
|
517
|
+
evaluated = eval(formatted.join(' '))
|
518
|
+
if (typeof evaluated === 'string') {
|
519
|
+
evaluated = stringToNumber({
|
520
|
+
value: evaluated,
|
521
|
+
numberPrecision: this.numberPrecision,
|
522
|
+
minDecimals: this.minDecimals
|
523
|
+
})
|
524
|
+
} else if (typeof evaluated === 'number') {
|
525
|
+
evaluated = evaluated.toFixed(this.numberPrecision)
|
487
526
|
}
|
527
|
+
return evaluated
|
488
528
|
},
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
529
|
+
removeStringItemsAfterLastNumber(array) {
|
530
|
+
// fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
|
531
|
+
let lastNumberIndex = -1
|
532
|
+
// Find the index of the last number in the array
|
533
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
534
|
+
if (typeof array[i] === 'number') {
|
535
|
+
lastNumberIndex = i
|
536
|
+
break
|
493
537
|
}
|
494
|
-
}
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
538
|
+
}
|
539
|
+
// if there are no numbers, return an empty array
|
540
|
+
if (lastNumberIndex === -1) {
|
541
|
+
return []
|
542
|
+
}
|
543
|
+
// Remove non-numeric items after the last number
|
544
|
+
if (lastNumberIndex !== -1) {
|
545
|
+
const newArray = array.slice(0, lastNumberIndex + 1)
|
546
|
+
return newArray
|
547
|
+
}
|
548
|
+
return array
|
549
|
+
},
|
550
|
+
onInput(event) {
|
551
|
+
if (!this.isFocused) {
|
552
|
+
return
|
553
|
+
}
|
554
|
+
if (event.target.value === '') {
|
555
|
+
this.$emit('on-input', '')
|
556
|
+
}
|
557
|
+
let evaluatedVal
|
558
|
+
try {
|
559
|
+
evaluatedVal = this.onEvaluateCode(event)
|
560
|
+
} finally {
|
561
|
+
if (evaluatedVal && this.value != evaluatedVal) {
|
562
|
+
this.$emit('on-input', evaluatedVal)
|
499
563
|
}
|
500
564
|
}
|
501
565
|
},
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
})
|
509
|
-
} else if (this.defaultNumber !== null) {
|
566
|
+
onInputBlur(e) {
|
567
|
+
this.isFocused = false
|
568
|
+
let value = e.target.value
|
569
|
+
let evaluatedInput = this.onEvaluateCode(e)
|
570
|
+
this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
|
571
|
+
if ((evaluatedInput && value.length) || this.minNumber !== null) {
|
510
572
|
this.textInput = numberToString({
|
511
|
-
value:
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
value: this.minNumber,
|
573
|
+
value:
|
574
|
+
evaluatedInput && value.length
|
575
|
+
? evaluatedInput
|
576
|
+
: this.defaultNumber
|
577
|
+
? this.defaultNumber
|
578
|
+
: this.minNumber,
|
518
579
|
numberPrecision: this.numberPrecision,
|
519
580
|
minDecimals: this.minDecimals
|
520
581
|
})
|
521
582
|
}
|
583
|
+
let adjustedMinValue =
|
584
|
+
evaluatedInput && evaluatedInput.length
|
585
|
+
? evaluatedInput
|
586
|
+
: this.defaultNumber
|
587
|
+
? this.defaultNumber
|
588
|
+
: this.minNumber || this.minNumber === 0
|
589
|
+
? this.minNumber
|
590
|
+
: ''
|
591
|
+
this.$emit('input-blur', adjustedMinValue)
|
522
592
|
},
|
523
|
-
|
524
|
-
if (this.
|
525
|
-
|
593
|
+
focusInput() {
|
594
|
+
if (this.disabled) {
|
595
|
+
return
|
526
596
|
}
|
597
|
+
this.isFocused = true
|
598
|
+
this.$nextTick(() => {
|
599
|
+
this.$refs.inputField1.$el.select()
|
600
|
+
})
|
601
|
+
this.$emit('input-focus')
|
527
602
|
},
|
528
|
-
|
529
|
-
|
530
|
-
|
603
|
+
blurInput() {
|
604
|
+
if (this.disabled) {
|
605
|
+
return
|
606
|
+
}
|
607
|
+
this.isFocused = false
|
608
|
+
this.$nextTick(() => {
|
531
609
|
this.$refs.inputField1.$el.blur()
|
532
|
-
}
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
this.$emit('input-change', event)
|
547
|
-
},
|
548
|
-
onEvaluateCode(event) {
|
549
|
-
// function to perform math on the code
|
550
|
-
// filter the string in case of any malicious content
|
551
|
-
const val = event.target.value
|
552
|
-
let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
553
|
-
filtered = filtered.split(/([-+*/()])/)
|
554
|
-
let formatted = filtered.map((item) => {
|
555
|
-
if (
|
556
|
-
item === '+' ||
|
557
|
-
item === '-' ||
|
558
|
-
item === '*' ||
|
559
|
-
item === '/' ||
|
560
|
-
item === '(' ||
|
561
|
-
item === ')' ||
|
562
|
-
item === ''
|
563
|
-
) {
|
564
|
-
return item
|
565
|
-
} else {
|
566
|
-
let num = stringToNumber({
|
567
|
-
value: item,
|
568
|
-
numberPrecision: false,
|
569
|
-
minDecimals: this.minDecimals
|
570
|
-
})
|
571
|
-
return num
|
572
|
-
}
|
573
|
-
})
|
574
|
-
let evaluated
|
575
|
-
formatted = this.removeStringItemsAfterLastNumber(formatted)
|
576
|
-
evaluated = eval(formatted.join(' '))
|
577
|
-
if (typeof evaluated === 'string') {
|
578
|
-
evaluated = stringToNumber({
|
579
|
-
value: evaluated,
|
580
|
-
numberPrecision: this.numberPrecision,
|
581
|
-
minDecimals: this.minDecimals
|
582
|
-
})
|
583
|
-
} else if (typeof evaluated === 'number') {
|
584
|
-
evaluated = evaluated.toFixed(this.numberPrecision)
|
585
|
-
}
|
586
|
-
return evaluated
|
587
|
-
},
|
588
|
-
removeStringItemsAfterLastNumber(array) {
|
589
|
-
// fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
|
590
|
-
let lastNumberIndex = -1
|
591
|
-
// Find the index of the last number in the array
|
592
|
-
for (let i = array.length - 1; i >= 0; i--) {
|
593
|
-
if (typeof array[i] === 'number') {
|
594
|
-
lastNumberIndex = i
|
595
|
-
break
|
596
|
-
}
|
597
|
-
}
|
598
|
-
// if there are no numbers, return an empty array
|
599
|
-
if (lastNumberIndex === -1) {
|
600
|
-
return []
|
601
|
-
}
|
602
|
-
// Remove non-numeric items after the last number
|
603
|
-
if (lastNumberIndex !== -1) {
|
604
|
-
const newArray = array.slice(0, lastNumberIndex + 1)
|
605
|
-
return newArray
|
606
|
-
}
|
607
|
-
return array
|
608
|
-
},
|
609
|
-
onInput(event) {
|
610
|
-
if (!this.isFocused) {
|
611
|
-
return
|
612
|
-
}
|
613
|
-
if (event.target.value === '') {
|
614
|
-
this.$emit('on-input', '')
|
615
|
-
}
|
616
|
-
let evaluatedVal
|
617
|
-
try {
|
618
|
-
evaluatedVal = this.onEvaluateCode(event)
|
619
|
-
} finally {
|
620
|
-
if (evaluatedVal && this.value != evaluatedVal) {
|
621
|
-
this.$emit('on-input', evaluatedVal)
|
622
|
-
}
|
623
|
-
}
|
624
|
-
},
|
625
|
-
onInputBlur(e) {
|
626
|
-
this.isFocused = false
|
627
|
-
let value = e.target.value
|
628
|
-
let evaluatedInput = this.onEvaluateCode(e)
|
629
|
-
this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
|
630
|
-
if ((evaluatedInput && value.length) || this.minNumber !== null) {
|
631
|
-
this.textInput = numberToString({
|
632
|
-
value:
|
633
|
-
evaluatedInput && value.length
|
634
|
-
? evaluatedInput
|
635
|
-
: this.defaultNumber
|
636
|
-
? this.defaultNumber
|
637
|
-
: this.minNumber,
|
638
|
-
numberPrecision: this.numberPrecision,
|
639
|
-
minDecimals: this.minDecimals
|
640
|
-
})
|
641
|
-
}
|
642
|
-
let adjustedMinValue =
|
643
|
-
evaluatedInput && evaluatedInput.length
|
644
|
-
? evaluatedInput
|
645
|
-
: this.defaultNumber
|
646
|
-
? this.defaultNumber
|
647
|
-
: this.minNumber || this.minNumber === 0
|
648
|
-
? this.minNumber
|
649
|
-
: ''
|
650
|
-
this.$emit('input-blur', adjustedMinValue)
|
651
|
-
},
|
652
|
-
focusInput() {
|
653
|
-
if (this.disabled) {
|
654
|
-
return
|
655
|
-
}
|
656
|
-
this.isFocused = true
|
657
|
-
this.$nextTick(() => {
|
658
|
-
this.$refs.inputField1.$el.select()
|
659
|
-
})
|
660
|
-
this.$emit('input-focus')
|
661
|
-
},
|
662
|
-
blurInput() {
|
663
|
-
if (this.disabled) {
|
664
|
-
return
|
665
|
-
}
|
666
|
-
this.isFocused = false
|
667
|
-
this.$nextTick(() => {
|
668
|
-
this.$refs.inputField1.$el.blur()
|
669
|
-
})
|
670
|
-
},
|
671
|
-
formatWithCurrency(value) {
|
672
|
-
let adjustedMinValue =
|
673
|
-
value || value === 0
|
674
|
-
? value
|
675
|
-
: this.defaultNumber
|
676
|
-
? this.defaultNumber
|
677
|
-
: this.minNumber || this.minNumber === 0
|
678
|
-
? this.minNumber
|
679
|
-
: ''
|
680
|
-
if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
|
681
|
-
let input = this.numberToStringEnabled
|
682
|
-
? numberToString({
|
610
|
+
})
|
611
|
+
},
|
612
|
+
formatWithCurrency(value) {
|
613
|
+
let adjustedMinValue =
|
614
|
+
value || value === 0
|
615
|
+
? value
|
616
|
+
: this.defaultNumber
|
617
|
+
? this.defaultNumber
|
618
|
+
: this.minNumber || this.minNumber === 0
|
619
|
+
? this.minNumber
|
620
|
+
: ''
|
621
|
+
if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
|
622
|
+
let input = this.numberToStringEnabled
|
623
|
+
? numberToString({
|
683
624
|
value: adjustedMinValue,
|
684
625
|
numberPrecision: this.numberPrecision,
|
685
626
|
minDecimals: this.minDecimals
|
686
627
|
})
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
628
|
+
: adjustedMinValue
|
629
|
+
let unit = this.showLinearUnitName ? '' : this.unitName
|
630
|
+
//return input + ' ' + unit
|
631
|
+
return input + ' ' + unit
|
632
|
+
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
633
|
+
return ''
|
634
|
+
} else {
|
635
|
+
return this.numberToStringEnabled
|
636
|
+
? numberToString({
|
696
637
|
value: adjustedMinValue,
|
697
638
|
numberPrecision: this.numberPrecision,
|
698
639
|
minDecimals: this.minDecimals
|
699
640
|
})
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
641
|
+
: adjustedMinValue
|
642
|
+
}
|
643
|
+
},
|
644
|
+
initInteraction(e) {
|
645
|
+
this.focusInput()
|
646
|
+
e.preventDefault()
|
647
|
+
window.addEventListener('mousemove', this.interact, false)
|
648
|
+
window.addEventListener('mouseup', this.stopInteract, false)
|
649
|
+
},
|
650
|
+
interact(e) {
|
651
|
+
e.preventDefault()
|
652
|
+
let value = parseFloat(this.value || 0)
|
653
|
+
value += parseFloat(this.interactionStep) * parseInt(e.movementX)
|
654
|
+
this.$emit('on-input-drag', value)
|
714
655
|
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
656
|
+
this.textInput = numberToString({
|
657
|
+
value: value && value.length ? value : this.minNumber,
|
658
|
+
numberPrecision: this.numberPrecision,
|
659
|
+
minDecimals: this.minDecimals
|
660
|
+
})
|
720
661
|
//this.value=value
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
662
|
+
},
|
663
|
+
stopInteract(e) {
|
664
|
+
e.preventDefault()
|
665
|
+
window.removeEventListener('mousemove', this.interact, false)
|
666
|
+
window.removeEventListener('mouseup', this.stopInteract, false)
|
667
|
+
this.blurInput()
|
668
|
+
}
|
669
|
+
},
|
670
|
+
created() {
|
671
|
+
if (this.value) {
|
672
|
+
this.textInput = numberToString({
|
673
|
+
value: this.value,
|
674
|
+
numberPrecision: this.numberPrecision,
|
675
|
+
minDecimals: this.minDecimals
|
676
|
+
})
|
677
|
+
} else if (this.defaultNumber !== null) {
|
678
|
+
this.textInput = numberToString({
|
679
|
+
value: this.defaultNumber,
|
680
|
+
numberPrecision: this.numberPrecision,
|
681
|
+
minDecimals: this.minDecimals
|
682
|
+
})
|
683
|
+
} else if (this.minNumber !== null) {
|
684
|
+
this.textInput = numberToString({
|
685
|
+
value: this.minNumber,
|
686
|
+
numberPrecision: this.numberPrecision,
|
687
|
+
minDecimals: this.minDecimals
|
688
|
+
})
|
689
|
+
}
|
690
|
+
},
|
691
|
+
mounted() {
|
692
|
+
if (this.focus) {
|
693
|
+
this.focusInput()
|
694
|
+
}
|
695
|
+
},
|
696
|
+
watch: {
|
697
|
+
focus(value) {
|
698
|
+
if (value) {
|
699
|
+
this.focusInput()
|
700
|
+
}
|
701
|
+
},
|
702
|
+
clearInput: function (value) {
|
703
|
+
if (value) {
|
704
|
+
// If the value is typed, then we should clear the textInput on Continue
|
705
|
+
this.textInput = ''
|
727
706
|
}
|
728
707
|
}
|
729
708
|
}
|
709
|
+
}
|
730
710
|
</script>
|