@eturnity/eturnity_reusable_components 8.19.8-EPDM-14690.3 → 8.19.8-EPDM-13664.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.
@@ -0,0 +1,16 @@
1
+ export default {
2
+ text: 'default text',
3
+ size: '14px',
4
+ infoPosition: 'bottom',
5
+ alignArrow: 'center',
6
+ openTrigger: 'onHover',
7
+ width: '165px',
8
+ maxWidth: '165px',
9
+ shouldUseTeleport: false,
10
+ dotColor: '#00009f',
11
+ type: 'info',
12
+ iconTextContent: {
13
+ iconName: 'error',
14
+ text: 'Sample Text',
15
+ },
16
+ }
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <PageContainer
3
3
  ref="container"
4
+ data-test-id="infoText_container"
4
5
  :type="type"
5
6
  @click=";(isMobile || openTrigger === 'onClick') && toggleInfo()"
6
7
  @mouseenter="!isMobile && openTrigger === 'onHover' && showInfo()"
@@ -15,40 +16,37 @@
15
16
  :is-disabled="isDisabled"
16
17
  :padding="padding"
17
18
  >
18
- <template v-if="!$slots.trigger">
19
- <LabelWrapper
20
- v-if="labelText && labelAlign === 'left'"
21
- :color="iconColor || computedIconColor"
22
- :size="labelSize"
23
- >
24
- {{ labelText }}
25
- </LabelWrapper>
26
- <Dot
27
- v-if="type === 'dot'"
28
- :color="dotColor"
29
- data-test-id="infoText_dot"
30
- />
31
- <IconComponent
32
- v-else-if="!noIcon"
33
- :color="iconColor || computedIconColor"
34
- :cursor="isDisabled ? 'not-allowed' : 'pointer'"
35
- :disabled="isDisabled"
36
- :hovered-color="iconColor || computedIconColor"
37
- :name="iconName"
38
- :size="size"
39
- />
40
- <LabelWrapper
41
- v-if="labelText && labelAlign === 'right'"
42
- :color="iconColor || computedIconColor"
43
- :size="labelSize"
44
- >
45
- {{ labelText }}
46
- </LabelWrapper>
47
- </template>
48
- <slot name="trigger"></slot>
19
+ <LabelWrapper
20
+ v-if="labelText && labelAlign === 'left'"
21
+ :color="iconColor || computedIconColor"
22
+ :size="labelSize"
23
+ >
24
+ {{ labelText }}
25
+ </LabelWrapper>
26
+ <Dot
27
+ v-if="type === 'dot'"
28
+ :color="dotColor"
29
+ data-test-id="infoText_dot"
30
+ />
31
+ <IconComponent
32
+ v-else-if="!noIcon"
33
+ :color="iconColor || computedIconColor"
34
+ :cursor="isDisabled ? 'not-allowed' : 'pointer'"
35
+ :disabled="isDisabled"
36
+ :hovered-color="iconColor || computedIconColor"
37
+ :name="iconName"
38
+ :size="size"
39
+ />
40
+ <LabelWrapper
41
+ v-if="labelText && labelAlign === 'right'"
42
+ :color="iconColor || computedIconColor"
43
+ :size="labelSize"
44
+ >
45
+ {{ labelText }}
46
+ </LabelWrapper>
49
47
  </IconWrapper>
50
48
  </div>
51
- <Teleport v-if="isVisible && !!text" to="body">
49
+ <Teleport v-if="isVisible" to="body">
52
50
  <TextWrapper data-test-id="info_text_wrapper" :style="wrapperStyle">
53
51
  <TextOverlay
54
52
  ref="infoBox"
@@ -230,7 +228,7 @@
230
228
  },
231
229
  infoPosition: {
232
230
  required: false,
233
- default: null,
231
+ default: 'bottom',
234
232
  type: String,
235
233
  },
236
234
  maxWidth: {
@@ -290,6 +288,11 @@
290
288
  default: '',
291
289
  required: false,
292
290
  },
291
+ contentBackgroundColor: {
292
+ type: String,
293
+ default: '',
294
+ required: false,
295
+ },
293
296
  borderRadius: {
294
297
  type: String,
295
298
  default: '',
@@ -366,9 +369,7 @@
366
369
  { position: 'left', space: spaceLeft },
367
370
  ].sort((a, b) => b.space - a.space)
368
371
 
369
- const bestPosition = props.infoPosition
370
- ? props.infoPosition
371
- : positions[0].position
372
+ const bestPosition = positions[0].position
372
373
 
373
374
  let top, left, arrowPosition
374
375
 
@@ -471,7 +472,9 @@
471
472
  width: '100%',
472
473
  maxWidth: props.maxWidth,
473
474
  overflowY: 'auto',
474
- backgroundColor: props.image
475
+ backgroundColor: props.contentBackgroundColor
476
+ ? props.contentBackgroundColor
477
+ : props.image
475
478
  ? theme.colors.white
476
479
  : props.appTheme === 'light'
477
480
  ? theme.colors.black
@@ -1,7 +1,8 @@
1
1
  /* eslint-disable */
2
2
  import { mount } from '@vue/test-utils'
3
3
  import InfoText from '@/components/infoText'
4
- import theme from '@/assets/theme'
4
+ import defaultProps from './defaultProps'
5
+ import IconTextContent from './templates/iconTextContent.vue'
5
6
 
6
7
  jest.mock('@/components/icon/iconCache.mjs', () => ({
7
8
  // need to mock this due to how jest handles import.meta
@@ -13,31 +14,19 @@ describe('InfoText Component', () => {
13
14
 
14
15
  beforeEach(() => {
15
16
  wrapper = mount(InfoText, {
16
- props: {
17
- text: 'default text',
18
- size: '14px',
19
- infoPosition: 'bottom',
20
- alignArrow: 'center',
21
- openTrigger: 'onHover',
22
- width: '165px',
23
- maxWidth: '165px',
24
- shouldUseTeleport: false,
25
- dotColor: '#00009f',
26
- type: 'info',
27
- },
17
+ props: defaultProps,
28
18
  global: {
29
- provide: {
30
- theme,
31
- },
32
19
  stubs: {
33
- teleport: true
34
- }
20
+ teleport: true,
21
+ },
35
22
  },
36
23
  })
37
24
  })
38
25
 
39
26
  test('renders InfoText component with default props', () => {
40
- expect(wrapper.find('[data-test-id="infoText_info"]').exists()).toBe(true)
27
+ expect(wrapper.find('[data-test-id="infoText_container"]').exists()).toBe(
28
+ true
29
+ )
41
30
  expect(wrapper.vm.text).toContain('default text')
42
31
  expect(wrapper.vm.size).toContain('14px')
43
32
  expect(wrapper.vm.infoPosition).toContain('bottom')
@@ -52,7 +41,7 @@ describe('InfoText Component', () => {
52
41
  )
53
42
 
54
43
  //should see text upon click
55
- await wrapper.find('[data-test-id="infoText_trigger"]').trigger('click')
44
+ await wrapper.trigger('click')
56
45
  expect(wrapper.vm.isVisible).toBe(true)
57
46
 
58
47
  expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
@@ -64,4 +53,34 @@ describe('InfoText Component', () => {
64
53
  await wrapper.setProps({ type: 'dot' })
65
54
  expect(wrapper.find('[data-test-id="infoText_dot"]').exists()).toBe(true)
66
55
  })
56
+
57
+ test('iconTextContent slot is correctly rendered', async () => {
58
+ // override
59
+ const props = defaultProps.iconTextContent
60
+ wrapper = mount(InfoText, {
61
+ props: defaultProps,
62
+ slots: {
63
+ default: `<IconTextContent icon-name="${props.iconName}" text="${props.text}" />`,
64
+ },
65
+ global: {
66
+ stubs: {
67
+ teleport: true,
68
+ },
69
+ components: {
70
+ IconTextContent,
71
+ },
72
+ },
73
+ })
74
+
75
+ await wrapper.trigger('mouseenter')
76
+ expect(wrapper.vm.isVisible).toBe(true)
77
+
78
+ const container = wrapper.find('[data-test-id="iconTextContent_container"]')
79
+ const icon = container.find('[data-test-id="iconTextContent_icon"]')
80
+ const text = container.find('[data-test-id="iconTextContent_text"]')
81
+ expect(container.exists()).toBe(true)
82
+ expect(icon.exists()).toBe(true)
83
+ expect(text.exists()).toBe(true)
84
+ expect(text.text()).toBe(props.text)
85
+ })
67
86
  })
@@ -1,4 +1,6 @@
1
+ import theme from '../../assets/theme'
1
2
  import InfoText from './index.vue'
3
+ import IconTextContent from './templates/iconTextContent.vue'
2
4
 
3
5
  export default {
4
6
  title: 'infoText',
@@ -46,3 +48,29 @@ export const OnClick = {
46
48
  openTrigger: 'onClick',
47
49
  },
48
50
  }
51
+
52
+ export const IconTextContentTemplate = {
53
+ args: {
54
+ ...Default.args,
55
+ contentBackgroundColor: 'black',
56
+ iconName: 'warning_triangle',
57
+ iconColor: theme.colors.yellow,
58
+ size: '18px',
59
+ },
60
+ render: (args) => ({
61
+ components: { InfoText, IconTextContent },
62
+ setup() {
63
+ return { args }
64
+ },
65
+ template: `
66
+ <InfoText v-bind="args">
67
+ <IconTextContent
68
+ icon-name="warning_triangle"
69
+ text="This is a sample text with an icon"
70
+ icon-size="${args.size}"
71
+ icon-color="${args.iconColor}"
72
+ />
73
+ </InfoText>
74
+ `,
75
+ }),
76
+ }
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <Container data-test-id="iconTextContent_container">
3
+ <RCIcon
4
+ :color="iconColor"
5
+ data-test-id="iconTextContent_icon"
6
+ :name="iconName"
7
+ :size="iconSize"
8
+ />
9
+ <TextWrapper
10
+ data-test-id="iconTextContent_text"
11
+ :font-color="fontColor"
12
+ :font-size="fontSize"
13
+ >
14
+ {{ text }}
15
+ <slot data-test-id="iconTextContent_slot"></slot>
16
+ </TextWrapper>
17
+ </Container>
18
+ </template>
19
+
20
+ <script>
21
+ // import InfoText from "@eturnity/eturnity_reusable_components/src/components/infoText"
22
+ // import IconTextContent from "@eturnity/eturnity_reusable_components/src/components/infoText/templates/iconTextContent"
23
+ //To use:
24
+ // <InfoText
25
+ // icon-color="red"
26
+ // icon-name="error"
27
+ // size="20px"
28
+ // open-trigger="onClick"
29
+ // >
30
+ // <IconTextContent
31
+ // icon-name="error"
32
+ // text="Text"
33
+ // icon-size="18px"
34
+ // icon-color="red"
35
+ // />
36
+ // </InfoText>
37
+
38
+ import styled from 'vue3-styled-components'
39
+ import theme from '../../../assets/theme.js'
40
+ import RCIcon from '../../icon'
41
+
42
+ const Container = styled('div')`
43
+ display: flex;
44
+ flex-direction: row;
45
+ align-items: flex-start;
46
+ gap: 8px;
47
+ `
48
+
49
+ const TextAttrs = {
50
+ fontSize: String,
51
+ fontColor: String,
52
+ }
53
+ const TextWrapper = styled('div', TextAttrs)`
54
+ font-size: ${(props) => props.fontSize};
55
+ color: ${(props) => props.fontColor};
56
+ overflow: hidden;
57
+ display: flex;
58
+ flex-direction: column;
59
+ align-items: center;
60
+ gap: 8px;
61
+ font-weight: 400;
62
+ line-height: 150%;
63
+ letter-spacing: 0%;
64
+ vertical-align: middle;
65
+ `
66
+
67
+ export default {
68
+ name: 'IconTextContent',
69
+ components: {
70
+ Container,
71
+ TextWrapper,
72
+ RCIcon,
73
+ },
74
+ props: {
75
+ iconName: {
76
+ type: String,
77
+ required: true,
78
+ },
79
+ text: {
80
+ type: String,
81
+ required: true,
82
+ },
83
+ iconSize: {
84
+ type: String,
85
+ required: false,
86
+ default: '18px',
87
+ },
88
+ iconColor: {
89
+ type: String,
90
+ required: false,
91
+ default: '',
92
+ },
93
+ fontSize: {
94
+ type: String,
95
+ required: false,
96
+ default: '11px',
97
+ },
98
+ fontColor: {
99
+ type: String,
100
+ required: false,
101
+ default: theme.colors.white,
102
+ },
103
+ },
104
+ }
105
+ </script>
@@ -30,61 +30,7 @@
30
30
  />
31
31
  </LabelWrapper>
32
32
  <InputWrapper>
33
- <InputInfoText
34
- v-if="!!inputInfoText"
35
- info-position="bottom"
36
- :text="inputInfoText"
37
- >
38
- <template #trigger>
39
- <InputContainer
40
- v-bind="$attrs"
41
- ref="inputField1"
42
- :align-items="alignItems"
43
- :background-color="
44
- colorMode === 'transparent' ? 'transparent' : backgroundColor
45
- "
46
- :border-color="
47
- colorMode === 'transparent' && !borderColor
48
- ? 'white'
49
- : borderColor
50
- "
51
- :color-mode="colorMode"
52
- :data-id="inputDataId"
53
- :data-qa-id="dataQaId"
54
- :disabled="disabled && !isDisabledStyledOnly"
55
- :font-color="colorMode === 'transparent' ? 'white' : fontColor"
56
- :font-size="fontSize"
57
- :has-label-slot="hasLabelSlot"
58
- :has-slot="hasSlot"
59
- :has-unit="unitName && !!unitName.length"
60
- :input-height="inputHeight"
61
- :is-border-error-only="isBorderErrorOnly"
62
- :is-disabled="disabled"
63
- :is-error="isError"
64
- :is-info-border="isInfoBorder"
65
- :is-interactive="isInteractive"
66
- :min-width="minWidth"
67
- :no-border="noBorder"
68
- :placeholder="displayedPlaceholder"
69
- :read-only="isReadOnly"
70
- :readonly="isReadOnly"
71
- :show-arrow-controls="showArrowControls"
72
- :show-linear-unit-name="showLinearUnitName"
73
- :slot-size="slotSize"
74
- :text-align="textAlign"
75
- :value="formatWithCurrency(value)"
76
- @blur="onInputBlur($event)"
77
- @focus="focusInput()"
78
- @input="onInput($event)"
79
- @keydown.down="decrementValue"
80
- @keydown.up="incrementValue"
81
- @keyup.enter="onEnterPress"
82
- />
83
- </template>
84
- </InputInfoText>
85
-
86
33
  <InputContainer
87
- v-else
88
34
  v-bind="$attrs"
89
35
  ref="inputField1"
90
36
  :align-items="alignItems"
@@ -97,23 +43,20 @@
97
43
  :color-mode="colorMode"
98
44
  :data-id="inputDataId"
99
45
  :data-qa-id="dataQaId"
100
- :disabled="disabled && !isDisabledStyledOnly"
46
+ :disabled="disabled"
101
47
  :font-color="colorMode === 'transparent' ? 'white' : fontColor"
102
48
  :font-size="fontSize"
103
49
  :has-label-slot="hasLabelSlot"
104
50
  :has-slot="hasSlot"
105
51
  :has-unit="unitName && !!unitName.length"
106
52
  :input-height="inputHeight"
107
- :is-border-error-only="isBorderErrorOnly"
108
53
  :is-disabled="disabled"
109
54
  :is-error="isError"
110
- :is-info-border="isInfoBorder"
111
55
  :is-interactive="isInteractive"
112
56
  :min-width="minWidth"
113
57
  :no-border="noBorder"
114
58
  :placeholder="displayedPlaceholder"
115
59
  :read-only="isReadOnly"
116
- :readonly="isReadOnly"
117
60
  :show-arrow-controls="showArrowControls"
118
61
  :show-linear-unit-name="showLinearUnitName"
119
62
  :slot-size="slotSize"
@@ -126,7 +69,6 @@
126
69
  @keydown.up="incrementValue"
127
70
  @keyup.enter="onEnterPress"
128
71
  />
129
-
130
72
  <SlotContainer v-if="hasSlot" :is-error="isError" :slot-size="slotSize">
131
73
  <slot></slot>
132
74
  </SlotContainer>
@@ -138,7 +80,7 @@
138
80
  >{{ unitName }}</UnitContainer
139
81
  >
140
82
  <IconWrapper
141
- v-if="isError && !showLinearUnitName && !isBorderErrorOnly"
83
+ v-if="isError && !showLinearUnitName"
142
84
  :margin-right="showSelect ? selectWidth : 0"
143
85
  size="16px"
144
86
  >
@@ -192,9 +134,7 @@
192
134
  </ArrowButton>
193
135
  </ArrowControls>
194
136
  </InputWrapper>
195
- <ErrorMessage v-if="isError && errorMessage">{{
196
- errorMessage
197
- }}</ErrorMessage>
137
+ <ErrorMessage v-if="isError">{{ errorMessage }}</ErrorMessage>
198
138
  </Container>
199
139
  </template>
200
140
 
@@ -265,8 +205,6 @@
265
205
  colorMode: String,
266
206
  showArrowControls: Boolean,
267
207
  readOnly: Boolean,
268
- isBorderErrorOnly: Boolean,
269
- isInfoBorder: Boolean,
270
208
  }
271
209
 
272
210
  const Container = styled('div', inputProps)`
@@ -279,9 +217,7 @@
279
217
 
280
218
  const InputContainer = styled('input', inputProps)`
281
219
  border: ${(props) =>
282
- props.isInfoBorder
283
- ? '1px solid ' + props.theme.semanticColors.blue[500]
284
- : props.isError
220
+ props.isError
285
221
  ? '1px solid ' + props.theme.colors.red
286
222
  : props.noBorder
287
223
  ? 'none'
@@ -300,17 +236,16 @@
300
236
  showLinearUnitName,
301
237
  colorMode,
302
238
  showArrowControls,
303
- isBorderErrorOnly,
304
239
  }) =>
305
240
  showArrowControls
306
241
  ? '40px'
307
242
  : colorMode === 'transparent'
308
243
  ? '0'
309
244
  : slotSize
310
- ? isError && !showLinearUnitName && !isBorderErrorOnly
245
+ ? isError && !showLinearUnitName
311
246
  ? 'calc(' + slotSize + ' + 24px)'
312
247
  : 'calc(' + slotSize + ' + 10px)'
313
- : isError && !showLinearUnitName && !isBorderErrorOnly
248
+ : isError && !showLinearUnitName
314
249
  ? '24px'
315
250
  : '5px'};
316
251
  border-radius: ${(props) =>
@@ -522,10 +457,6 @@
522
457
  background-color: ${({ theme }) => theme.colors.grey4};
523
458
  `
524
459
 
525
- const InputInfoText = styled(InfoText)`
526
- width: 100%;
527
- `
528
-
529
460
  export default {
530
461
  name: 'InputNumber',
531
462
  components: {
@@ -549,7 +480,6 @@
549
480
  ArrowControls,
550
481
  ArrowButton,
551
482
  ArrowDivider,
552
- InputInfoText,
553
483
  },
554
484
  inheritAttrs: false,
555
485
  props: {
@@ -769,22 +699,6 @@
769
699
  type: Boolean,
770
700
  default: false,
771
701
  },
772
- isBorderErrorOnly: {
773
- type: Boolean,
774
- default: false,
775
- },
776
- isInfoBorder: {
777
- type: Boolean,
778
- default: false,
779
- },
780
- inputInfoText: {
781
- type: String,
782
- default: '',
783
- },
784
- isDisabledStyledOnly: {
785
- type: Boolean,
786
- default: false,
787
- },
788
702
  },
789
703
  data() {
790
704
  return {
@@ -46,6 +46,7 @@
46
46
  color: ${(props) => (props.color ? props.color : props.theme.colors.black)};
47
47
  font-weight: 600;
48
48
  font-size: ${(props) => (props.fontSize ? props.fontSize : '20px')};
49
+ text-transform: ${(props) => (props.uppercase ? 'uppercase' : 'none')};
49
50
  `
50
51
 
51
52
  export default {