@gitlab/ui 94.2.0 → 94.3.0

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 (149) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/experimental/duo/chat/duo_chat.js +1 -2
  3. package/dist/vendor/bootstrap-vue/src/components/badge/index.js +0 -10
  4. package/dist/vendor/bootstrap-vue/src/components/breadcrumb/index.js +0 -14
  5. package/dist/vendor/bootstrap-vue/src/components/button/index.js +0 -14
  6. package/dist/vendor/bootstrap-vue/src/components/button-group/index.js +0 -11
  7. package/dist/vendor/bootstrap-vue/src/components/collapse/index.js +0 -14
  8. package/dist/vendor/bootstrap-vue/src/components/dropdown/index.js +0 -34
  9. package/dist/vendor/bootstrap-vue/src/components/form/index.js +0 -20
  10. package/dist/vendor/bootstrap-vue/src/components/form-checkbox/index.js +0 -16
  11. package/dist/vendor/bootstrap-vue/src/components/form-group/index.js +0 -11
  12. package/dist/vendor/bootstrap-vue/src/components/form-input/index.js +0 -11
  13. package/dist/vendor/bootstrap-vue/src/components/form-radio/index.js +0 -14
  14. package/dist/vendor/bootstrap-vue/src/components/form-select/index.js +0 -17
  15. package/dist/vendor/bootstrap-vue/src/components/form-textarea/index.js +0 -11
  16. package/dist/vendor/bootstrap-vue/src/components/index.js +1 -49
  17. package/dist/vendor/bootstrap-vue/src/components/input-group/index.js +0 -18
  18. package/dist/vendor/bootstrap-vue/src/components/layout/index.js +0 -12
  19. package/dist/vendor/bootstrap-vue/src/components/link/index.js +0 -10
  20. package/dist/vendor/bootstrap-vue/src/components/modal/index.js +0 -19
  21. package/dist/vendor/bootstrap-vue/src/components/nav/index.js +0 -21
  22. package/dist/vendor/bootstrap-vue/src/components/navbar/index.js +0 -20
  23. package/dist/vendor/bootstrap-vue/src/components/popover/index.js +0 -14
  24. package/dist/vendor/bootstrap-vue/src/components/progress/index.js +0 -12
  25. package/dist/vendor/bootstrap-vue/src/components/table/index.js +0 -38
  26. package/dist/vendor/bootstrap-vue/src/components/tabs/index.js +0 -12
  27. package/dist/vendor/bootstrap-vue/src/components/tooltip/helpers/bv-tooltip.js +1 -1
  28. package/dist/vendor/bootstrap-vue/src/components/tooltip/index.js +0 -14
  29. package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -2
  30. package/dist/vendor/bootstrap-vue/src/constants/env.js +1 -2
  31. package/dist/vendor/bootstrap-vue/src/constants/regex.js +1 -3
  32. package/dist/vendor/bootstrap-vue/src/directives/modal/index.js +0 -10
  33. package/dist/vendor/bootstrap-vue/src/directives/toggle/index.js +0 -10
  34. package/dist/vendor/bootstrap-vue/src/directives/tooltip/index.js +0 -10
  35. package/dist/vendor/bootstrap-vue/src/directives/visible/index.js +0 -10
  36. package/dist/vendor/bootstrap-vue/src/index.js +1 -38
  37. package/dist/vendor/bootstrap-vue/src/utils/object.js +1 -3
  38. package/dist/vendor/bootstrap-vue/src/utils/warn.js +2 -17
  39. package/package.json +1 -1
  40. package/src/components/experimental/duo/chat/duo_chat.vue +0 -10
  41. package/src/vendor/bootstrap-vue/src/components/badge/index.d.ts +1 -5
  42. package/src/vendor/bootstrap-vue/src/components/badge/index.js +1 -6
  43. package/src/vendor/bootstrap-vue/src/components/breadcrumb/index.d.ts +1 -5
  44. package/src/vendor/bootstrap-vue/src/components/breadcrumb/index.js +1 -6
  45. package/src/vendor/bootstrap-vue/src/components/button/index.d.ts +1 -5
  46. package/src/vendor/bootstrap-vue/src/components/button/index.js +1 -11
  47. package/src/vendor/bootstrap-vue/src/components/button-group/index.d.ts +1 -5
  48. package/src/vendor/bootstrap-vue/src/components/button-group/index.js +1 -9
  49. package/src/vendor/bootstrap-vue/src/components/collapse/index.d.ts +1 -5
  50. package/src/vendor/bootstrap-vue/src/components/collapse/index.js +1 -8
  51. package/src/vendor/bootstrap-vue/src/components/dropdown/index.d.ts +1 -5
  52. package/src/vendor/bootstrap-vue/src/components/dropdown/index.js +0 -25
  53. package/src/vendor/bootstrap-vue/src/components/form/index.d.ts +1 -5
  54. package/src/vendor/bootstrap-vue/src/components/form/index.js +1 -15
  55. package/src/vendor/bootstrap-vue/src/components/form-checkbox/index.d.ts +1 -5
  56. package/src/vendor/bootstrap-vue/src/components/form-checkbox/index.js +1 -13
  57. package/src/vendor/bootstrap-vue/src/components/form-group/index.d.ts +1 -5
  58. package/src/vendor/bootstrap-vue/src/components/form-group/index.js +1 -9
  59. package/src/vendor/bootstrap-vue/src/components/form-input/index.d.ts +1 -5
  60. package/src/vendor/bootstrap-vue/src/components/form-input/index.js +1 -9
  61. package/src/vendor/bootstrap-vue/src/components/form-radio/index.d.ts +1 -5
  62. package/src/vendor/bootstrap-vue/src/components/form-radio/index.js +1 -11
  63. package/src/vendor/bootstrap-vue/src/components/form-select/index.d.ts +1 -5
  64. package/src/vendor/bootstrap-vue/src/components/form-select/index.js +1 -13
  65. package/src/vendor/bootstrap-vue/src/components/form-textarea/index.d.ts +1 -5
  66. package/src/vendor/bootstrap-vue/src/components/form-textarea/index.js +1 -9
  67. package/src/vendor/bootstrap-vue/src/components/index.js +1 -50
  68. package/src/vendor/bootstrap-vue/src/components/input-group/index.d.ts +1 -5
  69. package/src/vendor/bootstrap-vue/src/components/input-group/index.js +1 -19
  70. package/src/vendor/bootstrap-vue/src/components/layout/index.d.ts +1 -5
  71. package/src/vendor/bootstrap-vue/src/components/layout/index.js +1 -9
  72. package/src/vendor/bootstrap-vue/src/components/link/index.d.ts +1 -5
  73. package/src/vendor/bootstrap-vue/src/components/link/index.js +1 -6
  74. package/src/vendor/bootstrap-vue/src/components/modal/README.md +0 -8
  75. package/src/vendor/bootstrap-vue/src/components/modal/index.d.ts +2 -5
  76. package/src/vendor/bootstrap-vue/src/components/modal/index.js +1 -11
  77. package/src/vendor/bootstrap-vue/src/components/modal/package.json +0 -3
  78. package/src/vendor/bootstrap-vue/src/components/nav/index.d.ts +1 -5
  79. package/src/vendor/bootstrap-vue/src/components/nav/index.js +1 -17
  80. package/src/vendor/bootstrap-vue/src/components/nav/package.json +0 -3
  81. package/src/vendor/bootstrap-vue/src/components/navbar/index.d.ts +1 -4
  82. package/src/vendor/bootstrap-vue/src/components/navbar/index.js +1 -17
  83. package/src/vendor/bootstrap-vue/src/components/navbar/package.json +0 -5
  84. package/src/vendor/bootstrap-vue/src/components/popover/README.md +1 -46
  85. package/src/vendor/bootstrap-vue/src/components/popover/index.d.ts +1 -5
  86. package/src/vendor/bootstrap-vue/src/components/popover/index.js +1 -8
  87. package/src/vendor/bootstrap-vue/src/components/popover/package.json +1 -4
  88. package/src/vendor/bootstrap-vue/src/components/progress/index.d.ts +1 -5
  89. package/src/vendor/bootstrap-vue/src/components/progress/index.js +1 -9
  90. package/src/vendor/bootstrap-vue/src/components/table/README.md +3 -15
  91. package/src/vendor/bootstrap-vue/src/components/table/index.d.ts +1 -7
  92. package/src/vendor/bootstrap-vue/src/components/table/index.js +0 -33
  93. package/src/vendor/bootstrap-vue/src/components/table/package.json +0 -4
  94. package/src/vendor/bootstrap-vue/src/components/tabs/index.d.ts +1 -5
  95. package/src/vendor/bootstrap-vue/src/components/tabs/index.js +1 -9
  96. package/src/vendor/bootstrap-vue/src/components/tooltip/helpers/bv-tooltip.js +1 -1
  97. package/src/vendor/bootstrap-vue/src/components/tooltip/index.d.ts +1 -5
  98. package/src/vendor/bootstrap-vue/src/components/tooltip/index.js +1 -8
  99. package/src/vendor/bootstrap-vue/src/components/tooltip/package.json +0 -3
  100. package/src/vendor/bootstrap-vue/src/constants/components.js +0 -1
  101. package/src/vendor/bootstrap-vue/src/constants/env.js +0 -1
  102. package/src/vendor/bootstrap-vue/src/constants/regex.js +0 -3
  103. package/src/vendor/bootstrap-vue/src/directives/modal/index.d.ts +1 -4
  104. package/src/vendor/bootstrap-vue/src/directives/modal/index.js +1 -6
  105. package/src/vendor/bootstrap-vue/src/directives/toggle/index.d.ts +1 -5
  106. package/src/vendor/bootstrap-vue/src/directives/toggle/index.js +1 -6
  107. package/src/vendor/bootstrap-vue/src/directives/tooltip/README.md +0 -1
  108. package/src/vendor/bootstrap-vue/src/directives/tooltip/index.d.ts +1 -5
  109. package/src/vendor/bootstrap-vue/src/directives/tooltip/index.js +1 -6
  110. package/src/vendor/bootstrap-vue/src/directives/visible/index.d.ts +1 -5
  111. package/src/vendor/bootstrap-vue/src/directives/visible/index.js +1 -6
  112. package/src/vendor/bootstrap-vue/src/icons/icons.js +1 -4
  113. package/src/vendor/bootstrap-vue/src/index.d.ts +0 -3
  114. package/src/vendor/bootstrap-vue/src/index.js +2 -45
  115. package/src/vendor/bootstrap-vue/src/utils/config.spec.js +2 -2
  116. package/src/vendor/bootstrap-vue/src/utils/object.js +0 -2
  117. package/src/vendor/bootstrap-vue/src/utils/warn.js +1 -16
  118. package/translations.js +0 -2
  119. package/dist/vendor/bootstrap-vue/src/components/modal/helpers/bv-modal.js +0 -279
  120. package/dist/vendor/bootstrap-vue/src/directives/hover/hover.js +0 -61
  121. package/dist/vendor/bootstrap-vue/src/directives/hover/index.js +0 -11
  122. package/dist/vendor/bootstrap-vue/src/directives/index.js +0 -23
  123. package/dist/vendor/bootstrap-vue/src/directives/popover/index.js +0 -11
  124. package/dist/vendor/bootstrap-vue/src/directives/popover/popover.js +0 -265
  125. package/dist/vendor/bootstrap-vue/src/directives/scrollspy/helpers/bv-scrollspy.class.js +0 -404
  126. package/dist/vendor/bootstrap-vue/src/directives/scrollspy/index.js +0 -11
  127. package/dist/vendor/bootstrap-vue/src/directives/scrollspy/scrollspy.js +0 -112
  128. package/src/vendor/bootstrap-vue/src/components/modal/helpers/bv-modal.js +0 -279
  129. package/src/vendor/bootstrap-vue/src/components/modal/helpers/bv-modal.spec.js +0 -178
  130. package/src/vendor/bootstrap-vue/src/directives/hover/README.md +0 -87
  131. package/src/vendor/bootstrap-vue/src/directives/hover/hover.js +0 -54
  132. package/src/vendor/bootstrap-vue/src/directives/hover/hover.spec.js +0 -49
  133. package/src/vendor/bootstrap-vue/src/directives/hover/index.d.ts +0 -11
  134. package/src/vendor/bootstrap-vue/src/directives/hover/index.js +0 -8
  135. package/src/vendor/bootstrap-vue/src/directives/hover/package.json +0 -13
  136. package/src/vendor/bootstrap-vue/src/directives/index.d.ts +0 -13
  137. package/src/vendor/bootstrap-vue/src/directives/index.js +0 -22
  138. package/src/vendor/bootstrap-vue/src/directives/popover/README.md +0 -648
  139. package/src/vendor/bootstrap-vue/src/directives/popover/index.d.ts +0 -11
  140. package/src/vendor/bootstrap-vue/src/directives/popover/index.js +0 -8
  141. package/src/vendor/bootstrap-vue/src/directives/popover/package.json +0 -111
  142. package/src/vendor/bootstrap-vue/src/directives/popover/popover.js +0 -275
  143. package/src/vendor/bootstrap-vue/src/directives/popover/popover.spec.js +0 -129
  144. package/src/vendor/bootstrap-vue/src/directives/scrollspy/README.md +0 -411
  145. package/src/vendor/bootstrap-vue/src/directives/scrollspy/helpers/bv-scrollspy.class.js +0 -480
  146. package/src/vendor/bootstrap-vue/src/directives/scrollspy/index.d.ts +0 -11
  147. package/src/vendor/bootstrap-vue/src/directives/scrollspy/index.js +0 -8
  148. package/src/vendor/bootstrap-vue/src/directives/scrollspy/package.json +0 -38
  149. package/src/vendor/bootstrap-vue/src/directives/scrollspy/scrollspy.js +0 -117
@@ -1,480 +0,0 @@
1
- /*
2
- * Scrollspy class definition
3
- */
4
-
5
- import { EVENT_OPTIONS_NO_CAPTURE } from '../../../constants/events'
6
- import { RX_HREF } from '../../../constants/regex'
7
- import {
8
- addClass,
9
- closest,
10
- getAttr,
11
- getBCR,
12
- hasClass,
13
- isElement,
14
- isVisible,
15
- matches,
16
- offset,
17
- position,
18
- removeClass,
19
- select,
20
- selectAll
21
- } from '../../../utils/dom'
22
- import { getRootEventName, eventOn, eventOff } from '../../../utils/events'
23
- import { identity } from '../../../utils/identity'
24
- import { isString, isUndefined } from '../../../utils/inspect'
25
- import { mathMax } from '../../../utils/math'
26
- import { toInteger } from '../../../utils/number'
27
- import { hasOwnProperty, toString as objectToString } from '../../../utils/object'
28
- import { observeDom } from '../../../utils/observe-dom'
29
- import { warn } from '../../../utils/warn'
30
-
31
- /*
32
- * Constants / Defaults
33
- */
34
-
35
- const NAME = 'v-b-scrollspy'
36
-
37
- const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'
38
- const CLASS_NAME_ACTIVE = 'active'
39
-
40
- const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'
41
- const SELECTOR_NAV_LINKS = '.nav-link'
42
- const SELECTOR_NAV_ITEMS = '.nav-item'
43
- const SELECTOR_LIST_ITEMS = '.list-group-item'
44
- const SELECTOR_DROPDOWN = '.dropdown, .dropup'
45
- const SELECTOR_DROPDOWN_ITEMS = '.dropdown-item'
46
- const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'
47
-
48
- const ROOT_EVENT_NAME_ACTIVATE = getRootEventName('BVScrollspy', 'activate')
49
-
50
- const METHOD_OFFSET = 'offset'
51
- const METHOD_POSITION = 'position'
52
-
53
- const Default = {
54
- element: 'body',
55
- offset: 10,
56
- method: 'auto',
57
- throttle: 75
58
- }
59
-
60
- const DefaultType = {
61
- element: '(string|element|component)',
62
- offset: 'number',
63
- method: 'string',
64
- throttle: 'number'
65
- }
66
-
67
- // Transition Events
68
- const TransitionEndEvents = [
69
- 'webkitTransitionEnd',
70
- 'transitionend',
71
- 'otransitionend',
72
- 'oTransitionEnd'
73
- ]
74
-
75
- /*
76
- * Utility Methods
77
- */
78
-
79
- // Better var type detection
80
- const toType = obj => /* istanbul ignore next: not easy to test */ {
81
- return objectToString(obj)
82
- .match(/\s([a-zA-Z]+)/)[1]
83
- .toLowerCase()
84
- }
85
-
86
- // Check config properties for expected types
87
- /* istanbul ignore next */
88
- const typeCheckConfig = (
89
- componentName,
90
- config,
91
- configTypes
92
- ) => /* istanbul ignore next: not easy to test */ {
93
- for (const property in configTypes) {
94
- if (hasOwnProperty(configTypes, property)) {
95
- const expectedTypes = configTypes[property]
96
- const value = config[property]
97
- let valueType = value && isElement(value) ? 'element' : toType(value)
98
- // handle Vue instances
99
- valueType = value && value._isVue ? 'component' : valueType
100
-
101
- if (!new RegExp(expectedTypes).test(valueType)) {
102
- /* istanbul ignore next */
103
- warn(
104
- `${componentName}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}"`
105
- )
106
- }
107
- }
108
- }
109
- }
110
-
111
- /*
112
- * ------------------------------------------------------------------------
113
- * Class Definition
114
- * ------------------------------------------------------------------------
115
- */
116
-
117
- /* istanbul ignore next: not easy to test */
118
- export class BVScrollspy /* istanbul ignore next: not easy to test */ {
119
- constructor(element, config, $root) {
120
- // The element we activate links in
121
- this.$el = element
122
- this.$scroller = null
123
- this.$selector = [SELECTOR_NAV_LINKS, SELECTOR_LIST_ITEMS, SELECTOR_DROPDOWN_ITEMS].join(',')
124
- this.$offsets = []
125
- this.$targets = []
126
- this.$activeTarget = null
127
- this.$scrollHeight = 0
128
- this.$resizeTimeout = null
129
- this.$scrollerObserver = null
130
- this.$targetsObserver = null
131
- this.$root = $root || null
132
- this.$config = null
133
-
134
- this.updateConfig(config)
135
- }
136
-
137
- static get Name() {
138
- return NAME
139
- }
140
-
141
- static get Default() {
142
- return Default
143
- }
144
-
145
- static get DefaultType() {
146
- return DefaultType
147
- }
148
-
149
- updateConfig(config, $root) {
150
- if (this.$scroller) {
151
- // Just in case out scroll element has changed
152
- this.unlisten()
153
- this.$scroller = null
154
- }
155
- const cfg = { ...this.constructor.Default, ...config }
156
- if ($root) {
157
- this.$root = $root
158
- }
159
- typeCheckConfig(this.constructor.Name, cfg, this.constructor.DefaultType)
160
- this.$config = cfg
161
-
162
- if (this.$root) {
163
- const self = this
164
- this.$root.$nextTick(() => {
165
- self.listen()
166
- })
167
- } else {
168
- this.listen()
169
- }
170
- }
171
-
172
- dispose() {
173
- this.unlisten()
174
- clearTimeout(this.$resizeTimeout)
175
- this.$resizeTimeout = null
176
- this.$el = null
177
- this.$config = null
178
- this.$scroller = null
179
- this.$selector = null
180
- this.$offsets = null
181
- this.$targets = null
182
- this.$activeTarget = null
183
- this.$scrollHeight = null
184
- }
185
-
186
- listen() {
187
- const scroller = this.getScroller()
188
- if (scroller && scroller.tagName !== 'BODY') {
189
- eventOn(scroller, 'scroll', this, EVENT_OPTIONS_NO_CAPTURE)
190
- }
191
- eventOn(window, 'scroll', this, EVENT_OPTIONS_NO_CAPTURE)
192
- eventOn(window, 'resize', this, EVENT_OPTIONS_NO_CAPTURE)
193
- eventOn(window, 'orientationchange', this, EVENT_OPTIONS_NO_CAPTURE)
194
- TransitionEndEvents.forEach(eventName => {
195
- eventOn(window, eventName, this, EVENT_OPTIONS_NO_CAPTURE)
196
- })
197
- this.setObservers(true)
198
- // Schedule a refresh
199
- this.handleEvent('refresh')
200
- }
201
-
202
- unlisten() {
203
- const scroller = this.getScroller()
204
- this.setObservers(false)
205
- if (scroller && scroller.tagName !== 'BODY') {
206
- eventOff(scroller, 'scroll', this, EVENT_OPTIONS_NO_CAPTURE)
207
- }
208
- eventOff(window, 'scroll', this, EVENT_OPTIONS_NO_CAPTURE)
209
- eventOff(window, 'resize', this, EVENT_OPTIONS_NO_CAPTURE)
210
- eventOff(window, 'orientationchange', this, EVENT_OPTIONS_NO_CAPTURE)
211
- TransitionEndEvents.forEach(eventName => {
212
- eventOff(window, eventName, this, EVENT_OPTIONS_NO_CAPTURE)
213
- })
214
- }
215
-
216
- setObservers(on) {
217
- // We observe both the scroller for content changes, and the target links
218
- this.$scrollerObserver && this.$scrollerObserver.disconnect()
219
- this.$targetsObserver && this.$targetsObserver.disconnect()
220
- this.$scrollerObserver = null
221
- this.$targetsObserver = null
222
- if (on) {
223
- this.$targetsObserver = observeDom(
224
- this.$el,
225
- () => {
226
- this.handleEvent('mutation')
227
- },
228
- {
229
- subtree: true,
230
- childList: true,
231
- attributes: true,
232
- attributeFilter: ['href']
233
- }
234
- )
235
- this.$scrollerObserver = observeDom(
236
- this.getScroller(),
237
- () => {
238
- this.handleEvent('mutation')
239
- },
240
- {
241
- subtree: true,
242
- childList: true,
243
- characterData: true,
244
- attributes: true,
245
- attributeFilter: ['id', 'style', 'class']
246
- }
247
- )
248
- }
249
- }
250
-
251
- // General event handler
252
- handleEvent(event) {
253
- const type = isString(event) ? event : event.type
254
-
255
- const self = this
256
- const resizeThrottle = () => {
257
- if (!self.$resizeTimeout) {
258
- self.$resizeTimeout = setTimeout(() => {
259
- self.refresh()
260
- self.process()
261
- self.$resizeTimeout = null
262
- }, self.$config.throttle)
263
- }
264
- }
265
-
266
- if (type === 'scroll') {
267
- if (!this.$scrollerObserver) {
268
- // Just in case we are added to the DOM before the scroll target is
269
- // We re-instantiate our listeners, just in case
270
- this.listen()
271
- }
272
- this.process()
273
- } else if (/(resize|orientationchange|mutation|refresh)/.test(type)) {
274
- // Postpone these events by throttle time
275
- resizeThrottle()
276
- }
277
- }
278
-
279
- // Refresh the list of target links on the element we are applied to
280
- refresh() {
281
- const scroller = this.getScroller()
282
- if (!scroller) {
283
- return
284
- }
285
- const autoMethod = scroller !== scroller.window ? METHOD_POSITION : METHOD_OFFSET
286
- const method = this.$config.method === 'auto' ? autoMethod : this.$config.method
287
- const methodFn = method === METHOD_POSITION ? position : offset
288
- const offsetBase = method === METHOD_POSITION ? this.getScrollTop() : 0
289
-
290
- this.$offsets = []
291
- this.$targets = []
292
-
293
- this.$scrollHeight = this.getScrollHeight()
294
-
295
- // Find all the unique link HREFs that we will control
296
- selectAll(this.$selector, this.$el)
297
- // Get HREF value
298
- .map(link => getAttr(link, 'href'))
299
- // Filter out HREFs that do not match our RegExp
300
- .filter(href => href && RX_HREF.test(href || ''))
301
- // Find all elements with ID that match HREF hash
302
- .map(href => {
303
- // Convert HREF into an ID (including # at beginning)
304
- const id = href.replace(RX_HREF, '$1').trim()
305
- if (!id) {
306
- return null
307
- }
308
- // Find the element with the ID specified by id
309
- const el = select(id, scroller)
310
- if (el && isVisible(el)) {
311
- return {
312
- offset: toInteger(methodFn(el).top, 0) + offsetBase,
313
- target: id
314
- }
315
- }
316
- return null
317
- })
318
- .filter(identity)
319
- // Sort them by their offsets (smallest first)
320
- .sort((a, b) => a.offset - b.offset)
321
- // record only unique targets/offsets
322
- .reduce((memo, item) => {
323
- if (!memo[item.target]) {
324
- this.$offsets.push(item.offset)
325
- this.$targets.push(item.target)
326
- memo[item.target] = true
327
- }
328
- return memo
329
- }, {})
330
-
331
- // Return this for easy chaining
332
- return this
333
- }
334
-
335
- // Handle activating/clearing
336
- process() {
337
- const scrollTop = this.getScrollTop() + this.$config.offset
338
- const scrollHeight = this.getScrollHeight()
339
- const maxScroll = this.$config.offset + scrollHeight - this.getOffsetHeight()
340
-
341
- if (this.$scrollHeight !== scrollHeight) {
342
- this.refresh()
343
- }
344
-
345
- if (scrollTop >= maxScroll) {
346
- const target = this.$targets[this.$targets.length - 1]
347
- if (this.$activeTarget !== target) {
348
- this.activate(target)
349
- }
350
- return
351
- }
352
-
353
- if (this.$activeTarget && scrollTop < this.$offsets[0] && this.$offsets[0] > 0) {
354
- this.$activeTarget = null
355
- this.clear()
356
- return
357
- }
358
-
359
- for (let i = this.$offsets.length; i--; ) {
360
- const isActiveTarget =
361
- this.$activeTarget !== this.$targets[i] &&
362
- scrollTop >= this.$offsets[i] &&
363
- (isUndefined(this.$offsets[i + 1]) || scrollTop < this.$offsets[i + 1])
364
-
365
- if (isActiveTarget) {
366
- this.activate(this.$targets[i])
367
- }
368
- }
369
- }
370
-
371
- getScroller() {
372
- if (this.$scroller) {
373
- return this.$scroller
374
- }
375
- let scroller = this.$config.element
376
- if (!scroller) {
377
- return null
378
- } else if (isElement(scroller.$el)) {
379
- scroller = scroller.$el
380
- } else if (isString(scroller)) {
381
- scroller = select(scroller)
382
- }
383
- if (!scroller) {
384
- return null
385
- }
386
- this.$scroller = scroller.tagName === 'BODY' ? window : scroller
387
- return this.$scroller
388
- }
389
-
390
- getScrollTop() {
391
- const scroller = this.getScroller()
392
- return scroller === window ? scroller.pageYOffset : scroller.scrollTop
393
- }
394
-
395
- getScrollHeight() {
396
- return (
397
- this.getScroller().scrollHeight ||
398
- mathMax(document.body.scrollHeight, document.documentElement.scrollHeight)
399
- )
400
- }
401
-
402
- getOffsetHeight() {
403
- const scroller = this.getScroller()
404
- return scroller === window ? window.innerHeight : getBCR(scroller).height
405
- }
406
-
407
- activate(target) {
408
- this.$activeTarget = target
409
- this.clear()
410
-
411
- // Grab the list of target links (<a href="{$target}">)
412
- const links = selectAll(
413
- this.$selector
414
- // Split out the base selectors
415
- .split(',')
416
- // Map to a selector that matches links with HREF ending in the ID (including '#')
417
- .map(selector => `${selector}[href$="${target}"]`)
418
- // Join back into a single selector string
419
- .join(','),
420
- this.$el
421
- )
422
-
423
- links.forEach(link => {
424
- if (hasClass(link, CLASS_NAME_DROPDOWN_ITEM)) {
425
- // This is a dropdown item, so find the .dropdown-toggle and set its state
426
- const dropdown = closest(SELECTOR_DROPDOWN, link)
427
- if (dropdown) {
428
- this.setActiveState(select(SELECTOR_DROPDOWN_TOGGLE, dropdown), true)
429
- }
430
- // Also set this link's state
431
- this.setActiveState(link, true)
432
- } else {
433
- // Set triggered link as active
434
- this.setActiveState(link, true)
435
- if (matches(link.parentElement, SELECTOR_NAV_ITEMS)) {
436
- // Handle nav-link inside nav-item, and set nav-item active
437
- this.setActiveState(link.parentElement, true)
438
- }
439
- // Set triggered links parents as active
440
- // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
441
- let el = link
442
- while (el) {
443
- el = closest(SELECTOR_NAV_LIST_GROUP, el)
444
- const sibling = el ? el.previousElementSibling : null
445
- if (sibling && matches(sibling, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`)) {
446
- this.setActiveState(sibling, true)
447
- }
448
- // Handle special case where nav-link is inside a nav-item
449
- if (sibling && matches(sibling, SELECTOR_NAV_ITEMS)) {
450
- this.setActiveState(select(SELECTOR_NAV_LINKS, sibling), true)
451
- // Add active state to nav-item as well
452
- this.setActiveState(sibling, true)
453
- }
454
- }
455
- }
456
- })
457
-
458
- // Signal event to via $root, passing ID of activated target and reference to array of links
459
- if (links && links.length > 0 && this.$root) {
460
- this.$root.$emit(ROOT_EVENT_NAME_ACTIVATE, target, links)
461
- }
462
- }
463
-
464
- clear() {
465
- selectAll(`${this.$selector}, ${SELECTOR_NAV_ITEMS}`, this.$el)
466
- .filter(el => hasClass(el, CLASS_NAME_ACTIVE))
467
- .forEach(el => this.setActiveState(el, false))
468
- }
469
-
470
- setActiveState(el, active) {
471
- if (!el) {
472
- return
473
- }
474
- if (active) {
475
- addClass(el, CLASS_NAME_ACTIVE)
476
- } else {
477
- removeClass(el, CLASS_NAME_ACTIVE)
478
- }
479
- }
480
- }
@@ -1,11 +0,0 @@
1
- //
2
- // VBScrollspy
3
- //
4
- import Vue, { DirectiveOptions } from 'vue'
5
- import { BvPlugin } from '../../'
6
-
7
- // Plugin
8
- export declare const VBScrollspyPlugin: BvPlugin
9
-
10
- // directive: v-b-scrollspy
11
- export declare const VBScrollspy: DirectiveOptions
@@ -1,8 +0,0 @@
1
- import { VBScrollspy } from './scrollspy'
2
- import { pluginFactory } from '../../utils/plugins'
3
-
4
- const VBScrollspyPlugin = /*#__PURE__*/ pluginFactory({
5
- directives: { VBScrollspy }
6
- })
7
-
8
- export { VBScrollspyPlugin, VBScrollspy }
@@ -1,38 +0,0 @@
1
- {
2
- "name": "@bootstrap-vue/scrollspy",
3
- "version": "0.0.0",
4
- "meta": {
5
- "title": "Scrollspy",
6
- "description": "Automatically activate BootstrapVue navigation or list group components based on scroll position to indicate which link is currently active in the viewport.",
7
- "directive": "VBScrollspy",
8
- "arg": {
9
- "pattern": "[a-zA-Z][a-zA-Z0-9_\\-]*",
10
- "description": "ID of element to monitor scrolling on (if not provided defaults to the body element)",
11
- "required": false
12
- },
13
- "expression": [
14
- "String",
15
- "Number",
16
- "Object"
17
- ],
18
- "modifiers": [
19
- {
20
- "name": "###",
21
- "pattern": "[\\d]+",
22
- "description": "Offset (in pixels) from top of scrolling viewport before triggering active state"
23
- },
24
- {
25
- "name": "offset",
26
- "description": "Position calculation method using `offset` procedure (default process for body)"
27
- },
28
- {
29
- "name": "position",
30
- "description": "Position calculation method using the `position` procedure"
31
- },
32
- {
33
- "name": "auto",
34
- "description": "Position calculation method: `auto` will choose `offset` if scroll element is body, else the method is `position`. This is the default"
35
- }
36
- ]
37
- }
38
- }
@@ -1,117 +0,0 @@
1
- import { IS_BROWSER } from '../../constants/env'
2
- import { isNumber, isObject, isString } from '../../utils/inspect'
3
- import { mathRound } from '../../utils/math'
4
- import { toInteger } from '../../utils/number'
5
- import { keys } from '../../utils/object'
6
- import { getEventRoot } from '../../utils/get-event-root'
7
- import { getInstanceFromDirective } from '../../utils/get-instance-from-directive'
8
- import { BVScrollspy } from './helpers/bv-scrollspy.class'
9
-
10
- // Key we use to store our instance
11
- const BV_SCROLLSPY = '__BV_Scrollspy__'
12
-
13
- // Pre-compiled regular expressions
14
- const onlyDigitsRE = /^\d+$/
15
- const offsetRE = /^(auto|position|offset)$/
16
-
17
- // Build a Scrollspy config based on bindings (if any)
18
- // Arguments and modifiers take precedence over passed value config object
19
- /* istanbul ignore next: not easy to test */
20
- const parseBindings = bindings => /* istanbul ignore next: not easy to test */ {
21
- const config = {}
22
-
23
- // If argument, assume element ID
24
- if (bindings.arg) {
25
- // Element ID specified as arg
26
- // We must prepend '#' to become a CSS selector
27
- config.element = `#${bindings.arg}`
28
- }
29
-
30
- // Process modifiers
31
- keys(bindings.modifiers).forEach(mod => {
32
- if (onlyDigitsRE.test(mod)) {
33
- // Offset value
34
- config.offset = toInteger(mod, 0)
35
- } else if (offsetRE.test(mod)) {
36
- // Offset method
37
- config.method = mod
38
- }
39
- })
40
-
41
- // Process value
42
- if (isString(bindings.value)) {
43
- // Value is a CSS ID or selector
44
- config.element = bindings.value
45
- } else if (isNumber(bindings.value)) {
46
- // Value is offset
47
- config.offset = mathRound(bindings.value)
48
- } else if (isObject(bindings.value)) {
49
- // Value is config object
50
- // Filter the object based on our supported config options
51
- keys(bindings.value)
52
- .filter(k => !!BVScrollspy.DefaultType[k])
53
- .forEach(k => {
54
- config[k] = bindings.value[k]
55
- })
56
- }
57
-
58
- return config
59
- }
60
-
61
- // Add or update Scrollspy on our element
62
- const applyScrollspy = (el, bindings, vnode) => /* istanbul ignore next: not easy to test */ {
63
- if (!IS_BROWSER) {
64
- /* istanbul ignore next */
65
- return
66
- }
67
- const config = parseBindings(bindings)
68
- if (el[BV_SCROLLSPY]) {
69
- el[BV_SCROLLSPY].updateConfig(config, getEventRoot(getInstanceFromDirective(vnode, bindings)))
70
- } else {
71
- el[BV_SCROLLSPY] = new BVScrollspy(
72
- el,
73
- config,
74
- getEventRoot(getInstanceFromDirective(vnode, bindings))
75
- )
76
- }
77
- }
78
-
79
- // Remove Scrollspy on our element
80
- /* istanbul ignore next: not easy to test */
81
- const removeScrollspy = el => /* istanbul ignore next: not easy to test */ {
82
- if (el[BV_SCROLLSPY]) {
83
- el[BV_SCROLLSPY].dispose()
84
- el[BV_SCROLLSPY] = null
85
- delete el[BV_SCROLLSPY]
86
- }
87
- }
88
-
89
- /*
90
- * Export our directive
91
- */
92
- export const VBScrollspy = {
93
- /* istanbul ignore next: not easy to test */
94
- bind(el, bindings, vnode) {
95
- applyScrollspy(el, bindings, vnode)
96
- },
97
- /* istanbul ignore next: not easy to test */
98
- inserted(el, bindings, vnode) {
99
- applyScrollspy(el, bindings, vnode)
100
- },
101
- /* istanbul ignore next: not easy to test */
102
- update(el, bindings, vnode) {
103
- if (bindings.value !== bindings.oldValue) {
104
- applyScrollspy(el, bindings, vnode)
105
- }
106
- },
107
- /* istanbul ignore next: not easy to test */
108
- componentUpdated(el, bindings, vnode) {
109
- if (bindings.value !== bindings.oldValue) {
110
- applyScrollspy(el, bindings, vnode)
111
- }
112
- },
113
- /* istanbul ignore next: not easy to test */
114
- unbind(el) {
115
- removeScrollspy(el)
116
- }
117
- }