@gitlab/ui 114.1.0 → 114.1.1

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 (136) hide show
  1. package/package.json +7 -26
  2. package/CHANGELOG.md +0 -13139
  3. package/src/vendor/bootstrap/LICENSE +0 -11
  4. package/src/vendor/bootstrap-vue/LICENSE +0 -11
  5. package/src/vendor/bootstrap-vue/package.json +0 -144
  6. package/src/vendor/bootstrap-vue/src/components/button/MODIFICATIONS.md +0 -16
  7. package/src/vendor/bootstrap-vue/src/components/button/README.md +0 -240
  8. package/src/vendor/bootstrap-vue/src/components/button/button-close.spec.js +0 -210
  9. package/src/vendor/bootstrap-vue/src/components/button/button.spec.js +0 -349
  10. package/src/vendor/bootstrap-vue/src/components/button/package.json +0 -105
  11. package/src/vendor/bootstrap-vue/src/components/dropdown/README.md +0 -730
  12. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-divider.spec.js +0 -58
  13. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-form.spec.js +0 -110
  14. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-group.spec.js +0 -94
  15. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-header.spec.js +0 -73
  16. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-item-button.spec.js +0 -117
  17. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-item.spec.js +0 -147
  18. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-text.spec.js +0 -59
  19. package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown.spec.js +0 -1121
  20. package/src/vendor/bootstrap-vue/src/components/dropdown/package.json +0 -368
  21. package/src/vendor/bootstrap-vue/src/components/form/README.md +0 -365
  22. package/src/vendor/bootstrap-vue/src/components/form/form-invalid-feedback.spec.js +0 -170
  23. package/src/vendor/bootstrap-vue/src/components/form/form-text.spec.js +0 -93
  24. package/src/vendor/bootstrap-vue/src/components/form/form-valid-feedback.spec.js +0 -157
  25. package/src/vendor/bootstrap-vue/src/components/form/form.spec.js +0 -97
  26. package/src/vendor/bootstrap-vue/src/components/form/package.json +0 -112
  27. package/src/vendor/bootstrap-vue/src/components/form-checkbox/README.md +0 -691
  28. package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox-group.spec.js +0 -525
  29. package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox.spec.js +0 -922
  30. package/src/vendor/bootstrap-vue/src/components/form-checkbox/package.json +0 -172
  31. package/src/vendor/bootstrap-vue/src/components/form-group/README.md +0 -339
  32. package/src/vendor/bootstrap-vue/src/components/form-group/form-group.spec.js +0 -477
  33. package/src/vendor/bootstrap-vue/src/components/form-group/package.json +0 -183
  34. package/src/vendor/bootstrap-vue/src/components/form-radio/README.md +0 -437
  35. package/src/vendor/bootstrap-vue/src/components/form-radio/form-radio-group.spec.js +0 -357
  36. package/src/vendor/bootstrap-vue/src/components/form-radio/form-radio.spec.js +0 -587
  37. package/src/vendor/bootstrap-vue/src/components/form-radio/package.json +0 -162
  38. package/src/vendor/bootstrap-vue/src/components/form-select/README.md +0 -504
  39. package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option-group.spec.js +0 -138
  40. package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option.spec.js +0 -75
  41. package/src/vendor/bootstrap-vue/src/components/form-select/form-select.spec.js +0 -723
  42. package/src/vendor/bootstrap-vue/src/components/form-select/package.json +0 -132
  43. package/src/vendor/bootstrap-vue/src/components/form-textarea/README.md +0 -453
  44. package/src/vendor/bootstrap-vue/src/components/form-textarea/form-textarea.spec.js +0 -1000
  45. package/src/vendor/bootstrap-vue/src/components/form-textarea/package.json +0 -122
  46. package/src/vendor/bootstrap-vue/src/components/layout/README.md +0 -791
  47. package/src/vendor/bootstrap-vue/src/components/layout/col.spec.js +0 -192
  48. package/src/vendor/bootstrap-vue/src/components/layout/form-row.spec.js +0 -45
  49. package/src/vendor/bootstrap-vue/src/components/layout/package.json +0 -99
  50. package/src/vendor/bootstrap-vue/src/components/link/README.md +0 -76
  51. package/src/vendor/bootstrap-vue/src/components/link/link.spec.js +0 -434
  52. package/src/vendor/bootstrap-vue/src/components/link/package.json +0 -57
  53. package/src/vendor/bootstrap-vue/src/components/modal/MODIFICATIONS.md +0 -30
  54. package/src/vendor/bootstrap-vue/src/components/modal/README.md +0 -1067
  55. package/src/vendor/bootstrap-vue/src/components/modal/helpers/bv-modal-event.class.spec.js +0 -82
  56. package/src/vendor/bootstrap-vue/src/components/modal/modal.spec.js +0 -1418
  57. package/src/vendor/bootstrap-vue/src/components/modal/package.json +0 -544
  58. package/src/vendor/bootstrap-vue/src/components/nav/README.md +0 -362
  59. package/src/vendor/bootstrap-vue/src/components/nav/nav-item.spec.js +0 -127
  60. package/src/vendor/bootstrap-vue/src/components/nav/nav.spec.js +0 -177
  61. package/src/vendor/bootstrap-vue/src/components/nav/package.json +0 -73
  62. package/src/vendor/bootstrap-vue/src/components/popover/README.md +0 -919
  63. package/src/vendor/bootstrap-vue/src/components/popover/package.json +0 -261
  64. package/src/vendor/bootstrap-vue/src/components/popover/popover.spec.js +0 -198
  65. package/src/vendor/bootstrap-vue/src/components/table/README.md +0 -3157
  66. package/src/vendor/bootstrap-vue/src/components/table/helpers/default-sort-compare.spec.js +0 -112
  67. package/src/vendor/bootstrap-vue/src/components/table/helpers/normalize-fields.spec.js +0 -93
  68. package/src/vendor/bootstrap-vue/src/components/table/package.json +0 -1763
  69. package/src/vendor/bootstrap-vue/src/components/table/table-busy.spec.js +0 -150
  70. package/src/vendor/bootstrap-vue/src/components/table/table-caption.spec.js +0 -176
  71. package/src/vendor/bootstrap-vue/src/components/table/table-colgroup.spec.js +0 -81
  72. package/src/vendor/bootstrap-vue/src/components/table/table-filtering.spec.js +0 -409
  73. package/src/vendor/bootstrap-vue/src/components/table/table-item-formatter.spec.js +0 -56
  74. package/src/vendor/bootstrap-vue/src/components/table/table-lite.spec.js +0 -682
  75. package/src/vendor/bootstrap-vue/src/components/table/table-pagination.spec.js +0 -133
  76. package/src/vendor/bootstrap-vue/src/components/table/table-primarykey.spec.js +0 -83
  77. package/src/vendor/bootstrap-vue/src/components/table/table-provider.spec.js +0 -411
  78. package/src/vendor/bootstrap-vue/src/components/table/table-row-details.spec.js +0 -459
  79. package/src/vendor/bootstrap-vue/src/components/table/table-selectable.spec.js +0 -1182
  80. package/src/vendor/bootstrap-vue/src/components/table/table-simple.spec.js +0 -206
  81. package/src/vendor/bootstrap-vue/src/components/table/table-sorting.spec.js +0 -858
  82. package/src/vendor/bootstrap-vue/src/components/table/table-sticky-column.spec.js +0 -377
  83. package/src/vendor/bootstrap-vue/src/components/table/table-tbody-bottom-row.spec.js +0 -94
  84. package/src/vendor/bootstrap-vue/src/components/table/table-tbody-row-events.spec.js +0 -529
  85. package/src/vendor/bootstrap-vue/src/components/table/table-tbody-top-row.spec.js +0 -88
  86. package/src/vendor/bootstrap-vue/src/components/table/table-tbody-transition.spec.js +0 -83
  87. package/src/vendor/bootstrap-vue/src/components/table/table-tfoot-custom.spec.js +0 -91
  88. package/src/vendor/bootstrap-vue/src/components/table/table-tfoot-events.spec.js +0 -137
  89. package/src/vendor/bootstrap-vue/src/components/table/table-thead-events.spec.js +0 -155
  90. package/src/vendor/bootstrap-vue/src/components/table/table-thead-top.spec.js +0 -96
  91. package/src/vendor/bootstrap-vue/src/components/table/table.spec.js +0 -692
  92. package/src/vendor/bootstrap-vue/src/components/tabs/README.md +0 -433
  93. package/src/vendor/bootstrap-vue/src/components/tabs/package.json +0 -205
  94. package/src/vendor/bootstrap-vue/src/components/tabs/tab.spec.js +0 -330
  95. package/src/vendor/bootstrap-vue/src/components/tabs/tabs.spec.js +0 -778
  96. package/src/vendor/bootstrap-vue/src/components/toast/README.md +0 -655
  97. package/src/vendor/bootstrap-vue/src/components/toast/helpers/bv-toast.spec.js +0 -117
  98. package/src/vendor/bootstrap-vue/src/components/toast/package.json +0 -184
  99. package/src/vendor/bootstrap-vue/src/components/toast/toast.spec.js +0 -294
  100. package/src/vendor/bootstrap-vue/src/components/toast/toaster.spec.js +0 -77
  101. package/src/vendor/bootstrap-vue/src/components/tooltip/README.md +0 -559
  102. package/src/vendor/bootstrap-vue/src/components/tooltip/package.json +0 -258
  103. package/src/vendor/bootstrap-vue/src/components/tooltip/tooltip.spec.js +0 -1240
  104. package/src/vendor/bootstrap-vue/src/components/transition/package.json +0 -5
  105. package/src/vendor/bootstrap-vue/src/components/transporter/package.json +0 -5
  106. package/src/vendor/bootstrap-vue/src/components/transporter/transporter.spec.js +0 -85
  107. package/src/vendor/bootstrap-vue/src/directives/modal/modal.spec.js +0 -191
  108. package/src/vendor/bootstrap-vue/src/directives/tooltip/README.md +0 -521
  109. package/src/vendor/bootstrap-vue/src/directives/tooltip/package.json +0 -131
  110. package/src/vendor/bootstrap-vue/src/directives/tooltip/tooltip.spec.js +0 -190
  111. package/src/vendor/bootstrap-vue/src/directives/visible/README.md +0 -244
  112. package/src/vendor/bootstrap-vue/src/directives/visible/package.json +0 -24
  113. package/src/vendor/bootstrap-vue/src/mixins/attrs.spec.js +0 -194
  114. package/src/vendor/bootstrap-vue/src/mixins/click-out.spec.js +0 -52
  115. package/src/vendor/bootstrap-vue/src/mixins/focus-in.spec.js +0 -53
  116. package/src/vendor/bootstrap-vue/src/mixins/listen-on-document.spec.js +0 -117
  117. package/src/vendor/bootstrap-vue/src/mixins/listen-on-root.spec.js +0 -77
  118. package/src/vendor/bootstrap-vue/src/mixins/listen-on-window.spec.js +0 -115
  119. package/src/vendor/bootstrap-vue/src/mixins/listeners.spec.js +0 -245
  120. package/src/vendor/bootstrap-vue/src/utils/bv-event.class.spec.js +0 -66
  121. package/src/vendor/bootstrap-vue/src/utils/clone-deep.spec.js +0 -70
  122. package/src/vendor/bootstrap-vue/src/utils/config.spec.js +0 -169
  123. package/src/vendor/bootstrap-vue/src/utils/css-escape.spec.js +0 -82
  124. package/src/vendor/bootstrap-vue/src/utils/dom.spec.js +0 -291
  125. package/src/vendor/bootstrap-vue/src/utils/events.spec.js +0 -41
  126. package/src/vendor/bootstrap-vue/src/utils/get.spec.js +0 -109
  127. package/src/vendor/bootstrap-vue/src/utils/inspect.spec.js +0 -251
  128. package/src/vendor/bootstrap-vue/src/utils/loose-equal.spec.js +0 -203
  129. package/src/vendor/bootstrap-vue/src/utils/normalize-slot.spec.js +0 -63
  130. package/src/vendor/bootstrap-vue/src/utils/number.spec.js +0 -72
  131. package/src/vendor/bootstrap-vue/src/utils/object.spec.js +0 -61
  132. package/src/vendor/bootstrap-vue/src/utils/props.spec.js +0 -112
  133. package/src/vendor/bootstrap-vue/src/utils/router.spec.js +0 -248
  134. package/src/vendor/bootstrap-vue/src/utils/string.spec.js +0 -65
  135. package/src/vendor/bootstrap-vue/src/utils/stringify-object-values.spec.js +0 -47
  136. package/src/vendor/bootstrap-vue/src/utils/warn.spec.js +0 -54
@@ -1,190 +0,0 @@
1
- import { mount } from '@vue/test-utils'
2
- import { waitNT, waitRAF } from '../../../tests/utils'
3
- import { VBTooltip } from './tooltip'
4
-
5
- // Key which we use to store tooltip object on element
6
- const BV_TOOLTIP = '__BV_Tooltip__'
7
-
8
- /**
9
- * @gitlab/ui Note: These specs have been rewritten to be working with jest >= 29
10
- */
11
- describe('v-b-tooltip directive', () => {
12
- const originalCreateRange = document.createRange
13
- const origGetBCR = Element.prototype.getBoundingClientRect
14
-
15
- beforeEach(() => {
16
- // Hack to make Popper not bork out during tests
17
- // Note: Popper still does not do any positioning calculation in JSDOM though
18
- // So we cannot test actual positioning - just detect when it is open
19
- // https://github.com/FezVrasta/popper.js/issues/478#issuecomment-407422016
20
- document.createRange = () => ({
21
- setStart: () => {},
22
- setEnd: () => {},
23
- commonAncestorContainer: {
24
- nodeName: 'BODY',
25
- ownerDocument: document
26
- }
27
- })
28
- // Mock `getBoundingClientRect()` so that the `isVisible(el)` test returns `true`
29
- // Needed for visibility checks of trigger element, etc.
30
- Element.prototype.getBoundingClientRect = jest.fn(() => ({
31
- width: 24,
32
- height: 24,
33
- top: 0,
34
- left: 0,
35
- bottom: 0,
36
- right: 0
37
- }))
38
- })
39
-
40
- afterEach(() => {
41
- // Reset overrides
42
- document.createRange = originalCreateRange
43
- Element.prototype.getBoundingClientRect = origGetBCR
44
- })
45
-
46
- /**
47
- * Little helper to wait until a tooltip is shown after a click
48
- *
49
- * @param $button {VueTestUtils.VueWrapper}
50
- * @returns {Promise<void>}
51
- */
52
- function waitForTooltipAfterClickOn($button) {
53
- return new Promise(resolve => {
54
- const resolver = () => {
55
- $button.vm.$root.$off('bv::tooltip::shown', resolver)
56
- resolve()
57
- }
58
-
59
- $button.vm.$root.$on('bv::tooltip::shown', resolver)
60
-
61
- // Trigger click
62
- $button.trigger('click')
63
- })
64
- }
65
-
66
- it('should have BVTooltip Vue class instance', async () => {
67
- const App = {
68
- directives: {
69
- bTooltip: VBTooltip
70
- },
71
- template: '<button v-b-tooltip title="foobar">button</button>'
72
- }
73
-
74
- const $button = mount(App, {
75
- attachTo: document.body
76
- })
77
-
78
- expect($button.vm).toBeDefined()
79
- await waitNT($button.vm)
80
- await waitRAF()
81
-
82
- expect($button.element.tagName).toBe('BUTTON')
83
-
84
- // Should have instance of popover class on it
85
- expect($button.element[BV_TOOLTIP]).toBeDefined()
86
- expect($button.element[BV_TOOLTIP].$options.name).toBe('BVTooltip')
87
-
88
- $button.destroy()
89
- })
90
-
91
- it('should work', async () => {
92
- const App = {
93
- directives: {
94
- bTooltip: VBTooltip
95
- },
96
- template: '<button v-b-tooltip.click.html title="<b>foobar</b>">button</button>'
97
- }
98
-
99
- const $button = mount(App, {
100
- attachTo: document.body
101
- })
102
-
103
- expect($button.vm).toBeDefined()
104
- await waitNT($button.vm)
105
- await waitRAF()
106
-
107
- expect($button.element.tagName).toBe('BUTTON')
108
-
109
- // Should have instance of popover class on it
110
- expect($button.element[BV_TOOLTIP]).toBeDefined()
111
- expect($button.element[BV_TOOLTIP].$options.name).toBe('BVTooltip')
112
-
113
- expect($button.attributes('aria-describedby')).toBeUndefined()
114
-
115
- await waitForTooltipAfterClickOn($button)
116
-
117
- expect($button.attributes('aria-describedby')).toBeDefined()
118
- const adb = $button.attributes('aria-describedby')
119
-
120
- const tip = document.querySelector(`#${adb}`)
121
- expect(tip).not.toBe(null)
122
- expect(tip.classList.contains('tooltip')).toBe(true)
123
-
124
- $button.destroy()
125
- })
126
-
127
- it('should not show tooltip when title is empty', async () => {
128
- const App = {
129
- directives: {
130
- bTooltip: VBTooltip
131
- },
132
- template: '<button v-b-tooltip.click title="">button</button>'
133
- }
134
-
135
- const $button = mount(App, {
136
- attachTo: document.body
137
- })
138
-
139
- expect($button.vm).toBeDefined()
140
- await waitNT($button.vm)
141
- await waitRAF()
142
-
143
- expect($button.element.tagName).toBe('BUTTON')
144
-
145
- // Should have instance of popover class on it
146
- expect($button.element[BV_TOOLTIP]).toBeDefined()
147
- expect($button.element[BV_TOOLTIP].$options.name).toBe('BVTooltip')
148
-
149
- expect($button.attributes('aria-describedby')).toBeUndefined()
150
-
151
- // Trigger click
152
- await $button.trigger('click')
153
-
154
- expect($button.attributes('aria-describedby')).toBeUndefined()
155
-
156
- $button.destroy()
157
- })
158
-
159
- it('variant and customClass should work', async () => {
160
- const App = {
161
- directives: {
162
- bTooltip: VBTooltip
163
- },
164
- template: `<button v-b-tooltip.click.html.v-info="{ customClass: 'foobar'}" title="<b>foobar</b>">button</button>`
165
- }
166
-
167
- const $button = mount(App, {
168
- attachTo: document.body
169
- })
170
-
171
- expect($button.vm).toBeDefined()
172
- await waitNT($button.vm)
173
- await waitRAF()
174
-
175
- expect($button.element.tagName).toBe('BUTTON')
176
-
177
- await waitForTooltipAfterClickOn($button)
178
-
179
- expect($button.attributes('aria-describedby')).toBeDefined()
180
- const adb = $button.attributes('aria-describedby')
181
-
182
- const tip = document.querySelector(`#${adb}`)
183
- expect(tip).not.toBe(null)
184
- expect(tip.classList.contains('tooltip')).toBe(true)
185
- expect(tip.classList.contains('b-tooltip-info')).toBe(true)
186
- expect(tip.classList.contains('foobar')).toBe(true)
187
-
188
- $button.destroy()
189
- })
190
- })
@@ -1,244 +0,0 @@
1
- # Visible
2
-
3
- > `v-b-visible` is a lightweight directive that allows you to react when an element becomes visible
4
- > in the viewport and/or when it moves out of the viewport (or is no longer visible).
5
-
6
- ## Overview
7
-
8
- - `v-b-visible` will call your callback method with a boolean value indicating if the element is
9
- visible (intersecting with the viewport) or not.
10
- - The directive can be placed on almost any element or component.
11
- - Changes in visibility can also be detected (such as `display: none`), as long as the element is
12
- within (or partially within) the viewport, or within the optional offset. Note: transitioning to a
13
- non-visible state due to `v-if="false"` _cannot_ be detected.
14
- - Internally, BootstrapVue uses this directive in several components, such as `<b-img-lazy>`.
15
- - The `v-b-visible` directive requires browser support of
16
- [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
17
- For older browsers that do not support `IntersectionObserver`, you will need to use a
18
- [polyfill](/docs/#js).
19
- - If `IntersectionObserver` support is not detected, then `v-b-visible` will assume the element is
20
- _always visible_, and will call the callback once with the argument set to `true`.
21
-
22
- ## Directive syntax and usage
23
-
24
- ```html
25
- <div v-b-visible.[mod1].[mod2]="callback">content</div>
26
- ```
27
-
28
- Where `callback` is required:
29
-
30
- - A function reference that will be called whenever visibility changes. The callback is passed a
31
- single boolean argument. `true` indicates that the element is intersecting (partially or entirely
32
- visible) in the viewport, or `false` if the element is not visible/intersecting with the viewport.
33
- The callback will be called each time the element's visibility changes (except when the `once`
34
- modifier is used. See below for details)
35
-
36
- Where `[mod1]` or `[mod2]` can be (all optional):
37
-
38
- - A positive integer number representing the offset (margin) in pixels _away_ from the edge of the
39
- _viewport_ to determine when the element is considered in (or just about to be in) the viewport.
40
- The value adds a margin around the viewport. The default value is `0`.
41
- - The keyword `once`. When this modifier is present, the callback will be called only once the first
42
- time the element is visible (with the argument of `true` indicating the element is
43
- intersecting/visible). Note the callback _may be_ called prior to this with an argument of `false`
44
- signifying the element is not intersecting/visible.
45
-
46
- The order of the modifiers is not important.
47
-
48
- ### Usage syntax examples
49
-
50
- In all use cases, the callback function is required.
51
-
52
- #### Basic (no modifiers)
53
-
54
- ```html
55
- <template>
56
- <div v-b-visible="visibleHandler"> ... </div>
57
- </template>
58
- <script>
59
- export default {
60
- methods: {
61
- visibleHandler(isVisible) {
62
- if (isVisible) {
63
- // Do something
64
- } else {
65
- // Do something else
66
- }
67
- }
68
- }
69
- }
70
- </script>
71
- ```
72
-
73
- #### With viewport offset modifier
74
-
75
- In this example, the modifier value represents 350px (if the element is outside of the physical
76
- viewport by at least 350px, then it will be considered "visible"):
77
-
78
- ```html
79
- <template>
80
- <div v-b-visible.350="visibleHandler"> ... </div>
81
- </template>
82
- <script>
83
- export default {
84
- methods: {
85
- visibleHandler(isVisible) {
86
- if (isVisible) {
87
- // Do something
88
- } else {
89
- // Do something else
90
- }
91
- }
92
- }
93
- }
94
- </script>
95
- ```
96
-
97
- #### With the `once` modifier
98
-
99
- ```html
100
- <template>
101
- <div v-b-visible.once="visibleHandler"> ... </div>
102
- </template>
103
- <script>
104
- export default {
105
- methods: {
106
- visibleHandler(isVisible) {
107
- if (isVisible) {
108
- // This will only ever happen once, when the
109
- // element has become visible for the first time
110
- } else {
111
- // This may happen zero or more times before
112
- // the element becomes visible, but will never
113
- // happen after the element has become visible
114
- }
115
- }
116
- }
117
- }
118
- </script>
119
- ```
120
-
121
- #### With both `once` and offset modifiers
122
-
123
- ```html
124
- <template>
125
- <div v-b-visible.once.350="visibleHandler"> ... </div>
126
- </template>
127
- <script>
128
- export default {
129
- methods: {
130
- visibleHandler(isVisible) {
131
- if (isVisible) {
132
- // This will only ever happen once, when the
133
- // element is outside of the physical viewport
134
- // by at least 350px for the first time
135
- } else {
136
- // This may happen zero or more times before
137
- // the element becomes visible, but will never
138
- // happen after the element has become visible
139
- }
140
- }
141
- }
142
- }
143
- </script>
144
- ```
145
-
146
- ## Live examples
147
-
148
- Here are two live examples showing two common use cases.
149
-
150
- ### Visibility of scrolled content
151
-
152
- Scroll the container to see the reaction when the `<b-badge>` scrolls into view. Note that
153
- visibility state will also change if the element is scrolled out of the viewport.
154
-
155
- ```html
156
- <template>
157
- <div>
158
- <div
159
- :class="[isVisible ? 'bg-info' : 'bg-light', 'border', 'p-2', 'text-center']"
160
- style="height: 85px; overflow-y: scroll;"
161
- >
162
- <p>{{ text }}</p>
163
- <b-badge v-b-visible="handleVisibility">Element with v-b-visible directive</b-badge>
164
- <p>{{ text }}</p>
165
- </div>
166
- <p class="mt-2">
167
- Visible: {{ isVisible }}
168
- </p>
169
- </div>
170
- </template>
171
-
172
- <script>
173
- export default {
174
- data() {
175
- return {
176
- isVisible: false,
177
- text: `
178
- Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla
179
- tempor. Laborum consequat non elit enim exercitation cillum aliqua
180
- consequat id aliqua. Esse ex consectetur mollit voluptate est in duis
181
- laboris ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam
182
- Lorem aliqua quis ullamco deserunt sit enim elit aliqua esse irure. Laborum
183
- nisi sit est tempor laborum mollit labore officia laborum excepteur commodo
184
- non commodo dolor excepteur commodo. Ipsum fugiat ex est consectetur ipsum
185
- commodo tempor sunt in proident. Non elixir food exorcism nacho tequila tasty.
186
- `
187
- }
188
- },
189
- methods: {
190
- handleVisibility(isVisible) {
191
- this.isVisible = isVisible
192
- }
193
- }
194
- }
195
- </script>
196
-
197
- <!-- v-b-visible-scroll.vue -->
198
- ```
199
-
200
- One use case for this, when combined with the `once` modifier, is to see if a user has scrolled to
201
- the bottom of a page or scrollable div (i.e. has "read" the entire terms of service).
202
-
203
- ### CSS display visibility detection
204
-
205
- Click the button to change the `<div>` visibility state. Note that visibility state will also change
206
- if the element is scrolled out of the viewport.
207
-
208
- ```html
209
- <template>
210
- <div>
211
- <b-button @click="show = !show" class="mb-2">Toggle display</b-button>
212
- <p>Visible: {{ isVisible }}</p>
213
- <div class="border p-3" style="height: 6em;">
214
- <!-- We use Vue's `v-show` directive to control the CSS `display` of the div -->
215
- <div v-show="show" class="bg-info p-3">
216
- <b-badge v-b-visible="handleVisibility">Element with v-b-visible directive</b-badge>
217
- </div>
218
- </div>
219
- </div>
220
- </template>
221
-
222
- <script>
223
- export default {
224
- data() {
225
- return {
226
- show: true,
227
- isVisible: false
228
- }
229
- },
230
- methods: {
231
- handleVisibility(isVisible) {
232
- this.isVisible = isVisible
233
- }
234
- }
235
- }
236
- </script>
237
-
238
- <!-- v-b-visible-display.vue -->
239
- ```
240
-
241
- ## See also
242
-
243
- For more details on `IntersectionObserver`, refer to the
244
- [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@bootstrap-vue/v-b-visible",
3
- "version": "0.0.0",
4
- "meta": {
5
- "title": "Visible",
6
- "description": "The `v-b-visible` directive allows you to react when an element becomes visible in the viewport.",
7
- "directive": "VBVisible",
8
- "version": "2.1.0",
9
- "expression": [
10
- "Function"
11
- ],
12
- "modifiers": [
13
- {
14
- "name": "once",
15
- "description": "Only calls the callback once when the element becomes visible in the viewport"
16
- },
17
- {
18
- "name": "{###}",
19
- "pattern": "[0-9]+",
20
- "description": "An offset value in pixels (where `{###}` is the number of pixels) relative to the viewport, defaults to 0. Negative values allowed"
21
- }
22
- ]
23
- }
24
- }
@@ -1,194 +0,0 @@
1
- import { isVue3 } from '../vue'
2
- import { mount } from '@vue/test-utils'
3
- import { attrsMixin } from './attrs'
4
-
5
- // Note: The following tests indirectly test `utils/cache`
6
-
7
- describe('mixins > attrs', () => {
8
- it('works', async () => {
9
- const BTest = {
10
- name: 'BTest',
11
- mixins: [attrsMixin],
12
- inheritAttrs: false,
13
- render(h) {
14
- return h('section', [h('article', { attrs: this.bvAttrs })])
15
- }
16
- }
17
- const App = {
18
- name: 'App',
19
- props: {
20
- attrs: {
21
- type: Object,
22
- default: () => ({})
23
- }
24
- },
25
- render(h) {
26
- return h(BTest, { attrs: this.attrs })
27
- }
28
- }
29
-
30
- const wrapper = mount(App)
31
-
32
- expect(wrapper).toBeDefined()
33
- expect(wrapper.vm).toBeDefined()
34
- expect(wrapper.element.tagName).toBe('SECTION')
35
-
36
- const $test = wrapper.findComponent(BTest)
37
-
38
- expect($test.exists()).toBe(true)
39
- expect($test.vm).toBeDefined()
40
-
41
- const $section = $test.find('section')
42
- expect($section.exists()).toBe(true)
43
-
44
- const $article = $test.find('article')
45
- expect($article.exists()).toBe(true)
46
-
47
- expect($section.attributes()).toEqual({})
48
- expect($article.attributes()).toEqual({})
49
-
50
- expect($test.vm.bvAttrs).toBeDefined()
51
- expect($test.vm.bvAttrs.foo).toBeUndefined()
52
- expect($test.vm.bvAttrs.baz).toBeUndefined()
53
-
54
- // Correctly adds new attrs data
55
- await wrapper.setProps({
56
- attrs: { foo: 'bar' }
57
- })
58
-
59
- expect($section.attributes()).toEqual({})
60
- expect($article.attributes()).toEqual({ foo: 'bar' })
61
- expect($test.vm.bvAttrs.foo).toEqual('bar')
62
- expect($test.vm.bvAttrs.baz).toBeUndefined()
63
-
64
- // Correctly updates attrs data
65
- await wrapper.setProps({
66
- attrs: { foo: 'bar', baz: 'biz' }
67
- })
68
-
69
- expect($section.attributes()).toEqual({})
70
- expect($article.attributes()).toEqual({ foo: 'bar', baz: 'biz' })
71
- expect($test.vm.bvAttrs.foo).toEqual('bar')
72
- expect($test.vm.bvAttrs.baz).toEqual('biz')
73
-
74
- // Correctly removes attrs data
75
- await wrapper.setProps({
76
- attrs: { foo: 'bar' }
77
- })
78
-
79
- expect($section.attributes()).toEqual({})
80
- expect($article.attributes()).toEqual({ foo: 'bar' })
81
- expect($test.vm.bvAttrs.foo).toEqual('bar')
82
- expect($test.vm.bvAttrs.baz).toBeUndefined()
83
-
84
- // Correctly removes all attrs data
85
- await wrapper.setProps({ attrs: {} })
86
-
87
- expect($section.attributes()).toEqual({})
88
- expect($article.attributes()).toEqual({})
89
- expect($test.vm.bvAttrs.foo).toBeUndefined()
90
- expect($test.vm.bvAttrs.baz).toBeUndefined()
91
-
92
- wrapper.destroy()
93
- })
94
-
95
- it('does not re-render parent child components', async () => {
96
- let input1RenderCount = 0
97
- let input2RenderCount = 0
98
-
99
- const Input1 = {
100
- props: ['value'],
101
- render(h) {
102
- input1RenderCount++
103
- return h('input', {
104
- attrs: { ...this.$attrs, value: this.value },
105
- domProps: { value: this.value },
106
- on: { input: e => this.$emit('input', e.target.value) }
107
- })
108
- }
109
- }
110
- const Input2 = {
111
- props: ['value'],
112
- mixins: [attrsMixin],
113
- render(h) {
114
- input2RenderCount++
115
- return h('input', {
116
- attrs: { ...this.bvAttrs, value: this.value },
117
- domProps: { value: this.value },
118
- on: { input: e => this.$emit('input', e.target.value) }
119
- })
120
- }
121
- }
122
-
123
- const App1 = {
124
- components: { Input1 },
125
- props: ['value1', 'value2'],
126
- template: `<div>
127
- <Input1 v-model="value1" />
128
- <Input1 v-model="value2" />
129
- </div>`
130
- }
131
- const App2 = {
132
- components: { Input2 },
133
- props: ['value1', 'value2'],
134
- template: `<div>
135
- <Input2 v-model="value1" />
136
- <Input2 v-model="value2" />
137
- </div>`
138
- }
139
-
140
- const wrapper1 = mount(App1)
141
- const wrapper2 = mount(App2)
142
-
143
- const $inputs1 = wrapper1.findAllComponents(Input1)
144
- expect($inputs1.length).toBe(2)
145
- expect($inputs1.at(0)).toBeDefined()
146
- expect($inputs1.at(0).vm.value).toBe(undefined)
147
- expect($inputs1.at(1)).toBeDefined()
148
- expect($inputs1.at(1).vm.value).toBe(undefined)
149
- expect(input1RenderCount).toBe(2)
150
-
151
- const $inputs2 = wrapper2.findAllComponents(Input2)
152
- expect($inputs2.length).toBe(2)
153
- expect($inputs2.at(0)).toBeDefined()
154
- expect($inputs2.at(0).vm.value).toBe(undefined)
155
- expect($inputs2.at(1)).toBeDefined()
156
- expect($inputs2.at(1).vm.value).toBe(undefined)
157
- expect(input2RenderCount).toBe(2)
158
-
159
- // Update the value for the first `Input1`
160
- await wrapper1.setProps({ value1: 'foo' })
161
- expect($inputs1.at(0).vm.value).toBe('foo')
162
- expect($inputs1.at(1).vm.value).toBe(undefined)
163
- if (!isVue3) {
164
- // Both `Input1`'s are re-rendered (See: https://github.com/vuejs/vue/issues/7257)
165
- expect(input1RenderCount).toBe(4)
166
- }
167
-
168
- // Update the value for the second `Input1`
169
- await wrapper1.setProps({ value2: 'bar' })
170
- expect($inputs1.at(0).vm.value).toBe('foo')
171
- expect($inputs1.at(1).vm.value).toBe('bar')
172
- if (!isVue3) {
173
- // Both `Input1`'s are re-rendered (See: https://github.com/vuejs/vue/issues/7257)
174
- expect(input1RenderCount).toBe(6)
175
- }
176
-
177
- // Update the value for the first `Input2`
178
- await wrapper2.setProps({ value1: 'foo' })
179
- expect($inputs2.at(0).vm.value).toBe('foo')
180
- expect($inputs2.at(1).vm.value).toBe(undefined)
181
- // With `attrsMixin` only the affected `Input2` is re-rendered
182
- expect(input2RenderCount).toBe(3)
183
-
184
- // Update the value for the second `Input2`
185
- await wrapper2.setProps({ value2: 'bar' })
186
- expect($inputs2.at(0).vm.value).toBe('foo')
187
- expect($inputs2.at(1).vm.value).toBe('bar')
188
- // With `attrsMixin` only the affected `Input2` is re-rendered
189
- expect(input2RenderCount).toBe(4)
190
-
191
- wrapper1.destroy()
192
- wrapper2.destroy()
193
- })
194
- })
@@ -1,52 +0,0 @@
1
- import { mount } from '@vue/test-utils'
2
- import { waitNT } from '../../tests/utils'
3
- import { clickOutMixin } from './click-out'
4
-
5
- describe('utils/click-out', () => {
6
- it('works', async () => {
7
- let count = 0
8
- const App = {
9
- mixins: [clickOutMixin],
10
- // `listenForClickOut` comes from the mixin data
11
- created() {
12
- this.listenForClickOut = true
13
- },
14
- methods: {
15
- clickOutHandler() {
16
- count++
17
- }
18
- },
19
- render(h) {
20
- return h('div', [h('button', 'button')])
21
- }
22
- }
23
-
24
- const wrapper = mount(App, {
25
- attachTo: document.body
26
- })
27
-
28
- const clickEvent = new MouseEvent('click')
29
-
30
- expect(wrapper).toBeDefined()
31
- expect(count).toBe(0)
32
- expect(wrapper.vm.listenForClickOut).toBe(true)
33
-
34
- // When `this.listenForClickOut` is `true`
35
- expect(count).toBe(0)
36
- await wrapper.find('button').trigger('click')
37
- expect(count).toBe(0)
38
- await wrapper.trigger('click')
39
- expect(count).toBe(0)
40
- document.dispatchEvent(clickEvent)
41
- await waitNT(wrapper.vm)
42
- expect(count).toBe(1)
43
-
44
- // When `this.listenForClickOut` is `false`
45
- await wrapper.setData({ listenForClickOut: false })
46
- document.dispatchEvent(clickEvent)
47
- await waitNT(wrapper.vm)
48
- expect(count).toBe(1)
49
-
50
- wrapper.destroy()
51
- })
52
- })