@webitel/ui-sdk 2.0.3 → 2.0.4-1
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 +25 -16
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +25 -16
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +4 -4
- 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 +1 -35
- package/src/components/atoms/wt-context-menu/wt-context-menu.vue +27 -21
- package/src/components/molecules/wt-button-select/__tests__/WtButtonSelect.spec.js +2 -36
- package/src/components/molecules/wt-button-select/wt-button-select.vue +19 -23
- package/src/css/components/atoms/wt-context-menu/_variables.scss +1 -1
- package/src/locale/en/en.js +2 -0
- package/src/locale/ru/ru.js +2 -0
- package/src/locale/ua/ua.js +2 -0
- package/src/modules/QueryFilters/components/__tests__/filter-from-to.spec.js +65 -0
- package/src/modules/QueryFilters/components/abstract-api-filter.vue +1 -1
- package/src/modules/QueryFilters/components/abstract-enum-filter.vue +1 -1
- package/src/modules/QueryFilters/components/filter-from-to.vue +136 -0
- package/src/modules/QueryFilters/mixins/apiFilterMixin.js +5 -0
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +5 -0
package/package.json
CHANGED
|
@@ -2,42 +2,8 @@ import { shallowMount } from '@vue/test-utils';
|
|
|
2
2
|
import WtContextMenu from '../wt-context-menu.vue';
|
|
3
3
|
|
|
4
4
|
describe('WtContextMenu', () => {
|
|
5
|
-
const options = ['1', '2'];
|
|
6
|
-
|
|
7
5
|
it('renders a component', () => {
|
|
8
|
-
const wrapper = shallowMount(WtContextMenu);
|
|
6
|
+
const wrapper = shallowMount(WtContextMenu, { propsData: { options: [] } });
|
|
9
7
|
expect(wrapper.classes('wt-context-menu')).toBe(true);
|
|
10
8
|
});
|
|
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
9
|
});
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<v-dropdown
|
|
3
3
|
class="wt-context-menu"
|
|
4
|
-
:
|
|
4
|
+
:shown="visible"
|
|
5
|
+
:triggers="['click', 'touch']"
|
|
6
|
+
placement="bottom-end"
|
|
5
7
|
>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class="wt-context-menu__option"
|
|
14
|
-
href="#"
|
|
15
|
-
@click.prevent="$emit('click', { option, index })"
|
|
8
|
+
<slot name="activator"></slot>
|
|
9
|
+
<template #popper>
|
|
10
|
+
<ul class="wt-context-menu__menu">
|
|
11
|
+
<li
|
|
12
|
+
class="wt-context-menu__option-wrapper"
|
|
13
|
+
v-for="(option, index) in options"
|
|
14
|
+
:key="index"
|
|
16
15
|
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
<!-- <a> click.prevent prevents redirect to # -->
|
|
17
|
+
<a
|
|
18
|
+
class="wt-context-menu__option"
|
|
19
|
+
href="#"
|
|
20
|
+
@click.prevent="$emit('click', { option, index })"
|
|
21
|
+
>
|
|
22
|
+
{{ option.text || option }}
|
|
23
|
+
</a>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</template>
|
|
27
|
+
</v-dropdown>
|
|
21
28
|
</template>
|
|
22
29
|
|
|
23
30
|
<script>
|
|
@@ -39,6 +46,10 @@ export default {
|
|
|
39
46
|
|
|
40
47
|
<style lang="scss" scoped>
|
|
41
48
|
.wt-context-menu {
|
|
49
|
+
line-height: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.wt-context-menu__menu {
|
|
42
53
|
@extend %typo-body-2;
|
|
43
54
|
min-width: var(--context-menu-min-width);
|
|
44
55
|
max-width: var(--context-menu-max-width);
|
|
@@ -47,11 +58,6 @@ export default {
|
|
|
47
58
|
box-shadow: var(--box-shadow);
|
|
48
59
|
transition: var(--transition);
|
|
49
60
|
z-index: 1;
|
|
50
|
-
|
|
51
|
-
&--hidden {
|
|
52
|
-
opacity: 0;
|
|
53
|
-
pointer-events: none;
|
|
54
|
-
}
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
.wt-context-menu__option-wrapper {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { shallowMount, mount } from '@vue/test-utils';
|
|
2
2
|
import WtSelectButton from '../wt-button-select.vue';
|
|
3
|
-
import WtContextMenu from '../../../atoms/wt-context-menu/wt-context-menu.vue';
|
|
4
3
|
|
|
5
4
|
describe('WtSelectButton', () => {
|
|
6
5
|
it('renders a component', () => {
|
|
@@ -18,41 +17,8 @@ describe('WtSelectButton', () => {
|
|
|
18
17
|
expect(wrapper.find('.wt-button-select__button').text()).toBe(content);
|
|
19
18
|
});
|
|
20
19
|
|
|
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
20
|
it('should rotate the arrow', () => {
|
|
55
|
-
const wrapper =
|
|
21
|
+
const wrapper = mount(WtSelectButton, {
|
|
56
22
|
data: () => ({
|
|
57
23
|
isOpened: true,
|
|
58
24
|
}),
|
|
@@ -12,26 +12,28 @@
|
|
|
12
12
|
<slot></slot>
|
|
13
13
|
</wt-button>
|
|
14
14
|
|
|
15
|
-
<wt-button
|
|
16
|
-
class="wt-button-select__select-btn"
|
|
17
|
-
v-bind="$attrs"
|
|
18
|
-
:disabled="disabled"
|
|
19
|
-
:loading="false"
|
|
20
|
-
@click="isOpened = !isOpened"
|
|
21
|
-
>
|
|
22
|
-
<wt-icon
|
|
23
|
-
class="wt-button-select__select-arrow"
|
|
24
|
-
:class="{'wt-button-select__select-arrow--active': isOpened}"
|
|
25
|
-
icon="arrow-down"
|
|
26
|
-
:disabled="disabled"
|
|
27
|
-
></wt-icon>
|
|
28
|
-
</wt-button>
|
|
29
|
-
|
|
30
15
|
<wt-context-menu
|
|
31
|
-
:visible="isOpened"
|
|
32
16
|
:options="options"
|
|
17
|
+
:visible="isOpened"
|
|
33
18
|
@click="selectOption"
|
|
34
|
-
|
|
19
|
+
>
|
|
20
|
+
<template v-slot:activator>
|
|
21
|
+
<wt-button
|
|
22
|
+
class="wt-button-select__select-btn"
|
|
23
|
+
v-bind="$attrs"
|
|
24
|
+
:disabled="disabled"
|
|
25
|
+
:loading="false"
|
|
26
|
+
@click="isOpened = !isOpened"
|
|
27
|
+
>
|
|
28
|
+
<wt-icon
|
|
29
|
+
class="wt-button-select__select-arrow"
|
|
30
|
+
:class="{'wt-button-select__select-arrow--active': isOpened}"
|
|
31
|
+
icon="arrow-down"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
></wt-icon>
|
|
34
|
+
</wt-button>
|
|
35
|
+
</template>
|
|
36
|
+
</wt-context-menu>
|
|
35
37
|
</div>
|
|
36
38
|
</template>
|
|
37
39
|
|
|
@@ -69,12 +71,6 @@ export default {
|
|
|
69
71
|
display: inline-flex;
|
|
70
72
|
align-items: center;
|
|
71
73
|
gap: var(--button-select-buttons-gap);
|
|
72
|
-
|
|
73
|
-
.wt-context-menu {
|
|
74
|
-
position: absolute;
|
|
75
|
-
top: calc(100% + 1px);
|
|
76
|
-
left: 0;
|
|
77
|
-
}
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
.wt-button-select__button {
|
package/src/locale/en/en.js
CHANGED
package/src/locale/ru/ru.js
CHANGED
package/src/locale/ua/ua.js
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
3
|
+
import Vuex from 'vuex';
|
|
4
|
+
import BaseFilterSchema from '../../classes/BaseFilterSchema';
|
|
5
|
+
import baseFilterMixin from '../../mixins/baseFilterMixin/baseFilterMixin';
|
|
6
|
+
import FilterFromTo from '../filter-from-to.vue';
|
|
7
|
+
|
|
8
|
+
const localVue = createLocalVue();
|
|
9
|
+
localVue.use(Vuex);
|
|
10
|
+
localVue.use(VueRouter);
|
|
11
|
+
const router = new VueRouter();
|
|
12
|
+
|
|
13
|
+
describe('FilterFromTo Filter', () => {
|
|
14
|
+
const namespace = 'jest';
|
|
15
|
+
const filterQuery = 'jest';
|
|
16
|
+
const filterSchema = new BaseFilterSchema();
|
|
17
|
+
const store = new Vuex.Store({
|
|
18
|
+
modules: {
|
|
19
|
+
[namespace]: {
|
|
20
|
+
namespaced: true,
|
|
21
|
+
state: {
|
|
22
|
+
[filterQuery]: filterSchema,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const mountOptions = {
|
|
29
|
+
localVue,
|
|
30
|
+
store,
|
|
31
|
+
router,
|
|
32
|
+
propsData: {
|
|
33
|
+
namespace,
|
|
34
|
+
filterQuery,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
it('renders a component', () => {
|
|
38
|
+
const wrapper = shallowMount(FilterFromTo, mountOptions);
|
|
39
|
+
expect(wrapper.exists()).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it('initial restoreValue() triggers setValue() method: From case', async () => {
|
|
42
|
+
const value = 10;
|
|
43
|
+
await router.replace({ query: { [`${filterQuery}From`]: value } });
|
|
44
|
+
const setValueMock = jest.fn();
|
|
45
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue')
|
|
46
|
+
.mockImplementation(setValueMock);
|
|
47
|
+
shallowMount(FilterFromTo, mountOptions);
|
|
48
|
+
expect(setValueMock).toHaveBeenNthCalledWith(1, {
|
|
49
|
+
filter: filterQuery,
|
|
50
|
+
value: { to: undefined, from: value },
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it('initial restoreValue() triggers setValue() method: To case', async () => {
|
|
54
|
+
const value = 10;
|
|
55
|
+
await router.replace({ query: { [`${filterQuery}To`]: value } });
|
|
56
|
+
const setValueMock = jest.fn();
|
|
57
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue')
|
|
58
|
+
.mockImplementation(setValueMock);
|
|
59
|
+
shallowMount(FilterFromTo, mountOptions);
|
|
60
|
+
expect(setValueMock).toHaveBeenNthCalledWith(2, {
|
|
61
|
+
filter: filterQuery,
|
|
62
|
+
value: { to: value, from: undefined },
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="filter-from-to">
|
|
3
|
+
<wt-label>{{ label }}</wt-label>
|
|
4
|
+
<div class="filter-from-to__inputs-wrapper">
|
|
5
|
+
<div class="filter-from-to__input-wrapper">
|
|
6
|
+
<wt-label
|
|
7
|
+
class="filter-from-to__input-label"
|
|
8
|
+
for="filter-from-to-from"
|
|
9
|
+
>{{ $t('reusable.from') }}
|
|
10
|
+
</wt-label>
|
|
11
|
+
<wt-input
|
|
12
|
+
class="filter-from-to-input"
|
|
13
|
+
name="filter-from-to-from"
|
|
14
|
+
:value="filterSchema.value.from"
|
|
15
|
+
type="number"
|
|
16
|
+
:number-min="0"
|
|
17
|
+
@input="setFrom"
|
|
18
|
+
></wt-input>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="filter-from-to__input-wrapper">
|
|
21
|
+
<wt-label
|
|
22
|
+
class="filter-from-to__input-label"
|
|
23
|
+
for="filter-from-to-to"
|
|
24
|
+
>{{ $t('reusable.to') }}
|
|
25
|
+
</wt-label>
|
|
26
|
+
<wt-input
|
|
27
|
+
class="filter-from-to-input"
|
|
28
|
+
name="filter-from-to-to"
|
|
29
|
+
:value="filterSchema.value.to"
|
|
30
|
+
type="number"
|
|
31
|
+
:number-min="0"
|
|
32
|
+
@input="setTo"
|
|
33
|
+
></wt-input>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script>
|
|
40
|
+
import debounce from '../../../scripts/debounce';
|
|
41
|
+
import baseFilterMixin from '../mixins/baseFilterMixin/baseFilterMixin';
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
name: 'filter-from-to',
|
|
45
|
+
mixins: [baseFilterMixin],
|
|
46
|
+
props: {
|
|
47
|
+
filterQuery: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
label: {
|
|
52
|
+
type: String,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
restore() {
|
|
57
|
+
this.restoreFrom();
|
|
58
|
+
this.restoreTo();
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
restoreFrom() {
|
|
62
|
+
const from = 0;
|
|
63
|
+
const queryValue = this.$route.query[`${this.filterQuery}From`];
|
|
64
|
+
// this.value.from = +queryValue || from;
|
|
65
|
+
const value = { from: +queryValue || from, to: this.value.to };
|
|
66
|
+
this.setValue({ filter: this.filterQuery, value });
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
restoreTo() {
|
|
70
|
+
const to = null;
|
|
71
|
+
const queryValue = this.$route.query[`${this.filterQuery}To`];
|
|
72
|
+
// this.value.to = +queryValue || to;
|
|
73
|
+
const value = { from: this.value.from, to: +queryValue || to };
|
|
74
|
+
this.setValue({ filter: this.filterQuery, value });
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
setFrom(value) {
|
|
78
|
+
this.setValueToQuery({
|
|
79
|
+
filterQuery: `${this.filterQuery}From`,
|
|
80
|
+
value,
|
|
81
|
+
});
|
|
82
|
+
this.restoreFrom();
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
setTo(value) {
|
|
86
|
+
this.setValueToQuery({
|
|
87
|
+
filterQuery: `${this.filterQuery}To`,
|
|
88
|
+
value,
|
|
89
|
+
});
|
|
90
|
+
this.restoreTo();
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
created() {
|
|
95
|
+
this.setFrom = debounce(this.setFrom);
|
|
96
|
+
this.setTo = debounce(this.setTo);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<style lang="scss" scoped>
|
|
102
|
+
.filter-from-to {
|
|
103
|
+
&:hover > .wt-label {
|
|
104
|
+
color: var(--form-label--hover-color);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&:focus-within > .wt-label {
|
|
108
|
+
color: var(--form-label--active-color);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.filter-from-to__inputs-wrapper,
|
|
113
|
+
.filter-from-to__input-wrapper {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.filter-from-to__input-label {
|
|
119
|
+
@extend %typo-subtitle-1;
|
|
120
|
+
margin-right: 5px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.filter-from-to__input-wrapper {
|
|
124
|
+
&:focus-within .wt-label {
|
|
125
|
+
color: var(--form-label--active-color)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.filter-from-to-input {
|
|
129
|
+
width: 70px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&:first-child {
|
|
133
|
+
margin-right: 10px;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
@@ -15,6 +15,11 @@ export default {
|
|
|
15
15
|
closeOnSelect() {
|
|
16
16
|
return this.filterSchema?.storedProp;
|
|
17
17
|
},
|
|
18
|
+
label() {
|
|
19
|
+
return Array.isArray(this.locale.label)
|
|
20
|
+
? this.$tc(...this.locale.label)
|
|
21
|
+
: this.$t(this.locale.label);
|
|
22
|
+
},
|
|
18
23
|
},
|
|
19
24
|
methods: {
|
|
20
25
|
async restoreValue(id) {
|
|
@@ -18,6 +18,11 @@ export default {
|
|
|
18
18
|
closeOnSelect() {
|
|
19
19
|
return this.filterSchema?.storedProp;
|
|
20
20
|
},
|
|
21
|
+
label() {
|
|
22
|
+
return Array.isArray(this.locale.label)
|
|
23
|
+
? this.$tc(...this.locale.label)
|
|
24
|
+
: this.$t(this.locale.label);
|
|
25
|
+
},
|
|
21
26
|
localizedOptions() {
|
|
22
27
|
const optsHaveLocale = this.options.length && this.options[0].locale; // just check 1st el
|
|
23
28
|
if (optsHaveLocale) {
|