@avakhula/ui 0.1.15 → 0.1.16

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": "@avakhula/ui",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.umd.cjs",
6
6
  "source": "src/index.js",
@@ -289,6 +289,7 @@ import IbAlert from "../Alert/Alert.vue";
289
289
  import List from "../List.vue";
290
290
  import InfinityLoaderMixin from "./mixins/InfinityLoaderMixin";
291
291
  import { TooltipDirective as Tooltip } from "../../directives/tooltip/tooltip";
292
+ import debounce from "../../helpers/debounce";
292
293
 
293
294
  function copy(data) {
294
295
  return JSON.parse(JSON.stringify(data));
@@ -455,7 +456,7 @@ export default {
455
456
  },
456
457
  searchDebounce: {
457
458
  type: Number,
458
- default: 0,
459
+ default: 500,
459
460
  },
460
461
  alphabeticStyle: {
461
462
  type: Boolean,
@@ -559,15 +560,15 @@ export default {
559
560
  document.addEventListener("mouseup", this.endResizing);
560
561
  },
561
562
  data() {
562
- this.defaultFilter = (options) => {
563
+ this.defaultFilter = debounce((options) => {
563
564
  this.marker.unmark();
564
565
  const filterString = this.filterString.toLowerCase().trim();
565
- this.filterFunc.call(this, options, filterString);
566
+ this.countVisibleChildren = this.filterFunc.call(this, options, filterString);
566
567
 
567
568
  if (filterString && this.keywordHighlighter) {
568
569
  this.marker.mark(filterString);
569
570
  }
570
- };
571
+ }, 1000);
571
572
 
572
573
  return {
573
574
  initialOptions: typeof this.options === "function" ? this.options : copy(this.options),
@@ -830,6 +831,7 @@ export default {
830
831
  filterFunc(options, filterString) {
831
832
  let visibleOptionsCount = 0;
832
833
 
834
+ console.log("filterFunc called")
833
835
  options.forEach(option => {
834
836
  let isVisible = option.initiallyVisible && option.title && option.title.toString().toLowerCase().includes(filterString) && !this.actualBookmarkedOptions[option.id];
835
837
 
@@ -0,0 +1,23 @@
1
+ export default function debounce(f, ms) {
2
+ let timer = null;
3
+
4
+ function debounced(...args) {
5
+ if (timer) {
6
+ clearTimeout(timer);
7
+ }
8
+
9
+ timer = setTimeout(() => {
10
+ f.apply(this, args);
11
+ timer = null;
12
+ }, ms);
13
+ }
14
+
15
+ debounced.cancel = function() {
16
+ if (timer) {
17
+ clearTimeout(timer);
18
+ timer = null;
19
+ }
20
+ };
21
+
22
+ return debounced;
23
+ }