buefy 1.0.1 → 1.0.2

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.
Files changed (108) hide show
  1. package/README.md +21 -11
  2. package/dist/buefy.css +1 -10
  3. package/dist/buefy.d.ts +11 -18
  4. package/dist/buefy.esm.js +137 -33
  5. package/dist/buefy.esm.min.js +2 -2
  6. package/dist/buefy.js +137 -33
  7. package/dist/buefy.min.css +1 -1
  8. package/dist/buefy.min.js +2 -2
  9. package/dist/cjs/{Autocomplete-bK5HLaUH.js → Autocomplete-BMmOsPiK.js} +120 -27
  10. package/dist/cjs/autocomplete.js +1 -1
  11. package/dist/cjs/clockpicker.js +16 -5
  12. package/dist/cjs/index.js +1 -1
  13. package/dist/cjs/taginput.js +1 -1
  14. package/dist/components/autocomplete/index.js +121 -28
  15. package/dist/components/autocomplete/index.min.js +2 -2
  16. package/dist/components/breadcrumb/index.js +1 -1
  17. package/dist/components/breadcrumb/index.min.js +1 -1
  18. package/dist/components/button/index.js +1 -1
  19. package/dist/components/button/index.min.js +1 -1
  20. package/dist/components/carousel/index.js +1 -1
  21. package/dist/components/carousel/index.min.js +1 -1
  22. package/dist/components/checkbox/index.js +1 -1
  23. package/dist/components/checkbox/index.min.js +1 -1
  24. package/dist/components/clockpicker/index.js +17 -6
  25. package/dist/components/clockpicker/index.min.js +2 -2
  26. package/dist/components/collapse/index.js +1 -1
  27. package/dist/components/collapse/index.min.js +1 -1
  28. package/dist/components/colorpicker/index.js +1 -1
  29. package/dist/components/colorpicker/index.min.js +1 -1
  30. package/dist/components/datepicker/index.js +1 -1
  31. package/dist/components/datepicker/index.min.js +1 -1
  32. package/dist/components/datetimepicker/index.js +1 -1
  33. package/dist/components/datetimepicker/index.min.js +1 -1
  34. package/dist/components/dialog/index.js +1 -1
  35. package/dist/components/dialog/index.min.js +1 -1
  36. package/dist/components/dropdown/index.js +1 -1
  37. package/dist/components/dropdown/index.min.js +1 -1
  38. package/dist/components/field/index.js +1 -1
  39. package/dist/components/field/index.min.js +1 -1
  40. package/dist/components/icon/index.js +1 -1
  41. package/dist/components/icon/index.min.js +1 -1
  42. package/dist/components/image/index.js +1 -1
  43. package/dist/components/image/index.min.js +1 -1
  44. package/dist/components/input/index.js +1 -1
  45. package/dist/components/input/index.min.js +1 -1
  46. package/dist/components/loading/index.js +1 -1
  47. package/dist/components/loading/index.min.js +1 -1
  48. package/dist/components/menu/index.js +1 -1
  49. package/dist/components/menu/index.min.js +1 -1
  50. package/dist/components/message/index.js +1 -1
  51. package/dist/components/message/index.min.js +1 -1
  52. package/dist/components/modal/index.js +1 -1
  53. package/dist/components/modal/index.min.js +1 -1
  54. package/dist/components/navbar/index.js +1 -1
  55. package/dist/components/navbar/index.min.js +1 -1
  56. package/dist/components/notification/index.js +1 -1
  57. package/dist/components/notification/index.min.js +1 -1
  58. package/dist/components/numberinput/index.js +1 -1
  59. package/dist/components/numberinput/index.min.js +1 -1
  60. package/dist/components/pagination/index.js +1 -1
  61. package/dist/components/pagination/index.min.js +1 -1
  62. package/dist/components/progress/index.js +1 -1
  63. package/dist/components/progress/index.min.js +1 -1
  64. package/dist/components/radio/index.js +1 -1
  65. package/dist/components/radio/index.min.js +1 -1
  66. package/dist/components/rate/index.js +1 -1
  67. package/dist/components/rate/index.min.js +1 -1
  68. package/dist/components/select/index.js +1 -1
  69. package/dist/components/select/index.min.js +1 -1
  70. package/dist/components/sidebar/index.js +1 -1
  71. package/dist/components/sidebar/index.min.js +1 -1
  72. package/dist/components/skeleton/index.js +1 -1
  73. package/dist/components/skeleton/index.min.js +1 -1
  74. package/dist/components/slider/index.js +1 -1
  75. package/dist/components/slider/index.min.js +1 -1
  76. package/dist/components/snackbar/index.js +1 -1
  77. package/dist/components/snackbar/index.min.js +1 -1
  78. package/dist/components/steps/index.js +1 -1
  79. package/dist/components/steps/index.min.js +1 -1
  80. package/dist/components/switch/index.js +1 -1
  81. package/dist/components/switch/index.min.js +1 -1
  82. package/dist/components/table/index.js +1 -1
  83. package/dist/components/table/index.min.js +1 -1
  84. package/dist/components/tabs/index.js +1 -1
  85. package/dist/components/tabs/index.min.js +1 -1
  86. package/dist/components/tag/index.js +1 -1
  87. package/dist/components/tag/index.min.js +1 -1
  88. package/dist/components/taginput/index.js +121 -28
  89. package/dist/components/taginput/index.min.js +2 -2
  90. package/dist/components/timepicker/index.js +1 -1
  91. package/dist/components/timepicker/index.min.js +1 -1
  92. package/dist/components/toast/index.js +1 -1
  93. package/dist/components/toast/index.min.js +1 -1
  94. package/dist/components/tooltip/index.js +1 -1
  95. package/dist/components/tooltip/index.min.js +1 -1
  96. package/dist/components/upload/index.js +1 -1
  97. package/dist/components/upload/index.min.js +1 -1
  98. package/dist/esm/{Autocomplete-DyPAHhWD.js → Autocomplete-CjbTh9D8.js} +120 -27
  99. package/dist/esm/autocomplete.js +1 -1
  100. package/dist/esm/clockpicker.js +16 -5
  101. package/dist/esm/index.js +1 -1
  102. package/dist/esm/taginput.js +1 -1
  103. package/package.json +6 -3
  104. package/src/components/autocomplete/Autocomplete.spec.ts +349 -11
  105. package/src/components/autocomplete/Autocomplete.vue +232 -64
  106. package/src/components/clockpicker/Clockpicker.vue +18 -5
  107. package/src/components/snackbar/index.ts +1 -1
  108. package/src/scss/components/_upload.scss +0 -11
@@ -122,7 +122,9 @@ var _sfc_main = vue.defineComponent({
122
122
  },
123
123
  isEmpty() {
124
124
  if (!this.computedData) return true;
125
- return !this.computedData.some((element) => element.items && element.items.length);
125
+ return !this.computedData.some(
126
+ (element) => element.items && element.items.length
127
+ );
126
128
  },
127
129
  /*
128
130
  * White-listed items to not close when clicked.
@@ -130,6 +132,7 @@ var _sfc_main = vue.defineComponent({
130
132
  */
131
133
  whiteList() {
132
134
  var _a;
135
+ this.computedData;
133
136
  const whiteList = [];
134
137
  whiteList.push(this.$refs.input.$el.querySelector("input"));
135
138
  whiteList.push(this.$refs.dropdown);
@@ -225,13 +228,22 @@ var _sfc_main = vue.defineComponent({
225
228
  * When checkInfiniteScroll property changes scroll event should be removed or added
226
229
  */
227
230
  checkInfiniteScroll(checkInfiniteScroll) {
228
- if ((this.$refs.dropdown && this.$refs.dropdown.querySelector(".dropdown-content")) === false) return;
229
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
231
+ if (!this.$refs.dropdown) return;
232
+ const list = this.$refs.dropdown.querySelector(
233
+ ".dropdown-content"
234
+ );
235
+ if (!list) return;
230
236
  if (checkInfiniteScroll === true) {
231
- list.addEventListener("scroll", this.checkIfReachedTheEndOfScroll);
237
+ list.addEventListener(
238
+ "scroll",
239
+ this.checkIfReachedTheEndOfScroll
240
+ );
232
241
  return;
233
242
  }
234
- list.removeEventListener("scroll", this.checkIfReachedTheEndOfScroll);
243
+ list.removeEventListener(
244
+ "scroll",
245
+ this.checkIfReachedTheEndOfScroll
246
+ );
235
247
  },
236
248
  /*
237
249
  * When updating input's value
@@ -242,11 +254,11 @@ var _sfc_main = vue.defineComponent({
242
254
  newValue(value) {
243
255
  this.$emit("update:modelValue", value);
244
256
  const currentValue = this.getValue(this.selected);
245
- if (currentValue && currentValue !== value) {
257
+ if (currentValue !== void 0 && currentValue !== null && currentValue !== value) {
246
258
  this.setSelected(null, false);
247
259
  }
248
- if (this.hasFocus && (!this.openOnFocus || value)) {
249
- this.isActive = !!value;
260
+ if (this.hasFocus && (!this.openOnFocus || value !== "")) {
261
+ this.isActive = value !== "" && value !== void 0 && value !== null;
250
262
  }
251
263
  },
252
264
  /*
@@ -257,6 +269,9 @@ var _sfc_main = vue.defineComponent({
257
269
  modelValue(value) {
258
270
  this.newValue = value;
259
271
  },
272
+ keepFirst(value) {
273
+ this.ariaAutocomplete = value ? "both" : "list";
274
+ },
260
275
  /*
261
276
  * Select first option if "keep-first
262
277
  */
@@ -278,6 +293,24 @@ var _sfc_main = vue.defineComponent({
278
293
  }
279
294
  }
280
295
  }
296
+ },
297
+ /*
298
+ * When appendToBody property changes, handle the transition properly
299
+ */
300
+ appendToBody(newValue, oldValue) {
301
+ if (newValue && !oldValue) {
302
+ if (this.isActive && this.$refs.dropdown && !this.$data._bodyEl) {
303
+ this.$data._bodyEl = helpers.createAbsoluteElement(
304
+ this.$refs.dropdown
305
+ );
306
+ this.updateAppendToBody();
307
+ }
308
+ } else if (!newValue && oldValue) {
309
+ if (this.$data._bodyEl) {
310
+ helpers.removeElement(this.$data._bodyEl);
311
+ this.$data._bodyEl = void 0;
312
+ }
313
+ }
281
314
  }
282
315
  },
283
316
  methods: {
@@ -300,10 +333,7 @@ var _sfc_main = vue.defineComponent({
300
333
  this.$emit("select", this.selected, event);
301
334
  if (this.selected !== null) {
302
335
  if (this.clearOnSelect) {
303
- const input = this.$refs.input;
304
- input.newValue = "";
305
- const innerInput = input.$refs.input;
306
- innerInput.value = "";
336
+ this.newValue = "";
307
337
  } else {
308
338
  this.newValue = this.getValue(this.selected);
309
339
  }
@@ -330,6 +360,31 @@ var _sfc_main = vue.defineComponent({
330
360
  }
331
361
  });
332
362
  },
363
+ /*
364
+ * Find index of hovered item in data array by comparing display values
365
+ * instead of object references. This fixes the bug with computed data
366
+ * where proxy objects cause indexOf to fail.
367
+ */
368
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
369
+ findHoveredIndex(data) {
370
+ if (this.hovered === null || this.hovered === void 0) {
371
+ return -1;
372
+ }
373
+ const exactIndex = data.indexOf(this.hovered);
374
+ if (exactIndex !== -1) {
375
+ return exactIndex;
376
+ }
377
+ const hoveredValue = this.getValue(this.hovered);
378
+ if (hoveredValue === null || hoveredValue === void 0) {
379
+ return -1;
380
+ }
381
+ return data.findIndex((item) => {
382
+ if (item === null || item === void 0) {
383
+ return hoveredValue === null || hoveredValue === void 0;
384
+ }
385
+ return this.getValue(item) === hoveredValue;
386
+ });
387
+ },
333
388
  keydown(event) {
334
389
  const { key } = event;
335
390
  if (key === "Enter") event.preventDefault();
@@ -340,7 +395,11 @@ var _sfc_main = vue.defineComponent({
340
395
  if (key === ",") event.preventDefault();
341
396
  const closeDropdown = !this.keepOpen || key === "Tab";
342
397
  if (this.hovered === null) {
343
- this.checkIfHeaderOrFooterSelected(event, null, closeDropdown);
398
+ this.checkIfHeaderOrFooterSelected(
399
+ event,
400
+ null,
401
+ closeDropdown
402
+ );
344
403
  return;
345
404
  }
346
405
  this.setSelected(this.hovered, closeDropdown, event);
@@ -396,7 +455,9 @@ var _sfc_main = vue.defineComponent({
396
455
  * reached it's end.
397
456
  */
398
457
  checkIfReachedTheEndOfScroll() {
399
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
458
+ const list = this.$refs.dropdown.querySelector(
459
+ ".dropdown-content"
460
+ );
400
461
  const footerHeight = this.hasFooterSlot ? list.querySelectorAll("div.dropdown-footer")[0].clientHeight : 0;
401
462
  if (list.clientHeight !== list.scrollHeight && list.scrollTop + list.parentElement.clientHeight + footerHeight >= list.scrollHeight) {
402
463
  this.$emit("infinite-scroll");
@@ -424,9 +485,7 @@ var _sfc_main = vue.defineComponent({
424
485
  keyArrows(direction) {
425
486
  const sum = direction === "down" ? 1 : -1;
426
487
  if (this.isActive) {
427
- const data = this.computedData.map(
428
- (d) => d.items
429
- ).reduce((a, b) => [...a, ...b], []);
488
+ const data = this.computedData.map((d) => d.items).reduce((a, b) => [...a, ...b], []);
430
489
  if (this.hasHeaderSlot && this.selectableHeader) {
431
490
  data.unshift(void 0);
432
491
  }
@@ -439,7 +498,7 @@ var _sfc_main = vue.defineComponent({
439
498
  } else if (this.footerHovered) {
440
499
  index = data.length - 1 + sum;
441
500
  } else {
442
- index = data.indexOf(this.hovered) + sum;
501
+ index = this.findHoveredIndex(data) + sum;
443
502
  }
444
503
  index = index > data.length - 1 ? data.length - 1 : index;
445
504
  index = index < 0 ? 0 : index;
@@ -452,7 +511,9 @@ var _sfc_main = vue.defineComponent({
452
511
  if (this.hasHeaderSlot && this.selectableHeader && index === 0) {
453
512
  this.headerHovered = true;
454
513
  }
455
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
514
+ const list = this.$refs.dropdown.querySelector(
515
+ ".dropdown-content"
516
+ );
456
517
  let querySelectorText = "a.dropdown-item:not(.is-disabled)";
457
518
  if (this.hasHeaderSlot && this.selectableHeader) {
458
519
  querySelectorText += ",div.dropdown-header";
@@ -499,7 +560,9 @@ var _sfc_main = vue.defineComponent({
499
560
  },
500
561
  onInput() {
501
562
  const currentValue = this.getValue(this.selected);
502
- if (currentValue && currentValue === this.newValue) return;
563
+ if (currentValue !== void 0 && currentValue !== null && currentValue === this.newValue) {
564
+ return;
565
+ }
503
566
  this.$emit("typing", this.newValue);
504
567
  this.checkValidity();
505
568
  },
@@ -525,6 +588,9 @@ var _sfc_main = vue.defineComponent({
525
588
  const dropdownMenu = this.$refs.dropdown;
526
589
  const trigger = this.$parent.$data._isTaginput ? this.$parent.$el : this.$refs.input.$el;
527
590
  if (dropdownMenu && trigger) {
591
+ if (!this.$data._bodyEl) {
592
+ this.$data._bodyEl = helpers.createAbsoluteElement(dropdownMenu);
593
+ }
528
594
  const root = this.$data._bodyEl;
529
595
  root.classList.forEach((item) => root.classList.remove(item));
530
596
  root.classList.add("autocomplete");
@@ -555,17 +621,30 @@ var _sfc_main = vue.defineComponent({
555
621
  if (typeof window !== "undefined") {
556
622
  document.addEventListener("click", this.clickedOutside);
557
623
  if (this.dropdownPosition === "auto") {
558
- window.addEventListener("resize", this.calcDropdownInViewportVertical);
624
+ window.addEventListener(
625
+ "resize",
626
+ this.calcDropdownInViewportVertical
627
+ );
628
+ }
629
+ if (this.appendToBody) {
630
+ window.addEventListener(
631
+ "scroll",
632
+ this.calcDropdownInViewportVertical
633
+ );
559
634
  }
560
635
  }
561
636
  },
562
637
  mounted() {
563
638
  if (this.checkInfiniteScroll && this.$refs.dropdown && this.$refs.dropdown.querySelector(".dropdown-content")) {
564
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
639
+ const list = this.$refs.dropdown.querySelector(
640
+ ".dropdown-content"
641
+ );
565
642
  list.addEventListener("scroll", this.checkIfReachedTheEndOfScroll);
566
643
  }
567
644
  if (this.appendToBody) {
568
- this.$data._bodyEl = helpers.createAbsoluteElement(this.$refs.dropdown);
645
+ this.$data._bodyEl = helpers.createAbsoluteElement(
646
+ this.$refs.dropdown
647
+ );
569
648
  this.updateAppendToBody();
570
649
  }
571
650
  },
@@ -573,14 +652,28 @@ var _sfc_main = vue.defineComponent({
573
652
  if (typeof window !== "undefined") {
574
653
  document.removeEventListener("click", this.clickedOutside);
575
654
  if (this.dropdownPosition === "auto") {
576
- window.removeEventListener("resize", this.calcDropdownInViewportVertical);
655
+ window.removeEventListener(
656
+ "resize",
657
+ this.calcDropdownInViewportVertical
658
+ );
659
+ }
660
+ if (this.appendToBody) {
661
+ window.removeEventListener(
662
+ "scroll",
663
+ this.calcDropdownInViewportVertical
664
+ );
577
665
  }
578
666
  }
579
667
  if (this.checkInfiniteScroll && this.$refs.dropdown && this.$refs.dropdown.querySelector(".dropdown-content")) {
580
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
581
- list.removeEventListener("scroll", this.checkIfReachedTheEndOfScroll);
668
+ const list = this.$refs.dropdown.querySelector(
669
+ ".dropdown-content"
670
+ );
671
+ list.removeEventListener(
672
+ "scroll",
673
+ this.checkIfReachedTheEndOfScroll
674
+ );
582
675
  }
583
- if (this.appendToBody) {
676
+ if (this.appendToBody && this.$data._bodyEl) {
584
677
  helpers.removeElement(this.$data._bodyEl);
585
678
  }
586
679
  clearTimeout(this.timeOutID);
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Autocomplete = require('./Autocomplete-bK5HLaUH.js');
5
+ var Autocomplete = require('./Autocomplete-BMmOsPiK.js');
6
6
  var plugins = require('./plugins-DbyYGVpp.js');
7
7
  require('vue');
8
8
  require('./helpers.js');
@@ -316,10 +316,6 @@ var _sfc_main = vue.defineComponent({
316
316
  type: Number,
317
317
  default: 5
318
318
  },
319
- autoSwitch: {
320
- type: Boolean,
321
- default: true
322
- },
323
319
  type: {
324
320
  type: String,
325
321
  default: "is-primary"
@@ -378,8 +374,22 @@ var _sfc_main = vue.defineComponent({
378
374
  }
379
375
  },
380
376
  onClockChange() {
381
- if (this.autoSwitch && this.isSelectingHour) {
377
+ if (this.isSelectingHour) {
382
378
  this.isSelectingHour = !this.isSelectingHour;
379
+ } else {
380
+ this.toggle(false);
381
+ }
382
+ },
383
+ /*
384
+ * Toggle clockpicker
385
+ */
386
+ toggle(active) {
387
+ if (this.$refs.dropdown) {
388
+ const dropdown = this.$refs.dropdown;
389
+ dropdown.isActive = active != null ? active : !dropdown.isActive;
390
+ if (dropdown.isActive) {
391
+ this.isSelectingHour = true;
392
+ }
383
393
  }
384
394
  },
385
395
  onMeridienClick(value) {
@@ -566,6 +576,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
566
576
  )
567
577
  ])) : vue.createCommentVNode("v-if", true),
568
578
  vue.createVNode(_component_b_clockpicker_face, {
579
+ ref: "clockpickerFace",
569
580
  "picker-size": _ctx.faceSize,
570
581
  min: _ctx.minFaceValue,
571
582
  max: _ctx.maxFaceValue,
package/dist/cjs/index.js CHANGED
@@ -49,7 +49,7 @@ var upload = require('./upload.js');
49
49
  var helpers = require('./helpers.js');
50
50
  var config$1 = require('./config-DR826Ki2.js');
51
51
  var plugins = require('./plugins-DbyYGVpp.js');
52
- var Autocomplete = require('./Autocomplete-bK5HLaUH.js');
52
+ var Autocomplete = require('./Autocomplete-BMmOsPiK.js');
53
53
  var Button = require('./Button-Cq7yqI8p.js');
54
54
  var Checkbox = require('./Checkbox-GPzAMQqM.js');
55
55
  var Datepicker = require('./Datepicker-B-9ReBe6.js');
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var vue = require('vue');
6
6
  var helpers = require('./helpers.js');
7
7
  var Tag = require('./Tag-BprnwJJ1.js');
8
- var Autocomplete = require('./Autocomplete-bK5HLaUH.js');
8
+ var Autocomplete = require('./Autocomplete-BMmOsPiK.js');
9
9
  var config = require('./config-DR826Ki2.js');
10
10
  var CompatFallthroughMixin = require('./CompatFallthroughMixin-hhK0Gkhr.js');
11
11
  var FormElementMixin = require('./FormElementMixin-DavX4iOv.js');
@@ -1,4 +1,4 @@
1
- /*! Buefy v1.0.1 | MIT License | github.com/buefy/buefy */
1
+ /*! Buefy v1.0.2 | MIT License | github.com/buefy/buefy */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
@@ -886,7 +886,9 @@
886
886
  },
887
887
  isEmpty() {
888
888
  if (!this.computedData) return true;
889
- return !this.computedData.some((element) => element.items && element.items.length);
889
+ return !this.computedData.some(
890
+ (element) => element.items && element.items.length
891
+ );
890
892
  },
891
893
  /*
892
894
  * White-listed items to not close when clicked.
@@ -894,6 +896,7 @@
894
896
  */
895
897
  whiteList() {
896
898
  var _a;
899
+ this.computedData;
897
900
  const whiteList = [];
898
901
  whiteList.push(this.$refs.input.$el.querySelector("input"));
899
902
  whiteList.push(this.$refs.dropdown);
@@ -989,13 +992,22 @@
989
992
  * When checkInfiniteScroll property changes scroll event should be removed or added
990
993
  */
991
994
  checkInfiniteScroll(checkInfiniteScroll) {
992
- if ((this.$refs.dropdown && this.$refs.dropdown.querySelector(".dropdown-content")) === false) return;
993
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
995
+ if (!this.$refs.dropdown) return;
996
+ const list = this.$refs.dropdown.querySelector(
997
+ ".dropdown-content"
998
+ );
999
+ if (!list) return;
994
1000
  if (checkInfiniteScroll === true) {
995
- list.addEventListener("scroll", this.checkIfReachedTheEndOfScroll);
1001
+ list.addEventListener(
1002
+ "scroll",
1003
+ this.checkIfReachedTheEndOfScroll
1004
+ );
996
1005
  return;
997
1006
  }
998
- list.removeEventListener("scroll", this.checkIfReachedTheEndOfScroll);
1007
+ list.removeEventListener(
1008
+ "scroll",
1009
+ this.checkIfReachedTheEndOfScroll
1010
+ );
999
1011
  },
1000
1012
  /*
1001
1013
  * When updating input's value
@@ -1006,11 +1018,11 @@
1006
1018
  newValue(value) {
1007
1019
  this.$emit("update:modelValue", value);
1008
1020
  const currentValue = this.getValue(this.selected);
1009
- if (currentValue && currentValue !== value) {
1021
+ if (currentValue !== void 0 && currentValue !== null && currentValue !== value) {
1010
1022
  this.setSelected(null, false);
1011
1023
  }
1012
- if (this.hasFocus && (!this.openOnFocus || value)) {
1013
- this.isActive = !!value;
1024
+ if (this.hasFocus && (!this.openOnFocus || value !== "")) {
1025
+ this.isActive = value !== "" && value !== void 0 && value !== null;
1014
1026
  }
1015
1027
  },
1016
1028
  /*
@@ -1021,6 +1033,9 @@
1021
1033
  modelValue(value) {
1022
1034
  this.newValue = value;
1023
1035
  },
1036
+ keepFirst(value) {
1037
+ this.ariaAutocomplete = value ? "both" : "list";
1038
+ },
1024
1039
  /*
1025
1040
  * Select first option if "keep-first
1026
1041
  */
@@ -1042,6 +1057,24 @@
1042
1057
  }
1043
1058
  }
1044
1059
  }
1060
+ },
1061
+ /*
1062
+ * When appendToBody property changes, handle the transition properly
1063
+ */
1064
+ appendToBody(newValue, oldValue) {
1065
+ if (newValue && !oldValue) {
1066
+ if (this.isActive && this.$refs.dropdown && !this.$data._bodyEl) {
1067
+ this.$data._bodyEl = createAbsoluteElement(
1068
+ this.$refs.dropdown
1069
+ );
1070
+ this.updateAppendToBody();
1071
+ }
1072
+ } else if (!newValue && oldValue) {
1073
+ if (this.$data._bodyEl) {
1074
+ removeElement(this.$data._bodyEl);
1075
+ this.$data._bodyEl = void 0;
1076
+ }
1077
+ }
1045
1078
  }
1046
1079
  },
1047
1080
  methods: {
@@ -1064,10 +1097,7 @@
1064
1097
  this.$emit("select", this.selected, event);
1065
1098
  if (this.selected !== null) {
1066
1099
  if (this.clearOnSelect) {
1067
- const input = this.$refs.input;
1068
- input.newValue = "";
1069
- const innerInput = input.$refs.input;
1070
- innerInput.value = "";
1100
+ this.newValue = "";
1071
1101
  } else {
1072
1102
  this.newValue = this.getValue(this.selected);
1073
1103
  }
@@ -1094,6 +1124,31 @@
1094
1124
  }
1095
1125
  });
1096
1126
  },
1127
+ /*
1128
+ * Find index of hovered item in data array by comparing display values
1129
+ * instead of object references. This fixes the bug with computed data
1130
+ * where proxy objects cause indexOf to fail.
1131
+ */
1132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1133
+ findHoveredIndex(data) {
1134
+ if (this.hovered === null || this.hovered === void 0) {
1135
+ return -1;
1136
+ }
1137
+ const exactIndex = data.indexOf(this.hovered);
1138
+ if (exactIndex !== -1) {
1139
+ return exactIndex;
1140
+ }
1141
+ const hoveredValue = this.getValue(this.hovered);
1142
+ if (hoveredValue === null || hoveredValue === void 0) {
1143
+ return -1;
1144
+ }
1145
+ return data.findIndex((item) => {
1146
+ if (item === null || item === void 0) {
1147
+ return hoveredValue === null || hoveredValue === void 0;
1148
+ }
1149
+ return this.getValue(item) === hoveredValue;
1150
+ });
1151
+ },
1097
1152
  keydown(event) {
1098
1153
  const { key } = event;
1099
1154
  if (key === "Enter") event.preventDefault();
@@ -1104,7 +1159,11 @@
1104
1159
  if (key === ",") event.preventDefault();
1105
1160
  const closeDropdown = !this.keepOpen || key === "Tab";
1106
1161
  if (this.hovered === null) {
1107
- this.checkIfHeaderOrFooterSelected(event, null, closeDropdown);
1162
+ this.checkIfHeaderOrFooterSelected(
1163
+ event,
1164
+ null,
1165
+ closeDropdown
1166
+ );
1108
1167
  return;
1109
1168
  }
1110
1169
  this.setSelected(this.hovered, closeDropdown, event);
@@ -1160,7 +1219,9 @@
1160
1219
  * reached it's end.
1161
1220
  */
1162
1221
  checkIfReachedTheEndOfScroll() {
1163
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
1222
+ const list = this.$refs.dropdown.querySelector(
1223
+ ".dropdown-content"
1224
+ );
1164
1225
  const footerHeight = this.hasFooterSlot ? list.querySelectorAll("div.dropdown-footer")[0].clientHeight : 0;
1165
1226
  if (list.clientHeight !== list.scrollHeight && list.scrollTop + list.parentElement.clientHeight + footerHeight >= list.scrollHeight) {
1166
1227
  this.$emit("infinite-scroll");
@@ -1188,9 +1249,7 @@
1188
1249
  keyArrows(direction) {
1189
1250
  const sum = direction === "down" ? 1 : -1;
1190
1251
  if (this.isActive) {
1191
- const data = this.computedData.map(
1192
- (d) => d.items
1193
- ).reduce((a, b) => [...a, ...b], []);
1252
+ const data = this.computedData.map((d) => d.items).reduce((a, b) => [...a, ...b], []);
1194
1253
  if (this.hasHeaderSlot && this.selectableHeader) {
1195
1254
  data.unshift(void 0);
1196
1255
  }
@@ -1203,7 +1262,7 @@
1203
1262
  } else if (this.footerHovered) {
1204
1263
  index = data.length - 1 + sum;
1205
1264
  } else {
1206
- index = data.indexOf(this.hovered) + sum;
1265
+ index = this.findHoveredIndex(data) + sum;
1207
1266
  }
1208
1267
  index = index > data.length - 1 ? data.length - 1 : index;
1209
1268
  index = index < 0 ? 0 : index;
@@ -1216,7 +1275,9 @@
1216
1275
  if (this.hasHeaderSlot && this.selectableHeader && index === 0) {
1217
1276
  this.headerHovered = true;
1218
1277
  }
1219
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
1278
+ const list = this.$refs.dropdown.querySelector(
1279
+ ".dropdown-content"
1280
+ );
1220
1281
  let querySelectorText = "a.dropdown-item:not(.is-disabled)";
1221
1282
  if (this.hasHeaderSlot && this.selectableHeader) {
1222
1283
  querySelectorText += ",div.dropdown-header";
@@ -1263,7 +1324,9 @@
1263
1324
  },
1264
1325
  onInput() {
1265
1326
  const currentValue = this.getValue(this.selected);
1266
- if (currentValue && currentValue === this.newValue) return;
1327
+ if (currentValue !== void 0 && currentValue !== null && currentValue === this.newValue) {
1328
+ return;
1329
+ }
1267
1330
  this.$emit("typing", this.newValue);
1268
1331
  this.checkValidity();
1269
1332
  },
@@ -1289,6 +1352,9 @@
1289
1352
  const dropdownMenu = this.$refs.dropdown;
1290
1353
  const trigger = this.$parent.$data._isTaginput ? this.$parent.$el : this.$refs.input.$el;
1291
1354
  if (dropdownMenu && trigger) {
1355
+ if (!this.$data._bodyEl) {
1356
+ this.$data._bodyEl = createAbsoluteElement(dropdownMenu);
1357
+ }
1292
1358
  const root = this.$data._bodyEl;
1293
1359
  root.classList.forEach((item) => root.classList.remove(item));
1294
1360
  root.classList.add("autocomplete");
@@ -1319,17 +1385,30 @@
1319
1385
  if (typeof window !== "undefined") {
1320
1386
  document.addEventListener("click", this.clickedOutside);
1321
1387
  if (this.dropdownPosition === "auto") {
1322
- window.addEventListener("resize", this.calcDropdownInViewportVertical);
1388
+ window.addEventListener(
1389
+ "resize",
1390
+ this.calcDropdownInViewportVertical
1391
+ );
1392
+ }
1393
+ if (this.appendToBody) {
1394
+ window.addEventListener(
1395
+ "scroll",
1396
+ this.calcDropdownInViewportVertical
1397
+ );
1323
1398
  }
1324
1399
  }
1325
1400
  },
1326
1401
  mounted() {
1327
1402
  if (this.checkInfiniteScroll && this.$refs.dropdown && this.$refs.dropdown.querySelector(".dropdown-content")) {
1328
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
1403
+ const list = this.$refs.dropdown.querySelector(
1404
+ ".dropdown-content"
1405
+ );
1329
1406
  list.addEventListener("scroll", this.checkIfReachedTheEndOfScroll);
1330
1407
  }
1331
1408
  if (this.appendToBody) {
1332
- this.$data._bodyEl = createAbsoluteElement(this.$refs.dropdown);
1409
+ this.$data._bodyEl = createAbsoluteElement(
1410
+ this.$refs.dropdown
1411
+ );
1333
1412
  this.updateAppendToBody();
1334
1413
  }
1335
1414
  },
@@ -1337,14 +1416,28 @@
1337
1416
  if (typeof window !== "undefined") {
1338
1417
  document.removeEventListener("click", this.clickedOutside);
1339
1418
  if (this.dropdownPosition === "auto") {
1340
- window.removeEventListener("resize", this.calcDropdownInViewportVertical);
1419
+ window.removeEventListener(
1420
+ "resize",
1421
+ this.calcDropdownInViewportVertical
1422
+ );
1423
+ }
1424
+ if (this.appendToBody) {
1425
+ window.removeEventListener(
1426
+ "scroll",
1427
+ this.calcDropdownInViewportVertical
1428
+ );
1341
1429
  }
1342
1430
  }
1343
1431
  if (this.checkInfiniteScroll && this.$refs.dropdown && this.$refs.dropdown.querySelector(".dropdown-content")) {
1344
- const list = this.$refs.dropdown.querySelector(".dropdown-content");
1345
- list.removeEventListener("scroll", this.checkIfReachedTheEndOfScroll);
1432
+ const list = this.$refs.dropdown.querySelector(
1433
+ ".dropdown-content"
1434
+ );
1435
+ list.removeEventListener(
1436
+ "scroll",
1437
+ this.checkIfReachedTheEndOfScroll
1438
+ );
1346
1439
  }
1347
- if (this.appendToBody) {
1440
+ if (this.appendToBody && this.$data._bodyEl) {
1348
1441
  removeElement(this.$data._bodyEl);
1349
1442
  }
1350
1443
  clearTimeout(this.timeOutID);