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