@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 +1 -1
- package/src/components/buttons/mainButton/mainButton.spec.js +7 -4
- package/src/components/filter/filterSettings.vue +54 -24
- package/src/components/filter/index.vue +1 -1
- package/src/components/inputs/checkbox/Checkbox.stories.js +49 -43
- package/src/components/inputs/checkbox/checkbox.spec.js +109 -0
- package/src/components/inputs/checkbox/index.vue +1 -0
- package/src/components/inputs/toggle/toggle.spec.js +2 -2
package/package.json
CHANGED
@@ -9,8 +9,10 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
|
|
9
9
|
}))
|
10
10
|
|
11
11
|
describe('MainButton.vue', () => {
|
12
|
-
|
13
|
-
|
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="
|
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
|
-
<
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
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
|
},
|
@@ -3,55 +3,61 @@ import Checkbox from './index.vue'
|
|
3
3
|
export default {
|
4
4
|
title: 'Checkbox',
|
5
5
|
component: Checkbox,
|
6
|
-
|
6
|
+
tags: ['autodocs'],
|
7
7
|
}
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
export const SmallCheckbox = {
|
40
|
+
args: {
|
41
|
+
isChecked: 'false',
|
42
|
+
label: 'Click me',
|
43
|
+
size: 'small',
|
44
|
+
},
|
41
45
|
}
|
42
46
|
|
43
|
-
export const
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
+
})
|
@@ -9,7 +9,7 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
|
|
9
9
|
}))
|
10
10
|
|
11
11
|
describe('RCToggle.vue', () => {
|
12
|
-
it('
|
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('
|
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: {
|