@eturnity/eturnity_reusable_components 6.48.2 → 6.50.1-EPDM-9012.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.
@@ -1,7 +1,12 @@
1
1
  <template>
2
2
  <component-wrapper :layout="layout">
3
3
  <radio-wrapper v-for="(item, index) in options" :key="item.value">
4
- <label-container :size="size" :isDisabled="item.disabled" :isChecked="selectedOption === item.value" :checkmarkColor="checkmarkColor">
4
+ <label-container
5
+ :size="size"
6
+ :isDisabled="item.disabled"
7
+ :isChecked="selectedOption === item.value"
8
+ :checkmarkColor="checkmarkColor"
9
+ >
5
10
  <radio
6
11
  type="radio"
7
12
  :value="selectedOption"
@@ -9,6 +14,7 @@
9
14
  :name="'radioButtons_' + radioName"
10
15
  :checked="selectedOption === item.value"
11
16
  :disabled="item.disabled"
17
+ :data-id="`radio_button_${dataId}_option_${item.value}`"
12
18
  />
13
19
  <span class="checkmark"></span>
14
20
  <label-text :isDisabled="item.disabled">{{ item.label }}</label-text>
@@ -54,17 +60,17 @@
54
60
  // { label: 'Button 4', value: 'button_4', disabled: true }
55
61
  // ]
56
62
 
57
- import styled from "vue-styled-components"
58
- import Modal from "../../modals/modal"
59
- import InfoText from "../../infoText"
63
+ import styled from 'vue-styled-components'
64
+ import Modal from '../../modals/modal'
65
+ import InfoText from '../../infoText'
60
66
 
61
67
  const wrapperProps = {
62
- layout: String,
68
+ layout: String
63
69
  }
64
- const ComponentWrapper = styled("div", wrapperProps)`
70
+ const ComponentWrapper = styled('div', wrapperProps)`
65
71
  display: flex;
66
72
  flex-direction: ${(props) =>
67
- props.layout === "vertical" ? "column" : "row"};
73
+ props.layout === 'vertical' ? 'column' : 'row'};
68
74
  grid-gap: 10px 5px;
69
75
  flex-wrap: wrap;
70
76
  `
@@ -83,8 +89,13 @@ const RadioWrapper = styled.div`
83
89
  grid-gap: 10px;
84
90
  `
85
91
 
86
- const containerProps = { size: String, isDisabled: Boolean, isChecked: Boolean, checkmarkColor: String }
87
- const LabelContainer = styled("label", containerProps)`
92
+ const containerProps = {
93
+ size: String,
94
+ isDisabled: Boolean,
95
+ isChecked: Boolean,
96
+ checkmarkColor: String
97
+ }
98
+ const LabelContainer = styled('label', containerProps)`
88
99
  display: grid;
89
100
  grid-template-columns: auto 1fr auto;
90
101
  grid-gap: 15px;
@@ -92,30 +103,30 @@ const LabelContainer = styled("label", containerProps)`
92
103
  color: ${(props) =>
93
104
  props.isDisabled ? props.theme.colors.grey2 : props.theme.colors.black};
94
105
  position: relative;
95
- cursor: ${(props) => (props.isDisabled ? "not-allowed" : "pointer")};
106
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
96
107
  font-size: ${(props) =>
97
- props.size === "large"
98
- ? "16px"
99
- : props.size === "medium"
100
- ? "13px"
101
- : "10px"};
108
+ props.size === 'large'
109
+ ? '16px'
110
+ : props.size === 'medium'
111
+ ? '13px'
112
+ : '10px'};
102
113
  user-select: none;
103
114
  flex: auto;
104
115
  align-self: baseline;
105
116
 
106
117
  .checkmark {
107
118
  height: ${(props) =>
108
- props.size === "large"
109
- ? "23px"
110
- : props.size === "medium"
111
- ? "16px"
112
- : "12px"};
119
+ props.size === 'large'
120
+ ? '23px'
121
+ : props.size === 'medium'
122
+ ? '16px'
123
+ : '12px'};
113
124
  width: ${(props) =>
114
- props.size === "large"
115
- ? "23px"
116
- : props.size === "medium"
117
- ? "16px"
118
- : "12px"};
125
+ props.size === 'large'
126
+ ? '23px'
127
+ : props.size === 'medium'
128
+ ? '16px'
129
+ : '12px'};
119
130
  background-color: #fff;
120
131
  border-radius: 100%;
121
132
  border: 1px solid ${(props) => props.theme.colors.mediumGray};
@@ -124,28 +135,29 @@ const LabelContainer = styled("label", containerProps)`
124
135
  justify-content: center;
125
136
 
126
137
  &:after {
127
- content: "";
128
- display: ${(props) => props.isChecked ? 'block' : 'none'};
138
+ content: '';
139
+ display: ${(props) => (props.isChecked ? 'block' : 'none')};
129
140
  width: ${(props) =>
130
- props.size === "large"
131
- ? "10px"
132
- : props.size === "medium"
133
- ? "8px"
134
- : "6px"};
141
+ props.size === 'large'
142
+ ? '10px'
143
+ : props.size === 'medium'
144
+ ? '8px'
145
+ : '6px'};
135
146
  height: ${(props) =>
136
- props.size === "large"
137
- ? "10px"
138
- : props.size === "medium"
139
- ? "8px"
140
- : "6px"};
147
+ props.size === 'large'
148
+ ? '10px'
149
+ : props.size === 'medium'
150
+ ? '8px'
151
+ : '6px'};
141
152
  border-radius: 100%;
142
- background: ${(props) => props.checkmarkColor ? props.checkmarkColor : props.theme.colors.green};
153
+ background: ${(props) =>
154
+ props.checkmarkColor ? props.checkmarkColor : props.theme.colors.green};
143
155
  }
144
156
  }
145
157
  `
146
158
 
147
159
  const textAttrs = { isDisabled: Boolean }
148
- const LabelText = styled("div", textAttrs)`
160
+ const LabelText = styled('div', textAttrs)`
149
161
  color: ${(props) =>
150
162
  props.isDisabled ? props.theme.colors.grey2 : props.theme.colors.black};
151
163
  `
@@ -186,7 +198,7 @@ const ModalImageContainer = styled.div`
186
198
  `
187
199
 
188
200
  export default {
189
- name: "radio-button",
201
+ name: 'radio-button',
190
202
  components: {
191
203
  Radio,
192
204
  ComponentWrapper,
@@ -198,24 +210,24 @@ export default {
198
210
  ModalImage,
199
211
  ModalImageContainer,
200
212
  InfoText,
201
- LabelText,
213
+ LabelText
202
214
  },
203
215
  props: {
204
216
  selectedOption: {
205
217
  required: true,
206
- default: false,
218
+ default: false
207
219
  },
208
220
  options: {
209
221
  required: true,
210
- default: [],
222
+ default: []
211
223
  },
212
224
  layout: {
213
225
  required: false,
214
- default: "horizontal", //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
226
+ default: 'horizontal' //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
215
227
  },
216
228
  size: {
217
229
  required: false,
218
- default: "medium", // small, medium, large
230
+ default: 'medium' // small, medium, large
219
231
  },
220
232
  name: {
221
233
  required: false,
@@ -224,6 +236,10 @@ export default {
224
236
  checkmarkColor: {
225
237
  required: false,
226
238
  default: ''
239
+ },
240
+ dataId: {
241
+ type: String,
242
+ default: 'key'
227
243
  }
228
244
  },
229
245
  data() {
@@ -234,17 +250,18 @@ export default {
234
250
  },
235
251
  methods: {
236
252
  onInputHandler(value) {
237
- this.$emit("on-radio-change", value)
253
+ this.$emit('on-radio-change', value)
238
254
  },
239
255
  isImageOpen(index) {
240
256
  return this.selectedImage === index
241
257
  },
242
258
  toggleImageModal(value) {
243
259
  this.selectedImage = value
244
- },
260
+ }
245
261
  },
246
262
  created() {
247
- this.radioName = this.name.length === 0 ? Math.round(Math.random() * 10000) : this.name
248
- },
263
+ this.radioName =
264
+ this.name.length === 0 ? Math.round(Math.random() * 10000) : this.name
265
+ }
249
266
  }
250
267
  </script>
@@ -22,9 +22,7 @@
22
22
  <info-text
23
23
  v-if="infoTextMessage"
24
24
  :text="infoTextMessage"
25
- borderColor="#ccc"
26
25
  :size="fontSize ? fontSize : '16px'"
27
- :alignText="infoTextAlign"
28
26
  />
29
27
  </label-wrapper>
30
28
  <select-button-wrapper :disabled="disabled">
@@ -313,9 +311,6 @@ export default {
313
311
  infoTextMessage: {
314
312
  required: false
315
313
  },
316
- infoTextAlign: {
317
- required: false
318
- },
319
314
  selectWidth: {
320
315
  required: false,
321
316
  default: null
@@ -492,10 +487,14 @@ export default {
492
487
  this.toggleDropdown()
493
488
  },
494
489
  clickOutside(event) {
490
+ const dropdownRef = this.$refs.dropdown
491
+ // we need to prevent closing on selecting an option, because in the case of
492
+ // a disabled option, we don't want to close the dropdown
495
493
  if (!this.isClickOutsideActive) return
496
494
  if (
497
495
  this.$refs.select.$el == event.target ||
498
- this.$refs.select.$el.contains(event.target)
496
+ this.$refs.select.$el.contains(event.target) ||
497
+ event.target.parentNode === dropdownRef.$el
499
498
  ) {
500
499
  return
501
500
  } else {
@@ -1,10 +1,18 @@
1
1
  <template>
2
2
  <optionContainer
3
3
  :data-value="value"
4
- :hoveredBgColor="colorMode == 'dark' ? '#000000' : 'hoveredBgColor'"
5
- :backgroundColor="colorMode == 'dark' ? 'eturnityGrey' : '#fff'"
4
+ :hoveredBgColor="
5
+ colorMode == 'dark'
6
+ ? '#000000'
7
+ : hoveredBgColor
8
+ ? hoveredBgColor
9
+ : 'grey5'
10
+ "
6
11
  @click="clickHandler"
7
12
  @mouseover="hoverHandler"
13
+ :cursorType="cursorType"
14
+ :backgroundColor="colorMode == 'dark' ? '#000000' : backgroundColor"
15
+ :title="hoverText"
8
16
  >
9
17
  <slot></slot>
10
18
  </optionContainer>
@@ -14,18 +22,29 @@
14
22
  // import selectButton from './selectButton'
15
23
  // import selectDropdown from './selectDropDown'
16
24
  import styled from 'vue-styled-components'
17
- const optionProps = { hoveredBgColor: String, backgroundColor: String }
25
+ const optionProps = {
26
+ hoveredBgColor: String,
27
+ cursorType: String,
28
+ backgroundColor: String
29
+ }
18
30
  const optionContainer = styled('div', optionProps)`
19
31
  display: flex;
20
- cursor: pointer;
32
+ cursor: ${(props) => props.cursorType};
21
33
  flex-direction: row;
22
34
  justify-content: space-between;
23
35
  align-items: center;
24
36
  padding: 12px 10px;
25
37
  gap: 14px;
26
38
  width: 100%;
27
- background-color: ${(props) => props.theme.colors[props.backgroundColor]?props.theme.colors[props.backgroundColor]:props.backgroundColor};
39
+ background-color: ${(props) =>
40
+ props.theme.colors[props.backgroundColor]
41
+ ? props.theme.colors[props.backgroundColor]
42
+ : props.backgroundColor};
28
43
  box-sizing: inherit;
44
+ background-color: ${(props) =>
45
+ props.theme.colors[props.backgroundColor]
46
+ ? props.theme.colors[props.backgroundColor]
47
+ : props.backgroundColor};
29
48
  &:hover {
30
49
  background-color: ${(props) =>
31
50
  props.theme.colors[props.hoveredBgColor]
@@ -47,6 +66,21 @@ export default {
47
66
  colorMode: {
48
67
  required: false,
49
68
  default: 'light'
69
+ },
70
+ cursorType: {
71
+ required: false,
72
+ default: 'cursor'
73
+ },
74
+ backgroundColor: {
75
+ required: false,
76
+ default: 'white'
77
+ },
78
+ hoverText: {
79
+ required: false
80
+ },
81
+ isDisabled: {
82
+ required: false,
83
+ default: false
50
84
  }
51
85
  },
52
86
 
@@ -57,7 +91,12 @@ export default {
57
91
  },
58
92
  methods: {
59
93
  clickHandler() {
60
- this.$parent.$emit('option-selected', this.value)
94
+ if (this.isDisabled) {
95
+ // prevent emitter if the option is disabled
96
+ return
97
+ } else {
98
+ this.$parent.$emit('option-selected', this.value)
99
+ }
61
100
  },
62
101
  hoverHandler() {
63
102
  this.$parent.$emit('option-hovered', this.value)
@@ -15,9 +15,6 @@
15
15
  <info-text
16
16
  v-if="infoTextMessage"
17
17
  :text="infoTextMessage"
18
- borderColor="#ccc"
19
- size="14px"
20
- :alignText="infoTextAlign"
21
18
  />
22
19
  </label-container>
23
20
 
@@ -48,9 +45,6 @@
48
45
  @click.native.stop
49
46
  v-if="infoTextMessage"
50
47
  :text="infoTextMessage"
51
- borderColor="#ccc"
52
- size="14px"
53
- :alignText="infoTextAlign"
54
48
  />
55
49
  </label-container>
56
50
  </flex-wrapper>
@@ -202,9 +196,6 @@ export default {
202
196
  infoTextMessage: {
203
197
  required: false
204
198
  },
205
- infoTextAlign: {
206
- required: false
207
- },
208
199
  colorMode: {
209
200
  required: false,
210
201
  default: 'light'
@@ -22,7 +22,6 @@ const Template = (args, { argTypes }) => ({
22
22
  // rowHeight="4" //optional
23
23
  // :isError="false"
24
24
  // :errorText="$gettext('field_required')"
25
- // infoTextAlign="right" // left by default
26
25
  // infoTextMessage="My info message"
27
26
  // label="Question 5"
28
27
  // alignItems="horizontal" // horizontal, vertical
@@ -37,7 +36,6 @@ Default.args = {
37
36
  rowHeight: "2",
38
37
  isError: false,
39
38
  errorText: "This field is required",
40
- infoTextAlign: "right",
41
39
  infoTextMessage: "",
42
40
  label: "",
43
41
  value: "",
@@ -52,7 +50,6 @@ Disabled.args = {
52
50
  rowHeight: "2",
53
51
  isError: false,
54
52
  errorText: "This field is required",
55
- infoTextAlign: "right",
56
53
  infoTextMessage: "",
57
54
  label: "",
58
55
  value: "",
@@ -67,7 +64,6 @@ Error.args = {
67
64
  rowHeight: "2",
68
65
  isError: true,
69
66
  errorText: "This field is required",
70
- infoTextAlign: "right",
71
67
  infoTextMessage: "",
72
68
  label: "",
73
69
  value: "",
@@ -82,7 +78,6 @@ WithLabel.args = {
82
78
  rowHeight: "2",
83
79
  isError: false,
84
80
  errorText: "This field is required",
85
- infoTextAlign: "right",
86
81
  infoTextMessage: "Here is some information",
87
82
  label: "Description",
88
83
  value: "Here is my description!",
@@ -97,7 +92,6 @@ HorizontalLabel.args = {
97
92
  rowHeight: "2",
98
93
  isError: false,
99
94
  errorText: "This field is required",
100
- infoTextAlign: "right",
101
95
  infoTextMessage: "Here is some information",
102
96
  label: "Description",
103
97
  value: "Here is my description!",
@@ -112,7 +106,6 @@ LargerTextArea.args = {
112
106
  rowHeight: "5",
113
107
  isError: false,
114
108
  errorText: "This field is required",
115
- infoTextAlign: "right",
116
109
  infoTextMessage: "Here is some information",
117
110
  label: "Description",
118
111
  value: "Here is my description!",
@@ -127,7 +120,6 @@ LargerFontSize.args = {
127
120
  fontSize: "24px",
128
121
  isError: false,
129
122
  errorText: "This field is required",
130
- infoTextAlign: "right",
131
123
  infoTextMessage: "Here is some information",
132
124
  label: "Description",
133
125
  value: "Here is my description!",
@@ -11,9 +11,7 @@
11
11
  <info-text
12
12
  v-if="infoTextMessage"
13
13
  :text="infoTextMessage"
14
- borderColor="#ccc"
15
14
  size="16px"
16
- :alignText="infoTextAlign"
17
15
  />
18
16
  </label-wrapper>
19
17
  <input-container
@@ -47,7 +45,6 @@
47
45
  // rowHeight="4" //optional
48
46
  // :isError="false"
49
47
  // :errorText="$gettext('field_required')"
50
- // infoTextAlign="right" // left by default
51
48
  // infoTextMessage="My info message"
52
49
  // label="Question 5"
53
50
  // alignItems="horizontal" // horizontal, vertical
@@ -167,9 +164,6 @@ export default {
167
164
  infoTextMessage: {
168
165
  required: false
169
166
  },
170
- infoTextAlign: {
171
- required: false
172
- },
173
167
  label: {
174
168
  required: false
175
169
  },