@eturnity/eturnity_reusable_components 7.39.4-EPDM-11716.0 → 7.39.4-EPDM-11717.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.39.4-EPDM-11716.0",
3
+ "version": "7.39.4-EPDM-11717.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -2,6 +2,7 @@
2
2
  <ComponentWrapper>
3
3
  <IconWrapper :size="size">
4
4
  <IconImg
5
+ data-test-id="infoText_trigger"
5
6
  @click.prevent="toggleShowInfo()"
6
7
  @mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
7
8
  @mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
@@ -3,68 +3,73 @@ import InputText from './index.vue'
3
3
  export default {
4
4
  title: 'InputText',
5
5
  component: InputText,
6
- tags: ['autodocs'],
6
+ // argTypes: {},
7
7
  }
8
8
 
9
- // import InputText from "@eturnity/eturnity_reusable_components/src/components/inputs/inputText"
10
- // To use:
11
- // <input-text
12
- // placeholder="Company name"
13
- // :value="companyName"
14
- // @input-change="onInputChange({ value: $event, type: 'companyName' })"
15
- // :isError="checkErrors()"
16
- // :errorMessage="This is my error message"
17
- // infoTextAlign="right" // left by default
18
- // infoTextMessage="My info message"
19
- // label="Question 5"
20
- // alignItems="horizontal" // horizontal, vertical
21
- // inputWidth="250px"
22
- // minWidth="100px"
23
- // />
9
+ const Template = (args, { argTypes }) => ({
10
+ // Components used in your story `template` are defined in the `components` object
11
+ components: { InputText },
12
+ // The story's `args` need to be mapped into the template through the `setup()` method
13
+ props: Object.keys(argTypes),
14
+ template: '<input-text v-bind="$props" />',
24
15
 
25
- export const Default = {
26
- args: {
27
- placeholder: 'Company name',
28
- disabled: false,
29
- value: '',
30
- inputWidth: '200px',
31
- minWidth: '10ch',
32
- isError: false,
33
- label: 'label test',
34
- labelOptional: true,
35
- },
16
+ // import InputText from "@eturnity/eturnity_reusable_components/src/components/inputs/inputText"
17
+ // To use:
18
+ // <input-text
19
+ // placeholder="Company name"
20
+ // :value="companyName"
21
+ // @input-change="onInputChange({ value: $event, type: 'companyName' })"
22
+ // :isError="checkErrors()"
23
+ // :errorMessage="This is my error message"
24
+ // infoTextAlign="right" // left by default
25
+ // infoTextMessage="My info message"
26
+ // label="Question 5"
27
+ // alignItems="horizontal" // horizontal, vertical
28
+ // inputWidth="250px"
29
+ // minWidth="100px"
30
+ // />
31
+ })
32
+
33
+ export const Default = Template.bind({})
34
+ Default.args = {
35
+ placeholder: 'Company name',
36
+ disabled: false,
37
+ value: '',
38
+ inputWidth: '200px',
39
+ minWidth: '10ch',
40
+ unitName: 'pc',
41
+ isError: false,
42
+ textAlign: 'left',
36
43
  }
37
44
 
38
- export const HasError = {
39
- args: {
40
- placeholder: 'Enter Value',
41
- errorMessage: 'This field is required',
42
- isError: true,
43
- disabled: false,
44
- inputWidth: '200px',
45
- },
45
+ export const hasError = Template.bind({})
46
+ hasError.args = {
47
+ placeholder: 'Enter Value',
48
+ errorMessage: 'This field is required',
49
+ isError: true,
50
+ disabled: false,
51
+ inputWidth: '200px',
46
52
  }
47
53
 
48
- export const Disabled = {
49
- args: {
50
- placeholder: 'Enter Value',
51
- disabled: true,
52
- value: '',
53
- inputWidth: '200px',
54
- isError: false,
55
- },
54
+ export const Disabled = Template.bind({})
55
+ Disabled.args = {
56
+ placeholder: 'Enter Value',
57
+ disabled: true,
58
+ value: '',
59
+ inputWidth: '200px',
60
+ isError: false,
56
61
  }
57
62
 
58
- export const WithLabel = {
59
- args: {
60
- placeholder: 'Company name',
61
- disabled: false,
62
- label: 'What is the best company in Switzerland?',
63
- value: 'Eturnity',
64
- inputWidth: '200px',
65
- unitName: 'pc',
66
- isError: false,
67
- errorMessage: 'Maximum 5 characters',
68
- alignItems: 'vertical',
69
- },
63
+ export const WithLabel = Template.bind({})
64
+ WithLabel.args = {
65
+ placeholder: 'Company name',
66
+ disabled: false,
67
+ label: 'What is the best company in Switzerland?',
68
+ value: 'Eturnity',
69
+ inputWidth: '200px',
70
+ unitName: 'pc',
71
+ isError: false,
72
+ errorMessage: 'Maximum 5 characters',
73
+ textAlign: 'left',
74
+ alignItems: 'vertical',
70
75
  }
@@ -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"
@@ -54,20 +49,16 @@
54
49
  />
55
50
  <IconWrapper
56
51
  v-if="inputType === 'password' && !isError"
57
- data-test-id="password_visiblity_change_icon"
58
52
  size="20px"
59
53
  @click="toggleShowPassword()"
60
54
  >
61
55
  <Icon name="current_variant" size="20px" />
62
56
  </IconWrapper>
63
- <IconWrapper v-if="hasError" data-test-id="error_wrapper" size="16px">
57
+ <IconWrapper v-if="hasError" size="16px">
64
58
  <Icon cursor="default" name="warning" size="16px" />
65
59
  </IconWrapper>
66
60
  </IconContainer>
67
- <ErrorMessage
68
- v-if="hasError && hasErrorMessage"
69
- data-test-id="error_message_wrapper"
70
- >
61
+ <ErrorMessage v-if="hasError && hasErrorMessage">
71
62
  {{ dynamicErrorMessage }}
72
63
  </ErrorMessage>
73
64
  </InputErrorWrapper>
@@ -245,123 +236,93 @@
245
236
  placeholder: {
246
237
  required: false,
247
238
  default: '',
248
- type: String,
249
239
  },
250
240
  alignItems: {
251
241
  required: false,
252
242
  default: 'horizontal',
253
- type: String,
254
- validator(value) {
255
- return ['horizontal', 'vertical'].includes(value)
256
- },
257
243
  },
258
244
  isError: {
259
245
  required: false,
260
246
  default: false,
261
- type: Boolean,
262
247
  },
263
248
  inputWidth: {
264
249
  required: false,
265
250
  default: null,
266
- type: String,
267
251
  },
268
252
  inputHeight: {
269
253
  required: false,
270
254
  default: null,
271
- type: String,
272
255
  },
273
256
  minWidth: {
274
257
  required: false,
275
258
  default: null,
276
- type: String,
277
259
  },
278
260
  value: {
279
261
  required: true,
280
262
  default: null,
281
- type: String,
282
263
  },
283
264
  errorMessage: {
284
265
  required: false,
285
266
  default: '',
286
- type: String,
287
267
  },
288
268
  infoTextMessage: {
289
269
  required: false,
290
- default: '',
291
- type: String,
292
270
  },
293
271
  infoTextAlign: {
294
272
  required: false,
295
- default: 'left',
296
- type: String,
297
273
  },
298
274
  label: {
299
275
  required: false,
300
- default: '',
301
- type: String,
302
276
  },
303
277
  labelOptional: {
304
278
  required: false,
305
279
  default: false,
306
- type: Boolean,
307
280
  },
308
281
  noBorder: {
309
282
  required: false,
310
283
  default: false,
311
- type: Boolean,
312
284
  },
313
285
  disabled: {
314
286
  required: false,
315
287
  default: false,
316
- type: Boolean,
317
288
  },
318
289
  fontSize: {
319
290
  required: false,
320
291
  default: null,
321
- type: String,
322
292
  },
323
293
  inputType: {
324
294
  required: false,
325
295
  default: 'text',
326
- type: String,
327
296
  },
328
297
  labelFontColor: {
329
298
  required: false,
330
299
  default: 'black',
331
- type: String,
332
300
  },
333
301
  backgroundColor: {
334
302
  required: false,
335
- type: String,
336
303
  },
337
304
  disabledBackgroundColor: {
338
305
  required: false,
339
306
  default: null,
340
- type: String,
341
307
  },
342
308
  fontColor: {
343
309
  required: false,
344
310
  default: 'black',
345
- type: String,
346
311
  },
347
312
  hasFocus: {
348
313
  required: false,
349
314
  default: false,
350
- type: Boolean,
351
315
  },
352
316
  borderColor: {
353
317
  required: false,
354
- type: String,
355
318
  },
356
319
  labelDataId: {
357
320
  required: false,
358
321
  default: '',
359
- type: String,
360
322
  },
361
323
  inputDataId: {
362
324
  required: false,
363
325
  default: '',
364
- type: String,
365
326
  },
366
327
  },
367
328
  data() {
@@ -374,10 +335,12 @@
374
335
  return this.isError || this.error
375
336
  },
376
337
  hasErrorMessage() {
377
- return this.errorMessage && this.errorMessage.length > 0
338
+ return (
339
+ (this.errorMessage && this.errorMessage.length > 0) || this.errMessage
340
+ )
378
341
  },
379
342
  dynamicErrorMessage() {
380
- return this.errorMessage
343
+ return this.errMessage || this.errorMessage
381
344
  },
382
345
  },
383
346
  watch: {
@@ -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