@webitel/ui-sdk 24.6.31 → 24.6.32
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.css +1 -1
- package/dist/ui-sdk.js +34 -27
- package/dist/ui-sdk.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/components/wt-search-bar/wt-search-bar.vue +10 -1
- package/src/modules/Filters/components/filter-search.vue +80 -0
- package/src/modules/Filters/store/FiltersStoreModule.js +2 -1
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<wt-context-menu
|
|
44
44
|
v-if="searchMode"
|
|
45
45
|
:options="searchModeOptions"
|
|
46
|
-
@click="
|
|
46
|
+
@click="updateSearchMode"
|
|
47
47
|
>
|
|
48
48
|
<template #activator>
|
|
49
49
|
<wt-tooltip>
|
|
@@ -117,6 +117,10 @@ const emit = defineEmits([
|
|
|
117
117
|
'input',
|
|
118
118
|
'search',
|
|
119
119
|
'enter',
|
|
120
|
+
'update:search-mode',
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated
|
|
123
|
+
*/
|
|
120
124
|
'change:search-mode',
|
|
121
125
|
]);
|
|
122
126
|
|
|
@@ -144,6 +148,11 @@ function handleKeyup(event) {
|
|
|
144
148
|
event.preventDefault();
|
|
145
149
|
}
|
|
146
150
|
}
|
|
151
|
+
|
|
152
|
+
function updateSearchMode(value) {
|
|
153
|
+
emit('update:search-mode', value);
|
|
154
|
+
emit('change:search-mode', value);
|
|
155
|
+
}
|
|
147
156
|
</script>
|
|
148
157
|
|
|
149
158
|
<style lang="scss">
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wt-search-bar
|
|
3
|
+
class="filter-search"
|
|
4
|
+
:search-mode="multisearch && filterName"
|
|
5
|
+
:search-mode-options="multisearch && searchModeOpts"
|
|
6
|
+
:value="localValue"
|
|
7
|
+
@input="localValue = $event"
|
|
8
|
+
@search="setValue({ name: filterName, value: localValue })"
|
|
9
|
+
@update:search-mode="changeMode"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
import { computed, ref, watch } from 'vue';
|
|
15
|
+
import { useStore } from 'vuex';
|
|
16
|
+
import FilterEvent from '../enums/FilterEvent.enum.js';
|
|
17
|
+
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
namespace: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
multisearch: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'q',
|
|
30
|
+
},
|
|
31
|
+
searchModeOpts: {
|
|
32
|
+
type: Array,
|
|
33
|
+
default: () => [],
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const store = useStore();
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function getValue(filter) {
|
|
41
|
+
return store.getters[`${props.namespace}/GET_FILTER`](filter);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function setValue(payload) {
|
|
45
|
+
return store.dispatch(`${props.namespace}/SET_FILTER`, payload);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const filterName = ref(props.multisearch ? props.searchModeOpts[0].value : props.name);
|
|
49
|
+
|
|
50
|
+
const filterValue = computed(() => getValue(filterName.value));
|
|
51
|
+
|
|
52
|
+
const localValue = ref(filterValue.value);
|
|
53
|
+
|
|
54
|
+
async function changeMode({ value }) {
|
|
55
|
+
await setValue({ name: filterName.value, value: '' });
|
|
56
|
+
filterName.value = value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function restoreSearchMode() {
|
|
60
|
+
const mode = props.searchModeOpts.value.find(({ value }) => !!getValue(value));
|
|
61
|
+
if (mode) changeMode({ value: mode.value });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function subscribe(payload) {
|
|
65
|
+
store.dispatch(`${props.namespace}/SUBSCRIBE`, payload);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
subscribe({
|
|
69
|
+
event: FilterEvent.RESTORED,
|
|
70
|
+
callback: restoreSearchMode,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
watch(() => filterValue.value, () => {
|
|
74
|
+
localValue.value = filterValue.value;
|
|
75
|
+
});
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<style scoped lang="scss">
|
|
79
|
+
|
|
80
|
+
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import mitt from 'mitt';
|
|
2
2
|
import isEmpty from '../../../scripts/isEmpty.js';
|
|
3
|
-
import BaseStoreModule
|
|
3
|
+
import BaseStoreModule
|
|
4
|
+
from '../../../store/BaseStoreModules/BaseStoreModule.js';
|
|
4
5
|
import BaseFilterSchema from '../classes/BaseFilterSchema.js';
|
|
5
6
|
import FilterEvent from '../enums/FilterEvent.enum.js';
|
|
6
7
|
|