@weni/unnnic-system 3.2.9-alpha.10 → 3.2.9-alpha.12
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/dist/components/Button/Button.vue.d.ts.map +1 -1
- package/dist/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue.d.ts.map +1 -1
- package/dist/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue.d.ts +43 -0
- package/dist/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue.d.ts.map +1 -0
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts +1 -1
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/{es-3cbe331a.js → es-66126ef1.mjs} +1 -1
- package/dist/{index-2241773d.js → index-f6e9b879.mjs} +1539 -1486
- package/dist/{pt-br-9ddee0e9.js → pt-br-3b5a8852.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/{unnnic.js → unnnic.mjs} +1 -1
- package/dist/{unnnic.umd.cjs → unnnic.umd.js} +30 -30
- package/package.json +2 -2
- package/src/components/Button/Button.vue +4 -7
- package/src/components/ChartFunnel/ChartFunnel.vue +4 -0
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +9 -2
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelBaseRow.vue +1 -1
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +65 -0
- package/src/components/Chip/Chip.vue +1 -1
- package/src/components/Input/BaseInput.vue +4 -4
- package/src/components/Input/Input.vue +1 -1
- package/src/components/Input/TextInput.vue +3 -2
- package/src/components/ModalDialog/ModalDialog.vue +26 -29
- package/src/components/Popover/__tests__/Popover.spec.js +18 -18
- package/src/components/Popover/index.vue +78 -93
- package/src/components/Select/SelectOption.vue +37 -43
- package/src/components/Select/__tests__/Select.spec.js +36 -41
- package/src/components/Select/__tests__/SelectItem.spec.js +15 -35
- package/src/components/Select/__tests__/SelectOption.spec.js +3 -6
- package/src/components/Select/index.vue +142 -192
- package/src/components/TemplatePreview/TemplatePreview.vue +25 -28
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +10 -10
- package/src/components/TemplatePreview/types.d.ts +3 -3
- package/src/stories/Button.stories.js +7 -1
- package/src/stories/ChartFunnel.stories.js +19 -0
- package/src/stories/Input.stories.js +4 -4
- package/src/stories/Popover.stories.js +9 -9
- package/src/stories/Select.stories.js +39 -39
- package/src/stories/TemplatePreview.stories.js +27 -27
- package/src/stories/TemplatePreviewModal.stories.js +31 -31
|
@@ -1,146 +1,131 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
<slot name="trigger" />
|
|
12
|
-
</div>
|
|
13
|
-
<div
|
|
14
|
-
v-if="open"
|
|
15
|
-
class="unnnic-popover__balloon"
|
|
16
|
-
data-testid="popover-balloon"
|
|
17
|
-
>
|
|
18
|
-
<slot name="content" />
|
|
19
|
-
</div>
|
|
20
|
-
</section>
|
|
2
|
+
<section class="unnnic-popover" ref="popover">
|
|
3
|
+
<div class="unnnic-popover__trigger" data-testid="popover-trigger" @click="toggleOpen()">
|
|
4
|
+
<slot name="trigger" />
|
|
5
|
+
</div>
|
|
6
|
+
<div v-if="open" class="unnnic-popover__balloon" data-testid="popover-balloon">
|
|
7
|
+
<slot name="content" />
|
|
8
|
+
</div>
|
|
9
|
+
</section>
|
|
21
10
|
</template>
|
|
22
11
|
|
|
23
12
|
<script setup lang="ts">
|
|
24
13
|
import { computed, onMounted, ref, useTemplateRef, watch } from 'vue';
|
|
25
14
|
import { onClickOutside, useResizeObserver } from '@vueuse/core';
|
|
26
15
|
|
|
27
|
-
const target = useTemplateRef<HTMLDivElement>('popover')
|
|
16
|
+
const target = useTemplateRef<HTMLDivElement>('popover')
|
|
28
17
|
|
|
29
|
-
const popoverWidth = ref<string>('')
|
|
18
|
+
const popoverWidth = ref<string>('')
|
|
30
19
|
|
|
31
20
|
useResizeObserver(target, (entries) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
21
|
+
const entry = entries[0]
|
|
22
|
+
const { width } = entry.contentRect
|
|
23
|
+
popoverWidth.value = `${width}px`
|
|
24
|
+
})
|
|
36
25
|
|
|
37
26
|
onClickOutside(target, () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
27
|
+
if (props.persistent) return;
|
|
28
|
+
open.value = false;
|
|
29
|
+
})
|
|
41
30
|
|
|
42
31
|
defineOptions({
|
|
43
|
-
|
|
44
|
-
})
|
|
32
|
+
name: "UnnnicPopover"
|
|
33
|
+
})
|
|
45
34
|
|
|
46
35
|
interface PopoverBalloonProps {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
width?: string;
|
|
37
|
+
height?: string;
|
|
38
|
+
maxHeight?: string;
|
|
50
39
|
}
|
|
51
40
|
|
|
52
41
|
interface PopoverProps {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
modelValue?: boolean;
|
|
43
|
+
persistent?: boolean;
|
|
44
|
+
popoverBalloonProps?: PopoverBalloonProps;
|
|
56
45
|
}
|
|
57
46
|
|
|
58
47
|
const props = withDefaults(defineProps<PopoverProps>(), {
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
modelValue: undefined,
|
|
49
|
+
persistent: false,
|
|
61
50
|
});
|
|
62
51
|
|
|
63
52
|
const emit = defineEmits<{
|
|
64
|
-
|
|
65
|
-
}>()
|
|
53
|
+
'update:modelValue': [value: boolean];
|
|
54
|
+
}>()
|
|
66
55
|
|
|
67
56
|
const useModelValue = computed(() => props.modelValue !== undefined);
|
|
68
57
|
|
|
69
|
-
const open = ref<boolean>(
|
|
70
|
-
useModelValue.value ? Boolean(props.modelValue) : false,
|
|
71
|
-
);
|
|
58
|
+
const open = ref<boolean>(useModelValue.value ? Boolean(props.modelValue) : false);
|
|
72
59
|
|
|
73
60
|
const toggleOpen = () => {
|
|
74
|
-
|
|
75
|
-
}
|
|
61
|
+
open.value = !open.value;
|
|
62
|
+
}
|
|
76
63
|
|
|
77
64
|
const calculatedPopoverWidth = computed(() => {
|
|
78
|
-
|
|
79
|
-
})
|
|
65
|
+
return props.popoverBalloonProps?.width || popoverWidth.value
|
|
66
|
+
})
|
|
80
67
|
|
|
81
68
|
const popoverHeight = computed(() => {
|
|
82
|
-
|
|
83
|
-
})
|
|
69
|
+
return props.popoverBalloonProps?.height || 'unset'
|
|
70
|
+
})
|
|
84
71
|
|
|
85
72
|
const popoverMaxHeight = computed(() => {
|
|
86
|
-
|
|
87
|
-
})
|
|
73
|
+
return props.popoverBalloonProps?.maxHeight || 'unset'
|
|
74
|
+
})
|
|
88
75
|
|
|
89
76
|
onMounted(() => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
77
|
+
if (useModelValue.value) {
|
|
78
|
+
open.value = Boolean(props.modelValue);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
94
81
|
|
|
95
82
|
watch(open, (value) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
83
|
+
if (useModelValue.value) {
|
|
84
|
+
emit('update:modelValue', value);
|
|
85
|
+
}
|
|
86
|
+
})
|
|
100
87
|
|
|
101
|
-
watch(
|
|
102
|
-
() => props.modelValue,
|
|
103
|
-
(value) => {
|
|
88
|
+
watch(() => props.modelValue, (value) => {
|
|
104
89
|
open.value = !!value;
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
})
|
|
91
|
+
|
|
107
92
|
</script>
|
|
108
93
|
|
|
109
94
|
<style lang="scss" scoped>
|
|
110
95
|
@use '@/assets/scss/unnnic' as *;
|
|
111
96
|
|
|
112
97
|
* {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
98
|
+
margin: 0;
|
|
99
|
+
padding: 0;
|
|
100
|
+
box-sizing: border-box;
|
|
116
101
|
}
|
|
117
102
|
|
|
118
103
|
.unnnic-popover {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
104
|
+
&__balloon {
|
|
105
|
+
border-radius: $unnnic-radius-2;
|
|
106
|
+
padding: $unnnic-space-4;
|
|
107
|
+
background: $unnnic-color-bg-base;
|
|
108
|
+
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.16);
|
|
109
|
+
// margin-top: $unnnic-space-1;
|
|
110
|
+
position: fixed;
|
|
111
|
+
width: v-bind(calculatedPopoverWidth);
|
|
112
|
+
height: v-bind(popoverHeight);
|
|
113
|
+
max-height: v-bind(popoverMaxHeight);
|
|
114
|
+
overflow: auto;
|
|
115
|
+
|
|
116
|
+
&::-webkit-scrollbar {
|
|
117
|
+
width: $unnnic-spacing-inline-nano;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&::-webkit-scrollbar-thumb {
|
|
121
|
+
background: $unnnic-color-neutral-cleanest;
|
|
122
|
+
border-radius: $unnnic-border-radius-pill;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&::-webkit-scrollbar-track {
|
|
126
|
+
background: $unnnic-color-neutral-soft;
|
|
127
|
+
border-radius: $unnnic-border-radius-pill;
|
|
128
|
+
}
|
|
143
129
|
}
|
|
144
|
-
}
|
|
145
130
|
}
|
|
146
|
-
</style>
|
|
131
|
+
</style>
|
|
@@ -1,65 +1,59 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
:class="[
|
|
4
|
-
'unnnic-select-option',
|
|
5
|
-
{
|
|
2
|
+
<div :class="['unnnic-select-option', {
|
|
6
3
|
'unnnic-select-option--disabled': props.disabled,
|
|
7
4
|
'unnnic-select-option--active': props.active,
|
|
8
5
|
'unnnic-select-option--focused': props.focused,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<p class="unnnic-select-option__label">{{ props.label }}</p>
|
|
13
|
-
</div>
|
|
6
|
+
}]">
|
|
7
|
+
<p class="unnnic-select-option__label">{{ props.label }}</p>
|
|
8
|
+
</div>
|
|
14
9
|
</template>
|
|
15
10
|
|
|
16
11
|
<script setup lang="ts">
|
|
17
12
|
defineOptions({
|
|
18
|
-
|
|
19
|
-
})
|
|
13
|
+
name: "UnnnicSelectOption"
|
|
14
|
+
})
|
|
20
15
|
|
|
21
16
|
interface SelectOptionProps {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
label: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
active?: boolean;
|
|
20
|
+
focused?: boolean;
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
const props = withDefaults(defineProps<SelectOptionProps>(), {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
24
|
+
disabled: false,
|
|
25
|
+
active: false,
|
|
26
|
+
focused: false,
|
|
27
|
+
})
|
|
33
28
|
</script>
|
|
34
29
|
|
|
35
30
|
<style lang="scss" scoped>
|
|
36
31
|
@use '@/assets/scss/unnnic' as *;
|
|
37
32
|
* {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: 0;
|
|
35
|
+
box-sizing: border-box;
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
.unnnic-select-option {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
border-radius: $unnnic-radius-1;
|
|
41
|
+
padding: $unnnic-space-2 $unnnic-space-4;
|
|
42
|
+
font: $unnnic-font-emphasis;
|
|
43
|
+
|
|
44
|
+
&:hover:not(&--active):not(&--disabled), &--focused {
|
|
45
|
+
background-color: $unnnic-color-bg-soft;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&--active {
|
|
49
|
+
background-color: $unnnic-color-bg-active;
|
|
50
|
+
color: $unnnic-color-fg-inverted;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&--disabled {
|
|
54
|
+
color: $unnnic-color-fg-muted;
|
|
55
|
+
background-color: $unnnic-color-bg-muted;
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
}
|
|
64
58
|
}
|
|
65
|
-
</style>
|
|
59
|
+
</style>
|
|
@@ -5,9 +5,9 @@ import UnnnicSelect from '../index.vue';
|
|
|
5
5
|
vi.mock('../../mixins/i18n', () => ({
|
|
6
6
|
default: {
|
|
7
7
|
methods: {
|
|
8
|
-
$t: (key) => key
|
|
9
|
-
}
|
|
10
|
-
}
|
|
8
|
+
$t: (key) => key
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
13
|
describe('UnnnicSelect.vue', () => {
|
|
@@ -17,23 +17,23 @@ describe('UnnnicSelect.vue', () => {
|
|
|
17
17
|
options: [
|
|
18
18
|
{ label: 'Option 1', value: 'option1' },
|
|
19
19
|
{ label: 'Option 2', value: 'option2' },
|
|
20
|
-
{ label: 'Option 3', value: 'option3' }
|
|
20
|
+
{ label: 'Option 3', value: 'option3' }
|
|
21
21
|
],
|
|
22
|
-
modelValue: null
|
|
22
|
+
modelValue: null
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const mountWrapper = (props = {}, slots = {}) => {
|
|
26
26
|
return mount(UnnnicSelect, {
|
|
27
27
|
props: {
|
|
28
28
|
...defaultProps,
|
|
29
|
-
...props
|
|
29
|
+
...props
|
|
30
30
|
},
|
|
31
31
|
global: {
|
|
32
32
|
mocks: {
|
|
33
|
-
$t: (key) => key
|
|
34
|
-
}
|
|
33
|
+
$t: (key) => key
|
|
34
|
+
}
|
|
35
35
|
},
|
|
36
|
-
slots
|
|
36
|
+
slots
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -119,10 +119,10 @@ describe('UnnnicSelect.vue', () => {
|
|
|
119
119
|
|
|
120
120
|
test('input shows correct icon based on popover state', async () => {
|
|
121
121
|
const input = wrapper.findComponent({ name: 'UnnnicInput' });
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
// Initially closed
|
|
124
124
|
expect(input.props('iconRight')).toBe('keyboard_arrow_down');
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
// When popover is open
|
|
127
127
|
wrapper.vm.openPopover = true;
|
|
128
128
|
await wrapper.vm.$nextTick();
|
|
@@ -135,9 +135,9 @@ describe('UnnnicSelect.vue', () => {
|
|
|
135
135
|
wrapper.vm.openPopover = true;
|
|
136
136
|
await wrapper.vm.$nextTick();
|
|
137
137
|
const options = wrapper.findAllComponents({ name: 'UnnnicSelectOption' });
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
await options[0].vm.$emit('click');
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
142
142
|
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['option1']);
|
|
143
143
|
});
|
|
@@ -147,12 +147,10 @@ describe('UnnnicSelect.vue', () => {
|
|
|
147
147
|
wrapper.vm.openPopover = true;
|
|
148
148
|
await wrapper.vm.$nextTick();
|
|
149
149
|
const options = wrapper.findAllComponents({ name: 'UnnnicSelectOption' });
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
await options[0].vm.$emit('click');
|
|
152
|
-
|
|
153
|
-
expect(wrapper.emitted('update:modelValue')[0]).toEqual([
|
|
154
|
-
{ label: 'Option 1', value: 'option1' },
|
|
155
|
-
]);
|
|
152
|
+
|
|
153
|
+
expect(wrapper.emitted('update:modelValue')[0]).toEqual([{ label: 'Option 1', value: 'option1' }]);
|
|
156
154
|
});
|
|
157
155
|
|
|
158
156
|
test('does not emit when same option is selected', async () => {
|
|
@@ -160,25 +158,25 @@ describe('UnnnicSelect.vue', () => {
|
|
|
160
158
|
wrapper.vm.openPopover = true;
|
|
161
159
|
await wrapper.vm.$nextTick();
|
|
162
160
|
const options = wrapper.findAllComponents({ name: 'UnnnicSelectOption' });
|
|
163
|
-
|
|
161
|
+
|
|
164
162
|
await options[0].vm.$emit('click');
|
|
165
|
-
|
|
163
|
+
|
|
166
164
|
expect(wrapper.emitted('update:modelValue')).toBeFalsy();
|
|
167
165
|
});
|
|
168
166
|
|
|
169
167
|
test('does not emit when disabled option is clicked', async () => {
|
|
170
168
|
const disabledOptions = [
|
|
171
169
|
{ label: 'Option 1', value: 'option1' },
|
|
172
|
-
{ label: 'Disabled Option', value: 'disabled', disabled: true }
|
|
170
|
+
{ label: 'Disabled Option', value: 'disabled', disabled: true }
|
|
173
171
|
];
|
|
174
|
-
|
|
172
|
+
|
|
175
173
|
await wrapper.setProps({ options: disabledOptions });
|
|
176
174
|
wrapper.vm.openPopover = true;
|
|
177
175
|
await wrapper.vm.$nextTick();
|
|
178
176
|
const options = wrapper.findAllComponents({ name: 'UnnnicSelectOption' });
|
|
179
|
-
|
|
177
|
+
|
|
180
178
|
await options[1].vm.$emit('click');
|
|
181
|
-
|
|
179
|
+
|
|
182
180
|
expect(wrapper.emitted('update:modelValue')).toBeFalsy();
|
|
183
181
|
});
|
|
184
182
|
});
|
|
@@ -199,20 +197,20 @@ describe('UnnnicSelect.vue', () => {
|
|
|
199
197
|
});
|
|
200
198
|
|
|
201
199
|
test('emits update:search when search input changes', async () => {
|
|
202
|
-
await wrapper.setProps({ enableSearch: true
|
|
200
|
+
await wrapper.setProps({ enableSearch: true});
|
|
203
201
|
wrapper.vm.openPopover = true;
|
|
204
202
|
await wrapper.vm.$nextTick();
|
|
205
203
|
const searchInput = wrapper.findAllComponents({ name: 'UnnnicInput' })[1];
|
|
206
|
-
|
|
204
|
+
|
|
207
205
|
await searchInput.vm.$emit('update:modelValue', 'test search');
|
|
208
|
-
|
|
206
|
+
|
|
209
207
|
expect(wrapper.emitted('update:search')).toBeTruthy();
|
|
210
208
|
expect(wrapper.emitted('update:search')[0]).toEqual(['test search']);
|
|
211
209
|
});
|
|
212
210
|
|
|
213
211
|
test('filters options based on search term', async () => {
|
|
214
212
|
await wrapper.setProps({ enableSearch: true, search: 'Option 1' });
|
|
215
|
-
|
|
213
|
+
|
|
216
214
|
const filteredOptions = wrapper.vm.filteredOptions;
|
|
217
215
|
expect(filteredOptions.length).toBe(1);
|
|
218
216
|
expect(filteredOptions[0].label).toBe('Option 1');
|
|
@@ -220,7 +218,7 @@ describe('UnnnicSelect.vue', () => {
|
|
|
220
218
|
|
|
221
219
|
test('filters options by both label and value', async () => {
|
|
222
220
|
await wrapper.setProps({ enableSearch: true, search: 'option1' });
|
|
223
|
-
|
|
221
|
+
|
|
224
222
|
const filteredOptions = wrapper.vm.filteredOptions;
|
|
225
223
|
expect(filteredOptions.length).toBe(1);
|
|
226
224
|
expect(filteredOptions[0].value).toBe('option1');
|
|
@@ -228,7 +226,7 @@ describe('UnnnicSelect.vue', () => {
|
|
|
228
226
|
|
|
229
227
|
test('shows all options when search is empty', async () => {
|
|
230
228
|
await wrapper.setProps({ enableSearch: true, search: '' });
|
|
231
|
-
|
|
229
|
+
|
|
232
230
|
const filteredOptions = wrapper.vm.filteredOptions;
|
|
233
231
|
expect(filteredOptions.length).toBe(3);
|
|
234
232
|
});
|
|
@@ -261,10 +259,7 @@ describe('UnnnicSelect.vue', () => {
|
|
|
261
259
|
|
|
262
260
|
test('selectedItem returns modelValue for returnObject true', async () => {
|
|
263
261
|
const selectedOption = { label: 'Option 2', value: 'option2' };
|
|
264
|
-
await wrapper.setProps({
|
|
265
|
-
returnObject: true,
|
|
266
|
-
modelValue: selectedOption,
|
|
267
|
-
});
|
|
262
|
+
await wrapper.setProps({ returnObject: true, modelValue: selectedOption });
|
|
268
263
|
const selectedItem = wrapper.vm.selectedItem;
|
|
269
264
|
expect(selectedItem).toStrictEqual(selectedOption);
|
|
270
265
|
});
|
|
@@ -331,16 +326,16 @@ describe('UnnnicSelect.vue', () => {
|
|
|
331
326
|
test('uses custom itemLabel and itemValue', async () => {
|
|
332
327
|
const customOptions = [
|
|
333
328
|
{ name: 'Custom 1', id: 'custom1' },
|
|
334
|
-
{ name: 'Custom 2', id: 'custom2' }
|
|
329
|
+
{ name: 'Custom 2', id: 'custom2' }
|
|
335
330
|
];
|
|
336
|
-
|
|
337
|
-
await wrapper.setProps({
|
|
338
|
-
options: customOptions,
|
|
339
|
-
itemLabel: 'name',
|
|
331
|
+
|
|
332
|
+
await wrapper.setProps({
|
|
333
|
+
options: customOptions,
|
|
334
|
+
itemLabel: 'name',
|
|
340
335
|
itemValue: 'id',
|
|
341
|
-
modelValue: 'custom1'
|
|
336
|
+
modelValue: 'custom1'
|
|
342
337
|
});
|
|
343
|
-
|
|
338
|
+
|
|
344
339
|
const inputValue = wrapper.vm.inputValue;
|
|
345
340
|
expect(inputValue).toBe('Custom 1');
|
|
346
341
|
});
|
|
@@ -3,9 +3,9 @@ import { beforeEach, describe, expect, test } from 'vitest';
|
|
|
3
3
|
import SelectItem from '../SelectItem.vue';
|
|
4
4
|
|
|
5
5
|
const createWrapper = (props = {}, slots = {}) => {
|
|
6
|
-
return mount(SelectItem, {
|
|
6
|
+
return mount(SelectItem, {
|
|
7
7
|
props,
|
|
8
|
-
slots: slots.default ? { default: slots.default } : {}
|
|
8
|
+
slots: slots.default ? { default: slots.default } : {}
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -76,12 +76,8 @@ describe('SelectItem.vue', () => {
|
|
|
76
76
|
test('does not apply size class when size is empty', async () => {
|
|
77
77
|
await wrapper.setProps({ size: '' });
|
|
78
78
|
const labelElement = wrapper.find('.unnnic-select-item__label');
|
|
79
|
-
expect(labelElement.classes()).not.toContain(
|
|
80
|
-
|
|
81
|
-
);
|
|
82
|
-
expect(labelElement.classes()).not.toContain(
|
|
83
|
-
'unnnic-select-item__label--sm',
|
|
84
|
-
);
|
|
79
|
+
expect(labelElement.classes()).not.toContain('unnnic-select-item__label--md');
|
|
80
|
+
expect(labelElement.classes()).not.toContain('unnnic-select-item__label--sm');
|
|
85
81
|
});
|
|
86
82
|
});
|
|
87
83
|
|
|
@@ -132,10 +128,7 @@ describe('SelectItem.vue', () => {
|
|
|
132
128
|
});
|
|
133
129
|
|
|
134
130
|
test('emits click event even when selectable is false', async () => {
|
|
135
|
-
const clickWrapper = createWrapper(
|
|
136
|
-
{ selectable: false },
|
|
137
|
-
{ default: 'Test Item' },
|
|
138
|
-
);
|
|
131
|
+
const clickWrapper = createWrapper({ selectable: false }, { default: 'Test Item' });
|
|
139
132
|
await clickWrapper.trigger('click');
|
|
140
133
|
expect(clickWrapper.emitted('click')).toBeTruthy();
|
|
141
134
|
expect(clickWrapper.emitted('click').length).toBeGreaterThanOrEqual(1);
|
|
@@ -201,7 +194,7 @@ describe('SelectItem.vue', () => {
|
|
|
201
194
|
test('has proper semantic structure', () => {
|
|
202
195
|
const div = wrapper.find('.unnnic-select-item');
|
|
203
196
|
const span = wrapper.find('.unnnic-select-item__label');
|
|
204
|
-
|
|
197
|
+
|
|
205
198
|
expect(div.exists()).toBe(true);
|
|
206
199
|
expect(span.exists()).toBe(true);
|
|
207
200
|
expect(span.element.tagName).toBe('SPAN');
|
|
@@ -221,8 +214,7 @@ describe('SelectItem.vue', () => {
|
|
|
221
214
|
});
|
|
222
215
|
|
|
223
216
|
test('handles long slot content', async () => {
|
|
224
|
-
const longText =
|
|
225
|
-
'This is a very long text content that should be handled properly by the component';
|
|
217
|
+
const longText = 'This is a very long text content that should be handled properly by the component';
|
|
226
218
|
const longWrapper = createWrapper({}, { default: longText });
|
|
227
219
|
const labelElement = longWrapper.find('.unnnic-select-item__label');
|
|
228
220
|
expect(labelElement.text()).toBe(longText);
|
|
@@ -245,12 +237,8 @@ describe('SelectItem.vue', () => {
|
|
|
245
237
|
|
|
246
238
|
describe('CSS class combinations', () => {
|
|
247
239
|
test('applies correct classes for non-selectable inactive item', async () => {
|
|
248
|
-
await wrapper.setProps({
|
|
249
|
-
|
|
250
|
-
active: false,
|
|
251
|
-
textFocused: false,
|
|
252
|
-
});
|
|
253
|
-
|
|
240
|
+
await wrapper.setProps({ selectable: false, active: false, textFocused: false });
|
|
241
|
+
|
|
254
242
|
expect(wrapper.classes()).toContain('unnnic-select-item');
|
|
255
243
|
expect(wrapper.classes()).not.toContain('unnnic-select-item--selectable');
|
|
256
244
|
expect(wrapper.classes()).not.toContain('unnnic--clickable');
|
|
@@ -259,12 +247,8 @@ describe('SelectItem.vue', () => {
|
|
|
259
247
|
});
|
|
260
248
|
|
|
261
249
|
test('applies correct classes for selectable active item', async () => {
|
|
262
|
-
await wrapper.setProps({
|
|
263
|
-
|
|
264
|
-
active: true,
|
|
265
|
-
textFocused: false,
|
|
266
|
-
});
|
|
267
|
-
|
|
250
|
+
await wrapper.setProps({ selectable: true, active: true, textFocused: false });
|
|
251
|
+
|
|
268
252
|
expect(wrapper.classes()).toContain('unnnic-select-item');
|
|
269
253
|
expect(wrapper.classes()).toContain('unnnic-select-item--selectable');
|
|
270
254
|
expect(wrapper.classes()).toContain('unnnic--clickable');
|
|
@@ -273,12 +257,8 @@ describe('SelectItem.vue', () => {
|
|
|
273
257
|
});
|
|
274
258
|
|
|
275
259
|
test('applies correct classes for text-focused item', async () => {
|
|
276
|
-
await wrapper.setProps({
|
|
277
|
-
|
|
278
|
-
active: false,
|
|
279
|
-
textFocused: true,
|
|
280
|
-
});
|
|
281
|
-
|
|
260
|
+
await wrapper.setProps({ selectable: true, active: false, textFocused: true });
|
|
261
|
+
|
|
282
262
|
expect(wrapper.classes()).toContain('unnnic-select-item');
|
|
283
263
|
expect(wrapper.classes()).toContain('unnnic-select-item--selectable');
|
|
284
264
|
expect(wrapper.classes()).toContain('unnnic--clickable');
|
|
@@ -318,11 +298,11 @@ describe('SelectItem.vue', () => {
|
|
|
318
298
|
});
|
|
319
299
|
|
|
320
300
|
test('matches snapshot with all states combined', async () => {
|
|
321
|
-
await wrapper.setProps({
|
|
301
|
+
await wrapper.setProps({
|
|
322
302
|
size: 'md',
|
|
323
303
|
selectable: true,
|
|
324
304
|
active: true,
|
|
325
|
-
textFocused: true
|
|
305
|
+
textFocused: true
|
|
326
306
|
});
|
|
327
307
|
expect(wrapper.html()).toMatchSnapshot();
|
|
328
308
|
});
|
|
@@ -89,9 +89,7 @@ describe('SelectOption.vue', () => {
|
|
|
89
89
|
disabled: false,
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
expect(wrapper.find('.unnnic-select-option__label').text()).toBe(
|
|
93
|
-
'Complex Option',
|
|
94
|
-
);
|
|
92
|
+
expect(wrapper.find('.unnnic-select-option__label').text()).toBe('Complex Option');
|
|
95
93
|
expect(wrapper.classes()).toContain('unnnic-select-option--active');
|
|
96
94
|
expect(wrapper.classes()).not.toContain('unnnic-select-option--disabled');
|
|
97
95
|
});
|
|
@@ -116,7 +114,7 @@ describe('SelectOption.vue', () => {
|
|
|
116
114
|
test('has proper semantic structure', () => {
|
|
117
115
|
const div = wrapper.find('.unnnic-select-option');
|
|
118
116
|
const p = wrapper.find('.unnnic-select-option__label');
|
|
119
|
-
|
|
117
|
+
|
|
120
118
|
expect(div.exists()).toBe(true);
|
|
121
119
|
expect(p.exists()).toBe(true);
|
|
122
120
|
expect(p.element.tagName).toBe('P');
|
|
@@ -136,8 +134,7 @@ describe('SelectOption.vue', () => {
|
|
|
136
134
|
});
|
|
137
135
|
|
|
138
136
|
test('handles long label text', async () => {
|
|
139
|
-
const longText =
|
|
140
|
-
'This is a very long label text that should be handled properly by the component';
|
|
137
|
+
const longText = 'This is a very long label text that should be handled properly by the component';
|
|
141
138
|
await wrapper.setProps({ label: longText });
|
|
142
139
|
const labelElement = wrapper.find('.unnnic-select-option__label');
|
|
143
140
|
expect(labelElement.text()).toBe(longText);
|