@tekkare/auriga 0.2.35 → 0.2.37

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/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.2.35"
7
+ "version": "0.2.37"
8
8
  }
@@ -24,7 +24,7 @@
24
24
  </p>
25
25
  </div>
26
26
  <input
27
- id="search_input"
27
+ id="search_input_advanced"
28
28
  v-model="value"
29
29
  class="filters_input_style"
30
30
  :placeholder="placeHolderValue"
@@ -228,6 +228,7 @@
228
228
  <script>
229
229
  import {
230
230
  onMounted,
231
+ onUnmounted,
231
232
  ref,
232
233
  computed,
233
234
  watch,
@@ -338,9 +339,6 @@ export default defineComponent({
338
339
  es: "cargando m\xE1s sugerencias"
339
340
  };
340
341
  watch(value, (new_value) => {
341
- setTimeout(() => {
342
- emit("onTyping", value.value);
343
- }, 1e3);
344
342
  typing.value = false;
345
343
  if (new_value === "") {
346
344
  hoverShortcut.value = "";
@@ -360,6 +358,16 @@ export default defineComponent({
360
358
  }
361
359
  optionIndex.value = 1;
362
360
  });
361
+ function debounce(func, delay) {
362
+ let debounceTimer;
363
+ return function(...args) {
364
+ clearTimeout(debounceTimer);
365
+ debounceTimer = window.setTimeout(() => func.apply(this, args), delay);
366
+ };
367
+ }
368
+ function handleInput() {
369
+ emit("onTyping", value.value);
370
+ }
363
371
  watch(
364
372
  () => typing.value,
365
373
  () => {
@@ -388,7 +396,8 @@ export default defineComponent({
388
396
  }, 100);
389
397
  });
390
398
  onMounted(() => {
391
- searchBar.value = document.getElementById("search_input");
399
+ searchBar.value = document.getElementById("search_input_advanced");
400
+ searchBar.value.addEventListener("input", debounce(handleInput, 200));
392
401
  tagsSection.value = document.getElementById("tags");
393
402
  if (props.customShortcuts.length > 0) {
394
403
  for (let i = 0; i < props.customShortcuts.length; i++) {
@@ -406,6 +415,9 @@ export default defineComponent({
406
415
  searchedWords.value = props.defaultInputs;
407
416
  }
408
417
  });
418
+ onUnmounted(() => {
419
+ searchBar.value.removeEventListener("input", debounce(handleInput, 200));
420
+ });
409
421
  function shortcutColor(shortcut) {
410
422
  if (shortcut === selectedShortcut.value || shortcut === hoverShortcut.value) {
411
423
  return "var(--darkest)";
@@ -13,14 +13,14 @@
13
13
  class="search-icon"
14
14
  />
15
15
  <input
16
- :value="searchValue"
16
+ id="search_input"
17
+ v-model="searchValue"
17
18
  class="filters_input_style"
18
19
  :placeholder="placeHolderValue"
19
- @input="changeInput"
20
20
  @keydown.enter="submitSearch"
21
21
  @keydown.down="selectOption(true)"
22
22
  @keydown.up="selectOption(false)"
23
- :autocomplete="false"
23
+ autocomplete="off"
24
24
  />
25
25
  </div>
26
26
  <div
@@ -73,7 +73,8 @@ import {
73
73
  ref,
74
74
  computed,
75
75
  watch,
76
- defineComponent
76
+ defineComponent,
77
+ onUnmounted
77
78
  } from "vue";
78
79
  export default defineComponent({
79
80
  name: "argSearchInput",
@@ -115,6 +116,7 @@ export default defineComponent({
115
116
  setup(props, { emit }) {
116
117
  const searchValue = ref("");
117
118
  const suggOpen = ref(false);
119
+ const searchBar = ref();
118
120
  const notFound = {
119
121
  fr: "Aucune suggestion n'a \xE9t\xE9 trouv\xE9e",
120
122
  en: "No suggestions were found",
@@ -215,19 +217,31 @@ export default defineComponent({
215
217
  suggOpen.value = true;
216
218
  }
217
219
  }
220
+ function debounce(func, delay) {
221
+ let debounceTimer;
222
+ return function(...args) {
223
+ clearTimeout(debounceTimer);
224
+ debounceTimer = window.setTimeout(() => func.apply(this, args), delay);
225
+ };
226
+ }
227
+ function handleInput(event) {
228
+ searchValue.value = event?.target?.value;
229
+ emit("update:Value", searchValue.value);
230
+ }
218
231
  onMounted(() => {
232
+ searchBar.value = document.getElementById("search_input");
233
+ searchBar.value.addEventListener("input", debounce(handleInput, 200));
219
234
  searchValue.value = props.defaultValue;
220
235
  });
236
+ onUnmounted(() => {
237
+ searchBar.value.removeEventListener("input", debounce(handleInput, 200));
238
+ });
221
239
  watch(
222
240
  () => props.defaultValue,
223
241
  (new_value) => {
224
242
  searchValue.value = new_value;
225
243
  }
226
244
  );
227
- function changeInput(event) {
228
- searchValue.value = event.target.value;
229
- emit("update:Value", searchValue.value);
230
- }
231
245
  function submitSearch() {
232
246
  if (optionIndex.value > 0) {
233
247
  closeOnEnter.value = true;
@@ -243,7 +257,6 @@ export default defineComponent({
243
257
  }
244
258
  return {
245
259
  searchValue,
246
- changeInput,
247
260
  submitSearch,
248
261
  clearValue,
249
262
  suggOpen,
@@ -48,7 +48,6 @@ declare const _default: import("vue").DefineComponent<{
48
48
  };
49
49
  }, {
50
50
  searchValue: import("vue").Ref<string>;
51
- changeInput: (event: any) => void;
52
51
  submitSearch: () => void;
53
52
  clearValue: () => void;
54
53
  suggOpen: import("vue").Ref<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/auriga",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "description": "Aurgia is a UI kit developped by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",