@eturnity/eturnity_reusable_components 7.39.5-qa-elisee-7.42.1 → 7.45.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.
@@ -2,26 +2,22 @@
2
2
  <Container>
3
3
  <InputWrapper
4
4
  :align-items="alignItems"
5
- data-test-id="input_wrapper"
6
5
  :has-label="!!label && label.length > 0"
7
6
  >
8
7
  <LabelWrapper v-if="label">
9
8
  <InputLabel
10
- ref="label"
11
9
  :data-id="labelDataId"
12
- data-test-id="label_wrapper"
13
10
  :font-size="fontSize"
14
11
  :label-font-color="labelFontColor"
15
12
  >
16
13
  {{ label }}
17
- <OptionalLabel v-if="labelOptional" data-test-id="label_optional">
14
+ <OptionalLabel v-if="labelOptional">
18
15
  ({{ $gettext('Optional') }})
19
16
  </OptionalLabel>
20
17
  </InputLabel>
21
18
  <InfoText
22
- v-if="infoTextMessage != ''"
19
+ v-if="infoTextMessage"
23
20
  :align-arrow="infoTextAlign"
24
- data-test-id="info_text_message"
25
21
  :size="fontSize ? fontSize : '16px'"
26
22
  :text="infoTextMessage"
27
23
  />
@@ -32,7 +28,6 @@
32
28
  ref="inputElement"
33
29
  :background-color="backgroundColor"
34
30
  :data-id="inputDataId"
35
- data-test-id="input"
36
31
  :disabled="disabled"
37
32
  :disabled-background-color="disabledBackgroundColor"
38
33
  :font-color="fontColor"
@@ -49,26 +44,21 @@
49
44
  :type="inputTypeData"
50
45
  :value="value"
51
46
  @blur="onInputBlur"
52
- @focus="onInputFocus"
53
47
  @input="onChangeHandler"
54
48
  @keyup.enter="onEnterPress"
55
49
  />
56
50
  <IconWrapper
57
51
  v-if="inputType === 'password' && !isError"
58
- data-test-id="password_visiblity_change_icon"
59
52
  size="20px"
60
53
  @click="toggleShowPassword()"
61
54
  >
62
55
  <Icon name="current_variant" size="20px" />
63
56
  </IconWrapper>
64
- <IconWrapper v-if="hasError" data-test-id="error_wrapper" size="16px">
57
+ <IconWrapper v-if="hasError" size="16px">
65
58
  <Icon cursor="default" name="warning" size="16px" />
66
59
  </IconWrapper>
67
60
  </IconContainer>
68
- <ErrorMessage
69
- v-if="hasError && hasErrorMessage"
70
- data-test-id="error_message_wrapper"
71
- >
61
+ <ErrorMessage v-if="hasError && hasErrorMessage">
72
62
  {{ dynamicErrorMessage }}
73
63
  </ErrorMessage>
74
64
  </InputErrorWrapper>
@@ -246,123 +236,93 @@
246
236
  placeholder: {
247
237
  required: false,
248
238
  default: '',
249
- type: String,
250
239
  },
251
240
  alignItems: {
252
241
  required: false,
253
242
  default: 'horizontal',
254
- type: String,
255
- validator(value) {
256
- return ['horizontal', 'vertical'].includes(value)
257
- },
258
243
  },
259
244
  isError: {
260
245
  required: false,
261
246
  default: false,
262
- type: Boolean,
263
247
  },
264
248
  inputWidth: {
265
249
  required: false,
266
250
  default: null,
267
- type: String,
268
251
  },
269
252
  inputHeight: {
270
253
  required: false,
271
254
  default: null,
272
- type: String,
273
255
  },
274
256
  minWidth: {
275
257
  required: false,
276
258
  default: null,
277
- type: String,
278
259
  },
279
260
  value: {
280
261
  required: true,
281
262
  default: null,
282
- type: String,
283
263
  },
284
264
  errorMessage: {
285
265
  required: false,
286
266
  default: '',
287
- type: String,
288
267
  },
289
268
  infoTextMessage: {
290
269
  required: false,
291
- default: '',
292
- type: String,
293
270
  },
294
271
  infoTextAlign: {
295
272
  required: false,
296
- default: 'left',
297
- type: String,
298
273
  },
299
274
  label: {
300
275
  required: false,
301
- default: '',
302
- type: String,
303
276
  },
304
277
  labelOptional: {
305
278
  required: false,
306
279
  default: false,
307
- type: Boolean,
308
280
  },
309
281
  noBorder: {
310
282
  required: false,
311
283
  default: false,
312
- type: Boolean,
313
284
  },
314
285
  disabled: {
315
286
  required: false,
316
287
  default: false,
317
- type: Boolean,
318
288
  },
319
289
  fontSize: {
320
290
  required: false,
321
291
  default: null,
322
- type: String,
323
292
  },
324
293
  inputType: {
325
294
  required: false,
326
295
  default: 'text',
327
- type: String,
328
296
  },
329
297
  labelFontColor: {
330
298
  required: false,
331
299
  default: 'black',
332
- type: String,
333
300
  },
334
301
  backgroundColor: {
335
302
  required: false,
336
- type: String,
337
303
  },
338
304
  disabledBackgroundColor: {
339
305
  required: false,
340
306
  default: null,
341
- type: String,
342
307
  },
343
308
  fontColor: {
344
309
  required: false,
345
310
  default: 'black',
346
- type: String,
347
311
  },
348
312
  hasFocus: {
349
313
  required: false,
350
314
  default: false,
351
- type: Boolean,
352
315
  },
353
316
  borderColor: {
354
317
  required: false,
355
- type: String,
356
318
  },
357
319
  labelDataId: {
358
320
  required: false,
359
321
  default: '',
360
- type: String,
361
322
  },
362
323
  inputDataId: {
363
324
  required: false,
364
325
  default: '',
365
- type: String,
366
326
  },
367
327
  },
368
328
  data() {
@@ -375,10 +335,12 @@
375
335
  return this.isError || this.error
376
336
  },
377
337
  hasErrorMessage() {
378
- return this.errorMessage && this.errorMessage.length > 0
338
+ return (
339
+ (this.errorMessage && this.errorMessage.length > 0) || this.errMessage
340
+ )
379
341
  },
380
342
  dynamicErrorMessage() {
381
- return this.errorMessage
343
+ return this.errMessage || this.errorMessage
382
344
  },
383
345
  },
384
346
  watch: {
@@ -405,9 +367,6 @@
405
367
  this.validateInput($event.target.value)
406
368
  this.$emit('input-blur', $event.target.value)
407
369
  },
408
- onInputFocus($event) {
409
- this.$emit('input-focus', $event.target.value)
410
- },
411
370
  toggleShowPassword() {
412
371
  this.inputTypeData =
413
372
  this.inputTypeData === 'password' ? 'text' : 'password'
@@ -1,58 +1,77 @@
1
+ import { useArgs } from '@storybook/preview-api'
2
+ import { action } from '@storybook/addon-actions'
3
+ import defaultRadioButtonProps from './defaultProps'
1
4
  import RadioButton from './index.vue'
2
5
 
3
6
  export default {
4
7
  title: 'RadioButton',
5
8
  component: RadioButton,
6
- // argTypes: {},
9
+ tags: ['autodocs'],
7
10
  }
8
11
 
9
- const Template = (args, { argTypes }) => ({
10
- // Components used in your story `template` are defined in the `components` object
11
- components: { RadioButton },
12
- // The story's `args` need to be mapped into the template through the `setup()` method
13
- props: Object.keys(argTypes),
14
- template: '<radio-button v-bind="$props" />',
15
-
16
- // import RadioButton from "@eturnity/eturnity_reusable_components/src/components/inputs/radioButton"
17
- // To use:
18
- // <radio-button
19
- // :options="radioOptions"
20
- // :selectedOption="checkedOption"
21
- // @on-radio-change="onInputChange($event)"
22
- // layout="vertical"
23
- // size="large"
24
- // />
25
- // Data being passed should look like:
26
- // radioOptions: [
27
- // { label: 'Button 1', value: 'button_1', img: 'www.imagesrc.com', infoText: 'my info text' },
28
- // { label: 'Button 2', value: 'button_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
29
- // { label: 'Button 3', value: 'button_3', img: 'www.imagesrc.com', disabled: true },
30
- // { label: 'Button 4', value: 'button_4', disabled: true }
31
- // ]
32
- })
12
+ // To use:
13
+ // import RadioButton from "@eturnity/eturnity_reusable_components/src/components/inputs/radioButton"
14
+ // <radio-button
15
+ // checkmarkColor="red"
16
+ // dataId="radio_button"
17
+ // layout="horizontal" //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
18
+ // name="Name for Radio buttons"
19
+ // :options="radioOptions"
20
+ // :selectedOption="checkedOption"
21
+ // size="medium" // small, medium, large
22
+ // @on-radio-change="onInputChange($event)"
23
+ // />
24
+ // Data being passed should look like:
25
+ // radioOptions: [
26
+ // { label: 'Option 1', value: 'option_1', img: 'www.imagesrc.com', infoText: 'my info text' },
27
+ // { label: 'Option 2', value: 'option_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
28
+ // { label: 'Option 3', value: 'option_3', img: 'www.imagesrc.com', disabled: true },
29
+ // { label: 'Option 4', value: 'option_4', disabled: true }
30
+ // ]
31
+
32
+ const defaultProps = defaultRadioButtonProps
33
+
34
+ const Template = (args) => {
35
+ const [currentArgs, updateArgs] = useArgs()
36
+
37
+ const handleRadioChange = ($event) => {
38
+ action('on-radio-change')($event)
39
+ updateArgs({ selectedOption: $event })
40
+ }
41
+
42
+ return {
43
+ components: { RadioButton },
44
+ setup() {
45
+ return { args: currentArgs, handleRadioChange }
46
+ },
47
+ template: `
48
+ <RadioButton
49
+ v-bind="args"
50
+ @on-radio-change="handleRadioChange"
51
+ />
52
+ `,
53
+ }
54
+ }
33
55
 
34
56
  export const Default = Template.bind({})
35
57
  Default.args = {
36
- options: [
37
- { label: 'Button 1', value: 'button_1', infoText: 'my info text' },
38
- { label: 'Button 2', value: 'button_2', infoText: 'my info text 2' },
39
- { label: 'Button 3', value: 'button_3', disabled: true },
40
- { label: 'Button 4', value: 'button_4', disabled: true },
41
- ],
42
- selectedOption: 'button_2',
43
- layout: 'horizontal',
44
- size: 'medium',
58
+ ...defaultProps,
59
+ }
60
+
61
+ export const BlueCheckmark = Template.bind({})
62
+ BlueCheckmark.args = {
63
+ ...defaultProps,
64
+ checkmarkColor: '#00f',
65
+ }
66
+
67
+ export const Small = Template.bind({})
68
+ Small.args = {
69
+ ...defaultProps,
70
+ size: 'small',
45
71
  }
46
72
 
47
- export const VerticalLayout = Template.bind({})
48
- VerticalLayout.args = {
49
- options: [
50
- { label: 'Button 1', value: 'button_1' },
51
- { label: 'Button 2', value: 'button_2' },
52
- { label: 'Button 3', value: 'button_3' },
53
- { label: 'Button 4', value: 'button_4', disabled: true },
54
- ],
55
- selectedOption: 'button_2',
73
+ export const Vertical = Template.bind({})
74
+ Vertical.args = {
75
+ ...defaultProps,
56
76
  layout: 'vertical',
57
- size: 'medium',
58
77
  }
@@ -0,0 +1,33 @@
1
+ const defaultRadioButtonProps = {
2
+ dataId: 'radio_buttons',
3
+ name: 'options',
4
+ options: [
5
+ {
6
+ label: 'Option 1',
7
+ value: 'option_1',
8
+ img: 'https://staging-01-backend.eturnity.dev/static/e_templates/base/styles/solar_img_i.png',
9
+ },
10
+ {
11
+ label: 'Option 2',
12
+ value: 'option_2',
13
+ img: 'https://staging-01-backend.eturnity.dev/static/e_templates/base/styles/switcher_img_i.png',
14
+ infoText: 'Option 2 info text',
15
+ },
16
+ {
17
+ label: 'Option 3',
18
+ value: 'option_3',
19
+ img: 'https://staging-01-backend.eturnity.dev/static/e_templates/base/styles/varta_img_i.png',
20
+ infoText: 'Option 3 info text',
21
+ disabled: true,
22
+ },
23
+ {
24
+ label: 'Option 4',
25
+ value: 'option_4',
26
+ disabled: true,
27
+ infoText: 'Option 4 info text',
28
+ },
29
+ ],
30
+ selectedOption: 'option_2',
31
+ }
32
+
33
+ export default defaultRadioButtonProps
@@ -1,6 +1,10 @@
1
1
  <template>
2
2
  <ComponentWrapper :layout="layout">
3
- <RadioWrapper v-for="(item, index) in options" :key="item.value">
3
+ <RadioWrapper
4
+ v-for="(item, index) in options"
5
+ :key="item.value"
6
+ :data-test-id="'radioWrapper_' + item.value"
7
+ >
4
8
  <LabelContainer
5
9
  :checkmark-color="checkmarkColor"
6
10
  :has-label="!!item.label"
@@ -11,6 +15,7 @@
11
15
  <Radio
12
16
  :checked="selectedOption === item.value"
13
17
  :data-id="`radio_button_${dataId}_option_${item.value}`"
18
+ :data-test-id="'radioInput_' + item.value"
14
19
  :disabled="item.disabled"
15
20
  :name="'radioButtons_' + radioName"
16
21
  type="radio"
@@ -18,15 +23,32 @@
18
23
  @click="onInputHandler(item.value)"
19
24
  />
20
25
  <span class="checkmark"></span>
21
- <LabelText v-if="item.label" :is-disabled="item.disabled">
26
+ <LabelText
27
+ v-if="item.label"
28
+ :data-test-id="'radioLabel_' + item.value"
29
+ :is-disabled="item.disabled"
30
+ >
22
31
  {{ item.label }}
23
32
  </LabelText>
24
- <InfoText v-if="item.infoText" size="16px" :text="item.infoText" />
33
+ <InfoText
34
+ v-if="item.infoText"
35
+ :data-test-id="'radioInfo_' + item.value"
36
+ size="16px"
37
+ :text="item.infoText"
38
+ />
25
39
  </LabelContainer>
26
40
  <ImageContainer v-if="item.img">
27
- <RadioImage :src="item.img" />
28
- <div class="search-icn-container" @click="toggleImageModal(index)">
41
+ <RadioImage
42
+ :data-test-id="'radioImage_' + item.value"
43
+ :src="item.img"
44
+ />
45
+ <div
46
+ class="search-icn-container"
47
+ :data-test-id="'radioOpenImage_' + item.value"
48
+ @click="toggleImageModal(index)"
49
+ >
29
50
  <img
51
+ alt=""
30
52
  class="search-icn"
31
53
  :src="require('../../../assets/icons/search_icon.png')"
32
54
  />
@@ -34,6 +56,7 @@
34
56
  </ImageContainer>
35
57
  <Modal
36
58
  v-if="item.img"
59
+ :data-test-id="'radioModal_' + item.value"
37
60
  :is-open="isImageOpen(index)"
38
61
  @on-close="toggleImageModal(null)"
39
62
  >
@@ -49,18 +72,21 @@
49
72
  // import RadioButton from "@eturnity/eturnity_reusable_components/src/components/inputs/radioButton"
50
73
  // To use:
51
74
  // <radio-button
75
+ // checkmarkColor="red"
76
+ // dataId="radio_button"
77
+ // layout="horizontal"
78
+ // name="Name for Radio buttons"
52
79
  // :options="radioOptions"
53
80
  // :selectedOption="checkedOption"
54
- // @on-radio-change="onInputChange($event)"
55
- // layout="vertical"
56
81
  // size="large"
82
+ // @on-radio-change="onInputChange($event)"
57
83
  // />
58
84
  // Data being passed should look like:
59
85
  // radioOptions: [
60
- // { label: 'Button 1', value: 'button_1', img: 'www.imagesrc.com', infoText: 'my info text' },
61
- // { label: 'Button 2', value: 'button_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
62
- // { label: 'Button 3', value: 'button_3', img: 'www.imagesrc.com', disabled: true },
63
- // { label: 'Button 4', value: 'button_4', disabled: true }
86
+ // { label: 'Option 1', value: 'option_1', img: 'www.imagesrc.com', infoText: 'my info text' },
87
+ // { label: 'Option 2', value: 'option_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
88
+ // { label: 'Option 3', value: 'option_3', img: 'www.imagesrc.com', disabled: true },
89
+ // { label: 'Option 4', value: 'option_4', disabled: true }
64
90
  // ]
65
91
 
66
92
  import styled from 'vue3-styled-components'
@@ -82,7 +108,6 @@
82
108
  cursor: pointer;
83
109
  position: absolute;
84
110
  opacity: 0;
85
- cursor: pointer;
86
111
  height: 0;
87
112
  width: 0;
88
113
  `
@@ -221,33 +246,42 @@
221
246
  props: {
222
247
  selectedOption: {
223
248
  required: true,
224
- default: false,
249
+ type: [String, Number],
225
250
  },
226
251
  options: {
252
+ default() {
253
+ return []
254
+ },
227
255
  required: true,
228
- default: [],
256
+ type: Array,
229
257
  },
230
258
  layout: {
231
- required: false,
232
259
  default: 'horizontal', //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
260
+ required: false,
261
+ type: String,
233
262
  },
234
263
  size: {
235
- required: false,
236
264
  default: 'medium', // small, medium, large
265
+ required: false,
266
+ type: String,
237
267
  },
238
268
  name: {
239
- required: false,
240
269
  default: '',
270
+ required: false,
271
+ type: String,
241
272
  },
242
273
  checkmarkColor: {
243
- required: false,
244
274
  default: '',
275
+ required: false,
276
+ type: String,
245
277
  },
246
278
  dataId: {
247
- type: String,
248
279
  default: 'key',
280
+ required: false,
281
+ type: String,
249
282
  },
250
283
  },
284
+ emits: ['on-radio-change'],
251
285
  data() {
252
286
  return {
253
287
  selectedImage: null,
@@ -260,7 +294,9 @@
260
294
  },
261
295
  methods: {
262
296
  onInputHandler(value) {
263
- this.$emit('on-radio-change', value)
297
+ if (value !== this.selectedOption) {
298
+ this.$emit('on-radio-change', value)
299
+ }
264
300
  },
265
301
  isImageOpen(index) {
266
302
  return this.selectedImage === index