@eturnity/eturnity_reusable_components 7.48.1-EPDM-10964.0 → 7.48.1-dev-14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.48.1-EPDM-10964.0",
3
+ "version": "7.48.1-dev-14.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -12,6 +12,7 @@ const theme = {
12
12
  white: '#ffffff',
13
13
  blue: '#48a2d0',
14
14
  red: '#ff5656',
15
+ pureRed: '#ff0000',
15
16
  blue1: '#e4efff',
16
17
  brightBlue: '#0068DE',
17
18
  grey1: '#666',
@@ -0,0 +1,170 @@
1
+ import defaultInfoCardProps from './defaultProps'
2
+ import InfoCard from './index.vue'
3
+ import theme from '@/assets/theme'
4
+
5
+ export default {
6
+ title: 'InfoCard',
7
+ component: InfoCard,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ type: {
11
+ description: 'Defines preset styles',
12
+ control: 'select',
13
+ options: ['info', 'warning'],
14
+ },
15
+ minWidth: {
16
+ description: '',
17
+ },
18
+ color: {
19
+ description: 'Color of the text (can overwrite preset styles)',
20
+ control: {
21
+ type: 'color',
22
+ presetColors: [
23
+ theme.colors.grey3,
24
+ theme.colors.grey4,
25
+ theme.colors.red,
26
+ ],
27
+ },
28
+ },
29
+ iconColor: {
30
+ description: 'Color of the icon (can overwrite preset styles)',
31
+ control: {
32
+ type: 'color',
33
+ presetColors: [
34
+ theme.colors.grey3,
35
+ theme.colors.grey4,
36
+ theme.colors.red,
37
+ ],
38
+ },
39
+ },
40
+ alignItems: {
41
+ description: 'Icon and text alignment (can overwrite preset styles)',
42
+ control: 'select',
43
+ options: ['flex-start', 'flex-end', 'center'],
44
+ },
45
+ padding: {
46
+ description: 'Info card padding (can overwrite preset styles)',
47
+ },
48
+ borderColor: {
49
+ description: 'Info card border color (can overwrite preset styles)',
50
+ control: {
51
+ type: 'color',
52
+ presetColors: [
53
+ theme.colors.grey3,
54
+ theme.colors.grey4,
55
+ theme.colors.red,
56
+ ],
57
+ },
58
+ },
59
+ borderStyle: {
60
+ description: 'Info card border style (can overwrite preset styles)',
61
+ control: 'select',
62
+ options: ['dashed', 'dotted', 'inset', 'dashed solid', 'none'],
63
+ },
64
+
65
+ // info card content slot
66
+ default: {
67
+ description: 'Info card slot content',
68
+ },
69
+ },
70
+ }
71
+
72
+ // To use:
73
+ // <InfoCard
74
+ // type="warning"
75
+ // min-width="auto'
76
+ // color="red"
77
+ // align-items="center"
78
+ // padding="100px"
79
+ // border-color="red"
80
+ // border-style="solid"
81
+ // >
82
+ // Some Text
83
+ // </InfoCard>
84
+ // all props after "min-width" are used to overwrite the preset styles set by "type"
85
+
86
+ const Template = (args) => {
87
+ return {
88
+ components: { InfoCard },
89
+ setup() {
90
+ return { args }
91
+ },
92
+ template: `
93
+ <InfoCard v-bind="args">
94
+ {{ args.default }}
95
+ </InfoCard>
96
+ `,
97
+ }
98
+ }
99
+
100
+ export const Default = Template.bind({})
101
+ Default.args = {
102
+ ...defaultInfoCardProps,
103
+ }
104
+
105
+ export const InfoCardTypeWarning = Template.bind({})
106
+ InfoCardTypeWarning.args = {
107
+ ...defaultInfoCardProps,
108
+ type: 'warning',
109
+ }
110
+
111
+ export const InfoCardTypeErrorMinor = Template.bind({})
112
+ InfoCardTypeErrorMinor.args = {
113
+ ...defaultInfoCardProps,
114
+ type: 'error_minor',
115
+ }
116
+
117
+ export const InfoCardTypeInfoMinWidth = Template.bind({})
118
+ InfoCardTypeInfoMinWidth.args = {
119
+ ...defaultInfoCardProps,
120
+
121
+ minWidth: '250px',
122
+ }
123
+
124
+ export const InfoCardTypeInfoColorOverwritten = Template.bind({})
125
+ InfoCardTypeInfoColorOverwritten.args = {
126
+ ...defaultInfoCardProps,
127
+
128
+ color: theme.colors.green,
129
+ }
130
+
131
+ export const InfoCardTypeInfoIconColorOverwritten = Template.bind({})
132
+ InfoCardTypeInfoIconColorOverwritten.args = {
133
+ ...defaultInfoCardProps,
134
+
135
+ iconColor: theme.colors.green,
136
+ }
137
+
138
+ export const InfoCardTypeWarningAlignItemsOverwritten = Template.bind({})
139
+ InfoCardTypeWarningAlignItemsOverwritten.args = {
140
+ ...defaultInfoCardProps,
141
+ type: 'warning',
142
+ default:
143
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
144
+
145
+ alignItems: 'center',
146
+ }
147
+
148
+ export const InfoCardTypeWarningPaddingOverwritten = Template.bind({})
149
+ InfoCardTypeWarningPaddingOverwritten.args = {
150
+ ...defaultInfoCardProps,
151
+ type: 'warning',
152
+
153
+ padding: '50px',
154
+ }
155
+
156
+ export const InfoCardTypeErrorMinorBorderColorOverwritten = Template.bind({})
157
+ InfoCardTypeErrorMinorBorderColorOverwritten.args = {
158
+ ...defaultInfoCardProps,
159
+ type: 'error_minor',
160
+
161
+ borderColor: theme.colors.green,
162
+ }
163
+
164
+ export const InfoCardTypeErrorMinorBorderStyleOverwritten = Template.bind({})
165
+ InfoCardTypeErrorMinorBorderStyleOverwritten.args = {
166
+ ...defaultInfoCardProps,
167
+ type: 'error_minor',
168
+
169
+ borderStyle: 'solid none',
170
+ }
@@ -0,0 +1,7 @@
1
+ const defaultInfoCardProps = {
2
+ // info card content slot
3
+ default:
4
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
5
+ }
6
+
7
+ export default defaultInfoCardProps
@@ -1,11 +1,21 @@
1
1
  <template>
2
2
  <InfoContainer
3
- background-color="backgrounColor"
3
+ :align-items="alignItems"
4
4
  :border-color="borderColor"
5
- :has-dashed-border="hasDashedBorder"
5
+ :border-style="borderStyle"
6
+ :color="color"
7
+ data-test-id="info_card_wrapper"
8
+ :min-width="minWidth"
9
+ :padding="padding"
10
+ :preset-styles="presetStyles"
6
11
  >
7
- <RCIcon :color="color" name="info" size="24px" />
8
- <TextContainer>
12
+ <RCIcon
13
+ :color="iconColor ? iconColor : presetStyles.iconColor"
14
+ data-test-id="info_card_icon"
15
+ name="info"
16
+ size="24px"
17
+ />
18
+ <TextContainer data-test-id="info_card_text_container">
9
19
  <slot></slot>
10
20
  </TextContainer>
11
21
  </InfoContainer>
@@ -13,26 +23,37 @@
13
23
 
14
24
  <script>
15
25
  import styled from 'vue3-styled-components'
26
+ import theme from '../../assets/theme.js'
16
27
  import RCIcon from '../icon'
17
- const propsContainer = {
18
- backgroundColor: String,
19
- hasDashedBorder: Boolean,
28
+
29
+ const infoContainerAttrs = {
30
+ minWidth: String,
31
+ color: String,
32
+ alignItems: String,
33
+ padding: String,
20
34
  borderColor: String,
35
+ borderStyle: String,
36
+ presetStyles: Object,
21
37
  }
22
- const InfoContainer = styled('div', propsContainer)`
38
+ const InfoContainer = styled('div', infoContainerAttrs)`
23
39
  display: flex;
40
+ align-items: ${(props) =>
41
+ props.alignItems ? props.alignItems : props.presetStyles.alignItems};
24
42
  gap: 15px;
25
- padding: 15px;
26
- border: 1px ${(props) => (props.hasDashedBorder ? 'dashed' : 'solid')}
27
- ${(props) =>
28
- props.theme.colors[props.borderColor]
29
- ? props.theme.colors[props.borderColor]
30
- : props.borderColor};
31
- background-color: ${(props) =>
32
- props.theme.colors[props.backgroundColor]
33
- ? props.theme.colors[props.backgroundColor]
34
- : props.backgroundColor};
43
+ min-width: ${(props) => props.minWidth};
44
+ padding: ${(props) =>
45
+ props.padding ? props.padding : props.presetStyles.padding};
46
+ color: ${(props) => (props.color ? props.color : props.presetStyles.color)};
35
47
  border-radius: 4px;
48
+ background-color: ${(props) =>
49
+ props.backgroundColor
50
+ ? props.backgroundColor
51
+ : props.presetStyles.backgroundColor};
52
+ border-width: ${(props) => props.presetStyles.borderWidth};
53
+ border-style: ${(props) =>
54
+ props.borderStyle ? props.borderStyle : props.presetStyles.borderStyle};
55
+ border-color: ${(props) =>
56
+ props.borderColor ? props.borderColor : props.presetStyles.borderColor};
36
57
  `
37
58
 
38
59
  const TextContainer = styled.div`
@@ -48,19 +69,83 @@
48
69
  TextContainer,
49
70
  },
50
71
  props: {
72
+ type: {
73
+ required: false,
74
+ type: String,
75
+ default: 'info',
76
+ },
77
+ minWidth: {
78
+ required: false,
79
+ type: String,
80
+ default: '',
81
+ },
82
+ iconColor: {
83
+ required: false,
84
+ type: String,
85
+ default: '',
86
+ },
51
87
  color: {
52
88
  required: false,
89
+ type: String,
90
+ default: '',
53
91
  },
54
- backgrounColor: {
92
+ alignItems: {
55
93
  required: false,
94
+ type: String,
95
+ default: '',
56
96
  },
57
- hasDashedBorder: {
97
+ padding: {
58
98
  required: false,
59
- default: true,
99
+ type: String,
100
+ default: '',
60
101
  },
61
102
  borderColor: {
62
103
  required: false,
63
- default: 'grey4',
104
+ type: String,
105
+ default: '',
106
+ },
107
+ borderStyle: {
108
+ required: false,
109
+ type: String,
110
+ default: '',
111
+ },
112
+ },
113
+ computed: {
114
+ isInfo() {
115
+ // this property is used for tests
116
+ return this.type === 'info'
117
+ },
118
+ isWarning() {
119
+ return this.type === 'warning'
120
+ },
121
+ isErrorMinor() {
122
+ return this.type === 'error_minor'
123
+ },
124
+ presetStyles() {
125
+ // the types that doesn't have explicit border anyway have it transparent
126
+ // to avoid flickering in case the same info card would switch the types
127
+ let stylesCollection = {
128
+ alignItems: 'flex-start',
129
+ padding: '20px',
130
+ borderWidth: '1px',
131
+ borderStyle: 'solid',
132
+ borderColor: 'transparent',
133
+ }
134
+
135
+ if (this.isWarning) {
136
+ stylesCollection.color = theme.colors.white
137
+ stylesCollection.backgroundColor = theme.colors.yellow
138
+ stylesCollection.iconColor = theme.colors.white
139
+ } else if (this.isErrorMinor) {
140
+ stylesCollection.borderStyle = 'dashed'
141
+ stylesCollection.borderColor = theme.colors.pureRed
142
+ stylesCollection.iconColor = theme.colors.pureRed
143
+ } else {
144
+ stylesCollection.borderStyle = 'dashed'
145
+ stylesCollection.borderColor = theme.colors.grey4
146
+ }
147
+
148
+ return stylesCollection
64
149
  },
65
150
  },
66
151
  }
@@ -0,0 +1,64 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import RCInfoCard from '@/components/infoCard'
3
+ import RCIcon from '@/components/icon'
4
+ import defaultInfoCardProps from './defaultProps'
5
+ import theme from '@/assets/theme'
6
+
7
+ jest.mock('@/components/icon/iconCache.mjs', () => ({
8
+ // need to mock this due to how jest handles import.meta
9
+ fetchIcon: jest.fn(() => Promise.resolve('mocked-icon-url.svg')),
10
+ }))
11
+
12
+ describe('RCInfoCard.vue', () => {
13
+ it('info card is rendered with icon and correct text', async () => {
14
+ const wrapper = mount(RCInfoCard, {
15
+ props: { ...defaultInfoCardProps },
16
+ slots: {
17
+ default: defaultInfoCardProps.default,
18
+ },
19
+ global: {
20
+ provide: {
21
+ theme,
22
+ },
23
+ },
24
+ })
25
+
26
+ const iconComponent = wrapper.findComponent(RCIcon)
27
+ const infoCardText = wrapper.find(
28
+ '[data-test-id="info_card_text_container"]'
29
+ )
30
+
31
+ expect(iconComponent.exists()).toBe(true)
32
+ expect(infoCardText.exists()).toBe(true)
33
+ expect(infoCardText.text()).toContain(defaultInfoCardProps.default)
34
+ }),
35
+ it('info card rendered with type info have correct computed values', async () => {
36
+ const wrapper = mount(RCInfoCard, {
37
+ props: { ...defaultInfoCardProps },
38
+ slots: {
39
+ default: defaultInfoCardProps.default,
40
+ },
41
+ global: {
42
+ provide: {
43
+ theme,
44
+ },
45
+ },
46
+ })
47
+
48
+ expect(wrapper.vm.isInfo).toBe(true)
49
+ expect(wrapper.vm.isWarning).toBe(false)
50
+ expect(wrapper.vm.isErrorMinor).toBe(false)
51
+
52
+ await wrapper.setProps({ type: 'warning' })
53
+
54
+ expect(wrapper.vm.isInfo).toBe(false)
55
+ expect(wrapper.vm.isWarning).toBe(true)
56
+ expect(wrapper.vm.isErrorMinor).toBe(false)
57
+
58
+ await wrapper.setProps({ type: 'error_minor' })
59
+
60
+ expect(wrapper.vm.isInfo).toBe(false)
61
+ expect(wrapper.vm.isWarning).toBe(false)
62
+ expect(wrapper.vm.isErrorMinor).toBe(true)
63
+ })
64
+ })
@@ -1,6 +1,4 @@
1
1
  const defaultRadioButtonProps = {
2
- dataId: 'radio_buttons',
3
- name: 'options',
4
2
  options: [
5
3
  {
6
4
  label: 'Option 1',
@@ -86,6 +86,7 @@
86
86
  />
87
87
  <Selector
88
88
  v-else
89
+ :disabled="disabled"
89
90
  :padding-left="paddingLeft"
90
91
  :select-width="selectWidth"
91
92
  :show-border="showBorder"
@@ -96,7 +97,9 @@
96
97
  <Icon
97
98
  v-if="isDropdownOpen"
98
99
  :color="
99
- caretColor || colorMode == 'dark'
100
+ caretColor || disabled
101
+ ? 'grey2'
102
+ : colorMode == 'dark'
100
103
  ? 'white'
101
104
  : 'transparentBlack1'
102
105
  "
@@ -106,7 +109,9 @@
106
109
  <Icon
107
110
  v-else
108
111
  :color="
109
- caretColor || colorMode == 'dark'
112
+ caretColor || disabled
113
+ ? 'grey2'
114
+ : colorMode == 'dark'
110
115
  ? 'white'
111
116
  : 'transparentBlack1'
112
117
  "
@@ -199,11 +204,13 @@
199
204
  `
200
205
 
201
206
  const selectorProps = {
207
+ disabled: Boolean,
202
208
  selectWidth: String,
203
209
  paddingLeft: String,
204
210
  showBorder: Boolean,
205
211
  }
206
212
  const Selector = styled('div', selectorProps)`
213
+ color: ${(props) => (props.disabled ? props.theme.colors.grey2 : '')};
207
214
  ${(props) =>
208
215
  props.selectWidth === '100%'
209
216
  ? 'width: 100%;'
@@ -535,6 +542,7 @@
535
542
  },
536
543
  disabled: {
537
544
  required: false,
545
+ type: Boolean,
538
546
  default: false,
539
547
  },
540
548
  isAutoSearch: {
@@ -5,7 +5,7 @@
5
5
  :is-open="isOpen"
6
6
  :position="position"
7
7
  >
8
- <ModalContainer @click="onClickModalContainer">
8
+ <ModalContainer :overflow="overflowRule" @click="onClickModalContainer">
9
9
  <Spinner v-if="isLoading" :limited-to-modal="true" size="50px" />
10
10
  <ContentContainer :visible="!isLoading">
11
11
  <slot></slot>
@@ -67,7 +67,8 @@
67
67
  }
68
68
  `
69
69
 
70
- const ModalContainer = styled.div`
70
+ const modalContainerAttrs = { overflow: String }
71
+ const ModalContainer = styled('div', modalContainerAttrs)`
71
72
  align-self: center;
72
73
  justify-self: center;
73
74
  position: relative;
@@ -75,7 +76,7 @@
75
76
  border-radius: 4px;
76
77
  background: white;
77
78
  margin: 0 auto;
78
- overflow: auto;
79
+ overflow: ${(props) => props.overflow};
79
80
  max-width: 95%;
80
81
  max-height: 95%;
81
82
  min-width: 100px;
@@ -152,6 +153,11 @@
152
153
  type: Boolean,
153
154
  default: true,
154
155
  },
156
+ overflowRule: {
157
+ required: false,
158
+ type: String,
159
+ default: 'auto',
160
+ },
155
161
  },
156
162
  watch: {
157
163
  isOpen: {
@@ -254,9 +254,6 @@
254
254
  activeDropdown: null,
255
255
  }
256
256
  },
257
- mounted() {
258
- this.activeDropdown = this.activeParentTab
259
- },
260
257
  methods: {
261
258
  toggleActiveDropdown(value) {
262
259
  if (this.activeDropdown === value) {
@@ -266,5 +263,17 @@
266
263
  }
267
264
  },
268
265
  },
266
+ watch: {
267
+ activeTab: {
268
+ // once active tab is received, check if any parent
269
+ // tab is active and if so open according dropdown
270
+ handler() {
271
+ if (this.activeParentTab) {
272
+ this.activeDropdown = this.activeParentTab
273
+ }
274
+ },
275
+ once: true,
276
+ },
277
+ },
269
278
  }
270
279
  </script>