@tekkare/auriga 0.2.34 → 0.2.36

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.34"
7
+ "version": "0.2.36"
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,
@@ -299,9 +300,10 @@ export default defineComponent({
299
300
  const showChangeType = ref(null);
300
301
  const regexSearch = /^[\s\.\/\!]|[\/\!\s][\s\.]+|\s+[\/]|\s+$/g;
301
302
  const suggOpen = ref(false);
302
- const optionIndex = ref(0);
303
+ const optionIndex = ref(1);
303
304
  const iconColor = computed(() => {
304
305
  if (typing.value === true) {
306
+ f;
305
307
  return "var(--primary)";
306
308
  } else
307
309
  return "var(--medium)";
@@ -337,14 +339,11 @@ export default defineComponent({
337
339
  es: "cargando m\xE1s sugerencias"
338
340
  };
339
341
  watch(value, (new_value) => {
340
- setTimeout(() => {
341
- emit("onTyping", value.value);
342
- }, 500);
343
342
  typing.value = false;
344
343
  if (new_value === "") {
345
344
  hoverShortcut.value = "";
346
345
  suggOpen.value = false;
347
- optionIndex.value = 0;
346
+ optionIndex.value = 1;
348
347
  document.removeEventListener("click", closeSugg);
349
348
  } else {
350
349
  suggOpen.value = true;
@@ -357,7 +356,18 @@ export default defineComponent({
357
356
  }
358
357
  }
359
358
  }
359
+ optionIndex.value = 1;
360
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
+ }
361
371
  watch(
362
372
  () => typing.value,
363
373
  () => {
@@ -386,7 +396,8 @@ export default defineComponent({
386
396
  }, 100);
387
397
  });
388
398
  onMounted(() => {
389
- searchBar.value = document.getElementById("search_input");
399
+ searchBar.value = document.getElementById("search_input_advanced");
400
+ searchBar.value.addEventListener("input", debounce(handleInput, 500));
390
401
  tagsSection.value = document.getElementById("tags");
391
402
  if (props.customShortcuts.length > 0) {
392
403
  for (let i = 0; i < props.customShortcuts.length; i++) {
@@ -404,6 +415,9 @@ export default defineComponent({
404
415
  searchedWords.value = props.defaultInputs;
405
416
  }
406
417
  });
418
+ onUnmounted(() => {
419
+ searchBar.value.removeEventListener("input", debounce(handleInput, 500));
420
+ });
407
421
  function shortcutColor(shortcut) {
408
422
  if (shortcut === selectedShortcut.value || shortcut === hoverShortcut.value) {
409
423
  return "var(--darkest)";
@@ -467,15 +481,34 @@ export default defineComponent({
467
481
  }));
468
482
  const filterSuggestions = computed(() => {
469
483
  if (value.value.replace(/[+/!]/g, "").length > 0) {
470
- return props.suggestions.filter(
471
- (f) => useFuse(
484
+ const filteredSuggs = props.suggestions.filter(
485
+ (f2) => useFuse(
472
486
  value.value.replace(/[+/!]/g, ""),
473
487
  props.suggestions.map((a) => a.text),
474
488
  options.value
475
- ).results.value.map((a) => a.item).includes(f.text)
489
+ ).results.value.map((a) => a.item).includes(f2.text)
476
490
  ).slice(0, 50);
491
+ return [
492
+ ...[
493
+ {
494
+ text: value.value,
495
+ icon: "MagnifyingGlass",
496
+ html: `<span style="color: var(--primary)">${value.value}</span>`
497
+ }
498
+ ],
499
+ filteredSuggs
500
+ ].flat();
477
501
  } else
478
- return props.suggestions.slice(0, 50);
502
+ return [
503
+ ...[
504
+ {
505
+ text: value.value,
506
+ icon: "MagnifyingGlass",
507
+ html: `<span style="color: var(--primary)">${value.value}</span>`
508
+ }
509
+ ],
510
+ props.suggestions.slice(0, 50)
511
+ ].flat();
479
512
  });
480
513
  function selectTag(index, direction) {
481
514
  let nextTag;
@@ -534,7 +567,7 @@ export default defineComponent({
534
567
  if (optionIndex.value > 0) {
535
568
  value.value = filterSuggestions.value[optionIndex.value - 1].text;
536
569
  if (searchedWords.value.filter(
537
- (f) => f.value === filterSuggestions.value[optionIndex.value - 1].text
570
+ (f2) => f2.value === filterSuggestions.value[optionIndex.value - 1].text
538
571
  ).length > 0) {
539
572
  setTimeout(() => {
540
573
  suggOpen.value = false;
@@ -566,7 +599,7 @@ export default defineComponent({
566
599
  }
567
600
  }
568
601
  if (searchValue.length > 0 && arrayValues.length === 0) {
569
- if (searchedWords.value.filter((f) => f.value === searchValue).length === 0) {
602
+ if (searchedWords.value.filter((f2) => f2.value === searchValue).length === 0) {
570
603
  addToSearch(search, searchValue, false);
571
604
  } else {
572
605
  handleDuplicate(searchValue);
@@ -577,7 +610,7 @@ export default defineComponent({
577
610
  const arraySearchValue = arrayValues[i].replace(regexSearch, "");
578
611
  if (arraySearchValue.length > 0) {
579
612
  if (searchedWords.value.filter(
580
- (f) => f.value === arraySearchValue
613
+ (f2) => f2.value === arraySearchValue
581
614
  ).length === 0) {
582
615
  addToSearch(search, arraySearchValue, false);
583
616
  } else {
@@ -616,7 +649,7 @@ export default defineComponent({
616
649
  const searchValue = value.value.replace(regexSearch, "");
617
650
  selectedShortcut.value = item.symbol;
618
651
  if (searchValue.length > 0) {
619
- if (searchedWords.value.filter((f) => f.value === searchValue).length === 0) {
652
+ if (searchedWords.value.filter((f2) => f2.value === searchValue).length === 0) {
620
653
  addToSearch(getKeyword(item.symbol), searchValue, false);
621
654
  } else {
622
655
  handleDuplicate(searchValue);
@@ -139,7 +139,11 @@ declare const _default: import("vue").DefineComponent<{
139
139
  hasShortcut: import("vue").ComputedRef<boolean>;
140
140
  infoHeight: import("vue").ComputedRef<boolean>;
141
141
  suggOpen: import("vue").Ref<boolean>;
142
- filterSuggestions: import("vue").ComputedRef<Suggestion[]>;
142
+ filterSuggestions: import("vue").ComputedRef<(Suggestion | {
143
+ text: string;
144
+ icon: string;
145
+ html: string;
146
+ })[]>;
143
147
  selectOption: (isDown: boolean) => void;
144
148
  optionIndex: import("vue").Ref<number>;
145
149
  selectSugg: (sugg: Suggestion) => void;
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <span class="custom-loader" />
3
+ </template>
4
+
5
+ <script>
6
+ import { defineComponent } from "vue";
7
+ export default defineComponent({
8
+ name: "ArgLoader",
9
+ props: {},
10
+ setup() {
11
+ return {};
12
+ }
13
+ });
14
+ </script>
15
+
16
+ <style scope>
17
+ .custom-loader{animation:rotation 1s linear infinite;border:3px solid #5dc8ff;display:inline-block;height:48px;position:relative;width:48px}.custom-loader,.custom-loader:after{border-radius:50%;box-sizing:border-box}.custom-loader:after{border:3px solid transparent;border-bottom-color:#ffaeff;content:"";height:56px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:56px}@keyframes rotation{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
18
+ </style>
@@ -0,0 +1,8 @@
1
+ declare const _default: import("vue").DefineComponent<Readonly<import("vue").ComponentPropsOptions<{
2
+ [x: string]: unknown;
3
+ }>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, readonly string[] | Readonly<import("vue").ExtractPropTypes<Readonly<import("vue").ComponentObjectPropsOptions<{
4
+ [x: string]: unknown;
5
+ }>>>>, {
6
+ readonly [x: number]: string;
7
+ } | {}, {}>;
8
+ export default _default;
@@ -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",
@@ -126,7 +128,7 @@ export default defineComponent({
126
128
  es: "cargando m\xE1s sugerencias"
127
129
  };
128
130
  const closeOnEnter = ref(false);
129
- const optionIndex = ref(0);
131
+ const optionIndex = ref(1);
130
132
  function selectOption(isDown) {
131
133
  if (isDown) {
132
134
  optionIndex.value = optionIndex.value === filterSuggestions.value.length ? filterSuggestions.value.length : optionIndex.value + 1;
@@ -165,13 +167,14 @@ export default defineComponent({
165
167
  suggOpen.value = false;
166
168
  document.removeEventListener("click", closeSugg);
167
169
  }
170
+ optionIndex.value = 1;
168
171
  }
169
172
  );
170
173
  watch(
171
174
  () => suggOpen.value,
172
175
  () => {
173
176
  if (!suggOpen.value) {
174
- optionIndex.value = 0;
177
+ optionIndex.value = 1;
175
178
  }
176
179
  }
177
180
  );
@@ -182,13 +185,23 @@ export default defineComponent({
182
185
  }
183
186
  }));
184
187
  const filterSuggestions = computed(() => {
185
- return props.suggestions.filter(
188
+ const filteredSuggs = props.suggestions.filter(
186
189
  (f) => useFuse(
187
- searchValue,
190
+ searchValue.value.replace(/[+/!]/g, ""),
188
191
  props.suggestions.map((a) => a.text),
189
192
  options.value
190
193
  ).results.value.map((a) => a.item).includes(f.text)
191
194
  ).slice(0, 50);
195
+ return [
196
+ ...[
197
+ {
198
+ text: searchValue.value,
199
+ icon: "MagnifyingGlass",
200
+ html: `<span style="color: var(--primary)">${searchValue.value}</span>`
201
+ }
202
+ ],
203
+ filteredSuggs
204
+ ].flat();
192
205
  });
193
206
  const selectSugg = (sugg) => {
194
207
  closeOnEnter.value = true;
@@ -204,19 +217,31 @@ export default defineComponent({
204
217
  suggOpen.value = true;
205
218
  }
206
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
+ }
207
231
  onMounted(() => {
232
+ searchBar.value = document.getElementById("search_input");
233
+ searchBar.value.addEventListener("input", debounce(handleInput, 500));
208
234
  searchValue.value = props.defaultValue;
209
235
  });
236
+ onUnmounted(() => {
237
+ searchBar.value.removeEventListener("input", debounce(handleInput, 500));
238
+ });
210
239
  watch(
211
240
  () => props.defaultValue,
212
241
  (new_value) => {
213
242
  searchValue.value = new_value;
214
243
  }
215
244
  );
216
- function changeInput(event) {
217
- searchValue.value = event.target.value;
218
- emit("update:Value", searchValue.value);
219
- }
220
245
  function submitSearch() {
221
246
  if (optionIndex.value > 0) {
222
247
  closeOnEnter.value = true;
@@ -232,7 +257,6 @@ export default defineComponent({
232
257
  }
233
258
  return {
234
259
  searchValue,
235
- changeInput,
236
260
  submitSearch,
237
261
  clearValue,
238
262
  suggOpen,
@@ -48,12 +48,15 @@ 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>;
55
54
  openSugg: () => void;
56
- filterSuggestions: import("vue").ComputedRef<Suggestion[]>;
55
+ filterSuggestions: import("vue").ComputedRef<(Suggestion | {
56
+ text: string;
57
+ icon: string;
58
+ html: string;
59
+ })[]>;
57
60
  selectSugg: (sugg: Suggestion) => void;
58
61
  selectOption: (isDown: boolean) => void;
59
62
  optionIndex: import("vue").Ref<number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/auriga",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "description": "Aurgia is a UI kit developped by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",