buefy 0.9.18 → 0.9.21

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 (230) hide show
  1. package/CHANGELOG.md +1741 -1719
  2. package/dist/buefy.css +15848 -1
  3. package/dist/buefy.esm.js +77 -38
  4. package/dist/buefy.esm.min.js +2 -2
  5. package/dist/buefy.js +77 -38
  6. package/dist/buefy.min.css +1 -1
  7. package/dist/buefy.min.js +2 -2
  8. package/dist/cjs/autocomplete.js +5 -5
  9. package/dist/cjs/breadcrumb.js +1 -1
  10. package/dist/cjs/button.js +3 -3
  11. package/dist/cjs/carousel.js +3 -3
  12. package/dist/cjs/checkbox.js +1 -1
  13. package/dist/cjs/{chunk-5ed8a75a.js → chunk-09574ad9.js} +3 -3
  14. package/dist/cjs/{chunk-7c11fdde.js → chunk-201c9e5c.js} +1 -1
  15. package/dist/cjs/{chunk-545e1c7f.js → chunk-2a96ec68.js} +2 -2
  16. package/dist/cjs/{chunk-9103eeda.js → chunk-437dd7a0.js} +1 -0
  17. package/dist/cjs/{chunk-3b43d77a.js → chunk-5cd29907.js} +1 -1
  18. package/dist/cjs/{chunk-334bc809.js → chunk-7b44db6e.js} +2 -2
  19. package/dist/cjs/{chunk-779e6a5d.js → chunk-85b00a19.js} +8 -8
  20. package/dist/cjs/{chunk-5058e659.js → chunk-95c4b826.js} +3 -3
  21. package/dist/cjs/{chunk-83b41298.js → chunk-99367591.js} +24 -8
  22. package/dist/cjs/{chunk-73f8eef8.js → chunk-a6b29437.js} +1 -1
  23. package/dist/cjs/{chunk-8ef75f09.js → chunk-bcab8905.js} +6 -6
  24. package/dist/cjs/{chunk-54b0042d.js → chunk-befea70a.js} +2 -2
  25. package/dist/cjs/{chunk-4bcfaf1c.js → chunk-cc9676a6.js} +1 -1
  26. package/dist/cjs/{chunk-03279fd8.js → chunk-dddb035c.js} +1 -1
  27. package/dist/cjs/{chunk-e872f5e2.js → chunk-e0373ab6.js} +1 -1
  28. package/dist/cjs/{chunk-1f7e4ed3.js → chunk-e90b3d05.js} +2 -2
  29. package/dist/cjs/{chunk-f5285f14.js → chunk-eba24a95.js} +1 -1
  30. package/dist/cjs/{chunk-e86d3eeb.js → chunk-f5139026.js} +1 -1
  31. package/dist/cjs/{chunk-c8abb3ed.js → chunk-f8eb56c6.js} +2 -2
  32. package/dist/cjs/{chunk-87a116d9.js → chunk-fb8ff6be.js} +1 -2
  33. package/dist/cjs/clockpicker.js +17 -8
  34. package/dist/cjs/colorpicker.js +18 -11
  35. package/dist/cjs/config.js +1 -1
  36. package/dist/cjs/datepicker.js +8 -8
  37. package/dist/cjs/datetimepicker.js +10 -10
  38. package/dist/cjs/dialog.js +4 -4
  39. package/dist/cjs/dropdown.js +2 -2
  40. package/dist/cjs/field.js +2 -2
  41. package/dist/cjs/icon.js +2 -2
  42. package/dist/cjs/image.js +2 -2
  43. package/dist/cjs/index.js +20 -20
  44. package/dist/cjs/input.js +4 -4
  45. package/dist/cjs/loading.js +1 -1
  46. package/dist/cjs/menu.js +3 -3
  47. package/dist/cjs/message.js +3 -3
  48. package/dist/cjs/modal.js +2 -2
  49. package/dist/cjs/notification.js +4 -4
  50. package/dist/cjs/numberinput.js +4 -4
  51. package/dist/cjs/pagination.js +3 -3
  52. package/dist/cjs/progress.js +1 -1
  53. package/dist/cjs/rate.js +2 -2
  54. package/dist/cjs/select.js +4 -4
  55. package/dist/cjs/sidebar.js +16 -16
  56. package/dist/cjs/slider.js +2 -2
  57. package/dist/cjs/snackbar.js +2 -2
  58. package/dist/cjs/steps.js +3 -3
  59. package/dist/cjs/switch.js +1 -1
  60. package/dist/cjs/table.js +19 -12
  61. package/dist/cjs/tabs.js +3 -3
  62. package/dist/cjs/taginput.js +5 -5
  63. package/dist/cjs/timepicker.js +9 -9
  64. package/dist/cjs/toast.js +2 -2
  65. package/dist/cjs/tooltip.js +2 -2
  66. package/dist/cjs/upload.js +2 -2
  67. package/dist/components/autocomplete/index.js +2 -2
  68. package/dist/components/autocomplete/index.min.js +2 -2
  69. package/dist/components/breadcrumb/index.js +2 -1
  70. package/dist/components/breadcrumb/index.min.js +1 -1
  71. package/dist/components/button/index.js +3 -2
  72. package/dist/components/button/index.min.js +2 -2
  73. package/dist/components/carousel/index.js +2 -1
  74. package/dist/components/carousel/index.min.js +2 -2
  75. package/dist/components/checkbox/index.js +2 -2
  76. package/dist/components/checkbox/index.min.js +2 -2
  77. package/dist/components/clockpicker/index.js +13 -4
  78. package/dist/components/clockpicker/index.min.js +2 -2
  79. package/dist/components/collapse/index.js +1 -1
  80. package/dist/components/collapse/index.min.js +1 -1
  81. package/dist/components/colorpicker/index.js +36 -13
  82. package/dist/components/colorpicker/index.min.js +2 -2
  83. package/dist/components/datepicker/index.js +4 -4
  84. package/dist/components/datepicker/index.min.js +2 -2
  85. package/dist/components/datetimepicker/index.js +4 -4
  86. package/dist/components/datetimepicker/index.min.js +2 -2
  87. package/dist/components/dialog/index.js +3 -2
  88. package/dist/components/dialog/index.min.js +2 -2
  89. package/dist/components/dropdown/index.js +2 -1
  90. package/dist/components/dropdown/index.min.js +1 -1
  91. package/dist/components/field/index.js +3 -2
  92. package/dist/components/field/index.min.js +2 -2
  93. package/dist/components/icon/index.js +2 -1
  94. package/dist/components/icon/index.min.js +2 -2
  95. package/dist/components/image/index.js +2 -1
  96. package/dist/components/image/index.min.js +2 -2
  97. package/dist/components/input/index.js +2 -2
  98. package/dist/components/input/index.min.js +2 -2
  99. package/dist/components/loading/index.js +1 -1
  100. package/dist/components/loading/index.min.js +1 -1
  101. package/dist/components/menu/index.js +3 -2
  102. package/dist/components/menu/index.min.js +2 -2
  103. package/dist/components/message/index.js +2 -1
  104. package/dist/components/message/index.min.js +2 -2
  105. package/dist/components/modal/index.js +2 -1
  106. package/dist/components/modal/index.min.js +2 -2
  107. package/dist/components/navbar/index.js +1 -1
  108. package/dist/components/navbar/index.min.js +1 -1
  109. package/dist/components/notification/index.js +2 -1
  110. package/dist/components/notification/index.min.js +2 -2
  111. package/dist/components/numberinput/index.js +2 -2
  112. package/dist/components/numberinput/index.min.js +2 -2
  113. package/dist/components/pagination/index.js +2 -1
  114. package/dist/components/pagination/index.min.js +2 -2
  115. package/dist/components/progress/index.js +2 -1
  116. package/dist/components/progress/index.min.js +2 -2
  117. package/dist/components/radio/index.js +1 -1
  118. package/dist/components/radio/index.min.js +1 -1
  119. package/dist/components/rate/index.js +2 -1
  120. package/dist/components/rate/index.min.js +2 -2
  121. package/dist/components/select/index.js +2 -2
  122. package/dist/components/select/index.min.js +2 -2
  123. package/dist/components/sidebar/index.js +17 -16
  124. package/dist/components/sidebar/index.min.js +1 -1
  125. package/dist/components/skeleton/index.js +1 -1
  126. package/dist/components/skeleton/index.min.js +1 -1
  127. package/dist/components/slider/index.js +25 -8
  128. package/dist/components/slider/index.min.js +2 -2
  129. package/dist/components/snackbar/index.js +2 -1
  130. package/dist/components/snackbar/index.min.js +1 -1
  131. package/dist/components/steps/index.js +2 -1
  132. package/dist/components/steps/index.min.js +2 -2
  133. package/dist/components/switch/index.js +2 -1
  134. package/dist/components/switch/index.min.js +1 -1
  135. package/dist/components/table/index.js +15 -8
  136. package/dist/components/table/index.min.js +2 -2
  137. package/dist/components/tabs/index.js +2 -1
  138. package/dist/components/tabs/index.min.js +2 -2
  139. package/dist/components/tag/index.js +1 -1
  140. package/dist/components/tag/index.min.js +1 -1
  141. package/dist/components/taginput/index.js +2 -2
  142. package/dist/components/taginput/index.min.js +2 -2
  143. package/dist/components/timepicker/index.js +3 -3
  144. package/dist/components/timepicker/index.min.js +2 -2
  145. package/dist/components/toast/index.js +2 -1
  146. package/dist/components/toast/index.min.js +1 -1
  147. package/dist/components/tooltip/index.js +25 -8
  148. package/dist/components/tooltip/index.min.js +2 -2
  149. package/dist/components/upload/index.js +2 -2
  150. package/dist/components/upload/index.min.js +2 -2
  151. package/dist/esm/autocomplete.js +6 -6
  152. package/dist/esm/breadcrumb.js +1 -1
  153. package/dist/esm/button.js +4 -4
  154. package/dist/esm/carousel.js +3 -3
  155. package/dist/esm/checkbox.js +2 -2
  156. package/dist/esm/{chunk-84c6dfd6.js → chunk-17b33cd2.js} +1 -2
  157. package/dist/esm/{chunk-a5e3ae5d.js → chunk-293c457c.js} +6 -6
  158. package/dist/esm/{chunk-d35985c7.js → chunk-33e1434e.js} +1 -1
  159. package/dist/esm/{chunk-690d5be4.js → chunk-493ff0a9.js} +1 -1
  160. package/dist/esm/{chunk-252f2b57.js → chunk-4a2008fa.js} +1 -1
  161. package/dist/esm/{chunk-6adc5c5d.js → chunk-4e788733.js} +2 -2
  162. package/dist/esm/{chunk-43fb1457.js → chunk-6c64686f.js} +8 -8
  163. package/dist/esm/{chunk-262b3f82.js → chunk-6e56b8bc.js} +2 -2
  164. package/dist/esm/{chunk-5435bd9a.js → chunk-7bb9107f.js} +1 -1
  165. package/dist/esm/{chunk-e044aa02.js → chunk-7e17a637.js} +1 -1
  166. package/dist/esm/{chunk-a628d44d.js → chunk-83c8b459.js} +3 -3
  167. package/dist/esm/{chunk-f967f402.js → chunk-9b0b8225.js} +24 -8
  168. package/dist/esm/{chunk-d9232770.js → chunk-a32d1427.js} +1 -1
  169. package/dist/esm/{chunk-598015da.js → chunk-ade5b253.js} +1 -1
  170. package/dist/esm/{chunk-f9eaeac4.js → chunk-b0123b89.js} +2 -2
  171. package/dist/esm/{chunk-58cdbf2b.js → chunk-b5576437.js} +3 -3
  172. package/dist/esm/{chunk-1a4fde6d.js → chunk-c5284276.js} +2 -2
  173. package/dist/esm/{chunk-effa4d25.js → chunk-d46e7ff0.js} +2 -2
  174. package/dist/esm/{chunk-8ed29c41.js → chunk-e92e3389.js} +1 -0
  175. package/dist/esm/{chunk-6d96579e.js → chunk-f32d0228.js} +1 -1
  176. package/dist/esm/clockpicker.js +17 -8
  177. package/dist/esm/colorpicker.js +18 -11
  178. package/dist/esm/config.js +1 -1
  179. package/dist/esm/datepicker.js +9 -9
  180. package/dist/esm/datetimepicker.js +10 -10
  181. package/dist/esm/dialog.js +4 -4
  182. package/dist/esm/dropdown.js +3 -3
  183. package/dist/esm/field.js +3 -3
  184. package/dist/esm/icon.js +3 -3
  185. package/dist/esm/image.js +3 -3
  186. package/dist/esm/index.js +20 -20
  187. package/dist/esm/input.js +5 -5
  188. package/dist/esm/loading.js +1 -1
  189. package/dist/esm/menu.js +3 -3
  190. package/dist/esm/message.js +3 -3
  191. package/dist/esm/modal.js +3 -3
  192. package/dist/esm/notification.js +4 -4
  193. package/dist/esm/numberinput.js +4 -4
  194. package/dist/esm/pagination.js +4 -4
  195. package/dist/esm/progress.js +1 -1
  196. package/dist/esm/rate.js +2 -2
  197. package/dist/esm/select.js +5 -5
  198. package/dist/esm/sidebar.js +16 -16
  199. package/dist/esm/slider.js +2 -2
  200. package/dist/esm/snackbar.js +2 -2
  201. package/dist/esm/steps.js +3 -3
  202. package/dist/esm/switch.js +1 -1
  203. package/dist/esm/table.js +19 -12
  204. package/dist/esm/tabs.js +3 -3
  205. package/dist/esm/taginput.js +5 -5
  206. package/dist/esm/timepicker.js +10 -10
  207. package/dist/esm/toast.js +2 -2
  208. package/dist/esm/tooltip.js +3 -3
  209. package/dist/esm/upload.js +2 -2
  210. package/dist/vetur/attributes.json +9 -1
  211. package/dist/vetur/tags.json +2 -1
  212. package/package.json +1 -1
  213. package/src/components/button/Button.spec.js +14 -0
  214. package/src/components/button/Button.vue +1 -1
  215. package/src/components/checkbox/Checkbox.vue +5 -1
  216. package/src/components/clockpicker/Clockpicker.vue +9 -1
  217. package/src/components/colorpicker/Colorpicker.vue +7 -2
  218. package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.vue +3 -1
  219. package/src/components/datepicker/Datepicker.vue +1 -1
  220. package/src/components/field/Field.vue +1 -0
  221. package/src/components/menu/MenuItem.vue +1 -1
  222. package/src/components/sidebar/Sidebar.spec.js +105 -105
  223. package/src/components/sidebar/Sidebar.vue +303 -303
  224. package/src/components/table/Table.vue +10 -2
  225. package/src/components/table/TableColumn.vue +121 -118
  226. package/src/components/tooltip/Tooltip.vue +299 -288
  227. package/src/scss/components/_dropdown.scss +6 -0
  228. package/src/scss/utils/_helpers.scss +0 -6
  229. package/src/utils/FormElementMixin.js +0 -1
  230. package/src/utils/config.js +1 -0
@@ -1,288 +1,299 @@
1
- <template>
2
- <div ref="tooltip" :class="rootClasses">
3
- <transition :name="newAnimation">
4
- <div
5
- v-show="active && (isActive || always)"
6
- ref="content"
7
- :class="['tooltip-content', contentClass]">
8
- <template v-if="label">{{ label }}</template>
9
- <template v-else-if="$slots.content">
10
- <slot name="content" />
11
- </template>
12
- </div>
13
- </transition>
14
- <div
15
- ref="trigger"
16
- class="tooltip-trigger"
17
- :style="triggerStyle"
18
- @click="onClick"
19
- @contextmenu="onContextMenu"
20
- @mouseenter="onHover"
21
- @focus.capture="onFocus"
22
- @blur.capture="close"
23
- @mouseleave="close">
24
- <slot ref="slot" />
25
- </div>
26
- </div>
27
- </template>
28
-
29
- <script>
30
- import config from '../../utils/config'
31
- import { createAbsoluteElement, removeElement } from '../../utils/helpers'
32
-
33
- export default {
34
- name: 'BTooltip',
35
- props: {
36
- active: {
37
- type: Boolean,
38
- default: true
39
- },
40
- type: {
41
- type: String,
42
- default: () => config.defaultTooltipType
43
- },
44
- label: String,
45
- delay: {
46
- type: Number,
47
- default: () => config.defaultTooltipDelay
48
- },
49
- position: {
50
- type: String,
51
- default: 'is-top',
52
- validator(value) {
53
- return [
54
- 'is-top',
55
- 'is-bottom',
56
- 'is-left',
57
- 'is-right'
58
- ].indexOf(value) > -1
59
- }
60
- },
61
- triggers: {
62
- type: Array,
63
- default: () => ['hover']
64
- },
65
- always: Boolean,
66
- square: Boolean,
67
- dashed: Boolean,
68
- multilined: Boolean,
69
- size: {
70
- type: String,
71
- default: 'is-medium'
72
- },
73
- appendToBody: Boolean,
74
- animated: {
75
- type: Boolean,
76
- default: true
77
- },
78
- animation: {
79
- type: String,
80
- default: 'fade'
81
- },
82
- contentClass: String,
83
- autoClose: {
84
- type: [Array, Boolean],
85
- default: true
86
- }
87
- },
88
- data() {
89
- return {
90
- isActive: false,
91
- triggerStyle: {},
92
- timer: null,
93
- _bodyEl: undefined // Used to append to body
94
- }
95
- },
96
- computed: {
97
- rootClasses() {
98
- return ['b-tooltip', this.type, this.position, this.size, {
99
- 'is-square': this.square,
100
- 'is-always': this.always,
101
- 'is-multiline': this.multilined,
102
- 'is-dashed': this.dashed
103
- }]
104
- },
105
- newAnimation() {
106
- return this.animated ? this.animation : undefined
107
- }
108
- },
109
- watch: {
110
- isActive() {
111
- this.$emit(this.isActive ? 'open' : 'close')
112
- if (this.appendToBody) {
113
- this.updateAppendToBody()
114
- }
115
- }
116
- },
117
- methods: {
118
- updateAppendToBody() {
119
- const tooltip = this.$refs.tooltip
120
- const trigger = this.$refs.trigger
121
- if (tooltip && trigger) {
122
- // update wrapper tooltip
123
- const tooltipEl = this.$data._bodyEl.children[0]
124
- tooltipEl.classList.forEach((item) => tooltipEl.classList.remove(item))
125
- if (
126
- this.$vnode &&
127
- this.$vnode.data &&
128
- this.$vnode.data.staticClass
129
- ) {
130
- tooltipEl.classList.add(this.$vnode.data.staticClass)
131
- }
132
- this.rootClasses.forEach((item) => {
133
- if (typeof item === 'object') {
134
- for (let key in item) {
135
- if (item[key]) {
136
- tooltipEl.classList.add(key)
137
- }
138
- }
139
- } else {
140
- tooltipEl.classList.add(item)
141
- }
142
- })
143
-
144
- const rect = trigger.getBoundingClientRect()
145
-
146
- let top = rect.top + window.scrollY
147
- let left = rect.left + window.scrollX
148
-
149
- const quaterHeight = trigger.clientHeight / 2 / 2
150
-
151
- switch (this.position) {
152
- case 'is-top':
153
- tooltipEl.style.width = `${trigger.clientWidth}px`
154
- tooltipEl.style.height = `0px`
155
- top -= trigger.clientHeight - quaterHeight
156
- break
157
- case 'is-bottom':
158
- tooltipEl.style.width = `${trigger.clientWidth}px`
159
- tooltipEl.style.height = `0px`
160
- top += quaterHeight
161
- break
162
- case 'is-left':
163
- tooltipEl.style.width = `0px`
164
- tooltipEl.style.height = `${trigger.clientHeight}px`
165
- break
166
- case 'is-right':
167
- tooltipEl.style.width = `0px`
168
- tooltipEl.style.height = `${trigger.clientHeight}px`
169
- left += trigger.clientWidth
170
- break
171
- }
172
-
173
- const wrapper = this.$data._bodyEl
174
- wrapper.style.position = 'absolute'
175
- wrapper.style.top = `${top}px`
176
- wrapper.style.left = `${left}px`
177
- wrapper.style.width = `0px`
178
- wrapper.style.zIndex = this.isActive || this.always ? '99' : '-1'
179
- this.triggerStyle = {
180
- zIndex: this.isActive || this.always ? '100' : undefined
181
- }
182
- }
183
- },
184
- onClick() {
185
- if (this.triggers.indexOf('click') < 0) return
186
- // if not active, toggle after clickOutside event
187
- // this fixes toggling programmatic
188
- this.$nextTick(() => {
189
- setTimeout(() => this.open())
190
- })
191
- },
192
- onHover() {
193
- if (this.triggers.indexOf('hover') < 0) return
194
- this.open()
195
- },
196
- onContextMenu(e) {
197
- if (this.triggers.indexOf('contextmenu') < 0) return
198
- e.preventDefault()
199
- this.open()
200
- },
201
- onFocus() {
202
- if (this.triggers.indexOf('focus') < 0) return
203
- this.open()
204
- },
205
- open() {
206
- if (this.delay) {
207
- this.timer = setTimeout(() => {
208
- this.isActive = true
209
- this.timer = null
210
- }, this.delay)
211
- } else {
212
- this.isActive = true
213
- }
214
- },
215
- close() {
216
- if (typeof this.autoClose === 'boolean') {
217
- this.isActive = !this.autoClose
218
- if (this.autoClose && this.timer) clearTimeout(this.timer)
219
- }
220
- },
221
- /**
222
- * Close tooltip if clicked outside.
223
- */
224
- clickedOutside(event) {
225
- if (this.isActive) {
226
- if (Array.isArray(this.autoClose)) {
227
- if (this.autoClose.includes('outside')) {
228
- if (!this.isInWhiteList(event.target)) {
229
- this.isActive = false
230
- return
231
- }
232
- }
233
- if (this.autoClose.includes('inside')) {
234
- if (this.isInWhiteList(event.target)) this.isActive = false
235
- }
236
- }
237
- }
238
- },
239
- /**
240
- * Keypress event that is bound to the document
241
- */
242
- keyPress({ key }) {
243
- if (this.isActive && (key === 'Escape' || key === 'Esc')) {
244
- if (Array.isArray(this.autoClose)) {
245
- if (this.autoClose.indexOf('escape') >= 0) this.isActive = false
246
- }
247
- }
248
- },
249
- /**
250
- * White-listed items to not close when clicked.
251
- */
252
- isInWhiteList(el) {
253
- if (el === this.$refs.content) return true
254
- // All chidren from content
255
- if (this.$refs.content !== undefined) {
256
- const children = this.$refs.content.querySelectorAll('*')
257
- for (const child of children) {
258
- if (el === child) {
259
- return true
260
- }
261
- }
262
- }
263
- return false
264
- }
265
- },
266
- mounted() {
267
- if (this.appendToBody && typeof window !== 'undefined') {
268
- this.$data._bodyEl = createAbsoluteElement(this.$refs.content)
269
- this.updateAppendToBody()
270
- }
271
- },
272
- created() {
273
- if (typeof window !== 'undefined') {
274
- document.addEventListener('click', this.clickedOutside)
275
- document.addEventListener('keyup', this.keyPress)
276
- }
277
- },
278
- beforeDestroy() {
279
- if (typeof window !== 'undefined') {
280
- document.removeEventListener('click', this.clickedOutside)
281
- document.removeEventListener('keyup', this.keyPress)
282
- }
283
- if (this.appendToBody) {
284
- removeElement(this.$data._bodyEl)
285
- }
286
- }
287
- }
288
- </script>
1
+ <template>
2
+ <div ref="tooltip" :class="rootClasses">
3
+ <transition :name="newAnimation">
4
+ <div
5
+ v-show="active && (isActive || always)"
6
+ ref="content"
7
+ :class="['tooltip-content', contentClass]">
8
+ <template v-if="label">{{ label }}</template>
9
+ <template v-else-if="$slots.content">
10
+ <slot name="content" />
11
+ </template>
12
+ </div>
13
+ </transition>
14
+ <div
15
+ ref="trigger"
16
+ class="tooltip-trigger"
17
+ :style="triggerStyle"
18
+ @click="onClick"
19
+ @contextmenu="onContextMenu"
20
+ @mouseenter="onHover"
21
+ @focus.capture="onFocus"
22
+ @blur.capture="close"
23
+ @mouseleave="close">
24
+ <slot ref="slot" />
25
+ </div>
26
+ </div>
27
+ </template>
28
+
29
+ <script>
30
+ import config from '../../utils/config'
31
+ import { createAbsoluteElement, removeElement } from '../../utils/helpers'
32
+
33
+ export default {
34
+ name: 'BTooltip',
35
+ props: {
36
+ active: {
37
+ type: Boolean,
38
+ default: true
39
+ },
40
+ type: {
41
+ type: String,
42
+ default: () => config.defaultTooltipType
43
+ },
44
+ label: String,
45
+ delay: {
46
+ type: Number,
47
+ default: () => config.defaultTooltipDelay
48
+ },
49
+ closeDelay: {
50
+ type: Number,
51
+ default: () => config.defaultTooltipCloseDelay
52
+ },
53
+ position: {
54
+ type: String,
55
+ default: 'is-top',
56
+ validator(value) {
57
+ return [
58
+ 'is-top',
59
+ 'is-bottom',
60
+ 'is-left',
61
+ 'is-right'
62
+ ].indexOf(value) > -1
63
+ }
64
+ },
65
+ triggers: {
66
+ type: Array,
67
+ default: () => ['hover']
68
+ },
69
+ always: Boolean,
70
+ square: Boolean,
71
+ dashed: Boolean,
72
+ multilined: Boolean,
73
+ size: {
74
+ type: String,
75
+ default: 'is-medium'
76
+ },
77
+ appendToBody: Boolean,
78
+ animated: {
79
+ type: Boolean,
80
+ default: true
81
+ },
82
+ animation: {
83
+ type: String,
84
+ default: 'fade'
85
+ },
86
+ contentClass: String,
87
+ autoClose: {
88
+ type: [Array, Boolean],
89
+ default: true
90
+ }
91
+ },
92
+ data() {
93
+ return {
94
+ isActive: false,
95
+ triggerStyle: {},
96
+ timer: null,
97
+ _bodyEl: undefined // Used to append to body
98
+ }
99
+ },
100
+ computed: {
101
+ rootClasses() {
102
+ return ['b-tooltip', this.type, this.position, this.size, {
103
+ 'is-square': this.square,
104
+ 'is-always': this.always,
105
+ 'is-multiline': this.multilined,
106
+ 'is-dashed': this.dashed
107
+ }]
108
+ },
109
+ newAnimation() {
110
+ return this.animated ? this.animation : undefined
111
+ }
112
+ },
113
+ watch: {
114
+ isActive() {
115
+ this.$emit(this.isActive ? 'open' : 'close')
116
+ if (this.appendToBody) {
117
+ this.updateAppendToBody()
118
+ }
119
+ }
120
+ },
121
+ methods: {
122
+ updateAppendToBody() {
123
+ const tooltip = this.$refs.tooltip
124
+ const trigger = this.$refs.trigger
125
+ if (tooltip && trigger) {
126
+ // update wrapper tooltip
127
+ const tooltipEl = this.$data._bodyEl.children[0]
128
+ tooltipEl.classList.forEach((item) => tooltipEl.classList.remove(item))
129
+ if (
130
+ this.$vnode &&
131
+ this.$vnode.data &&
132
+ this.$vnode.data.staticClass
133
+ ) {
134
+ tooltipEl.classList.add(this.$vnode.data.staticClass)
135
+ }
136
+ this.rootClasses.forEach((item) => {
137
+ if (typeof item === 'object') {
138
+ for (let key in item) {
139
+ if (item[key]) {
140
+ tooltipEl.classList.add(key)
141
+ }
142
+ }
143
+ } else {
144
+ tooltipEl.classList.add(item)
145
+ }
146
+ })
147
+
148
+ const rect = trigger.getBoundingClientRect()
149
+
150
+ let top = rect.top + window.scrollY
151
+ let left = rect.left + window.scrollX
152
+
153
+ const quaterHeight = trigger.clientHeight / 2 / 2
154
+
155
+ switch (this.position) {
156
+ case 'is-top':
157
+ tooltipEl.style.width = `${trigger.clientWidth}px`
158
+ tooltipEl.style.height = `0px`
159
+ top -= trigger.clientHeight - quaterHeight
160
+ break
161
+ case 'is-bottom':
162
+ tooltipEl.style.width = `${trigger.clientWidth}px`
163
+ tooltipEl.style.height = `0px`
164
+ top += quaterHeight
165
+ break
166
+ case 'is-left':
167
+ tooltipEl.style.width = `0px`
168
+ tooltipEl.style.height = `${trigger.clientHeight}px`
169
+ break
170
+ case 'is-right':
171
+ tooltipEl.style.width = `0px`
172
+ tooltipEl.style.height = `${trigger.clientHeight}px`
173
+ left += trigger.clientWidth
174
+ break
175
+ }
176
+
177
+ const wrapper = this.$data._bodyEl
178
+ wrapper.style.position = 'absolute'
179
+ wrapper.style.top = `${top}px`
180
+ wrapper.style.left = `${left}px`
181
+ wrapper.style.width = `0px`
182
+ wrapper.style.zIndex = this.isActive || this.always ? '99' : '-1'
183
+ this.triggerStyle = {
184
+ zIndex: this.isActive || this.always ? '100' : undefined
185
+ }
186
+ }
187
+ },
188
+ onClick() {
189
+ if (this.triggers.indexOf('click') < 0) return
190
+ // if not active, toggle after clickOutside event
191
+ // this fixes toggling programmatic
192
+ this.$nextTick(() => {
193
+ setTimeout(() => this.open())
194
+ })
195
+ },
196
+ onHover() {
197
+ if (this.triggers.indexOf('hover') < 0) return
198
+ this.open()
199
+ },
200
+ onContextMenu(e) {
201
+ if (this.triggers.indexOf('contextmenu') < 0) return
202
+ e.preventDefault()
203
+ this.open()
204
+ },
205
+ onFocus() {
206
+ if (this.triggers.indexOf('focus') < 0) return
207
+ this.open()
208
+ },
209
+ open() {
210
+ if (this.delay) {
211
+ this.timer = setTimeout(() => {
212
+ this.isActive = true
213
+ this.timer = null
214
+ }, this.delay)
215
+ } else {
216
+ this.isActive = true
217
+ }
218
+ },
219
+ close() {
220
+ if (typeof this.autoClose === 'boolean') {
221
+ if (this.autoClose && this.timer) clearTimeout(this.timer)
222
+ if (this.closeDelay) {
223
+ this.timer = setTimeout(() => {
224
+ this.isActive = !this.autoClose
225
+ this.timer = null
226
+ }, this.closeDelay)
227
+ } else {
228
+ this.isActive = !this.autoClose
229
+ }
230
+ }
231
+ },
232
+ /**
233
+ * Close tooltip if clicked outside.
234
+ */
235
+ clickedOutside(event) {
236
+ if (this.isActive) {
237
+ if (Array.isArray(this.autoClose)) {
238
+ if (this.autoClose.includes('outside')) {
239
+ if (!this.isInWhiteList(event.target)) {
240
+ this.isActive = false
241
+ return
242
+ }
243
+ }
244
+ if (this.autoClose.includes('inside')) {
245
+ if (this.isInWhiteList(event.target)) this.isActive = false
246
+ }
247
+ }
248
+ }
249
+ },
250
+ /**
251
+ * Keypress event that is bound to the document
252
+ */
253
+ keyPress({ key }) {
254
+ if (this.isActive && (key === 'Escape' || key === 'Esc')) {
255
+ if (Array.isArray(this.autoClose)) {
256
+ if (this.autoClose.indexOf('escape') >= 0) this.isActive = false
257
+ }
258
+ }
259
+ },
260
+ /**
261
+ * White-listed items to not close when clicked.
262
+ */
263
+ isInWhiteList(el) {
264
+ if (el === this.$refs.content) return true
265
+ // All chidren from content
266
+ if (this.$refs.content !== undefined) {
267
+ const children = this.$refs.content.querySelectorAll('*')
268
+ for (const child of children) {
269
+ if (el === child) {
270
+ return true
271
+ }
272
+ }
273
+ }
274
+ return false
275
+ }
276
+ },
277
+ mounted() {
278
+ if (this.appendToBody && typeof window !== 'undefined') {
279
+ this.$data._bodyEl = createAbsoluteElement(this.$refs.content)
280
+ this.updateAppendToBody()
281
+ }
282
+ },
283
+ created() {
284
+ if (typeof window !== 'undefined') {
285
+ document.addEventListener('click', this.clickedOutside)
286
+ document.addEventListener('keyup', this.keyPress)
287
+ }
288
+ },
289
+ beforeDestroy() {
290
+ if (typeof window !== 'undefined') {
291
+ document.removeEventListener('click', this.clickedOutside)
292
+ document.removeEventListener('keyup', this.keyPress)
293
+ }
294
+ if (this.appendToBody) {
295
+ removeElement(this.$data._bodyEl)
296
+ }
297
+ }
298
+ }
299
+ </script>
@@ -133,3 +133,9 @@ $dropdown-disabled-opacity: 0.5 !default;
133
133
  }
134
134
  }
135
135
  }
136
+
137
+ html.is-clipped-touch {
138
+ @include touch {
139
+ overflow: hidden !important;
140
+ }
141
+ }
@@ -4,9 +4,3 @@
4
4
  width: 100%;
5
5
  bottom: 0;
6
6
  }
7
-
8
- html.is-clipped-touch {
9
- @include touch {
10
- overflow: hidden !important;
11
- }
12
- }
@@ -114,7 +114,6 @@ export default {
114
114
  onFocus($event) {
115
115
  this.isFocused = true
116
116
  this.$emit('focus', $event)
117
- this.checkHtml5Validity()
118
117
  },
119
118
 
120
119
  getElement() {
@@ -15,6 +15,7 @@ let config = {
15
15
  defaultNotificationPosition: null,
16
16
  defaultTooltipType: 'is-primary',
17
17
  defaultTooltipDelay: null,
18
+ defaultTooltipCloseDelay: null,
18
19
  defaultSidebarDelay: null,
19
20
  defaultInputAutocomplete: 'on',
20
21
  defaultDateFormatter: null,