@webitel/ui-sdk 0.9.47 → 0.9.51
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 +143 -138
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +143 -138
- 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-button/wt-button.vue +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 +45 -30
- package/src/components/organisms/wt-table-column-select/wt-table-column-select.vue +4 -0
- package/src/css/components/molecules/wt-button-select/_variables.scss +1 -1
- package/src/mixins/validationMixin/validationMixin.js +14 -13
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,22 @@ export default {
|
|
|
75
88
|
|
|
76
89
|
// NORMAL MODE
|
|
77
90
|
&:not(.wt-button--outline)::v-deep {
|
|
78
|
-
& .wt-icon--color-default .wt-icon__icon {
|
|
79
|
-
fill: var(--button-select-icon-color-dark);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//For danger, success, transfer icon fill-colors.
|
|
83
|
-
//In another case we will need to write three additional strings
|
|
84
91
|
& .wt-icon__icon {
|
|
85
|
-
fill: var(--button-select-icon-color-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&.secondary .wt-icon--color-secondary .wt-icon__icon {
|
|
89
|
-
fill: var(--button-select-icon-color-secondary);
|
|
92
|
+
fill: var(--button-select-icon-color-dark);
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
&.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
95
|
+
&.danger,
|
|
96
|
+
&.success,
|
|
97
|
+
&.transfer {
|
|
98
|
+
.wt-icon__icon {
|
|
99
|
+
fill: var(--button-select-icon-color-ligth);
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
//OUTLINE MODE
|
|
103
105
|
&.wt-button--outline::v-deep {
|
|
104
|
-
& .wt-
|
|
106
|
+
& .wt-icon__icon {
|
|
105
107
|
fill: var(--button-select-icon-color-primary);
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -112,11 +114,11 @@ export default {
|
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
.wt-icon--color-secondary .wt-icon__icon {
|
|
116
|
-
fill: var(--button-select-icon-color-secondary);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
117
|
&.danger {
|
|
118
|
+
& .wt-icon__icon {
|
|
119
|
+
fill: var(--icon-color-danger)
|
|
120
|
+
}
|
|
121
|
+
|
|
120
122
|
&:hover,
|
|
121
123
|
&:active {
|
|
122
124
|
.wt-icon__icon {
|
|
@@ -126,6 +128,10 @@ export default {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
&.success {
|
|
131
|
+
& .wt-icon__icon {
|
|
132
|
+
fill: var(--icon-color-success)
|
|
133
|
+
}
|
|
134
|
+
|
|
129
135
|
&:hover,
|
|
130
136
|
&:active {
|
|
131
137
|
.wt-icon__icon {
|
|
@@ -135,6 +141,10 @@ export default {
|
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
&.transfer {
|
|
144
|
+
& .wt-icon__icon {
|
|
145
|
+
fill: var(--icon-color-transfer)
|
|
146
|
+
}
|
|
147
|
+
|
|
138
148
|
&:hover,
|
|
139
149
|
&:active {
|
|
140
150
|
.wt-icon__icon {
|
|
@@ -142,13 +152,18 @@ export default {
|
|
|
142
152
|
}
|
|
143
153
|
}
|
|
144
154
|
}
|
|
155
|
+
}
|
|
145
156
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
// SECONDARY MODE (is same for outline and normal modes)
|
|
158
|
+
&.secondary::v-deep {
|
|
159
|
+
.wt-icon__icon {
|
|
160
|
+
fill: var(--button-select-icon-color-secondary);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&:hover,
|
|
164
|
+
&:active {
|
|
165
|
+
.wt-icon__icon {
|
|
166
|
+
fill: var(--button-select-icon-color-secondary--hover);
|
|
152
167
|
}
|
|
153
168
|
}
|
|
154
169
|
}
|
|
@@ -100,6 +100,10 @@ export default {
|
|
|
100
100
|
</script>
|
|
101
101
|
|
|
102
102
|
<style lang="scss" scoped>
|
|
103
|
+
.wt-table-column-select {
|
|
104
|
+
line-height: 0; // prevent 24x28 icon heght :/
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
.wt-table-column-select__popup__list {
|
|
104
108
|
@extend %wt-scrollbar;
|
|
105
109
|
max-height: 35vh; // fixme popup fixed sizes
|
|
@@ -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
|
}
|
|
@@ -17,24 +17,25 @@ export default {
|
|
|
17
17
|
return this.isValidation && this.v.$error;
|
|
18
18
|
},
|
|
19
19
|
validationText() {
|
|
20
|
+
let validationText = '';
|
|
20
21
|
if (this.isValidation && this.invalid) {
|
|
21
|
-
if (this.v.required === false)
|
|
22
|
-
if (this.v.numeric === false)
|
|
23
|
-
if (this.v.email === false)
|
|
24
|
-
if (this.v.gatewayHostValidator === false)
|
|
25
|
-
if (this.v.ipValidator === false)
|
|
26
|
-
if (this.v.macValidator === false)
|
|
27
|
-
if (this.v.minValue === false)
|
|
28
|
-
if (this.v.maxValue === false)
|
|
29
|
-
if (this.v.sipAccountValidator === false)
|
|
30
|
-
if (this.v.minLength === false)
|
|
31
|
-
if (this.v.url === false)
|
|
22
|
+
if (this.v.required === false) validationText = this.$t('validation.required');
|
|
23
|
+
else if (this.v.numeric === false) validationText = this.$t('validation.numeric');
|
|
24
|
+
else if (this.v.email === false) validationText = this.$t('validation.email');
|
|
25
|
+
else if (this.v.gatewayHostValidator === false) validationText = this.$t('validation.gatewayHostValidator');
|
|
26
|
+
else if (this.v.ipValidator === false) validationText = this.$t('validation.ipValidator');
|
|
27
|
+
else if (this.v.macValidator === false) validationText = this.$t('validation.macValidator');
|
|
28
|
+
else if (this.v.minValue === false) validationText = `${this.$t('validation.minValue')} ${this.v.$params.minValue.min}`;
|
|
29
|
+
else if (this.v.maxValue === false) validationText = `${this.$t('validation.maxValue')} ${this.v.$params.maxValue.max}`;
|
|
30
|
+
else if (this.v.sipAccountValidator === false) validationText = this.$t('validation.sipAccountValidator');
|
|
31
|
+
else if (this.v.minLength === false) validationText = `${this.$t('validation.minLength')} ${this.v.$params.minLength.min}`;
|
|
32
|
+
else if (this.v.url === false) validationText = `${this.$t('validation.url')}`;
|
|
32
33
|
}
|
|
33
34
|
// eslint-disable-next-line no-restricted-syntax
|
|
34
35
|
for (const { name, text } of this.customValidators) {
|
|
35
|
-
if (this.v[name] === false)
|
|
36
|
+
if (this.v[name] === false) validationText = text;
|
|
36
37
|
}
|
|
37
|
-
return
|
|
38
|
+
return validationText;
|
|
38
39
|
},
|
|
39
40
|
},
|
|
40
41
|
};
|