@eturnity/eturnity_reusable_components 7.35.0 → 7.35.1-EPDM-10576.5

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.35.0",
3
+ "version": "7.35.1-EPDM-10576.5",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -9,8 +9,10 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
9
9
  }))
10
10
 
11
11
  describe('MainButton.vue', () => {
12
- it('button is rendered', async () => {
13
- const wrapper = mount(MainButton, {
12
+ let wrapper
13
+
14
+ beforeEach(() => {
15
+ wrapper = mount(MainButton, {
14
16
  props: {
15
17
  type: 'primary',
16
18
  text: 'Click me',
@@ -23,10 +25,11 @@ describe('MainButton.vue', () => {
23
25
  },
24
26
  },
25
27
  })
28
+ })
29
+
30
+ it('button is rendered with correct props', async () => {
26
31
  await wrapper.vm.$nextTick()
27
32
  const buttonWrapper = wrapper.find('[data-id="button_wrapper"]')
28
-
29
- // check that the element exists
30
33
  expect(buttonWrapper.exists()).toBe(true)
31
34
  })
32
35
  })
@@ -87,7 +87,10 @@
87
87
  :key="index + '_field'"
88
88
  >
89
89
  <SelectComponent
90
- v-if="isMultipleSelector(filter.filter_type)"
90
+ v-if="
91
+ isMultipleSelector(filter.filter_type) ||
92
+ isSingleSelector(filter.filter_type)
93
+ "
91
94
  align-items="vertical"
92
95
  :disabled="!filter.choices.length"
93
96
  font-size="13px"
@@ -102,16 +105,12 @@
102
105
  <OptionTitle> {{ filter.selectedText }} </OptionTitle>
103
106
  </template>
104
107
  <template #dropdown>
105
- <DropdownCheckboxContainer
106
- v-for="(filterOption, optionIdx) in filter.choices"
107
- :key="optionIdx + 'optionIdx'"
108
- @click.stop
109
- >
110
- <Checkbox
111
- :is-checked="filterOption.selected"
112
- :label="filterOption.text"
113
- size="small"
114
- @on-event-handler="
108
+ <template v-if="isSingleSelector(filter.filter_type)">
109
+ <Option
110
+ v-for="(filterOption, optionIdx) in filter.choices"
111
+ :key="optionIdx + 'optionIdx'"
112
+ :value="filterOption.text"
113
+ @click="
115
114
  onChange({
116
115
  dataType: item.type,
117
116
  value: $event,
@@ -119,8 +118,31 @@
119
118
  field: filter.field,
120
119
  })
121
120
  "
122
- />
123
- </DropdownCheckboxContainer>
121
+ >
122
+ {{ filterOption.text }}
123
+ </Option>
124
+ </template>
125
+ <template v-else>
126
+ <DropdownCheckboxContainer
127
+ v-for="(filterOption, optionIdx) in filter.choices"
128
+ :key="optionIdx + 'optionIdx'"
129
+ @click.stop
130
+ >
131
+ <Checkbox
132
+ :is-checked="filterOption.selected"
133
+ :label="filterOption.text"
134
+ size="small"
135
+ @on-event-handler="
136
+ onChange({
137
+ dataType: item.type,
138
+ value: $event,
139
+ choice: filterOption.choice,
140
+ field: filter.field,
141
+ })
142
+ "
143
+ />
144
+ </DropdownCheckboxContainer>
145
+ </template>
124
146
  </template>
125
147
  </SelectComponent>
126
148
  <SectionContainer v-else-if="isRangeSelector(filter.filter_type)">
@@ -305,6 +327,8 @@
305
327
  const ContainerWrapper = styled.div`
306
328
  position: absolute;
307
329
  margin-top: 4px;
330
+ max-height: 70vh;
331
+ overflow-y: auto;
308
332
  background-color: ${(props) => props.theme.colors.white};
309
333
  min-width: 100%;
310
334
  width: max-content;
@@ -317,13 +341,15 @@
317
341
  const ColAttrs = { numCols: Number, hasActiveView: Boolean }
318
342
  const ColumnWrapper = styled('div', ColAttrs)`
319
343
  display: grid;
344
+ max-height: 50vh;
345
+ overflow-y: auto;
320
346
  grid-template-columns: repeat(${(props) => props.numCols}, auto);
321
347
 
322
348
  ${({ hasActiveView, theme }) =>
323
349
  hasActiveView &&
324
350
  `
325
- border-top: 1px solid ${theme.colors.grey4};
326
- `}
351
+ border-top: 1px solid ${theme.colors.grey4};
352
+ `}
327
353
  `
328
354
 
329
355
  const TitleAttrs = { showBorder: Boolean }
@@ -335,8 +361,8 @@
335
361
  ${({ showBorder, theme }) =>
336
362
  showBorder &&
337
363
  `
338
- border-right: 1px solid ${theme.colors.grey4};
339
- `}
364
+ border-right: 1px solid ${theme.colors.grey4};
365
+ `}
340
366
  `
341
367
 
342
368
  const ButtonContainer = styled.div`
@@ -372,8 +398,8 @@
372
398
  ${({ showBorder, theme }) =>
373
399
  showBorder &&
374
400
  `
375
- border-right: 1px solid ${theme.colors.grey4};
376
- `}
401
+ border-right: 1px solid ${theme.colors.grey4};
402
+ `}
377
403
 
378
404
  .ghost {
379
405
  opacity: 0.5;
@@ -402,6 +428,7 @@
402
428
  display: grid;
403
429
  gap: 6px;
404
430
  width: 100%;
431
+ overflow-wrap: anywhere;
405
432
  padding: 7px 10px;
406
433
  background: ${(props) => props.theme.colors.grey5};
407
434
  `
@@ -435,11 +462,11 @@
435
462
  `
436
463
 
437
464
  const UpperContainer = styled.div`
438
- display: grid;
439
- grid-gap: 20px
440
- grid-template-columns: 1fr 1fr;
441
- padding: 10px 14px;
442
- `
465
+ display: grid;
466
+ grid-gap: 20px
467
+ grid-template-columns: 1fr 1fr;
468
+ padding: 10px 14px;
469
+ `
443
470
 
444
471
  const ResetButton = styled.div`
445
472
  display: inline-flex;
@@ -622,6 +649,9 @@
622
649
  const foundItem = options.find((item) => item.choice === value)
623
650
  return foundItem ? foundItem.text : value ? value : filter.selectedText
624
651
  },
652
+ isSingleSelector(type) {
653
+ return type === 'boolean'
654
+ },
625
655
  isMultipleSelector(type) {
626
656
  return type === 'multi_select_integer' || type === 'multi_select_string'
627
657
  },
@@ -92,7 +92,7 @@
92
92
  mounted() {
93
93
  document.addEventListener('click', this.clickOutside)
94
94
  },
95
- beforeDestroy() {
95
+ beforeUnmount() {
96
96
  document.removeEventListener('click', this.clickOutside)
97
97
  },
98
98
  methods: {
@@ -3,55 +3,61 @@ import Checkbox from './index.vue'
3
3
  export default {
4
4
  title: 'Checkbox',
5
5
  component: Checkbox,
6
- // argTypes: {},
6
+ tags: ['autodocs'],
7
7
  }
8
8
 
9
- const Template = (args, { argTypes }) => ({
10
- // Components used in your story `template` are defined in the `components` object
11
- components: { Checkbox },
12
- // The story's `args` need to be mapped into the template through the `setup()` method
13
- props: Object.keys(argTypes),
14
- template: '<checkbox v-bind="$props" />',
15
-
16
- // import Checkbox from "@eturnity/eturnity_reusable_components/src/components/inputs/checkbox"
17
- //To use:
18
- // <checkbox
19
- // label="Do you accept the Terms?"
20
- // :isChecked="isChecked" //required
21
- // @on-event-handler="onInputChange($event)" //required
22
- // checkColor="blue"
23
- // size="small"
24
- // backgroundColor="red"
25
- // :isDisabled="true"
26
- // />
27
- })
28
-
29
- export const Default = Template.bind({})
30
- Default.args = {
31
- isChecked: true,
32
- size: 'medium', // "small" or "medium"
33
- isDisabled: false,
9
+ // <checkbox
10
+ // label="Do you accept the Terms?"
11
+ // :isChecked="isChecked" //required
12
+ // @on-event-handler="onInputChange($event)" //required
13
+ // checkColor="blue"
14
+ // size="small"
15
+ // backgroundColor="red"
16
+ // :isDisabled="true"
17
+ // cursorType="default"
18
+ // />
19
+
20
+ export const DefaultCheckbox = {
21
+ args: {
22
+ isChecked: 'false',
23
+ },
24
+ }
25
+
26
+ export const IsChecked = {
27
+ args: {
28
+ isChecked: 'true',
29
+ },
30
+ }
31
+
32
+ export const CheckboxLabel = {
33
+ args: {
34
+ isChecked: 'false',
35
+ label: 'Click me',
36
+ },
34
37
  }
35
38
 
36
- export const Small = Template.bind({})
37
- Small.args = {
38
- isChecked: true,
39
- size: 'small', // "small" or "medium"
40
- isDisabled: false,
39
+ export const SmallCheckbox = {
40
+ args: {
41
+ isChecked: 'false',
42
+ label: 'Click me',
43
+ size: 'small',
44
+ },
41
45
  }
42
46
 
43
- export const CustomColor = Template.bind({})
44
- CustomColor.args = {
45
- isChecked: true,
46
- size: 'medium', // "small" or "medium"
47
- checkColor: 'blue',
48
- backgroundColor: 'red',
49
- isDisabled: false,
47
+ export const DisabledCheckbox = {
48
+ args: {
49
+ isChecked: false,
50
+ label: 'Click me',
51
+ size: 'small',
52
+ isDisabled: 'true',
53
+ },
50
54
  }
51
55
 
52
- export const Disabled = Template.bind({})
53
- Disabled.args = {
54
- isChecked: false,
55
- size: 'medium', // "small" or "medium"
56
- isDisabled: true,
56
+ export const CustomColor = {
57
+ args: {
58
+ isChecked: 'false',
59
+ size: 'medium',
60
+ checkColor: 'blue',
61
+ backgroundColor: 'yellow',
62
+ },
57
63
  }
@@ -0,0 +1,109 @@
1
+ /* eslint-disable */
2
+ import { mount } from '@vue/test-utils'
3
+ import Checkbox from '@/components/inputs/checkbox'
4
+ import theme from '@/assets/theme'
5
+
6
+ describe('Checkbox Component', () => {
7
+ let wrapper
8
+
9
+ beforeEach(() => {
10
+ wrapper = mount(Checkbox, {
11
+ props: {
12
+ isChecked: false,
13
+ label: 'Click me',
14
+ isDisabled: false,
15
+ dataId: 'checkbox_wrapper',
16
+ },
17
+ global: {
18
+ provide: {
19
+ theme,
20
+ },
21
+ },
22
+ })
23
+ })
24
+ it('checkbox is rendered and emits correct payload on change', async () => {
25
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
26
+
27
+ // check that the element exists with correct props
28
+ expect(checkboxWrapper.exists()).toBe(true)
29
+ expect(wrapper.vm.isChecked).toBe(false)
30
+ expect(wrapper.vm.label).toBe('Click me')
31
+ expect(wrapper.vm.size).toBe('medium')
32
+ expect(wrapper.vm.isDisabled).toBe(false)
33
+
34
+ // Test the change
35
+ const inputCheckbox = checkboxWrapper.find('input[type="checkbox"]')
36
+ await inputCheckbox.trigger('change')
37
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
38
+ const emittedEvent = wrapper.emitted('on-event-handler')
39
+ // To inspect emitted events:
40
+ expect(emittedEvent).toHaveLength(1) // Check if the event was emitted exactly once
41
+ // Check the payload of the event
42
+ expect(emittedEvent[0]).toEqual([true])
43
+ })
44
+ it('disabled should not emit anything', async () => {
45
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
46
+ await wrapper.setProps({ isDisabled: true })
47
+
48
+ // check that the element exists with correct props
49
+ expect(checkboxWrapper.exists()).toBe(true)
50
+ expect(wrapper.vm.isDisabled).toBe(true)
51
+
52
+ // Test the change
53
+ const inputCheckbox = checkboxWrapper.find('input[type="checkbox"]')
54
+ await inputCheckbox.trigger('change')
55
+ // expect(wrapper.emitted('on-event-handler')).toBeTruthy()
56
+ const emittedEvents = wrapper.emitted('on-event-handler')
57
+ // To inspect emitted events:
58
+ expect(emittedEvents).toBeUndefined() // No event should be emitted
59
+ })
60
+ it('checkbox can handle multiple clicks', async () => {
61
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
62
+
63
+ // check that the element exists with correct props
64
+ expect(checkboxWrapper.exists()).toBe(true)
65
+ expect(wrapper.vm.isChecked).toBe(false)
66
+
67
+ // Test the change
68
+ const inputCheckbox = checkboxWrapper.find('input[type="checkbox"]')
69
+ await inputCheckbox.trigger('change')
70
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
71
+ const emittedEvent = wrapper.emitted('on-event-handler')
72
+ expect(emittedEvent).toHaveLength(1) // Check if the event was emitted exactly once
73
+ // Check the payload of the event
74
+ expect(emittedEvent[0]).toEqual([true])
75
+ await wrapper.setProps({ isChecked: true }) // manually update the props
76
+
77
+ // test the 2nd click
78
+ await inputCheckbox.trigger('change')
79
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
80
+ expect(emittedEvent).toHaveLength(2) // Check if the event was emitted exactly once
81
+ // Check the payload of the event
82
+ expect(emittedEvent[1]).toEqual([false])
83
+ await wrapper.setProps({ isChecked: false }) // manually update the props
84
+
85
+ // test the 3rd click
86
+ await inputCheckbox.trigger('change')
87
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
88
+ expect(emittedEvent).toHaveLength(3) // Check if the event was emitted exactly once
89
+ // Check the payload of the event
90
+ expect(emittedEvent[2]).toEqual([true])
91
+ await wrapper.setProps({ isChecked: true }) // manually update the props
92
+ })
93
+ it('should have a custom background color', async () => {
94
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
95
+ await wrapper.setProps({ backgroundColor: theme.colors.red })
96
+
97
+ // check that the element exists with correct props
98
+ expect(checkboxWrapper.exists()).toBe(true)
99
+ expect(wrapper.vm.backgroundColor).toBe(theme.colors.red)
100
+ })
101
+ it('should have a custom checkbox color', async () => {
102
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
103
+ await wrapper.setProps({ checkColor: theme.colors.brightBlue })
104
+
105
+ // check that the element exists with correct props
106
+ expect(checkboxWrapper.exists()).toBe(true)
107
+ expect(wrapper.vm.checkColor).toBe(theme.colors.brightBlue)
108
+ })
109
+ })
@@ -4,6 +4,7 @@
4
4
  :background-color="backgroundColor"
5
5
  :check-color="checkColor"
6
6
  :cursor-type="cursorType"
7
+ :data-test-id="dataId"
7
8
  :has-label="hasLabel"
8
9
  :is-checked="isChecked"
9
10
  :is-disabled="isDisabled"
@@ -9,7 +9,7 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
9
9
  }))
10
10
 
11
11
  describe('RCToggle.vue', () => {
12
- it('checkbox is rendered and emits correct payload on change', async () => {
12
+ it('toggle is rendered and emits correct payload on change', async () => {
13
13
  const wrapper = mount(RCToggle, {
14
14
  props: { isChecked: true, label: 'Test label', disabled: false },
15
15
  global: {
@@ -42,7 +42,7 @@ describe('RCToggle.vue', () => {
42
42
  // Check the payload of the event
43
43
  expect(emittedEvent[0]).toEqual([false])
44
44
  }),
45
- it('checkbox disabled does not emit anything', async () => {
45
+ it('toggle disabled does not emit anything', async () => {
46
46
  const wrapper = mount(RCToggle, {
47
47
  props: { isChecked: false, disabled: true },
48
48
  global: {