buefy 0.9.26 → 0.9.28

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 (259) hide show
  1. package/README.md +3 -1
  2. package/dist/buefy.css +15904 -0
  3. package/dist/buefy.esm.js +17883 -0
  4. package/dist/buefy.esm.min.js +2 -0
  5. package/dist/buefy.js +17967 -0
  6. package/dist/buefy.min.css +1 -0
  7. package/dist/buefy.min.js +2 -0
  8. package/dist/cjs/Autocomplete-7a39c5ce.js +673 -0
  9. package/dist/cjs/Button-01827709.js +114 -0
  10. package/dist/cjs/CheckRadioMixin-c910f2ed.js +45 -0
  11. package/dist/cjs/Checkbox-43f54cc7.js +70 -0
  12. package/dist/cjs/Datepicker-680659bc.js +1679 -0
  13. package/dist/cjs/DropdownItem-422f8c34.js +559 -0
  14. package/dist/cjs/Field-4557b10c.js +315 -0
  15. package/dist/cjs/FormElementMixin-193a88b8.js +163 -0
  16. package/dist/cjs/Icon-78961800.js +189 -0
  17. package/dist/cjs/Image-c4bcd9b3.js +299 -0
  18. package/dist/cjs/InjectedChildMixin-d6bf7f91.js +135 -0
  19. package/dist/cjs/Input-e5a72d97.js +248 -0
  20. package/dist/cjs/Loading-6f2c7075.js +150 -0
  21. package/dist/cjs/MessageMixin-8d959514.js +146 -0
  22. package/dist/cjs/Modal-4cf07210.js +278 -0
  23. package/dist/cjs/NoticeMixin-01121bd2.js +154 -0
  24. package/dist/cjs/Pagination-d6b3fb85.js +413 -0
  25. package/dist/cjs/Select-2b3879bc.js +100 -0
  26. package/dist/cjs/SlotComponent-4fb48389.js +53 -0
  27. package/dist/cjs/TabbedChildMixin-907cad32.js +222 -0
  28. package/dist/cjs/Tag-437f65fb.js +154 -0
  29. package/dist/cjs/Timepicker-498fa02b.js +67 -0
  30. package/dist/cjs/TimepickerMixin-6c1a4ab4.js +661 -0
  31. package/dist/cjs/Tooltip-c1df7ee3.js +370 -0
  32. package/dist/cjs/_rollupPluginBabelHelpers-8b2e54ad.js +365 -0
  33. package/dist/cjs/autocomplete.js +22 -0
  34. package/dist/cjs/breadcrumb.js +139 -0
  35. package/dist/cjs/button.js +20 -0
  36. package/dist/cjs/carousel.js +662 -0
  37. package/dist/cjs/checkbox.js +86 -0
  38. package/dist/cjs/clockpicker.js +461 -0
  39. package/dist/cjs/collapse.js +128 -0
  40. package/dist/cjs/colorpicker.js +23 -0
  41. package/dist/cjs/config-8cfb5a4a.js +81 -0
  42. package/dist/cjs/config.js +18 -0
  43. package/dist/cjs/datepicker.js +27 -0
  44. package/dist/cjs/datetimepicker.js +377 -0
  45. package/dist/cjs/dialog.js +308 -0
  46. package/dist/cjs/dropdown.js +23 -0
  47. package/dist/cjs/field.js +18 -0
  48. package/dist/cjs/helpers.js +375 -0
  49. package/dist/cjs/icon.js +19 -0
  50. package/dist/cjs/image.js +19 -0
  51. package/dist/cjs/index-99d1c930.js +1633 -0
  52. package/dist/cjs/index.js +216 -0
  53. package/dist/cjs/input.js +21 -0
  54. package/dist/cjs/loading.js +38 -0
  55. package/dist/cjs/menu.js +304 -0
  56. package/dist/cjs/message.js +67 -0
  57. package/dist/cjs/modal.js +59 -0
  58. package/dist/cjs/navbar.js +679 -0
  59. package/dist/cjs/notification.js +181 -0
  60. package/dist/cjs/numberinput.js +278 -0
  61. package/dist/cjs/pagination.js +22 -0
  62. package/dist/cjs/plugins-7f41b028.js +94 -0
  63. package/dist/cjs/progress.js +239 -0
  64. package/dist/cjs/radio.js +130 -0
  65. package/dist/cjs/rate.js +156 -0
  66. package/dist/cjs/select.js +21 -0
  67. package/dist/cjs/sidebar.js +303 -0
  68. package/dist/cjs/skeleton.js +111 -0
  69. package/dist/cjs/slider.js +603 -0
  70. package/dist/cjs/snackbar.js +132 -0
  71. package/dist/cjs/ssr-20dba236.js +10 -0
  72. package/dist/cjs/steps.js +278 -0
  73. package/dist/cjs/switch.js +139 -0
  74. package/dist/cjs/table.js +1695 -0
  75. package/dist/cjs/tabs.js +214 -0
  76. package/dist/cjs/tag.js +70 -0
  77. package/dist/cjs/taginput.js +331 -0
  78. package/dist/cjs/timepicker.js +28 -0
  79. package/dist/cjs/toast.js +106 -0
  80. package/dist/cjs/tooltip.js +19 -0
  81. package/dist/cjs/trapFocus-261420b0.js +49 -0
  82. package/dist/cjs/upload.js +205 -0
  83. package/dist/components/autocomplete/index.js +1620 -0
  84. package/dist/components/autocomplete/index.min.js +2 -0
  85. package/dist/components/breadcrumb/index.js +297 -0
  86. package/dist/components/breadcrumb/index.min.js +2 -0
  87. package/dist/components/button/index.js +569 -0
  88. package/dist/components/button/index.min.js +2 -0
  89. package/dist/components/carousel/index.js +1629 -0
  90. package/dist/components/carousel/index.min.js +2 -0
  91. package/dist/components/checkbox/index.js +279 -0
  92. package/dist/components/checkbox/index.min.js +2 -0
  93. package/dist/components/clockpicker/index.js +3131 -0
  94. package/dist/components/clockpicker/index.min.js +2 -0
  95. package/dist/components/collapse/index.js +217 -0
  96. package/dist/components/collapse/index.min.js +2 -0
  97. package/dist/components/colorpicker/index.js +4249 -0
  98. package/dist/components/colorpicker/index.min.js +2 -0
  99. package/dist/components/datepicker/index.js +3845 -0
  100. package/dist/components/datepicker/index.min.js +2 -0
  101. package/dist/components/datetimepicker/index.js +4902 -0
  102. package/dist/components/datetimepicker/index.min.js +2 -0
  103. package/dist/components/dialog/index.js +1168 -0
  104. package/dist/components/dialog/index.min.js +2 -0
  105. package/dist/components/dropdown/index.js +1043 -0
  106. package/dist/components/dropdown/index.min.js +2 -0
  107. package/dist/components/field/index.js +511 -0
  108. package/dist/components/field/index.min.js +2 -0
  109. package/dist/components/icon/index.js +463 -0
  110. package/dist/components/icon/index.min.js +2 -0
  111. package/dist/components/image/index.js +513 -0
  112. package/dist/components/image/index.min.js +2 -0
  113. package/dist/components/input/index.js +862 -0
  114. package/dist/components/input/index.min.js +2 -0
  115. package/dist/components/loading/index.js +366 -0
  116. package/dist/components/loading/index.min.js +2 -0
  117. package/dist/components/menu/index.js +748 -0
  118. package/dist/components/menu/index.min.js +2 -0
  119. package/dist/components/message/index.js +650 -0
  120. package/dist/components/message/index.min.js +2 -0
  121. package/dist/components/modal/index.js +624 -0
  122. package/dist/components/modal/index.min.js +2 -0
  123. package/dist/components/navbar/index.js +805 -0
  124. package/dist/components/navbar/index.min.js +2 -0
  125. package/dist/components/notification/index.js +923 -0
  126. package/dist/components/notification/index.min.js +2 -0
  127. package/dist/components/numberinput/index.js +1119 -0
  128. package/dist/components/numberinput/index.min.js +2 -0
  129. package/dist/components/pagination/index.js +868 -0
  130. package/dist/components/pagination/index.min.js +2 -0
  131. package/dist/components/progress/index.js +621 -0
  132. package/dist/components/progress/index.min.js +2 -0
  133. package/dist/components/radio/index.js +260 -0
  134. package/dist/components/radio/index.min.js +2 -0
  135. package/dist/components/rate/index.js +600 -0
  136. package/dist/components/rate/index.min.js +2 -0
  137. package/dist/components/select/index.js +715 -0
  138. package/dist/components/select/index.min.js +2 -0
  139. package/dist/components/sidebar/index.js +467 -0
  140. package/dist/components/sidebar/index.min.js +2 -0
  141. package/dist/components/skeleton/index.js +200 -0
  142. package/dist/components/skeleton/index.min.js +2 -0
  143. package/dist/components/slider/index.js +1264 -0
  144. package/dist/components/slider/index.min.js +2 -0
  145. package/dist/components/snackbar/index.js +527 -0
  146. package/dist/components/snackbar/index.min.js +2 -0
  147. package/dist/components/steps/index.js +1180 -0
  148. package/dist/components/steps/index.min.js +2 -0
  149. package/dist/components/switch/index.js +297 -0
  150. package/dist/components/switch/index.min.js +2 -0
  151. package/dist/components/table/index.js +3480 -0
  152. package/dist/components/table/index.min.js +2 -0
  153. package/dist/components/tabs/index.js +1116 -0
  154. package/dist/components/tabs/index.min.js +2 -0
  155. package/dist/components/tag/index.js +307 -0
  156. package/dist/components/tag/index.min.js +2 -0
  157. package/dist/components/taginput/index.js +2104 -0
  158. package/dist/components/taginput/index.min.js +2 -0
  159. package/dist/components/timepicker/index.js +2843 -0
  160. package/dist/components/timepicker/index.min.js +2 -0
  161. package/dist/components/toast/index.js +501 -0
  162. package/dist/components/toast/index.min.js +2 -0
  163. package/dist/components/tooltip/index.js +630 -0
  164. package/dist/components/tooltip/index.min.js +2 -0
  165. package/dist/components/upload/index.js +525 -0
  166. package/dist/components/upload/index.min.js +2 -0
  167. package/dist/esm/Autocomplete-1a6e8770.js +671 -0
  168. package/dist/esm/Button-521f6efc.js +112 -0
  169. package/dist/esm/CheckRadioMixin-e726a83c.js +43 -0
  170. package/dist/esm/Checkbox-1d02686e.js +68 -0
  171. package/dist/esm/Datepicker-0ae1e826.js +1677 -0
  172. package/dist/esm/DropdownItem-55682322.js +556 -0
  173. package/dist/esm/Field-3ceba31e.js +313 -0
  174. package/dist/esm/FormElementMixin-b223d3c7.js +161 -0
  175. package/dist/esm/Icon-60d47b31.js +187 -0
  176. package/dist/esm/Image-75808acb.js +297 -0
  177. package/dist/esm/InjectedChildMixin-b4220787.js +130 -0
  178. package/dist/esm/Input-20612b63.js +246 -0
  179. package/dist/esm/Loading-ae028ea5.js +148 -0
  180. package/dist/esm/MessageMixin-d577a9f5.js +144 -0
  181. package/dist/esm/Modal-7da7641f.js +276 -0
  182. package/dist/esm/NoticeMixin-bd6f61d9.js +152 -0
  183. package/dist/esm/Pagination-68f12c1e.js +409 -0
  184. package/dist/esm/Select-97781d4e.js +98 -0
  185. package/dist/esm/SlotComponent-8871a20f.js +51 -0
  186. package/dist/esm/TabbedChildMixin-bcb13767.js +219 -0
  187. package/dist/esm/Tag-6365aa46.js +152 -0
  188. package/dist/esm/Timepicker-38480bbc.js +65 -0
  189. package/dist/esm/TimepickerMixin-d736b0a9.js +659 -0
  190. package/dist/esm/Tooltip-d98a769c.js +368 -0
  191. package/dist/esm/_rollupPluginBabelHelpers-df313029.js +350 -0
  192. package/dist/esm/autocomplete.js +18 -0
  193. package/dist/esm/breadcrumb.js +133 -0
  194. package/dist/esm/button.js +16 -0
  195. package/dist/esm/carousel.js +655 -0
  196. package/dist/esm/checkbox.js +81 -0
  197. package/dist/esm/clockpicker.js +456 -0
  198. package/dist/esm/collapse.js +123 -0
  199. package/dist/esm/colorpicker.js +14 -0
  200. package/dist/esm/config-e7d4b9c2.js +78 -0
  201. package/dist/esm/config.js +14 -0
  202. package/dist/esm/datepicker.js +23 -0
  203. package/dist/esm/datetimepicker.js +372 -0
  204. package/dist/esm/dialog.js +302 -0
  205. package/dist/esm/dropdown.js +18 -0
  206. package/dist/esm/field.js +14 -0
  207. package/dist/esm/helpers.js +348 -0
  208. package/dist/esm/icon.js +15 -0
  209. package/dist/esm/image.js +15 -0
  210. package/dist/esm/index-903f63ea.js +1629 -0
  211. package/dist/esm/index.js +182 -0
  212. package/dist/esm/input.js +17 -0
  213. package/dist/esm/loading.js +33 -0
  214. package/dist/esm/menu.js +297 -0
  215. package/dist/esm/message.js +62 -0
  216. package/dist/esm/modal.js +54 -0
  217. package/dist/esm/navbar.js +672 -0
  218. package/dist/esm/notification.js +175 -0
  219. package/dist/esm/numberinput.js +273 -0
  220. package/dist/esm/pagination.js +17 -0
  221. package/dist/esm/plugins-218aea86.js +89 -0
  222. package/dist/esm/progress.js +233 -0
  223. package/dist/esm/radio.js +124 -0
  224. package/dist/esm/rate.js +151 -0
  225. package/dist/esm/select.js +17 -0
  226. package/dist/esm/sidebar.js +298 -0
  227. package/dist/esm/skeleton.js +106 -0
  228. package/dist/esm/slider.js +597 -0
  229. package/dist/esm/snackbar.js +126 -0
  230. package/dist/esm/ssr-b847d137.js +7 -0
  231. package/dist/esm/steps.js +272 -0
  232. package/dist/esm/switch.js +134 -0
  233. package/dist/esm/table.js +1689 -0
  234. package/dist/esm/tabs.js +208 -0
  235. package/dist/esm/tag.js +65 -0
  236. package/dist/esm/taginput.js +326 -0
  237. package/dist/esm/timepicker.js +24 -0
  238. package/dist/esm/toast.js +100 -0
  239. package/dist/esm/tooltip.js +15 -0
  240. package/dist/esm/trapFocus-f0736873.js +47 -0
  241. package/dist/esm/upload.js +200 -0
  242. package/dist/vetur/attributes.json +3238 -0
  243. package/dist/vetur/tags.json +1183 -0
  244. package/package.json +3 -3
  245. package/src/components/autocomplete/Autocomplete.spec.js +16 -0
  246. package/src/components/autocomplete/Autocomplete.vue +9 -3
  247. package/src/components/colorpicker/ColorpickerHSLRepresentationSquare.vue +2 -0
  248. package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.vue +2 -0
  249. package/src/components/dropdown/Dropdown.vue +51 -3
  250. package/src/components/numberinput/Numberinput.vue +4 -0
  251. package/src/components/sidebar/Sidebar.vue +1 -0
  252. package/src/components/slider/Slider.vue +7 -2
  253. package/src/components/slider/SliderThumb.vue +8 -0
  254. package/src/components/table/Table.vue +4 -1
  255. package/src/components/table/TableColumn.spec.js +51 -0
  256. package/src/components/table/TableColumn.vue +8 -1
  257. package/src/components/taginput/Taginput.vue +7 -2
  258. package/src/components/tooltip/Tooltip.vue +10 -3
  259. package/src/scss/components/_dropdown.scss +4 -2
@@ -0,0 +1,673 @@
1
+ 'use strict';
2
+
3
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-8b2e54ad.js');
4
+ var helpers = require('./helpers.js');
5
+ var FormElementMixin = require('./FormElementMixin-193a88b8.js');
6
+ var Input = require('./Input-e5a72d97.js');
7
+ var plugins = require('./plugins-7f41b028.js');
8
+
9
+ var script = {
10
+ name: 'BAutocomplete',
11
+ components: _rollupPluginBabelHelpers._defineProperty({}, Input.Input.name, Input.Input),
12
+ mixins: [FormElementMixin.FormElementMixin],
13
+ inheritAttrs: false,
14
+ props: {
15
+ value: [Number, String],
16
+ data: {
17
+ type: Array,
18
+ default: function _default() {
19
+ return [];
20
+ }
21
+ },
22
+ field: {
23
+ type: String,
24
+ default: 'value'
25
+ },
26
+ keepFirst: Boolean,
27
+ clearOnSelect: Boolean,
28
+ openOnFocus: Boolean,
29
+ customFormatter: Function,
30
+ checkInfiniteScroll: Boolean,
31
+ keepOpen: Boolean,
32
+ selectOnClickOutside: Boolean,
33
+ clearable: Boolean,
34
+ maxHeight: [String, Number],
35
+ dropdownPosition: {
36
+ type: String,
37
+ default: 'auto'
38
+ },
39
+ groupField: String,
40
+ groupOptions: String,
41
+ iconRight: String,
42
+ iconRightClickable: Boolean,
43
+ appendToBody: Boolean,
44
+ type: {
45
+ type: String,
46
+ default: 'text'
47
+ },
48
+ confirmKeys: {
49
+ type: Array,
50
+ default: function _default() {
51
+ return ['Tab', 'Enter'];
52
+ }
53
+ },
54
+ selectableHeader: Boolean,
55
+ selectableFooter: Boolean
56
+ },
57
+ data: function data() {
58
+ return {
59
+ selected: null,
60
+ hovered: null,
61
+ headerHovered: null,
62
+ footerHovered: null,
63
+ isActive: false,
64
+ newValue: this.value,
65
+ newAutocomplete: this.autocomplete || 'off',
66
+ ariaAutocomplete: this.keepFirst ? 'both' : 'list',
67
+ isListInViewportVertically: true,
68
+ hasFocus: false,
69
+ style: {},
70
+ _isAutocomplete: true,
71
+ _elementRef: 'input',
72
+ _bodyEl: undefined,
73
+ // Used to append to body
74
+ timeOutID: null
75
+ };
76
+ },
77
+ computed: {
78
+ computedData: function computedData() {
79
+ var _this = this;
80
+ if (this.groupField) {
81
+ if (this.groupOptions) {
82
+ var newData = [];
83
+ this.data.forEach(function (option) {
84
+ var group = helpers.getValueByPath(option, _this.groupField);
85
+ var items = helpers.getValueByPath(option, _this.groupOptions);
86
+ newData.push({
87
+ group: group,
88
+ items: items
89
+ });
90
+ });
91
+ return newData;
92
+ } else {
93
+ var tmp = {};
94
+ this.data.forEach(function (option) {
95
+ var group = helpers.getValueByPath(option, _this.groupField);
96
+ if (!tmp[group]) tmp[group] = [];
97
+ tmp[group].push(option);
98
+ });
99
+ var _newData = [];
100
+ Object.keys(tmp).forEach(function (group) {
101
+ _newData.push({
102
+ group: group,
103
+ items: tmp[group]
104
+ });
105
+ });
106
+ return _newData;
107
+ }
108
+ }
109
+ return [{
110
+ items: this.data
111
+ }];
112
+ },
113
+ isEmpty: function isEmpty() {
114
+ if (!this.computedData) return true;
115
+ return !this.computedData.some(function (element) {
116
+ return element.items && element.items.length;
117
+ });
118
+ },
119
+ /**
120
+ * White-listed items to not close when clicked.
121
+ * Add input, dropdown and all children.
122
+ */
123
+ whiteList: function whiteList() {
124
+ var whiteList = [];
125
+ whiteList.push(this.$refs.input.$el.querySelector('input'));
126
+ whiteList.push(this.$refs.dropdown);
127
+ // Add all children from dropdown
128
+ if (this.$refs.dropdown !== undefined) {
129
+ var children = this.$refs.dropdown.querySelectorAll('*');
130
+ var _iterator = _rollupPluginBabelHelpers._createForOfIteratorHelper(children),
131
+ _step;
132
+ try {
133
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
134
+ var child = _step.value;
135
+ whiteList.push(child);
136
+ }
137
+ } catch (err) {
138
+ _iterator.e(err);
139
+ } finally {
140
+ _iterator.f();
141
+ }
142
+ }
143
+ if (this.$parent.$data._isTaginput) {
144
+ // Add taginput container
145
+ whiteList.push(this.$parent.$el);
146
+ // Add .tag and .delete
147
+ var tagInputChildren = this.$parent.$el.querySelectorAll('*');
148
+ var _iterator2 = _rollupPluginBabelHelpers._createForOfIteratorHelper(tagInputChildren),
149
+ _step2;
150
+ try {
151
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
152
+ var tagInputChild = _step2.value;
153
+ whiteList.push(tagInputChild);
154
+ }
155
+ } catch (err) {
156
+ _iterator2.e(err);
157
+ } finally {
158
+ _iterator2.f();
159
+ }
160
+ }
161
+ return whiteList;
162
+ },
163
+ /**
164
+ * Check if exists default slot
165
+ */
166
+ hasDefaultSlot: function hasDefaultSlot() {
167
+ return !!this.$scopedSlots.default;
168
+ },
169
+ /**
170
+ * Check if exists group slot
171
+ */
172
+ hasGroupSlot: function hasGroupSlot() {
173
+ return !!this.$scopedSlots.group;
174
+ },
175
+ /**
176
+ * Check if exists "empty" slot
177
+ */
178
+ hasEmptySlot: function hasEmptySlot() {
179
+ return !!this.$slots.empty;
180
+ },
181
+ /**
182
+ * Check if exists "header" slot
183
+ */
184
+ hasHeaderSlot: function hasHeaderSlot() {
185
+ return !!this.$slots.header;
186
+ },
187
+ /**
188
+ * Check if exists "footer" slot
189
+ */
190
+ hasFooterSlot: function hasFooterSlot() {
191
+ return !!this.$slots.footer;
192
+ },
193
+ /**
194
+ * Apply dropdownPosition property
195
+ */
196
+ isOpenedTop: function isOpenedTop() {
197
+ return this.dropdownPosition === 'top' || this.dropdownPosition === 'auto' && !this.isListInViewportVertically;
198
+ },
199
+ newIconRight: function newIconRight() {
200
+ if (this.clearable && this.newValue) {
201
+ return 'close-circle';
202
+ }
203
+ return this.iconRight;
204
+ },
205
+ newIconRightClickable: function newIconRightClickable() {
206
+ if (this.clearable) {
207
+ return true;
208
+ }
209
+ return this.iconRightClickable;
210
+ },
211
+ contentStyle: function contentStyle() {
212
+ return {
213
+ maxHeight: helpers.toCssWidth(this.maxHeight)
214
+ };
215
+ }
216
+ },
217
+ watch: {
218
+ /**
219
+ * When dropdown is toggled, check the visibility to know when
220
+ * to open upwards.
221
+ */
222
+ isActive: function isActive(active) {
223
+ var _this2 = this;
224
+ if (this.dropdownPosition === 'auto') {
225
+ if (active) {
226
+ this.calcDropdownInViewportVertical();
227
+ } else {
228
+ // Timeout to wait for the animation to finish before recalculating
229
+ this.timeOutID = setTimeout(function () {
230
+ _this2.calcDropdownInViewportVertical();
231
+ }, 100);
232
+ }
233
+ }
234
+ this.$nextTick(function () {
235
+ _this2.$emit('active', active);
236
+ });
237
+ },
238
+ /**
239
+ * When checkInfiniteScroll property changes scroll event should be removed or added
240
+ */
241
+ checkInfiniteScroll: function checkInfiniteScroll(_checkInfiniteScroll) {
242
+ if ((this.$refs.dropdown && this.$refs.dropdown.querySelector('.dropdown-content')) === false) return;
243
+ var list = this.$refs.dropdown.querySelector('.dropdown-content');
244
+ if (_checkInfiniteScroll === true) {
245
+ list.addEventListener('scroll', this.checkIfReachedTheEndOfScroll);
246
+ return;
247
+ }
248
+ list.removeEventListener('scroll', this.checkIfReachedTheEndOfScroll);
249
+ },
250
+ /**
251
+ * When updating input's value
252
+ * 1. Emit changes
253
+ * 2. If value isn't the same as selected, set null
254
+ * 3. Close dropdown if value is clear or else open it
255
+ */
256
+ newValue: function newValue(value) {
257
+ this.$emit('input', value);
258
+ // Check if selected is invalid
259
+ var currentValue = this.getValue(this.selected);
260
+ if (currentValue && currentValue !== value) {
261
+ this.setSelected(null, false);
262
+ }
263
+ // Close dropdown if input is clear or else open it
264
+ if (this.hasFocus && (!this.openOnFocus || value)) {
265
+ this.isActive = !!value;
266
+ }
267
+ },
268
+ /**
269
+ * When v-model is changed:
270
+ * 1. Update internal value.
271
+ * 2. If it's invalid, validate again.
272
+ */
273
+ value: function value(_value) {
274
+ this.newValue = _value;
275
+ },
276
+ /**
277
+ * Select first option if "keep-first
278
+ */
279
+ data: function data() {
280
+ var _this3 = this;
281
+ // Keep first option always pre-selected
282
+ if (this.keepFirst) {
283
+ this.$nextTick(function () {
284
+ if (_this3.isActive) {
285
+ _this3.selectFirstOption(_this3.computedData);
286
+ } else {
287
+ _this3.setHovered(null);
288
+ }
289
+ });
290
+ } else {
291
+ if (this.hovered) {
292
+ // reset hovered if list doesn't contain it
293
+ var hoveredValue = this.getValue(this.hovered);
294
+ var data = this.computedData.map(function (d) {
295
+ return d.items;
296
+ }).reduce(function (a, b) {
297
+ return [].concat(_rollupPluginBabelHelpers._toConsumableArray(a), _rollupPluginBabelHelpers._toConsumableArray(b));
298
+ }, []);
299
+ if (!data.some(function (d) {
300
+ return _this3.getValue(d) === hoveredValue;
301
+ })) {
302
+ this.setHovered(null);
303
+ }
304
+ }
305
+ }
306
+ }
307
+ },
308
+ methods: {
309
+ /**
310
+ * Set which option is currently hovered.
311
+ */
312
+ setHovered: function setHovered(option) {
313
+ if (option === undefined) return;
314
+ this.hovered = option;
315
+ },
316
+ /**
317
+ * Set which option is currently selected, update v-model,
318
+ * update input value and close dropdown.
319
+ */
320
+ setSelected: function setSelected(option) {
321
+ var _this4 = this;
322
+ var closeDropdown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
323
+ var event = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
324
+ if (option === undefined) return;
325
+ this.selected = option;
326
+ this.$emit('select', this.selected, event);
327
+ if (this.selected !== null) {
328
+ if (this.clearOnSelect) {
329
+ var input = this.$refs.input;
330
+ input.newValue = '';
331
+ input.$refs.input.value = '';
332
+ } else {
333
+ this.newValue = this.getValue(this.selected);
334
+ }
335
+ this.setHovered(null);
336
+ }
337
+ closeDropdown && this.$nextTick(function () {
338
+ _this4.isActive = false;
339
+ });
340
+ this.checkValidity();
341
+ },
342
+ /**
343
+ * Select first option
344
+ */
345
+ selectFirstOption: function selectFirstOption(computedData) {
346
+ var _this5 = this;
347
+ this.$nextTick(function () {
348
+ var nonEmptyElements = computedData.filter(function (element) {
349
+ return element.items && element.items.length;
350
+ });
351
+ if (nonEmptyElements.length) {
352
+ var option = nonEmptyElements[0].items[0];
353
+ _this5.setHovered(option);
354
+ } else {
355
+ _this5.setHovered(null);
356
+ }
357
+ });
358
+ },
359
+ keydown: function keydown(event) {
360
+ var key = event.key; // cannot destructure preventDefault (https://stackoverflow.com/a/49616808/2774496)
361
+ // prevent emit submit event
362
+ if (key === 'Enter') event.preventDefault();
363
+ // Close dropdown on Tab & no hovered
364
+ if (key === 'Escape' || key === 'Tab') {
365
+ this.isActive = false;
366
+ }
367
+ if (this.confirmKeys.indexOf(key) >= 0) {
368
+ // If adding by comma, don't add the comma to the input
369
+ if (key === ',') event.preventDefault();
370
+ // Close dropdown on select by Tab
371
+ var closeDropdown = !this.keepOpen || key === 'Tab';
372
+ if (this.hovered === null) {
373
+ // header and footer uses headerHovered && footerHovered. If header or footer
374
+ // was selected then fire event otherwise just return so a value isn't selected
375
+ this.checkIfHeaderOrFooterSelected(event, null, closeDropdown);
376
+ return;
377
+ }
378
+ this.setSelected(this.hovered, closeDropdown, event);
379
+ }
380
+ },
381
+ selectHeaderOrFoterByClick: function selectHeaderOrFoterByClick(event, origin) {
382
+ this.checkIfHeaderOrFooterSelected(event, {
383
+ origin: origin
384
+ });
385
+ },
386
+ /**
387
+ * Check if header or footer was selected.
388
+ */
389
+ checkIfHeaderOrFooterSelected: function checkIfHeaderOrFooterSelected(event, triggerClick) {
390
+ var closeDropdown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
391
+ if (this.selectableHeader && (this.headerHovered || triggerClick && triggerClick.origin === 'header')) {
392
+ this.$emit('select-header', event);
393
+ this.headerHovered = false;
394
+ if (triggerClick) this.setHovered(null);
395
+ if (closeDropdown) this.isActive = false;
396
+ }
397
+ if (this.selectableFooter && (this.footerHovered || triggerClick && triggerClick.origin === 'footer')) {
398
+ this.$emit('select-footer', event);
399
+ this.footerHovered = false;
400
+ if (triggerClick) this.setHovered(null);
401
+ if (closeDropdown) this.isActive = false;
402
+ }
403
+ },
404
+ /**
405
+ * Close dropdown if clicked outside.
406
+ */
407
+ clickedOutside: function clickedOutside(event) {
408
+ var target = helpers.isCustomElement(this) ? event.composedPath()[0] : event.target;
409
+ if (!this.hasFocus && this.whiteList.indexOf(target) < 0) {
410
+ if (this.keepFirst && this.hovered && this.selectOnClickOutside) {
411
+ this.setSelected(this.hovered, true);
412
+ } else {
413
+ this.isActive = false;
414
+ }
415
+ }
416
+ },
417
+ /**
418
+ * Return display text for the input.
419
+ * If object, get value from path, or else just the value.
420
+ */
421
+ getValue: function getValue(option) {
422
+ if (option === null) return;
423
+ if (typeof this.customFormatter !== 'undefined') {
424
+ return this.customFormatter(option);
425
+ }
426
+ return _rollupPluginBabelHelpers._typeof(option) === 'object' ? helpers.getValueByPath(option, this.field) : option;
427
+ },
428
+ /**
429
+ * Check if the scroll list inside the dropdown
430
+ * reached it's end.
431
+ */
432
+ checkIfReachedTheEndOfScroll: function checkIfReachedTheEndOfScroll() {
433
+ var list = this.$refs.dropdown.querySelector('.dropdown-content');
434
+ var footerHeight = this.hasFooterSlot ? list.querySelectorAll('div.dropdown-footer')[0].clientHeight : 0;
435
+ if (list.clientHeight !== list.scrollHeight && list.scrollTop + list.parentElement.clientHeight + footerHeight >= list.scrollHeight) {
436
+ this.$emit('infinite-scroll');
437
+ }
438
+ },
439
+ /**
440
+ * Calculate if the dropdown is vertically visible when activated,
441
+ * otherwise it is openened upwards.
442
+ */
443
+ calcDropdownInViewportVertical: function calcDropdownInViewportVertical() {
444
+ var _this6 = this;
445
+ this.$nextTick(function () {
446
+ /**
447
+ * this.$refs.dropdown may be undefined
448
+ * when Autocomplete is conditional rendered
449
+ */
450
+ if (_this6.$refs.dropdown === undefined) return;
451
+ var rect = _this6.$refs.dropdown.getBoundingClientRect();
452
+ _this6.isListInViewportVertically = rect.top >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight);
453
+ if (_this6.appendToBody) {
454
+ _this6.updateAppendToBody();
455
+ }
456
+ });
457
+ },
458
+ /**
459
+ * Arrows keys listener.
460
+ * If dropdown is active, set hovered option, or else just open.
461
+ */
462
+ keyArrows: function keyArrows(direction) {
463
+ var sum = direction === 'down' ? 1 : -1;
464
+ if (this.isActive) {
465
+ var data = this.computedData.map(function (d) {
466
+ return d.items;
467
+ }).reduce(function (a, b) {
468
+ return [].concat(_rollupPluginBabelHelpers._toConsumableArray(a), _rollupPluginBabelHelpers._toConsumableArray(b));
469
+ }, []);
470
+ if (this.hasHeaderSlot && this.selectableHeader) {
471
+ data.unshift(undefined);
472
+ }
473
+ if (this.hasFooterSlot && this.selectableFooter) {
474
+ data.push(undefined);
475
+ }
476
+ var index;
477
+ if (this.headerHovered) {
478
+ index = 0 + sum;
479
+ } else if (this.footerHovered) {
480
+ index = data.length - 1 + sum;
481
+ } else {
482
+ index = data.indexOf(this.hovered) + sum;
483
+ }
484
+ index = index > data.length - 1 ? data.length - 1 : index;
485
+ index = index < 0 ? 0 : index;
486
+ this.footerHovered = false;
487
+ this.headerHovered = false;
488
+ this.setHovered(data[index] !== undefined ? data[index] : null);
489
+ if (this.hasFooterSlot && this.selectableFooter && index === data.length - 1) {
490
+ this.footerHovered = true;
491
+ }
492
+ if (this.hasHeaderSlot && this.selectableHeader && index === 0) {
493
+ this.headerHovered = true;
494
+ }
495
+ var list = this.$refs.dropdown.querySelector('.dropdown-content');
496
+ var querySelectorText = 'a.dropdown-item:not(.is-disabled)';
497
+ if (this.hasHeaderSlot && this.selectableHeader) {
498
+ querySelectorText += ',div.dropdown-header';
499
+ }
500
+ if (this.hasFooterSlot && this.selectableFooter) {
501
+ querySelectorText += ',div.dropdown-footer';
502
+ }
503
+ var element = list.querySelectorAll(querySelectorText)[index];
504
+ if (!element) return;
505
+ var visMin = list.scrollTop;
506
+ var visMax = list.scrollTop + list.clientHeight - element.clientHeight;
507
+ if (element.offsetTop < visMin) {
508
+ list.scrollTop = element.offsetTop;
509
+ } else if (element.offsetTop >= visMax) {
510
+ list.scrollTop = element.offsetTop - list.clientHeight + element.clientHeight;
511
+ }
512
+ } else {
513
+ this.isActive = true;
514
+ }
515
+ },
516
+ /**
517
+ * Focus listener.
518
+ * If value is the same as selected, select all text.
519
+ */
520
+ focused: function focused(event) {
521
+ if (this.getValue(this.selected) === this.newValue) {
522
+ this.$el.querySelector('input').select();
523
+ }
524
+ if (this.openOnFocus) {
525
+ this.isActive = true;
526
+ if (this.keepFirst) {
527
+ // If open on focus, update the hovered
528
+ this.selectFirstOption(this.computedData);
529
+ }
530
+ }
531
+ this.hasFocus = true;
532
+ this.$emit('focus', event);
533
+ },
534
+ /**
535
+ * Blur listener.
536
+ */
537
+ onBlur: function onBlur(event) {
538
+ this.hasFocus = false;
539
+ this.$emit('blur', event);
540
+ },
541
+ onInput: function onInput() {
542
+ var currentValue = this.getValue(this.selected);
543
+ if (currentValue && currentValue === this.newValue) return;
544
+ this.$emit('typing', this.newValue);
545
+ this.checkValidity();
546
+ },
547
+ rightIconClick: function rightIconClick(event) {
548
+ if (this.clearable) {
549
+ this.newValue = '';
550
+ this.setSelected(null, false);
551
+ if (this.openOnFocus) {
552
+ this.$refs.input.$el.focus();
553
+ }
554
+ } else {
555
+ this.$emit('icon-right-click', event);
556
+ }
557
+ },
558
+ checkValidity: function checkValidity() {
559
+ var _this7 = this;
560
+ if (this.useHtml5Validation) {
561
+ this.$nextTick(function () {
562
+ _this7.checkHtml5Validity();
563
+ });
564
+ }
565
+ },
566
+ updateAppendToBody: function updateAppendToBody() {
567
+ var dropdownMenu = this.$refs.dropdown;
568
+ var trigger = this.$parent.$data._isTaginput ? this.$parent.$el : this.$refs.input.$el;
569
+ if (dropdownMenu && trigger) {
570
+ // update wrapper dropdown
571
+ var root = this.$data._bodyEl;
572
+ root.classList.forEach(function (item) {
573
+ return root.classList.remove(item);
574
+ });
575
+ root.classList.add('autocomplete');
576
+ root.classList.add('control');
577
+ if (this.expandend) {
578
+ root.classList.add('is-expandend');
579
+ }
580
+ var rect = trigger.getBoundingClientRect();
581
+ var top = rect.top + window.scrollY;
582
+ var left = rect.left + window.scrollX;
583
+ if (!this.isOpenedTop) {
584
+ top += trigger.clientHeight;
585
+ } else {
586
+ top -= dropdownMenu.clientHeight;
587
+ }
588
+ this.style = {
589
+ position: 'absolute',
590
+ top: "".concat(top, "px"),
591
+ left: "".concat(left, "px"),
592
+ width: "".concat(trigger.clientWidth, "px"),
593
+ maxWidth: "".concat(trigger.clientWidth, "px"),
594
+ zIndex: '99'
595
+ };
596
+ }
597
+ }
598
+ },
599
+ created: function created() {
600
+ if (typeof window !== 'undefined') {
601
+ document.addEventListener('click', this.clickedOutside);
602
+ if (this.dropdownPosition === 'auto') {
603
+ window.addEventListener('resize', this.calcDropdownInViewportVertical);
604
+ }
605
+ }
606
+ },
607
+ mounted: function mounted() {
608
+ if (this.checkInfiniteScroll && this.$refs.dropdown && this.$refs.dropdown.querySelector('.dropdown-content')) {
609
+ var list = this.$refs.dropdown.querySelector('.dropdown-content');
610
+ list.addEventListener('scroll', this.checkIfReachedTheEndOfScroll);
611
+ }
612
+ if (this.appendToBody) {
613
+ this.$data._bodyEl = helpers.createAbsoluteElement(this.$refs.dropdown);
614
+ this.updateAppendToBody();
615
+ }
616
+ },
617
+ beforeDestroy: function beforeDestroy() {
618
+ if (typeof window !== 'undefined') {
619
+ document.removeEventListener('click', this.clickedOutside);
620
+ if (this.dropdownPosition === 'auto') {
621
+ window.removeEventListener('resize', this.calcDropdownInViewportVertical);
622
+ }
623
+ }
624
+ if (this.checkInfiniteScroll && this.$refs.dropdown && this.$refs.dropdown.querySelector('.dropdown-content')) {
625
+ var list = this.$refs.dropdown.querySelector('.dropdown-content');
626
+ list.removeEventListener('scroll', this.checkIfReachedTheEndOfScroll);
627
+ }
628
+ if (this.appendToBody) {
629
+ helpers.removeElement(this.$data._bodyEl);
630
+ }
631
+ clearTimeout(this.timeOutID);
632
+ }
633
+ };
634
+
635
+ /* script */
636
+ const __vue_script__ = script;
637
+
638
+ /* template */
639
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"autocomplete control",class:{ 'is-expanded': _vm.expanded }},[_c('b-input',_vm._b({ref:"input",attrs:{"type":_vm.type,"size":_vm.size,"loading":_vm.loading,"rounded":_vm.rounded,"icon":_vm.icon,"icon-right":_vm.newIconRight,"icon-right-clickable":_vm.newIconRightClickable,"icon-pack":_vm.iconPack,"maxlength":_vm.maxlength,"autocomplete":_vm.newAutocomplete,"use-html5-validation":false,"aria-autocomplete":_vm.ariaAutocomplete},on:{"input":_vm.onInput,"focus":_vm.focused,"blur":_vm.onBlur,"icon-right-click":_vm.rightIconClick,"icon-click":function (event) { return _vm.$emit('icon-click', event); }},nativeOn:{"keydown":[function($event){return _vm.keydown($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){ return null; }$event.preventDefault();return _vm.keyArrows('up')},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){ return null; }$event.preventDefault();return _vm.keyArrows('down')}]},model:{value:(_vm.newValue),callback:function ($$v) {_vm.newValue=$$v;},expression:"newValue"}},'b-input',_vm.$attrs,false)),_c('transition',{attrs:{"name":"fade"}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.isActive && (!_vm.isEmpty || _vm.hasEmptySlot || _vm.hasHeaderSlot || _vm.hasFooterSlot)),expression:"isActive && (!isEmpty || hasEmptySlot || hasHeaderSlot || hasFooterSlot)"}],ref:"dropdown",staticClass:"dropdown-menu",class:{ 'is-opened-top': _vm.isOpenedTop && !_vm.appendToBody },style:(_vm.style)},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.isActive),expression:"isActive"}],staticClass:"dropdown-content",style:(_vm.contentStyle)},[(_vm.hasHeaderSlot)?_c('div',{staticClass:"dropdown-item dropdown-header",class:{ 'is-hovered': _vm.headerHovered },attrs:{"role":"button","tabindex":"0"},on:{"click":function($event){return _vm.selectHeaderOrFoterByClick($event, 'header')}}},[_vm._t("header")],2):_vm._e(),_vm._l((_vm.computedData),function(element,groupindex){return [(element.group)?_c('div',{key:groupindex + 'group',staticClass:"dropdown-item"},[(_vm.hasGroupSlot)?_vm._t("group",null,{"group":element.group,"index":groupindex}):_c('span',{staticClass:"has-text-weight-bold"},[_vm._v(" "+_vm._s(element.group)+" ")])],2):_vm._e(),_vm._l((element.items),function(option,index){return _c('a',{key:groupindex + ':' + index,staticClass:"dropdown-item",class:{ 'is-hovered': option === _vm.hovered },attrs:{"role":"button","tabindex":"0"},on:{"click":function($event){$event.stopPropagation();return _vm.setSelected(option, !_vm.keepOpen, $event)}}},[(_vm.hasDefaultSlot)?_vm._t("default",null,{"option":option,"index":index}):_c('span',[_vm._v(" "+_vm._s(_vm.getValue(option, true))+" ")])],2)})]}),(_vm.isEmpty && _vm.hasEmptySlot)?_c('div',{staticClass:"dropdown-item is-disabled"},[_vm._t("empty")],2):_vm._e(),(_vm.hasFooterSlot)?_c('div',{staticClass:"dropdown-item dropdown-footer",class:{ 'is-hovered': _vm.footerHovered },attrs:{"role":"button","tabindex":"0"},on:{"click":function($event){return _vm.selectHeaderOrFoterByClick($event, 'footer')}}},[_vm._t("footer")],2):_vm._e()],2)])])],1)};
640
+ var __vue_staticRenderFns__ = [];
641
+
642
+ /* style */
643
+ const __vue_inject_styles__ = undefined;
644
+ /* scoped */
645
+ const __vue_scope_id__ = undefined;
646
+ /* module identifier */
647
+ const __vue_module_identifier__ = undefined;
648
+ /* functional template */
649
+ const __vue_is_functional_template__ = false;
650
+ /* style inject */
651
+
652
+ /* style inject SSR */
653
+
654
+ /* style inject shadow dom */
655
+
656
+
657
+
658
+ const __vue_component__ = /*#__PURE__*/plugins.normalizeComponent(
659
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
660
+ __vue_inject_styles__,
661
+ __vue_script__,
662
+ __vue_scope_id__,
663
+ __vue_is_functional_template__,
664
+ __vue_module_identifier__,
665
+ false,
666
+ undefined,
667
+ undefined,
668
+ undefined
669
+ );
670
+
671
+ var Autocomplete = __vue_component__;
672
+
673
+ exports.Autocomplete = Autocomplete;