@webitel/ui-sdk 0.9.49 → 0.9.53
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/ui-sdk.common.js +69 -57
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +69 -57
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +2 -2
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/wt-context-menu/__tests__/WtContextMenu.spec.js +43 -0
- package/src/components/molecules/wt-button-select/__tests__/WtButtonSelect.spec.js +63 -0
- package/src/components/molecules/wt-button-select/wt-button-select.vue +39 -23
- package/src/components/organisms/wt-table-column-select/wt-table-column-select.vue +5 -2
- package/src/css/components/molecules/wt-button-select/_variables.scss +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import WtContextMenu from '../wt-context-menu.vue';
|
|
3
|
+
|
|
4
|
+
describe('WtContextMenu', () => {
|
|
5
|
+
const options = ['1', '2'];
|
|
6
|
+
|
|
7
|
+
it('renders a component', () => {
|
|
8
|
+
const wrapper = shallowMount(WtContextMenu);
|
|
9
|
+
expect(wrapper.classes('wt-context-menu')).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('component is visible by default', () => {
|
|
13
|
+
const wrapper = shallowMount(WtContextMenu);
|
|
14
|
+
expect(wrapper.classes()).not.toContain('wt-context-menu--hidden');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('component is invisible, if "visible" prop = false', () => {
|
|
18
|
+
const wrapper = shallowMount(WtContextMenu, {
|
|
19
|
+
propsData: { visible: false },
|
|
20
|
+
});
|
|
21
|
+
// Here we don't use "isVsisble()" because we hide our elements with "opacity: 0"
|
|
22
|
+
expect(wrapper.classes('wt-context-menu--hidden')).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('correctly display the options length', () => {
|
|
26
|
+
const wrapper = shallowMount(WtContextMenu, {
|
|
27
|
+
propsData: { options },
|
|
28
|
+
});
|
|
29
|
+
expect(wrapper.findAll('.wt-context-menu__option').length).toBe(options.length);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should raise click event, and emit { option, index } when clicked', () => {
|
|
33
|
+
const emittingArgs = { option: '1', index: 0 };
|
|
34
|
+
const wrapper = shallowMount(WtContextMenu, {
|
|
35
|
+
propsData: { options },
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
wrapper.find('.wt-context-menu__option').trigger('click');
|
|
39
|
+
expect(wrapper.emitted().click).toBeTruthy();
|
|
40
|
+
|
|
41
|
+
expect(wrapper.emitted('click')[0][0]).toEqual(emittingArgs);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import WtSelectButton from '../wt-button-select.vue';
|
|
3
|
+
import WtContextMenu from '../../../atoms/wt-context-menu/wt-context-menu.vue';
|
|
4
|
+
|
|
5
|
+
describe('WtSelectButton', () => {
|
|
6
|
+
it('renders a component', () => {
|
|
7
|
+
const wrapper = shallowMount(WtSelectButton);
|
|
8
|
+
expect(wrapper.classes('wt-button-select')).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('renders a button content via default slot', () => {
|
|
12
|
+
const content = 'button content';
|
|
13
|
+
const wrapper = shallowMount(WtSelectButton, {
|
|
14
|
+
slots: {
|
|
15
|
+
default: content,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
expect(wrapper.find('.wt-button-select__button').text()).toBe(content);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('context-menu is invisible at start', () => {
|
|
22
|
+
const wrapper = shallowMount(WtSelectButton, {
|
|
23
|
+
stubs: { WtContextMenu },
|
|
24
|
+
});
|
|
25
|
+
expect(wrapper.findComponent(WtContextMenu).classes('wt-context-menu--hidden')).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('toggles isOpened, if select-btn is clicked', async () => {
|
|
29
|
+
const wrapper = shallowMount(WtSelectButton, {
|
|
30
|
+
stubs: { WtContextMenu },
|
|
31
|
+
});
|
|
32
|
+
wrapper.find('.wt-button-select__select-btn').vm.$emit('click');
|
|
33
|
+
await wrapper.vm.$nextTick();
|
|
34
|
+
expect(wrapper.findComponent(WtContextMenu).element.classList[1]).toBe(undefined);
|
|
35
|
+
|
|
36
|
+
wrapper.find('.wt-button-select__select-btn').vm.$emit('click');
|
|
37
|
+
await wrapper.vm.$nextTick();
|
|
38
|
+
expect(wrapper.findComponent(WtContextMenu).element.classList[1]).toBe('wt-context-menu--hidden');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('hides context-menu on its click event', async () => {
|
|
42
|
+
const isOpened = true;
|
|
43
|
+
const options = ['1', '2'];
|
|
44
|
+
const wrapper = shallowMount(WtSelectButton, {
|
|
45
|
+
stubs: { WtContextMenu },
|
|
46
|
+
data: () => ({ isOpened }),
|
|
47
|
+
propsData: { options },
|
|
48
|
+
});
|
|
49
|
+
wrapper.findComponent({ name: 'WtContextMenu' }).vm.$emit('click', { option: '1' });
|
|
50
|
+
await wrapper.vm.$nextTick();
|
|
51
|
+
expect(wrapper.findComponent({ name: 'WtContextMenu' }).classes()).toContain('wt-context-menu--hidden');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should rotate the arrow', () => {
|
|
55
|
+
const wrapper = shallowMount(WtSelectButton, {
|
|
56
|
+
data: () => ({
|
|
57
|
+
isOpened: true,
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
const wtIcon = wrapper.find('.wt-button-select__select-arrow');
|
|
61
|
+
expect(wtIcon.classes()).toContain('wt-button-select__select-arrow--active');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<wt-button
|
|
7
7
|
class="wt-button-select__button"
|
|
8
8
|
v-bind="$attrs"
|
|
9
|
+
:disabled="disabled"
|
|
9
10
|
@click="$emit('click', $event)"
|
|
10
11
|
>
|
|
11
12
|
<slot></slot>
|
|
@@ -14,20 +15,21 @@
|
|
|
14
15
|
<wt-button
|
|
15
16
|
class="wt-button-select__select-btn"
|
|
16
17
|
v-bind="$attrs"
|
|
18
|
+
:disabled="disabled"
|
|
17
19
|
:loading="false"
|
|
18
20
|
@click="isOpened = !isOpened"
|
|
19
21
|
>
|
|
20
22
|
<wt-icon
|
|
21
23
|
class="wt-button-select__select-arrow"
|
|
22
24
|
:class="{'wt-button-select__select-arrow--active': isOpened}"
|
|
23
|
-
v-bind="$attrs"
|
|
24
25
|
icon="arrow-down"
|
|
26
|
+
:disabled="disabled"
|
|
25
27
|
></wt-icon>
|
|
26
28
|
</wt-button>
|
|
27
29
|
|
|
28
30
|
<wt-context-menu
|
|
29
|
-
v-bind="$attrs"
|
|
30
31
|
:visible="isOpened"
|
|
32
|
+
:options="options"
|
|
31
33
|
@click="selectOption"
|
|
32
34
|
></wt-context-menu>
|
|
33
35
|
</div>
|
|
@@ -39,6 +41,17 @@ export default {
|
|
|
39
41
|
data: () => ({
|
|
40
42
|
isOpened: false,
|
|
41
43
|
}),
|
|
44
|
+
props: {
|
|
45
|
+
// all buttons props are passed as "$attrs"
|
|
46
|
+
options: {
|
|
47
|
+
type: Array,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
disabled: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
42
55
|
methods: {
|
|
43
56
|
selectOption({ option, index }) {
|
|
44
57
|
this.$emit('click:option', option, index);
|
|
@@ -75,33 +88,24 @@ export default {
|
|
|
75
88
|
|
|
76
89
|
// NORMAL MODE
|
|
77
90
|
&:not(.wt-button--outline)::v-deep {
|
|
78
|
-
& .wt-
|
|
91
|
+
& .wt-icon__icon {
|
|
79
92
|
fill: var(--button-select-icon-color-dark);
|
|
80
93
|
}
|
|
81
94
|
|
|
82
|
-
//For
|
|
83
|
-
//In another case we will need to write three additional strings
|
|
84
|
-
& .wt-icon__icon {
|
|
85
|
-
fill: var(--button-select-icon-color-ligth);
|
|
86
|
-
}
|
|
95
|
+
// For secondary color, the icon color and icon hover color are the same as in primary color mode
|
|
87
96
|
|
|
88
|
-
&.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
&:hover,
|
|
94
|
-
&:active {
|
|
95
|
-
.wt-icon__icon {
|
|
96
|
-
fill: var(--button-select-icon-color-secondary--hover);
|
|
97
|
-
}
|
|
97
|
+
&.danger,
|
|
98
|
+
&.success,
|
|
99
|
+
&.transfer {
|
|
100
|
+
.wt-icon__icon {
|
|
101
|
+
fill: var(--button-select-icon-color-ligth);
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
//OUTLINE MODE
|
|
103
107
|
&.wt-button--outline::v-deep {
|
|
104
|
-
& .wt-
|
|
108
|
+
& .wt-icon__icon {
|
|
105
109
|
fill: var(--button-select-icon-color-primary);
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -112,11 +116,11 @@ export default {
|
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
|
|
115
|
-
.wt-icon--color-secondary .wt-icon__icon {
|
|
116
|
-
fill: var(--button-select-icon-color-secondary);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
119
|
&.danger {
|
|
120
|
+
& .wt-icon__icon {
|
|
121
|
+
fill: var(--icon-color-danger)
|
|
122
|
+
}
|
|
123
|
+
|
|
120
124
|
&:hover,
|
|
121
125
|
&:active {
|
|
122
126
|
.wt-icon__icon {
|
|
@@ -126,6 +130,10 @@ export default {
|
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
&.success {
|
|
133
|
+
& .wt-icon__icon {
|
|
134
|
+
fill: var(--icon-color-success)
|
|
135
|
+
}
|
|
136
|
+
|
|
129
137
|
&:hover,
|
|
130
138
|
&:active {
|
|
131
139
|
.wt-icon__icon {
|
|
@@ -135,6 +143,10 @@ export default {
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
&.transfer {
|
|
146
|
+
& .wt-icon__icon {
|
|
147
|
+
fill: var(--icon-color-transfer)
|
|
148
|
+
}
|
|
149
|
+
|
|
138
150
|
&:hover,
|
|
139
151
|
&:active {
|
|
140
152
|
.wt-icon__icon {
|
|
@@ -144,6 +156,10 @@ export default {
|
|
|
144
156
|
}
|
|
145
157
|
|
|
146
158
|
&.secondary {
|
|
159
|
+
.wt-icon__icon {
|
|
160
|
+
fill: var(--button-select-icon-color-secondary);
|
|
161
|
+
}
|
|
162
|
+
|
|
147
163
|
&:hover,
|
|
148
164
|
&:active {
|
|
149
165
|
.wt-icon__icon {
|
|
@@ -69,11 +69,10 @@ export default {
|
|
|
69
69
|
}),
|
|
70
70
|
|
|
71
71
|
watch: {
|
|
72
|
-
|
|
72
|
+
isColumnSelectPopup: {
|
|
73
73
|
handler() {
|
|
74
74
|
this.fillHeadersDraft();
|
|
75
75
|
},
|
|
76
|
-
immediate: true,
|
|
77
76
|
},
|
|
78
77
|
},
|
|
79
78
|
computed: {
|
|
@@ -100,6 +99,10 @@ export default {
|
|
|
100
99
|
</script>
|
|
101
100
|
|
|
102
101
|
<style lang="scss" scoped>
|
|
102
|
+
.wt-table-column-select {
|
|
103
|
+
line-height: 0; // prevent 24x28 icon heght :/
|
|
104
|
+
}
|
|
105
|
+
|
|
103
106
|
.wt-table-column-select__popup__list {
|
|
104
107
|
@extend %wt-scrollbar;
|
|
105
108
|
max-height: 35vh; // fixme popup fixed sizes
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
--button-select-buttons-gap: 1px;
|
|
10
10
|
|
|
11
11
|
--button-select-icon-color-primary: var(--btn-primary-color);
|
|
12
|
-
--button-select-icon-color-secondary: var(--btn-
|
|
12
|
+
--button-select-icon-color-secondary: var(--btn-secondary-color);
|
|
13
13
|
--button-select-icon-color-dark: var(--btn-dark-font-color);
|
|
14
14
|
--button-select-icon-color-ligth: var(--main-color);
|
|
15
15
|
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
--button-select-icon-color-danger--hover: var(--btn-false--hover-color);
|
|
18
18
|
--button-select-icon-color-success--hover: var(--btn-true--hover-color);
|
|
19
19
|
--button-select-icon-color-transfer--hover: var(--btn-transfer--hover-color);
|
|
20
|
-
--button-select-icon-color-secondary--hover: var(--btn-
|
|
20
|
+
--button-select-icon-color-secondary--hover: var(--btn-secondary--hover-color);
|
|
21
21
|
}
|