@eturnity/eturnity_reusable_components 7.45.5-EPDM-12680.3 → 7.45.5-EPDM-10609.2

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": "7.45.5-EPDM-12680.3",
3
+ "version": "7.45.5-EPDM-10609.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -0,0 +1,3 @@
1
+ <svg width="10" height="8" viewBox="0 0 10 8" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1.64062 2.47656L3.75 4.58594L8.36719 0L10 1.60156L5.38281 6.25L3.74219 7.88281L2.10938 6.25L0 4.14063L1.64062 2.47656Z" fill="white"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M6 9.46199L9.708 11.7L8.724 7.48199L12 4.64399L7.686 4.27799L6 0.299988L4.314 4.27799L0 4.64399L3.276 7.48199L2.292 11.7L6 9.46199Z" fill="#FDB813"/>
3
+ </svg>
@@ -11,6 +11,7 @@ const theme = {
11
11
  lightGray: '#f2f2f2',
12
12
  white: '#ffffff',
13
13
  blue: '#48a2d0',
14
+ blue2: '#6CD4D4',
14
15
  red: '#ff5656',
15
16
  blue1: '#e4efff',
16
17
  brightBlue: '#0068DE',
@@ -52,9 +52,7 @@
52
52
  props.isDisabled
53
53
  ? props.theme.colors.disabled
54
54
  : props.customColor
55
- ? props.theme.colors[props.customColor]
56
- ? props.theme.colors[props.customColor]
57
- : props.customColor
55
+ ? props.customColor
58
56
  : props.theme.colors.yellow};
59
57
  cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
60
58
  user-select: none;
@@ -35,7 +35,6 @@
35
35
  },
36
36
  name: {
37
37
  required: true,
38
- type: String,
39
38
  },
40
39
  color: {
41
40
  required: false,
@@ -0,0 +1,4 @@
1
+ export const TEXT_OVERLAY_TOP_OFFSET = 45
2
+ export const TEXT_OVERLAY_LEFT_OFFSET = 3
3
+ export const TEXT_OVERLAY_ARROW_LEFT_OFFSET = 78
4
+ export const TEXT_OVERLAY_ARROW_RIGHT_NEGATIVE_OFFSET = 86
@@ -1,30 +1,50 @@
1
1
  <template>
2
2
  <ComponentWrapper>
3
- <IconWrapper :size="size">
3
+ <IconWrapper :size="type === 'dot' ? 'unset' : size">
4
4
  <IconImg
5
+ ref="iconImg"
5
6
  data-test-id="infoText_trigger"
6
7
  @click.prevent="toggleShowInfo()"
7
8
  @mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
8
9
  @mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
9
10
  >
11
+ <Dot v-if="type === 'dot'" :color="dotColor" />
10
12
  <IconComponent
13
+ v-else
11
14
  :color="iconColor"
12
15
  cursor="pointer"
13
16
  name="info"
14
17
  :size="size"
15
18
  />
16
19
  </IconImg>
17
- <TextOverlay
18
- v-if="showInfo"
19
- :align-arrow="alignArrow"
20
- :half-computed-text-info-width="halfComputedTextInfoWidth"
21
- :icon-size="size"
22
- :info-position="infoPosition"
23
- :max-width="maxWidth"
24
- :width="width"
25
- ><slot></slot>
26
- <span v-if="text.length > 0" v-html="text"></span>
27
- </TextOverlay>
20
+ <template v-if="!shouldUseTeleport">
21
+ <TextOverlay
22
+ v-if="showInfo"
23
+ :align-arrow="alignArrow"
24
+ :half-computed-text-info-width="halfComputedTextInfoWidth"
25
+ :icon-size="size"
26
+ :info-position="infoPosition"
27
+ :max-width="maxWidth"
28
+ :width="width"
29
+ ><slot></slot>
30
+ <span v-html="text"></span>
31
+ </TextOverlay>
32
+ </template>
33
+ <Teleport v-else to="#portal-target">
34
+ <TextOverlay
35
+ v-if="showInfo"
36
+ :align-arrow="alignArrow"
37
+ :half-computed-text-info-width="halfComputedTextInfoWidth"
38
+ :icon-size="size"
39
+ :info-position="infoPosition"
40
+ :left="position.left"
41
+ :max-width="maxWidth"
42
+ :top="position.top"
43
+ :width="width"
44
+ ><slot></slot>
45
+ <span v-html="text"></span>
46
+ </TextOverlay>
47
+ </Teleport>
28
48
  </IconWrapper>
29
49
  </ComponentWrapper>
30
50
  </template>
@@ -37,29 +57,41 @@
37
57
  // size="20px"
38
58
  // alignArrow="right" // which side the arrow should be on
39
59
  // />
60
+ import { Teleport } from 'vue'
40
61
  import theme from '../../assets/theme.js'
41
62
  import styled from 'vue3-styled-components'
42
63
  import IconComponent from '../icon'
64
+ import {
65
+ TEXT_OVERLAY_ARROW_LEFT_OFFSET,
66
+ TEXT_OVERLAY_ARROW_RIGHT_NEGATIVE_OFFSET,
67
+ TEXT_OVERLAY_TOP_OFFSET,
68
+ } from './constants.js'
43
69
 
44
70
  const textAttrs = {
45
71
  iconSize: String,
46
72
  alignArrow: String,
47
73
  width: String,
48
74
  halfComputedTextInfoWidth: Number,
75
+ top: String,
76
+ left: String,
49
77
  infoPosition: String,
50
78
  }
51
79
  const TextOverlay = styled('div', textAttrs)`
52
80
  position: absolute;
81
+ ${(props) => (props.infoPosition === 'top' ? 'bottom' : 'top')} : ${(
82
+ props
83
+ ) => (props.top ? props.top : 'calc(' + props.iconSize + ' + 5px)')};
53
84
  ${(props) =>
54
- props.infoPosition == 'top'
55
- ? 'bottom : calc(' + props.iconSize + ' + 15px)'
56
- : 'top : calc(' + props.iconSize + ' + 15px)'};
57
- ${(props) =>
58
- props.alignArrow === 'left'
85
+ props.left
86
+ ? 'left: ' + props.left
87
+ : props.alignArrow === 'left'
59
88
  ? 'left: calc(' + props.iconSize + ' /2 - 18px)'
60
89
  : props.alignArrow === 'center'
61
90
  ? 'left: calc((-' + props.width + ' + ' + props.iconSize + ') /2 + 2px)'
62
91
  : 'right: calc(' + props.iconSize + ' /2 - 17px)'};
92
+
93
+ ${(props) => (props.infoPosition === 'left' ? 'right' : 'left')} : 0;
94
+
63
95
  text-align: left;
64
96
  background: ${(props) => props.theme.colors.black};
65
97
  padding: 10px;
@@ -103,6 +135,14 @@
103
135
  height: ${(props) => props.size};
104
136
  `
105
137
 
138
+ const Dot = styled('div')`
139
+ width: 5px;
140
+ height: 5px;
141
+ background-color: ${(props) => props.color};
142
+ border-radius: 50%;
143
+ display: inline-block;
144
+ `
145
+
106
146
  const IconImg = styled.div`
107
147
  line-height: 0;
108
148
  `
@@ -114,19 +154,22 @@
114
154
  export default {
115
155
  name: 'InfoText',
116
156
  components: {
157
+ Dot,
117
158
  IconWrapper,
118
159
  TextOverlay,
119
160
  ComponentWrapper,
120
161
  IconImg,
121
162
  IconComponent,
163
+ Teleport,
122
164
  },
123
165
  props: {
124
166
  text: {
167
+ type: String,
125
168
  required: false,
126
169
  default: '',
127
- type: String,
128
170
  },
129
171
  size: {
172
+ type: String,
130
173
  required: false,
131
174
  default: '14px',
132
175
  type: String,
@@ -137,16 +180,19 @@
137
180
  type: String,
138
181
  },
139
182
  alignArrow: {
183
+ type: String,
140
184
  required: false,
141
185
  default: 'center',
142
186
  type: String,
143
187
  },
144
188
  openTrigger: {
189
+ type: String,
145
190
  required: false,
146
191
  default: 'onHover', // onHover, onClick
147
192
  type: String,
148
193
  },
149
194
  width: {
195
+ type: String,
150
196
  required: false,
151
197
  default: '165px',
152
198
  type: String,
@@ -155,10 +201,28 @@
155
201
  default: '400px',
156
202
  type: String,
157
203
  },
204
+ shouldUseTeleport: {
205
+ type: Boolean,
206
+ default: false,
207
+ },
208
+ dotColor: {
209
+ type: String,
210
+ required: false,
211
+ default: theme.colors.blue2,
212
+ },
213
+ type: {
214
+ type: String,
215
+ required: false,
216
+ default: 'info', // info, dot
217
+ },
158
218
  },
159
219
  data() {
160
220
  return {
161
221
  showInfo: false,
222
+ position: {
223
+ top: null,
224
+ left: null,
225
+ },
162
226
  }
163
227
  },
164
228
  computed: {
@@ -178,6 +242,10 @@
178
242
  } else {
179
243
  document.removeEventListener('click', this.clickOutside)
180
244
  }
245
+
246
+ if (this.shouldUseTeleport && this.showInfo) {
247
+ this.getTeleportPosition()
248
+ }
181
249
  },
182
250
  clickOutside(event) {
183
251
  if (this.$el.contains(event.target)) {
@@ -185,6 +253,35 @@
185
253
  }
186
254
  this.toggleShowInfo()
187
255
  },
256
+ getTextOverlayTop() {
257
+ const iconImg = this.$refs.iconImg.$el
258
+ const iconImgTop = iconImg.getBoundingClientRect().top
259
+ const iconImgHeight = iconImg.clientHeight
260
+ const textOverlayTop =
261
+ iconImgTop - iconImgHeight / 2 + TEXT_OVERLAY_TOP_OFFSET
262
+
263
+ console.log(textOverlayTop)
264
+
265
+ return `${textOverlayTop}px`
266
+ },
267
+ getTextOverlayLeft() {
268
+ const iconImg = this.$refs.iconImg.$el
269
+ const iconImgLeft = iconImg.getBoundingClientRect().left
270
+ const iconImgWidth = iconImg.clientWidth
271
+ const textOverlayLeft = iconImgLeft + iconImgWidth / 2 - 100 + 3
272
+
273
+ if (this.alignArrow === 'center') {
274
+ return `${textOverlayLeft}px`
275
+ } else if (this.alignArrow === 'left') {
276
+ return `${textOverlayLeft + TEXT_OVERLAY_ARROW_LEFT_OFFSET}px`
277
+ }
278
+
279
+ return `${textOverlayLeft - TEXT_OVERLAY_ARROW_RIGHT_NEGATIVE_OFFSET}px`
280
+ },
281
+ getTeleportPosition() {
282
+ this.position.top = this.getTextOverlayTop()
283
+ this.position.left = this.getTextOverlayLeft()
284
+ },
188
285
  },
189
286
  }
190
287
  </script>
@@ -28,14 +28,11 @@
28
28
  v-bind="$attrs"
29
29
  ref="inputField1"
30
30
  :align-items="alignItems"
31
- :background-color="
32
- colorMode === 'transparent' ? 'transparent' : backgroundColor
33
- "
34
- :border-color="colorMode === 'transparent' ? 'white' : borderColor"
35
- :color-mode="colorMode"
31
+ :background-color="backgroundColor"
32
+ :border-color="borderColor"
36
33
  :data-id="inputDataId"
37
34
  :disabled="disabled"
38
- :font-color="colorMode === 'transparent' ? 'white' : fontColor"
35
+ :font-color="fontColor"
39
36
  :font-size="fontSize"
40
37
  :has-label-slot="hasLabelSlot"
41
38
  :has-slot="hasSlot"
@@ -54,8 +51,6 @@
54
51
  @blur="onInputBlur($event)"
55
52
  @focus="focusInput()"
56
53
  @input="onInput($event)"
57
- @keydown.down="decrementValue"
58
- @keydown.up="incrementValue"
59
54
  @keyup.enter="onEnterPress"
60
55
  />
61
56
  <SlotContainer v-if="hasSlot" :is-error="isError" :slot-size="slotSize">
@@ -97,31 +92,6 @@
97
92
  </template>
98
93
  </RCSelect>
99
94
  </SelectWrapper>
100
-
101
- <ArrowControls
102
- v-if="!disabled && showArrowControls"
103
- :color-mode="colorMode"
104
- >
105
- <ArrowButton @click="incrementValue">
106
- <Icon
107
- :color="colorMode === 'transparent' ? 'white' : undefined"
108
- name="arrow_up"
109
- size="8px"
110
- />
111
- </ArrowButton>
112
- <ArrowDivider :color-mode="colorMode" />
113
- <ArrowButton
114
- :is-disabled="textInput <= minNumber"
115
- @click="decrementValue"
116
- >
117
- <Icon
118
- :color="colorMode === 'transparent' ? 'white' : undefined"
119
- :disabled="textInput <= minNumber"
120
- name="arrow_down"
121
- size="8px"
122
- />
123
- </ArrowButton>
124
- </ArrowControls>
125
95
  </InputWrapper>
126
96
  <ErrorMessage v-if="isError">{{ errorMessage }}</ErrorMessage>
127
97
  </Container>
@@ -153,7 +123,6 @@
153
123
  // labelInfoAlign="left"
154
124
  // :minNumber="0"
155
125
  // fontColor="blue"
156
- // colorMode="transparent" // Makes background transparent, border white, and font white
157
126
  // >
158
127
  //<template name=label><img>....</template>
159
128
  //</inputNumber>
@@ -189,7 +158,6 @@
189
158
  labelFontColor: String,
190
159
  borderColor: String,
191
160
  showLinearUnitName: Boolean,
192
- colorMode: String,
193
161
  }
194
162
 
195
163
  const Container = styled('div', inputProps)`
@@ -213,18 +181,15 @@
213
181
  : '1px solid ' + props.theme.colors.grey4};
214
182
  height: ${(props) => props.inputHeight};
215
183
  max-height: ${(props) => props.inputHeight};
216
- padding: ${({ colorMode }) =>
217
- colorMode === 'transparent' ? '10px 15px' : '0 10px'};
218
- padding-right: ${({ slotSize, isError, showLinearUnitName, colorMode }) =>
219
- colorMode === 'transparent'
220
- ? '0'
221
- : slotSize
184
+ padding: 0 10px;
185
+ padding-right: ${({ slotSize, isError, showLinearUnitName }) =>
186
+ slotSize
222
187
  ? isError && !showLinearUnitName
223
188
  ? 'calc(' + slotSize + ' + 24px)'
224
189
  : 'calc(' + slotSize + ' + 10px)'
225
190
  : isError && !showLinearUnitName
226
191
  ? '24px'
227
- : '40px'};
192
+ : '5px'};
228
193
  border-radius: ${(props) =>
229
194
  props.isInteractive && props.alignItems != 'vertical'
230
195
  ? '0 4px 4px 0'
@@ -248,7 +213,7 @@
248
213
  props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
249
214
  min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
250
215
  background-color: ${(props) =>
251
- props.isDisabled ? props.theme.colors.grey5 : props.theme.colors.white};
216
+ props.isDisabled ? props.theme.colors.grey5 : '#fff'};
252
217
  box-sizing: border-box;
253
218
 
254
219
  &::placeholder {
@@ -260,55 +225,6 @@
260
225
  }
261
226
  `
262
227
 
263
- const ArrowControlsProps = {
264
- colorMode: String,
265
- }
266
- const ArrowControls = styled('div', ArrowControlsProps)`
267
- position: absolute;
268
- right: 0;
269
- top: 0;
270
- bottom: 0;
271
- display: grid;
272
- grid-template-rows: 1fr auto 1fr;
273
- align-items: center;
274
- justify-items: center;
275
- cursor: pointer;
276
- width: 30px;
277
- background-color: ${(props) =>
278
- props.colorMode === 'transparent'
279
- ? 'transparent'
280
- : props.theme.colors.white};
281
- border-left: 1px solid
282
- ${(props) =>
283
- props.colorMode === 'transparent'
284
- ? props.theme.colors.white
285
- : props.theme.colors.black};
286
- `
287
-
288
- const ArrowButtonProps = {
289
- isDisabled: Boolean,
290
- }
291
- const ArrowButton = styled('button', ArrowButtonProps)`
292
- background: ${(props) =>
293
- props.isDisabled ? props.theme.colors.disabled : 'transparent'};
294
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
295
- display: flex;
296
- align-items: center;
297
- justify-content: center;
298
- padding: 0;
299
- width: 100%;
300
- height: 100%;
301
- `
302
-
303
- const ArrowDivider = styled('div', ArrowControlsProps)`
304
- width: 100%;
305
- height: 1px;
306
- background-color: ${(props) =>
307
- props.colorMode === 'transparent'
308
- ? props.theme.colors.white
309
- : props.theme.colors.black};
310
- `
311
-
312
228
  const InputWrapper = styled.span`
313
229
  position: relative;
314
230
  `
@@ -443,179 +359,140 @@
443
359
  SelectWrapper,
444
360
  SelectText,
445
361
  Divider,
446
- ArrowControls,
447
- ArrowButton,
448
- ArrowDivider,
449
362
  },
450
363
  inheritAttrs: false,
451
364
  props: {
452
365
  placeholder: {
453
- type: String,
454
366
  required: false,
455
367
  default: '',
456
368
  },
457
369
  isError: {
458
- type: Boolean,
459
370
  required: false,
460
371
  default: false,
461
372
  },
462
373
  inputWidth: {
463
- type: String,
464
374
  required: false,
465
375
  default: null,
466
376
  },
467
377
  minWidth: {
468
- type: String,
469
378
  required: false,
470
379
  default: null,
471
380
  },
472
381
  inputHeight: {
473
- type: String,
474
382
  required: false,
475
383
  default: '40px',
476
384
  },
477
385
  value: {
478
- type: [String, Number],
479
386
  required: true,
480
387
  default: null,
481
388
  },
482
389
  clearInput: {
483
- type: Boolean,
484
390
  required: false,
485
391
  default: false,
486
392
  },
487
393
  alignItems: {
488
- type: String,
489
394
  required: false,
490
395
  default: 'vertical',
491
396
  },
492
397
  errorMessage: {
493
- type: String,
494
398
  required: false,
495
399
  default: 'Please insert a correct number',
496
400
  },
497
401
  numberPrecision: {
498
- type: Number,
499
402
  required: false,
500
403
  default: 0,
501
404
  },
502
405
  minDecimals: {
503
- type: Number,
504
406
  required: false,
505
407
  default: 0,
506
408
  },
507
409
  unitName: {
508
- type: String,
509
410
  required: false,
510
411
  default: '',
511
412
  },
512
413
  showLinearUnitName: {
513
- type: Boolean,
514
414
  required: false,
515
415
  default: false,
516
416
  },
517
417
  disabled: {
518
- type: Boolean,
519
418
  required: false,
520
419
  default: false,
521
420
  },
522
421
  noBorder: {
523
- type: Boolean,
524
422
  required: false,
525
423
  default: false,
526
424
  },
527
425
  borderColor: {
528
- type: String,
529
426
  required: false,
530
- default: null,
531
427
  },
532
428
  textAlign: {
533
- type: String,
534
429
  required: false,
535
430
  default: 'left',
536
431
  },
537
432
  fontSize: {
538
- type: String,
539
433
  required: false,
540
434
  default: '13px',
541
435
  },
542
436
  isInteractive: {
543
- type: Boolean,
544
437
  required: false,
545
438
  default: false,
546
439
  },
547
440
  interactionStep: {
548
- type: Number,
549
441
  required: false,
550
442
  default: 1,
551
443
  },
552
444
  labelText: {
553
- type: String,
554
445
  required: false,
555
446
  default: null,
556
447
  },
557
448
  labelInfoText: {
558
- type: String,
559
449
  required: false,
560
450
  default: null,
561
451
  },
562
452
  labelInfoAlign: {
563
- type: String,
564
453
  required: false,
565
454
  default: 'left',
566
455
  },
567
456
  defaultNumber: {
568
- type: Number,
569
457
  required: false,
570
458
  default: null,
571
459
  },
572
460
  minNumber: {
573
- type: Number,
574
461
  required: false,
575
462
  default: null,
576
463
  },
577
464
  fontColor: {
578
- type: String,
579
465
  required: false,
580
466
  default: null,
581
467
  },
582
468
  backgroundColor: {
583
- type: String,
584
469
  required: false,
585
470
  default: null,
586
471
  },
587
472
  numberToStringEnabled: {
588
- type: Boolean,
589
473
  required: false,
590
474
  default: true,
591
475
  },
592
476
  allowNegative: {
593
- type: Boolean,
594
477
  required: false,
595
478
  default: true,
596
479
  },
597
480
  slotSize: {
598
- type: String,
599
481
  required: false,
600
- default: null,
601
482
  },
602
483
  labelFontColor: {
603
- type: String,
604
484
  required: false,
605
485
  default: 'eturnityGrey',
606
486
  },
607
487
  focus: {
608
- type: Boolean,
609
488
  required: false,
610
489
  default: false,
611
490
  },
612
491
  labelDataId: {
613
- type: String,
614
492
  required: false,
615
493
  default: '',
616
494
  },
617
495
  inputDataId: {
618
- type: String,
619
496
  required: false,
620
497
  default: '',
621
498
  },
@@ -639,14 +516,6 @@
639
516
  type: Boolean,
640
517
  default: false,
641
518
  },
642
- colorMode: {
643
- type: String,
644
- default: '',
645
- },
646
- showArrowControls: {
647
- type: Boolean,
648
- default: false,
649
- },
650
519
  },
651
520
  data() {
652
521
  return {
@@ -716,36 +585,6 @@
716
585
  }
717
586
  },
718
587
  methods: {
719
- incrementValue() {
720
- const currentValue = Math.max(
721
- parseFloat(this.textInput || 0),
722
- this.minNumber || 0
723
- )
724
- const newValue = currentValue + this.interactionStep
725
- this.textInput = numberToString({
726
- value: newValue,
727
- numberPrecision: this.numberPrecision,
728
- minDecimals: this.minDecimals,
729
- })
730
- this.$emit('on-input', newValue)
731
- this.$emit('input-change', newValue)
732
- },
733
- decrementValue() {
734
- const currentValue = Math.max(
735
- parseFloat(this.textInput || 0),
736
- this.minNumber || 0
737
- )
738
- const newValue = currentValue - this.interactionStep
739
- if (this.allowNegative || newValue >= 0) {
740
- this.textInput = numberToString({
741
- value: newValue,
742
- numberPrecision: this.numberPrecision,
743
- minDecimals: this.minDecimals,
744
- })
745
- this.$emit('on-input', newValue)
746
- this.$emit('input-change', newValue)
747
- }
748
- },
749
588
  onEnterPress() {
750
589
  this.$emit('on-enter-click')
751
590
  this.$refs.inputField1.$el.blur()
@@ -841,7 +680,6 @@
841
680
  this.$emit('on-input', evaluatedVal)
842
681
  }
843
682
  }
844
- this.textInput = evaluatedVal
845
683
  },
846
684
  onInputBlur(e) {
847
685
  this.isFocused = false