@webitel/ui-sdk 3.2.30 → 3.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "3.2.30",
3
+ "version": "3.2.32",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -7,11 +7,12 @@
7
7
  >
8
8
  <div class="wt-search-bar__wrapper">
9
9
  <input
10
- :placeholder="searchBarPlaceholder"
10
+ :placeholder="placeholder || $t('webitelUI.searchBar.placeholder')"
11
11
  :value="value"
12
12
  class="wt-search-bar__input"
13
13
  type="search"
14
- v-on="listeners"
14
+ @input="handleInput($event.target.value)"
15
+ @keyup="handleKeyup"
15
16
  >
16
17
  <div class="wt-search-bar__search-icon">
17
18
  <slot name="search-icon">
@@ -30,86 +31,67 @@
30
31
  </div>
31
32
  </template>
32
33
 
33
- <script>
34
+ <script setup>
34
35
  import debounce from '../../../scripts/debounce';
35
36
 
36
- export default {
37
- name: 'wt-search-bar',
38
- props: {
39
- /**
40
- * Current search-bar value (`v-model`)
41
- */
42
- value: {
43
- type: String,
44
- default: '',
45
- },
46
- /**
47
- * search-bar placeholder
48
- */
49
- placeholder: {
50
- type: String,
51
- },
52
- debounce: {
53
- type: Boolean,
54
- default: false,
55
- },
56
- debounceDelay: {
57
- type: Number,
58
- default: 1000,
59
- },
60
- outline: {
61
- type: Boolean,
62
- default: false,
63
- },
37
+ const props = defineProps({
38
+ /**
39
+ * Current search-bar value (`v-model`)
40
+ */
41
+ value: {
42
+ type: String,
43
+ default: '',
64
44
  },
65
-
66
- watch: {
67
- value() {
68
- this.search.call(this);
69
- },
45
+ /**
46
+ * search-bar placeholder
47
+ */
48
+ placeholder: {
49
+ type: String,
70
50
  },
71
-
72
- created() {
73
- if (this.debounce) {
74
- this.search = debounce(this.search, this.debounceDelay);
75
- }
51
+ debounce: {
52
+ type: Boolean,
53
+ default: false,
76
54
  },
77
-
78
- computed: {
79
- listeners() {
80
- return {
81
- ...this.$listeners,
82
- input: (event) => this.$emit('input', event.target.value),
83
- keyup: this.handleKeyup,
84
- };
85
- },
86
- searchBarPlaceholder() {
87
- return this.placeholder || this.$t('webitelUI.searchBar.placeholder');
88
- },
55
+ debounceDelay: {
56
+ type: Number,
57
+ default: 1000,
89
58
  },
90
-
91
- methods: {
92
- search() {
93
- this.$emit('search', this.value);
94
- },
95
- handleKeyup(event) {
96
- if (event.key === 'Enter') {
97
- this.$emit('enter');
98
- event.preventDefault();
99
- } else if (event.key === 'Esc') {
100
- this.$emit('input', '');
101
- event.preventDefault();
102
- }
103
- },
59
+ outline: {
60
+ type: Boolean,
61
+ default: false,
104
62
  },
105
- };
63
+ });
64
+
65
+ const emit = defineEmits([
66
+ 'input',
67
+ 'search',
68
+ 'enter',
69
+ ]);
70
+
71
+ const search = debounce((value) => {
72
+ emit('search', value);
73
+ });
74
+
75
+ function handleInput(value) {
76
+ emit('input', value);
77
+ search(value);
78
+ }
79
+
80
+ function handleKeyup(event) {
81
+ if (event.key === 'Enter') {
82
+ search(props.value);
83
+ event.preventDefault();
84
+ } else if (event.key === 'Esc') {
85
+ handleInput('');
86
+ event.preventDefault();
87
+ }
88
+ }
106
89
  </script>
107
90
 
108
91
  <style lang="scss" scoped>
109
92
  .wt-search-bar {
110
93
  cursor: text;
111
94
 
112
-
113
95
  .wt-search-bar__wrapper {
114
96
  position: relative;
115
97
  }
@@ -88,7 +88,7 @@ export default class FiltersStoreModule extends BaseStoreModule {
88
88
  RESET_FILTERS: (context) => {
89
89
  context.commit('RESET_FILTERS');
90
90
  },
91
- ON_FILTER_SET: () => debounce((context, { filter, value }) => context.dispatch('LOAD_DATA_LIST'))(),
91
+ ON_FILTER_SET: debounce((context, { filter, value }) => context.dispatch('LOAD_DATA_LIST')),
92
92
 
93
93
  LOAD_DATA_LIST: (context) => context.dispatch(
94
94
  `${context.getters.TABLE_NAMESPACE}/LOAD_DATA_LIST`,