buefy 0.9.12 → 0.9.13

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 (208) hide show
  1. package/dist/buefy.css +1 -1
  2. package/dist/buefy.esm.js +106 -104
  3. package/dist/buefy.esm.min.js +2 -2
  4. package/dist/buefy.js +106 -104
  5. package/dist/buefy.min.css +1 -1
  6. package/dist/buefy.min.js +2 -2
  7. package/dist/cjs/autocomplete.js +4 -4
  8. package/dist/cjs/button.js +2 -2
  9. package/dist/cjs/carousel.js +5 -5
  10. package/dist/cjs/{chunk-47e1b22b.js → chunk-114191ae.js} +2 -2
  11. package/dist/cjs/{chunk-db3fa73a.js → chunk-2062216d.js} +1 -1
  12. package/dist/cjs/{chunk-d9a33552.js → chunk-2911aa4b.js} +45 -45
  13. package/dist/cjs/{chunk-de7a7f98.js → chunk-2ae50815.js} +3 -3
  14. package/dist/cjs/{chunk-01268607.js → chunk-2c7de785.js} +0 -0
  15. package/dist/cjs/{chunk-30d55827.js → chunk-30670fac.js} +2 -2
  16. package/dist/cjs/{chunk-c3495010.js → chunk-34949503.js} +0 -0
  17. package/dist/cjs/{chunk-2dc027c9.js → chunk-3cc5d9a6.js} +0 -0
  18. package/dist/cjs/{chunk-a14ca5bf.js → chunk-61023b09.js} +1 -1
  19. package/dist/cjs/{chunk-c5a552d4.js → chunk-6cb902f8.js} +0 -0
  20. package/dist/cjs/{chunk-7b13241d.js → chunk-7da0c017.js} +4 -2
  21. package/dist/cjs/{chunk-bd1feb6c.js → chunk-9e4cf4c5.js} +0 -0
  22. package/dist/cjs/{chunk-ea7e1e7e.js → chunk-a11294f9.js} +1 -1
  23. package/dist/cjs/{chunk-3aaecc36.js → chunk-c6fbc7b4.js} +1 -1
  24. package/dist/cjs/{chunk-dcf024d2.js → chunk-c7b2aa4b.js} +0 -0
  25. package/dist/cjs/{chunk-40697b2f.js → chunk-d0f8ea39.js} +6 -6
  26. package/dist/cjs/{chunk-c00639be.js → chunk-d120e215.js} +0 -0
  27. package/dist/cjs/{chunk-cb3ee6f4.js → chunk-d54e40f6.js} +0 -0
  28. package/dist/cjs/{chunk-adaa5792.js → chunk-f5106717.js} +2 -2
  29. package/dist/cjs/{chunk-66710d19.js → chunk-fe2f57ee.js} +1 -1
  30. package/dist/cjs/{chunk-344f6275.js → chunk-fefd7b77.js} +0 -0
  31. package/dist/cjs/clockpicker.js +7 -7
  32. package/dist/cjs/datepicker.js +8 -8
  33. package/dist/cjs/datetimepicker.js +10 -10
  34. package/dist/cjs/dialog.js +10 -10
  35. package/dist/cjs/dropdown.js +2 -2
  36. package/dist/cjs/field.js +1 -1
  37. package/dist/cjs/helpers.js +50 -50
  38. package/dist/cjs/icon.js +1 -1
  39. package/dist/cjs/image.js +1 -1
  40. package/dist/cjs/index.js +21 -21
  41. package/dist/cjs/input.js +3 -3
  42. package/dist/cjs/loading.js +1 -1
  43. package/dist/cjs/menu.js +1 -1
  44. package/dist/cjs/message.js +2 -2
  45. package/dist/cjs/modal.js +1 -1
  46. package/dist/cjs/notification.js +3 -3
  47. package/dist/cjs/numberinput.js +6 -6
  48. package/dist/cjs/pagination.js +2 -2
  49. package/dist/cjs/progress.js +1 -1
  50. package/dist/cjs/rate.js +1 -1
  51. package/dist/cjs/select.js +3 -3
  52. package/dist/cjs/slider.js +1 -1
  53. package/dist/cjs/snackbar.js +1 -1
  54. package/dist/cjs/steps.js +4 -4
  55. package/dist/cjs/table.js +7 -7
  56. package/dist/cjs/tabs.js +4 -4
  57. package/dist/cjs/taginput.js +4 -4
  58. package/dist/cjs/timepicker.js +9 -9
  59. package/dist/cjs/toast.js +1 -1
  60. package/dist/cjs/tooltip.js +1 -1
  61. package/dist/cjs/upload.js +1 -1
  62. package/dist/components/autocomplete/index.js +5 -5
  63. package/dist/components/autocomplete/index.min.js +1 -1
  64. package/dist/components/breadcrumb/index.js +1 -1
  65. package/dist/components/breadcrumb/index.min.js +1 -1
  66. package/dist/components/button/index.js +3 -3
  67. package/dist/components/button/index.min.js +1 -1
  68. package/dist/components/carousel/index.js +26 -26
  69. package/dist/components/carousel/index.min.js +1 -1
  70. package/dist/components/checkbox/index.js +1 -1
  71. package/dist/components/checkbox/index.min.js +1 -1
  72. package/dist/components/clockpicker/index.js +22 -20
  73. package/dist/components/clockpicker/index.min.js +2 -2
  74. package/dist/components/collapse/index.js +1 -1
  75. package/dist/components/collapse/index.min.js +1 -1
  76. package/dist/components/datepicker/index.js +71 -69
  77. package/dist/components/datepicker/index.min.js +2 -2
  78. package/dist/components/datetimepicker/index.js +71 -69
  79. package/dist/components/datetimepicker/index.min.js +2 -2
  80. package/dist/components/dialog/index.js +10 -10
  81. package/dist/components/dialog/index.min.js +1 -1
  82. package/dist/components/dropdown/index.js +6 -6
  83. package/dist/components/dropdown/index.min.js +1 -1
  84. package/dist/components/field/index.js +5 -3
  85. package/dist/components/field/index.min.js +2 -2
  86. package/dist/components/icon/index.js +3 -3
  87. package/dist/components/icon/index.min.js +1 -1
  88. package/dist/components/image/index.js +4 -4
  89. package/dist/components/image/index.min.js +1 -1
  90. package/dist/components/input/index.js +3 -3
  91. package/dist/components/input/index.min.js +1 -1
  92. package/dist/components/loading/index.js +3 -3
  93. package/dist/components/loading/index.min.js +1 -1
  94. package/dist/components/menu/index.js +3 -3
  95. package/dist/components/menu/index.min.js +1 -1
  96. package/dist/components/message/index.js +3 -3
  97. package/dist/components/message/index.min.js +1 -1
  98. package/dist/components/modal/index.js +3 -3
  99. package/dist/components/modal/index.min.js +1 -1
  100. package/dist/components/navbar/index.js +1 -1
  101. package/dist/components/navbar/index.min.js +1 -1
  102. package/dist/components/notification/index.js +3 -3
  103. package/dist/components/notification/index.min.js +1 -1
  104. package/dist/components/numberinput/index.js +6 -6
  105. package/dist/components/numberinput/index.min.js +1 -1
  106. package/dist/components/pagination/index.js +3 -3
  107. package/dist/components/pagination/index.min.js +1 -1
  108. package/dist/components/progress/index.js +6 -6
  109. package/dist/components/progress/index.min.js +1 -1
  110. package/dist/components/radio/index.js +1 -1
  111. package/dist/components/radio/index.min.js +1 -1
  112. package/dist/components/rate/index.js +3 -3
  113. package/dist/components/rate/index.min.js +1 -1
  114. package/dist/components/select/index.js +3 -3
  115. package/dist/components/select/index.min.js +1 -1
  116. package/dist/components/sidebar/index.js +1 -1
  117. package/dist/components/sidebar/index.min.js +1 -1
  118. package/dist/components/skeleton/index.js +1 -1
  119. package/dist/components/skeleton/index.min.js +1 -1
  120. package/dist/components/slider/index.js +7 -7
  121. package/dist/components/slider/index.min.js +1 -1
  122. package/dist/components/snackbar/index.js +3 -3
  123. package/dist/components/snackbar/index.min.js +1 -1
  124. package/dist/components/steps/index.js +14 -14
  125. package/dist/components/steps/index.min.js +1 -1
  126. package/dist/components/switch/index.js +1 -1
  127. package/dist/components/switch/index.min.js +1 -1
  128. package/dist/components/table/index.js +10 -10
  129. package/dist/components/table/index.min.js +1 -1
  130. package/dist/components/tabs/index.js +14 -14
  131. package/dist/components/tabs/index.min.js +1 -1
  132. package/dist/components/tag/index.js +1 -1
  133. package/dist/components/tag/index.min.js +1 -1
  134. package/dist/components/taginput/index.js +5 -5
  135. package/dist/components/taginput/index.min.js +1 -1
  136. package/dist/components/timepicker/index.js +22 -20
  137. package/dist/components/timepicker/index.min.js +2 -2
  138. package/dist/components/toast/index.js +3 -3
  139. package/dist/components/toast/index.min.js +1 -1
  140. package/dist/components/tooltip/index.js +1 -1
  141. package/dist/components/tooltip/index.min.js +1 -1
  142. package/dist/components/upload/index.js +1 -1
  143. package/dist/components/upload/index.min.js +1 -1
  144. package/dist/esm/autocomplete.js +5 -5
  145. package/dist/esm/button.js +3 -3
  146. package/dist/esm/carousel.js +5 -5
  147. package/dist/esm/{chunk-3dbb54cd.js → chunk-18e8b067.js} +1 -1
  148. package/dist/esm/{chunk-7d9db167.js → chunk-21fc0948.js} +6 -6
  149. package/dist/esm/{chunk-a146937d.js → chunk-22e9f916.js} +45 -45
  150. package/dist/esm/{chunk-18fcd4ac.js → chunk-29ca0df8.js} +0 -0
  151. package/dist/esm/{chunk-affd6df1.js → chunk-3773c62d.js} +0 -0
  152. package/dist/esm/{chunk-7ee6c15c.js → chunk-4b67a181.js} +1 -1
  153. package/dist/esm/{chunk-f97f6a90.js → chunk-6019fd7a.js} +2 -2
  154. package/dist/esm/{chunk-d9794c38.js → chunk-71a547bc.js} +0 -0
  155. package/dist/esm/{chunk-161dac72.js → chunk-75a5af93.js} +0 -0
  156. package/dist/esm/{chunk-4f046bae.js → chunk-799e084d.js} +0 -0
  157. package/dist/esm/{chunk-6b53dd42.js → chunk-83eb0d37.js} +2 -2
  158. package/dist/esm/{chunk-80ec133b.js → chunk-8d0f95b8.js} +3 -3
  159. package/dist/esm/{chunk-50188ced.js → chunk-9f7f7441.js} +0 -0
  160. package/dist/esm/{chunk-3098b0e9.js → chunk-ae8ab23a.js} +2 -2
  161. package/dist/esm/{chunk-0f30042f.js → chunk-b07e3182.js} +4 -2
  162. package/dist/esm/{chunk-a64bdef6.js → chunk-b0c0c6b0.js} +0 -0
  163. package/dist/esm/{chunk-cdfb7fda.js → chunk-c9c58d0c.js} +0 -0
  164. package/dist/esm/{chunk-f6b30428.js → chunk-d7f92d97.js} +1 -1
  165. package/dist/esm/{chunk-9957ac1a.js → chunk-d92f0cd9.js} +0 -0
  166. package/dist/esm/{chunk-72ad8d50.js → chunk-e7c9b2cb.js} +1 -1
  167. package/dist/esm/{chunk-8b279c1f.js → chunk-ece062a7.js} +1 -1
  168. package/dist/esm/clockpicker.js +7 -7
  169. package/dist/esm/datepicker.js +9 -9
  170. package/dist/esm/datetimepicker.js +10 -10
  171. package/dist/esm/dialog.js +10 -10
  172. package/dist/esm/dropdown.js +3 -3
  173. package/dist/esm/field.js +2 -2
  174. package/dist/esm/helpers.js +50 -50
  175. package/dist/esm/icon.js +2 -2
  176. package/dist/esm/image.js +2 -2
  177. package/dist/esm/index.js +21 -21
  178. package/dist/esm/input.js +4 -4
  179. package/dist/esm/loading.js +2 -2
  180. package/dist/esm/menu.js +1 -1
  181. package/dist/esm/message.js +2 -2
  182. package/dist/esm/modal.js +2 -2
  183. package/dist/esm/notification.js +3 -3
  184. package/dist/esm/numberinput.js +6 -6
  185. package/dist/esm/pagination.js +3 -3
  186. package/dist/esm/progress.js +1 -1
  187. package/dist/esm/rate.js +1 -1
  188. package/dist/esm/select.js +4 -4
  189. package/dist/esm/slider.js +1 -1
  190. package/dist/esm/snackbar.js +1 -1
  191. package/dist/esm/steps.js +4 -4
  192. package/dist/esm/table.js +7 -7
  193. package/dist/esm/tabs.js +4 -4
  194. package/dist/esm/taginput.js +4 -4
  195. package/dist/esm/timepicker.js +10 -10
  196. package/dist/esm/toast.js +1 -1
  197. package/dist/esm/tooltip.js +2 -2
  198. package/dist/esm/upload.js +1 -1
  199. package/package.json +171 -171
  200. package/src/components/breadcrumb/BreadcrumbItem.spec.js +25 -25
  201. package/src/components/carousel/CarouselList.vue +313 -313
  202. package/src/components/carousel/__snapshots__/CarouselList.spec.js.snap +156 -156
  203. package/src/components/datepicker/Datepicker.vue +843 -843
  204. package/src/components/dialog/Dialog.vue +256 -256
  205. package/src/components/field/Field.vue +3 -3
  206. package/src/components/image/Image.vue +309 -309
  207. package/src/components/numberinput/Numberinput.vue +309 -309
  208. package/src/utils/helpers.js +291 -291
@@ -1,291 +1,291 @@
1
- /**
2
- * +/- function to native math sign
3
- */
4
- function signPoly(value) {
5
- if (value < 0) return -1
6
- return value > 0 ? 1 : 0
7
- }
8
- export const sign = Math.sign || signPoly
9
-
10
- /**
11
- * Checks if the flag is set
12
- * @param val
13
- * @param flag
14
- * @returns {boolean}
15
- */
16
- function hasFlag(val, flag) {
17
- return (val & flag) === flag
18
- }
19
-
20
- /**
21
- * Native modulo bug with negative numbers
22
- * @param n
23
- * @param mod
24
- * @returns {number}
25
- */
26
- function mod(n, mod) {
27
- return ((n % mod) + mod) % mod
28
- }
29
-
30
- /**
31
- * Asserts a value is beetween min and max
32
- * @param val
33
- * @param min
34
- * @param max
35
- * @returns {number}
36
- */
37
- function bound(val, min, max) {
38
- return Math.max(min, Math.min(max, val))
39
- }
40
-
41
- export {mod, bound, hasFlag}
42
-
43
- /**
44
- * Get value of an object property/path even if it's nested
45
- */
46
- export function getValueByPath(obj, path) {
47
- return path.split('.').reduce((o, i) => o ? o[i] : null, obj)
48
- }
49
-
50
- /**
51
- * Extension of indexOf method by equality function if specified
52
- */
53
- export function indexOf(array, obj, fn) {
54
- if (!array) return -1
55
-
56
- if (!fn || typeof fn !== 'function') return array.indexOf(obj)
57
-
58
- for (let i = 0; i < array.length; i++) {
59
- if (fn(array[i], obj)) {
60
- return i
61
- }
62
- }
63
-
64
- return -1
65
- }
66
-
67
- /**
68
- * Merge function to replace Object.assign with deep merging possibility
69
- */
70
- const isObject = (item) => typeof item === 'object' && !Array.isArray(item)
71
- const mergeFn = (target, source, deep = false) => {
72
- if (deep || !Object.assign) {
73
- const isDeep = (prop) =>
74
- isObject(source[prop]) &&
75
- target !== null &&
76
- target.hasOwnProperty(prop) &&
77
- isObject(target[prop])
78
- const replaced = Object.getOwnPropertyNames(source)
79
- .map((prop) => ({ [prop]: isDeep(prop)
80
- ? mergeFn(target[prop], source[prop], deep)
81
- : source[prop] }))
82
- .reduce((a, b) => ({ ...a, ...b }), {})
83
-
84
- return {
85
- ...target,
86
- ...replaced
87
- }
88
- } else {
89
- return Object.assign(target, source)
90
- }
91
- }
92
- export const merge = mergeFn
93
-
94
- /**
95
- * Mobile detection
96
- * https://www.abeautifulsite.net/detecting-mobile-devices-with-javascript
97
- */
98
- export const isMobile = {
99
- Android: function () {
100
- return (
101
- typeof window !== 'undefined' &&
102
- window.navigator.userAgent.match(/Android/i)
103
- )
104
- },
105
- BlackBerry: function () {
106
- return (
107
- typeof window !== 'undefined' &&
108
- window.navigator.userAgent.match(/BlackBerry/i)
109
- )
110
- },
111
- iOS: function () {
112
- return (
113
- typeof window !== 'undefined' &&
114
- (window.navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
115
- (window.navigator.platform === 'MacIntel' &&
116
- window.navigator.maxTouchPoints > 1))
117
- )
118
- },
119
- Opera: function () {
120
- return (
121
- typeof window !== 'undefined' &&
122
- window.navigator.userAgent.match(/Opera Mini/i)
123
- )
124
- },
125
- Windows: function () {
126
- return (
127
- typeof window !== 'undefined' &&
128
- window.navigator.userAgent.match(/IEMobile/i)
129
- )
130
- },
131
- any: function () {
132
- return (
133
- isMobile.Android() ||
134
- isMobile.BlackBerry() ||
135
- isMobile.iOS() ||
136
- isMobile.Opera() ||
137
- isMobile.Windows()
138
- )
139
- }
140
- }
141
-
142
- export function removeElement(el) {
143
- if (typeof el.remove !== 'undefined') {
144
- el.remove()
145
- } else if (typeof el.parentNode !== 'undefined' && el.parentNode !== null) {
146
- el.parentNode.removeChild(el)
147
- }
148
- }
149
-
150
- export function createAbsoluteElement(el) {
151
- const root = document.createElement('div')
152
- root.style.position = 'absolute'
153
- root.style.left = '0px'
154
- root.style.top = '0px'
155
- root.style.width = '100%'
156
- const wrapper = document.createElement('div')
157
- root.appendChild(wrapper)
158
- wrapper.appendChild(el)
159
- document.body.appendChild(root)
160
- return root
161
- }
162
-
163
- export function isVueComponent(c) {
164
- return c && c._isVue
165
- }
166
-
167
- /**
168
- * Escape regex characters
169
- * http://stackoverflow.com/a/6969486
170
- */
171
- export function escapeRegExpChars(value) {
172
- if (!value) return value
173
-
174
- // eslint-disable-next-line
175
- return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')
176
- }
177
-
178
- export function multiColumnSort(inputArray, sortingPriority) {
179
- // clone it to prevent the any watchers from triggering every sorting iteration
180
- let array = JSON.parse(JSON.stringify(inputArray))
181
- const fieldSorter = (fields) => (a, b) => fields.map((o) => {
182
- let dir = 1
183
- if (o[0] === '-') { dir = -1; o = o.substring(1) }
184
- const aValue = getValueByPath(a, o)
185
- const bValue = getValueByPath(b, o)
186
- return aValue > bValue ? dir : aValue < bValue ? -(dir) : 0
187
- }).reduce((p, n) => p || n, 0)
188
-
189
- return array.sort(fieldSorter(sortingPriority))
190
- }
191
-
192
- export function createNewEvent(eventName) {
193
- var event
194
- if (typeof Event === 'function') {
195
- event = new Event(eventName)
196
- } else {
197
- event = document.createEvent('Event')
198
- event.initEvent(eventName, true, true)
199
- }
200
- return event
201
- }
202
-
203
- export function toCssWidth(width) {
204
- return width === undefined ? null : (isNaN(width) ? width : width + 'px')
205
- }
206
-
207
- /**
208
- * Return month names according to a specified locale
209
- * @param {String} locale A bcp47 localerouter. undefined will use the user browser locale
210
- * @param {String} format long (ex. March), short (ex. Mar) or narrow (M)
211
- * @return {Array<String>} An array of month names
212
- */
213
- export function getMonthNames(locale = undefined, format = 'long') {
214
- const dates = []
215
- for (let i = 0; i < 12; i++) {
216
- dates.push(new Date(2000, i, 15))
217
- }
218
- const dtf = new Intl.DateTimeFormat(locale, {
219
- month: format
220
- })
221
- return dates.map((d) => dtf.format(d))
222
- }
223
-
224
- /**
225
- * Return weekday names according to a specified locale
226
- * @param {String} locale A bcp47 localerouter. undefined will use the user browser locale
227
- * @param {String} format long (ex. Thursday), short (ex. Thu) or narrow (T)
228
- * @return {Array<String>} An array of weekday names
229
- */
230
- export function getWeekdayNames(locale = undefined, format = 'narrow') {
231
- const dates = []
232
- for (let i = 0; i < 7; i++) {
233
- const dt = new Date(2000, 0, i + 1)
234
- dates[dt.getDay()] = dt
235
- }
236
- const dtf = new Intl.DateTimeFormat(locale, { weekday: format })
237
- return dates.map((d) => dtf.format(d))
238
- }
239
-
240
- /**
241
- * Accept a regex with group names and return an object
242
- * ex. matchWithGroups(/((?!=<year>)\d+)\/((?!=<month>)\d+)\/((?!=<day>)\d+)/, '2000/12/25')
243
- * will return { year: 2000, month: 12, day: 25 }
244
- * @param {String} includes injections of (?!={groupname}) for each group
245
- * @param {String} the string to run regex
246
- * @return {Object} an object with a property for each group having the group's match as the value
247
- */
248
- export function matchWithGroups(pattern, str) {
249
- const matches = str.match(pattern)
250
- return pattern
251
- // get the pattern as a string
252
- .toString()
253
- // suss out the groups
254
- .match(/<(.+?)>/g)
255
- // remove the braces
256
- .map((group) => {
257
- const groupMatches = group.match(/<(.+)>/)
258
- if (!groupMatches || groupMatches.length <= 0) {
259
- return null
260
- }
261
- return group.match(/<(.+)>/)[1]
262
- })
263
- // create an object with a property for each group having the group's match as the value
264
- .reduce((acc, curr, index, arr) => {
265
- if (matches && matches.length > index) {
266
- acc[curr] = matches[index + 1]
267
- } else {
268
- acc[curr] = null
269
- }
270
- return acc
271
- }, {})
272
- }
273
-
274
- /**
275
- * Based on
276
- * https://github.com/fregante/supports-webp
277
- */
278
- export function isWebpSupported() {
279
- return new Promise((resolve) => {
280
- const image = new Image()
281
- image.onerror = () => resolve(false)
282
- image.onload = () => resolve(image.width === 1)
283
- image.src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA='
284
- }).catch(() => false)
285
- }
286
-
287
- export function isCustomElement(vm) {
288
- return 'shadowRoot' in vm.$root.$options
289
- }
290
-
291
- export const isDefined = (d) => d !== undefined
1
+ /**
2
+ * +/- function to native math sign
3
+ */
4
+ function signPoly(value) {
5
+ if (value < 0) return -1
6
+ return value > 0 ? 1 : 0
7
+ }
8
+ export const sign = Math.sign || signPoly
9
+
10
+ /**
11
+ * Checks if the flag is set
12
+ * @param val
13
+ * @param flag
14
+ * @returns {boolean}
15
+ */
16
+ function hasFlag(val, flag) {
17
+ return (val & flag) === flag
18
+ }
19
+
20
+ /**
21
+ * Native modulo bug with negative numbers
22
+ * @param n
23
+ * @param mod
24
+ * @returns {number}
25
+ */
26
+ function mod(n, mod) {
27
+ return ((n % mod) + mod) % mod
28
+ }
29
+
30
+ /**
31
+ * Asserts a value is beetween min and max
32
+ * @param val
33
+ * @param min
34
+ * @param max
35
+ * @returns {number}
36
+ */
37
+ function bound(val, min, max) {
38
+ return Math.max(min, Math.min(max, val))
39
+ }
40
+
41
+ export {mod, bound, hasFlag}
42
+
43
+ /**
44
+ * Get value of an object property/path even if it's nested
45
+ */
46
+ export function getValueByPath(obj, path) {
47
+ return path.split('.').reduce((o, i) => o ? o[i] : null, obj)
48
+ }
49
+
50
+ /**
51
+ * Extension of indexOf method by equality function if specified
52
+ */
53
+ export function indexOf(array, obj, fn) {
54
+ if (!array) return -1
55
+
56
+ if (!fn || typeof fn !== 'function') return array.indexOf(obj)
57
+
58
+ for (let i = 0; i < array.length; i++) {
59
+ if (fn(array[i], obj)) {
60
+ return i
61
+ }
62
+ }
63
+
64
+ return -1
65
+ }
66
+
67
+ /**
68
+ * Merge function to replace Object.assign with deep merging possibility
69
+ */
70
+ const isObject = (item) => typeof item === 'object' && !Array.isArray(item)
71
+ const mergeFn = (target, source, deep = false) => {
72
+ if (deep || !Object.assign) {
73
+ const isDeep = (prop) =>
74
+ isObject(source[prop]) &&
75
+ target !== null &&
76
+ target.hasOwnProperty(prop) &&
77
+ isObject(target[prop])
78
+ const replaced = Object.getOwnPropertyNames(source)
79
+ .map((prop) => ({ [prop]: isDeep(prop)
80
+ ? mergeFn(target[prop], source[prop], deep)
81
+ : source[prop] }))
82
+ .reduce((a, b) => ({ ...a, ...b }), {})
83
+
84
+ return {
85
+ ...target,
86
+ ...replaced
87
+ }
88
+ } else {
89
+ return Object.assign(target, source)
90
+ }
91
+ }
92
+ export const merge = mergeFn
93
+
94
+ /**
95
+ * Mobile detection
96
+ * https://www.abeautifulsite.net/detecting-mobile-devices-with-javascript
97
+ */
98
+ export const isMobile = {
99
+ Android: function () {
100
+ return (
101
+ typeof window !== 'undefined' &&
102
+ window.navigator.userAgent.match(/Android/i)
103
+ )
104
+ },
105
+ BlackBerry: function () {
106
+ return (
107
+ typeof window !== 'undefined' &&
108
+ window.navigator.userAgent.match(/BlackBerry/i)
109
+ )
110
+ },
111
+ iOS: function () {
112
+ return (
113
+ typeof window !== 'undefined' &&
114
+ (window.navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
115
+ (window.navigator.platform === 'MacIntel' &&
116
+ window.navigator.maxTouchPoints > 1))
117
+ )
118
+ },
119
+ Opera: function () {
120
+ return (
121
+ typeof window !== 'undefined' &&
122
+ window.navigator.userAgent.match(/Opera Mini/i)
123
+ )
124
+ },
125
+ Windows: function () {
126
+ return (
127
+ typeof window !== 'undefined' &&
128
+ window.navigator.userAgent.match(/IEMobile/i)
129
+ )
130
+ },
131
+ any: function () {
132
+ return (
133
+ isMobile.Android() ||
134
+ isMobile.BlackBerry() ||
135
+ isMobile.iOS() ||
136
+ isMobile.Opera() ||
137
+ isMobile.Windows()
138
+ )
139
+ }
140
+ }
141
+
142
+ export function removeElement(el) {
143
+ if (typeof el.remove !== 'undefined') {
144
+ el.remove()
145
+ } else if (typeof el.parentNode !== 'undefined' && el.parentNode !== null) {
146
+ el.parentNode.removeChild(el)
147
+ }
148
+ }
149
+
150
+ export function createAbsoluteElement(el) {
151
+ const root = document.createElement('div')
152
+ root.style.position = 'absolute'
153
+ root.style.left = '0px'
154
+ root.style.top = '0px'
155
+ root.style.width = '100%'
156
+ const wrapper = document.createElement('div')
157
+ root.appendChild(wrapper)
158
+ wrapper.appendChild(el)
159
+ document.body.appendChild(root)
160
+ return root
161
+ }
162
+
163
+ export function isVueComponent(c) {
164
+ return c && c._isVue
165
+ }
166
+
167
+ /**
168
+ * Escape regex characters
169
+ * http://stackoverflow.com/a/6969486
170
+ */
171
+ export function escapeRegExpChars(value) {
172
+ if (!value) return value
173
+
174
+ // eslint-disable-next-line
175
+ return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')
176
+ }
177
+
178
+ export function multiColumnSort(inputArray, sortingPriority) {
179
+ // clone it to prevent the any watchers from triggering every sorting iteration
180
+ let array = JSON.parse(JSON.stringify(inputArray))
181
+ const fieldSorter = (fields) => (a, b) => fields.map((o) => {
182
+ let dir = 1
183
+ if (o[0] === '-') { dir = -1; o = o.substring(1) }
184
+ const aValue = getValueByPath(a, o)
185
+ const bValue = getValueByPath(b, o)
186
+ return aValue > bValue ? dir : aValue < bValue ? -(dir) : 0
187
+ }).reduce((p, n) => p || n, 0)
188
+
189
+ return array.sort(fieldSorter(sortingPriority))
190
+ }
191
+
192
+ export function createNewEvent(eventName) {
193
+ var event
194
+ if (typeof Event === 'function') {
195
+ event = new Event(eventName)
196
+ } else {
197
+ event = document.createEvent('Event')
198
+ event.initEvent(eventName, true, true)
199
+ }
200
+ return event
201
+ }
202
+
203
+ export function toCssWidth(width) {
204
+ return width === undefined ? null : (isNaN(width) ? width : width + 'px')
205
+ }
206
+
207
+ /**
208
+ * Return month names according to a specified locale
209
+ * @param {String} locale A bcp47 localerouter. undefined will use the user browser locale
210
+ * @param {String} format long (ex. March), short (ex. Mar) or narrow (M)
211
+ * @return {Array<String>} An array of month names
212
+ */
213
+ export function getMonthNames(locale = undefined, format = 'long') {
214
+ const dates = []
215
+ for (let i = 0; i < 12; i++) {
216
+ dates.push(new Date(2000, i, 15))
217
+ }
218
+ const dtf = new Intl.DateTimeFormat(locale, {
219
+ month: format
220
+ })
221
+ return dates.map((d) => dtf.format(d))
222
+ }
223
+
224
+ /**
225
+ * Return weekday names according to a specified locale
226
+ * @param {String} locale A bcp47 localerouter. undefined will use the user browser locale
227
+ * @param {String} format long (ex. Thursday), short (ex. Thu) or narrow (T)
228
+ * @return {Array<String>} An array of weekday names
229
+ */
230
+ export function getWeekdayNames(locale = undefined, format = 'narrow') {
231
+ const dates = []
232
+ for (let i = 0; i < 7; i++) {
233
+ const dt = new Date(2000, 0, i + 1)
234
+ dates[dt.getDay()] = dt
235
+ }
236
+ const dtf = new Intl.DateTimeFormat(locale, { weekday: format })
237
+ return dates.map((d) => dtf.format(d))
238
+ }
239
+
240
+ /**
241
+ * Accept a regex with group names and return an object
242
+ * ex. matchWithGroups(/((?!=<year>)\d+)\/((?!=<month>)\d+)\/((?!=<day>)\d+)/, '2000/12/25')
243
+ * will return { year: 2000, month: 12, day: 25 }
244
+ * @param {String} includes injections of (?!={groupname}) for each group
245
+ * @param {String} the string to run regex
246
+ * @return {Object} an object with a property for each group having the group's match as the value
247
+ */
248
+ export function matchWithGroups(pattern, str) {
249
+ const matches = str.match(pattern)
250
+ return pattern
251
+ // get the pattern as a string
252
+ .toString()
253
+ // suss out the groups
254
+ .match(/<(.+?)>/g)
255
+ // remove the braces
256
+ .map((group) => {
257
+ const groupMatches = group.match(/<(.+)>/)
258
+ if (!groupMatches || groupMatches.length <= 0) {
259
+ return null
260
+ }
261
+ return group.match(/<(.+)>/)[1]
262
+ })
263
+ // create an object with a property for each group having the group's match as the value
264
+ .reduce((acc, curr, index, arr) => {
265
+ if (matches && matches.length > index) {
266
+ acc[curr] = matches[index + 1]
267
+ } else {
268
+ acc[curr] = null
269
+ }
270
+ return acc
271
+ }, {})
272
+ }
273
+
274
+ /**
275
+ * Based on
276
+ * https://github.com/fregante/supports-webp
277
+ */
278
+ export function isWebpSupported() {
279
+ return new Promise((resolve) => {
280
+ const image = new Image()
281
+ image.onerror = () => resolve(false)
282
+ image.onload = () => resolve(image.width === 1)
283
+ image.src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA='
284
+ }).catch(() => false)
285
+ }
286
+
287
+ export function isCustomElement(vm) {
288
+ return 'shadowRoot' in vm.$root.$options
289
+ }
290
+
291
+ export const isDefined = (d) => d !== undefined