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