@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,279 +0,0 @@
1
- // Plugin for adding `$bvModal` property to all Vue instances
2
- import { NAME_MODAL, NAME_MSG_BOX } from '../../../constants/components'
3
- import {
4
- EVENT_NAME_HIDDEN,
5
- EVENT_NAME_HIDE,
6
- HOOK_EVENT_NAME_BEFORE_DESTROY,
7
- HOOK_EVENT_NAME_DESTROYED
8
- } from '../../../constants/events'
9
- import { useParentMixin } from '../../../mixins/use-parent'
10
- import { concat } from '../../../utils/array'
11
- import { getComponentConfig } from '../../../utils/config'
12
- import { requestAF } from '../../../utils/dom'
13
- import { getRootActionEventName } from '../../../utils/events'
14
- import { isUndefined, isFunction } from '../../../utils/inspect'
15
- import {
16
- assign,
17
- defineProperties,
18
- defineProperty,
19
- hasOwnProperty,
20
- keys,
21
- omit,
22
- readonlyDescriptor
23
- } from '../../../utils/object'
24
- import { pluginFactory } from '../../../utils/plugins'
25
- import { warn, warnNotClient, warnNoPromiseSupport } from '../../../utils/warn'
26
- import { createNewChildComponent } from '../../../utils/create-new-child-component'
27
- import { getEventRoot } from '../../../utils/get-event-root'
28
- import { BModal, props as modalProps } from '../modal'
29
-
30
- // --- Constants ---
31
-
32
- const PROP_NAME = '$bvModal'
33
- const PROP_NAME_PRIV = '_bv__modal'
34
-
35
- // Base modal props that are allowed
36
- // Some may be ignored or overridden on some message boxes
37
- // Prop ID is allowed, but really only should be used for testing
38
- // We need to add it in explicitly as it comes from the `idMixin`
39
- const BASE_PROPS = [
40
- 'id',
41
- ...keys(omit(modalProps, ['busy', 'lazy', 'noStacking', 'static', 'visible']))
42
- ]
43
-
44
- // Fallback event resolver (returns undefined)
45
- const defaultResolver = () => {}
46
-
47
- // Map prop names to modal slot names
48
- const propsToSlots = {
49
- msgBoxContent: 'default',
50
- title: 'modal-title',
51
- okTitle: 'modal-ok',
52
- cancelTitle: 'modal-cancel'
53
- }
54
-
55
- // --- Helper methods ---
56
-
57
- // Method to filter only recognized props that are not undefined
58
- const filterOptions = options => {
59
- return BASE_PROPS.reduce((memo, key) => {
60
- if (!isUndefined(options[key])) {
61
- memo[key] = options[key]
62
- }
63
- return memo
64
- }, {})
65
- }
66
-
67
- // Method to install `$bvModal` VM injection
68
- const plugin = Vue => {
69
- // Create a private sub-component that extends BModal
70
- // which self-destructs after hidden
71
- // @vue/component
72
- const BMsgBox = Vue.extend({
73
- name: NAME_MSG_BOX,
74
- extends: BModal,
75
- mixins: [useParentMixin],
76
- destroyed() {
77
- // Make sure we not in document any more
78
- if (this.$el && this.$el.parentNode) {
79
- this.$el.parentNode.removeChild(this.$el)
80
- }
81
- },
82
- mounted() {
83
- // Self destruct handler
84
- const handleDestroy = () => {
85
- this.$nextTick(() => {
86
- // In a `requestAF()` to release control back to application
87
- requestAF(() => {
88
- this.$destroy()
89
- })
90
- })
91
- }
92
- // Self destruct if parent destroyed
93
- this.bvParent.$once(HOOK_EVENT_NAME_DESTROYED, handleDestroy)
94
- // Self destruct after hidden
95
- this.$once(EVENT_NAME_HIDDEN, handleDestroy)
96
- // Self destruct on route change
97
- /* istanbul ignore if */
98
- if (this.$router && this.$route) {
99
- // Destroy ourselves if route changes
100
- /* istanbul ignore next */
101
- this.$once(HOOK_EVENT_NAME_BEFORE_DESTROY, this.$watch('$router', handleDestroy))
102
- }
103
- // Show the `BMsgBox`
104
- this.show()
105
- }
106
- })
107
-
108
- // Method to generate the on-demand modal message box
109
- // Returns a promise that resolves to a value returned by the resolve
110
- const asyncMsgBox = (parent, props, resolver = defaultResolver) => {
111
- if (warnNotClient(PROP_NAME) || warnNoPromiseSupport(PROP_NAME)) {
112
- /* istanbul ignore next */
113
- return
114
- }
115
- // Create an instance of `BMsgBox` component
116
- // We set parent as the local VM so these modals can emit events on
117
- // the app `$root`, as needed by things like tooltips and popovers
118
- // And it helps to ensure `BMsgBox` is destroyed when parent is destroyed
119
- const msgBox = createNewChildComponent(parent, BMsgBox, {
120
- // Preset the prop values
121
- propsData: {
122
- ...filterOptions(getComponentConfig(NAME_MODAL)),
123
- // Defaults that user can override
124
- hideHeaderClose: true,
125
- hideHeader: !(props.title || props.titleHtml),
126
- // Add in (filtered) user supplied props
127
- ...omit(props, keys(propsToSlots)),
128
- // Props that can't be overridden
129
- lazy: false,
130
- busy: false,
131
- visible: false,
132
- noStacking: false,
133
- noEnforceFocus: false
134
- }
135
- })
136
- // Convert certain props to scoped slots
137
- keys(propsToSlots).forEach(prop => {
138
- if (!isUndefined(props[prop])) {
139
- // Can be a string, or array of VNodes.
140
- // Alternatively, user can use HTML version of prop to pass an HTML string.
141
- msgBox.$slots[propsToSlots[prop]] = concat(props[prop])
142
- }
143
- })
144
- // Return a promise that resolves when hidden, or rejects on destroyed
145
- return new Promise((resolve, reject) => {
146
- let resolved = false
147
- msgBox.$once(HOOK_EVENT_NAME_DESTROYED, () => {
148
- if (!resolved) {
149
- /* istanbul ignore next */
150
- reject(new Error('BootstrapVue MsgBox destroyed before resolve'))
151
- }
152
- })
153
- msgBox.$on(EVENT_NAME_HIDE, bvModalEvent => {
154
- if (!bvModalEvent.defaultPrevented) {
155
- const result = resolver(bvModalEvent)
156
- // If resolver didn't cancel hide, we resolve
157
- if (!bvModalEvent.defaultPrevented) {
158
- resolved = true
159
- resolve(result)
160
- }
161
- }
162
- })
163
- // Create a mount point (a DIV) and mount the msgBo which will trigger it to show
164
- const div = document.createElement('div')
165
- document.body.appendChild(div)
166
- msgBox.$mount(div)
167
- })
168
- }
169
-
170
- // Private utility method to open a user defined message box and returns a promise.
171
- // Not to be used directly by consumers, as this method may change calling syntax
172
- const makeMsgBox = (parent, content, options = {}, resolver = null) => {
173
- if (
174
- !content ||
175
- warnNoPromiseSupport(PROP_NAME) ||
176
- warnNotClient(PROP_NAME) ||
177
- !isFunction(resolver)
178
- ) {
179
- /* istanbul ignore next */
180
- return
181
- }
182
- return asyncMsgBox(parent, { ...filterOptions(options), msgBoxContent: content }, resolver)
183
- }
184
-
185
- // BvModal instance class
186
- class BvModal {
187
- constructor(vm) {
188
- // Assign the new properties to this instance
189
- assign(this, { _vm: vm, _root: getEventRoot(vm) })
190
- // Set these properties as read-only and non-enumerable
191
- defineProperties(this, {
192
- _vm: readonlyDescriptor(),
193
- _root: readonlyDescriptor()
194
- })
195
- }
196
-
197
- // --- Instance methods ---
198
-
199
- // Show modal with the specified ID args are for future use
200
- show(id, ...args) {
201
- if (id && this._root) {
202
- this._root.$emit(getRootActionEventName(NAME_MODAL, 'show'), id, ...args)
203
- }
204
- }
205
-
206
- // Hide modal with the specified ID args are for future use
207
- hide(id, ...args) {
208
- if (id && this._root) {
209
- this._root.$emit(getRootActionEventName(NAME_MODAL, 'hide'), id, ...args)
210
- }
211
- }
212
-
213
- // The following methods require Promise support!
214
- // IE 11 and others do not support Promise natively, so users
215
- // should have a Polyfill loaded (which they need anyways for IE 11 support)
216
-
217
- // Open a message box with OK button only and returns a promise
218
- msgBoxOk(message, options = {}) {
219
- // Pick the modal props we support from options
220
- const props = {
221
- ...options,
222
- // Add in overrides and our content prop
223
- okOnly: true,
224
- okDisabled: false,
225
- hideFooter: false,
226
- msgBoxContent: message
227
- }
228
- return makeMsgBox(this._vm, message, props, () => {
229
- // Always resolve to true for OK
230
- return true
231
- })
232
- }
233
-
234
- // Open a message box modal with OK and CANCEL buttons
235
- // and returns a promise
236
- msgBoxConfirm(message, options = {}) {
237
- // Set the modal props we support from options
238
- const props = {
239
- ...options,
240
- // Add in overrides and our content prop
241
- okOnly: false,
242
- okDisabled: false,
243
- cancelDisabled: false,
244
- hideFooter: false
245
- }
246
- return makeMsgBox(this._vm, message, props, bvModalEvent => {
247
- const trigger = bvModalEvent.trigger
248
- return trigger === 'ok' ? true : trigger === 'cancel' ? false : null
249
- })
250
- }
251
- }
252
-
253
- // Add our instance mixin
254
- Vue.mixin({
255
- beforeCreate() {
256
- // Because we need access to `$root` for `$emits`, and VM for parenting,
257
- // we have to create a fresh instance of `BvModal` for each VM
258
- this[PROP_NAME_PRIV] = new BvModal(this)
259
- }
260
- })
261
-
262
- // Define our read-only `$bvModal` instance property
263
- // Placed in an if just in case in HMR mode
264
- if (!hasOwnProperty(Vue.prototype, PROP_NAME)) {
265
- defineProperty(Vue.prototype, PROP_NAME, {
266
- get() {
267
- /* istanbul ignore next */
268
- if (!this || !this[PROP_NAME_PRIV]) {
269
- warn(`"${PROP_NAME}" must be accessed from a Vue instance "this" context.`, NAME_MODAL)
270
- }
271
- return this[PROP_NAME_PRIV]
272
- }
273
- })
274
- }
275
- }
276
-
277
- export const BVModalPlugin = /*#__PURE__*/ pluginFactory({
278
- plugins: { plugin }
279
- })
@@ -1,178 +0,0 @@
1
- import { Vue } from '../../../vue'
2
- import { createWrapper, mount } from '@vue/test-utils'
3
- import { waitNT, waitRAF } from '../../../../tests/utils'
4
- import { ModalPlugin } from '../index'
5
-
6
- Vue.use(ModalPlugin)
7
-
8
- describe('$bvModal', () => {
9
- it('$bvModal.show() and $bvModal.hide() works', async () => {
10
- const App = {
11
- render(h) {
12
- return h('b-modal', { props: { static: true, id: 'test1' } }, 'content')
13
- }
14
- }
15
- const wrapper = mount(App, {
16
- attachTo: document.body
17
- })
18
-
19
- expect(wrapper.vm).toBeDefined()
20
-
21
- await waitNT(wrapper.vm)
22
- await waitRAF()
23
-
24
- expect(wrapper.vm.$bvModal).toBeDefined()
25
- expect(wrapper.vm.$bvModal.show).toBeDefined()
26
- expect(typeof wrapper.vm.$bvModal.show).toEqual('function')
27
- expect(wrapper.vm.$bvModal.hide).toBeDefined()
28
- expect(typeof wrapper.vm.$bvModal.hide).toEqual('function')
29
-
30
- const $modal = wrapper.find('.modal')
31
- expect($modal.exists()).toBe(true)
32
-
33
- expect($modal.element.style.display).toEqual('none')
34
-
35
- wrapper.vm.$bvModal.show('test1')
36
-
37
- await waitNT(wrapper.vm)
38
- await waitRAF()
39
- await waitNT(wrapper.vm)
40
- await waitRAF()
41
-
42
- expect($modal.element.style.display).not.toEqual('none')
43
-
44
- wrapper.vm.$bvModal.hide('test1')
45
-
46
- await waitNT(wrapper.vm)
47
- await waitRAF()
48
- await waitNT(wrapper.vm)
49
- await waitRAF()
50
-
51
- expect($modal.element.style.display).toEqual('none')
52
-
53
- wrapper.destroy()
54
- })
55
-
56
- it('$bvModal.msgBoxOk() works', async () => {
57
- const App = {
58
- render(h) {
59
- return h('div', 'app')
60
- }
61
- }
62
- const wrapper = mount(App, {
63
- attachTo: document.body
64
- })
65
-
66
- expect(wrapper.vm).toBeDefined()
67
-
68
- // `$bvModal.msgBoxOk`
69
- expect(wrapper.vm.$bvModal).toBeDefined()
70
- const bvModal = wrapper.vm.$bvModal
71
- expect(bvModal.msgBoxOk).toBeDefined()
72
-
73
- // Should get a promise as result
74
- const p = bvModal.msgBoxOk('message', {
75
- static: true,
76
- id: 'test2',
77
- title: 'title'
78
- })
79
- expect(p).toBeDefined()
80
- expect(p).toBeInstanceOf(Promise)
81
-
82
- await waitNT(wrapper.vm)
83
- await waitRAF()
84
- await waitNT(wrapper.vm)
85
- await waitRAF()
86
- await waitNT(wrapper.vm)
87
- await waitRAF()
88
-
89
- // Find the modal
90
- const modal = document.querySelector('#test2')
91
- expect(modal).toBeDefined()
92
- expect(modal).not.toEqual(null)
93
- const $modal = createWrapper(modal)
94
- expect($modal.element.tagName).toBe('DIV')
95
-
96
- // Find the OK button and click it
97
- expect($modal.findAll('button').length).toBe(1)
98
- const $button = $modal.find('button')
99
- expect($button.text()).toEqual('OK')
100
- await $button.trigger('click')
101
-
102
- // Promise should now resolve
103
- const result = await p
104
- expect(result).toEqual(true)
105
-
106
- await waitNT(wrapper.vm)
107
- await waitRAF()
108
- await waitNT(wrapper.vm)
109
- await waitRAF()
110
- await waitNT(wrapper.vm)
111
- await waitRAF()
112
-
113
- // Modal should be gone from DOM
114
- expect(document.querySelector('#test2')).toBe(null)
115
- })
116
-
117
- it('$bvModal.msgBoxConfirm() works', async () => {
118
- const App = {
119
- render(h) {
120
- return h('div', 'app')
121
- }
122
- }
123
- const wrapper = mount(App, {
124
- attachTo: document.body
125
- })
126
-
127
- expect(wrapper.vm).toBeDefined()
128
-
129
- // `$bvModal.msgBoxConfirm`
130
- expect(wrapper.vm.$bvModal).toBeDefined()
131
- const bvModal = wrapper.vm.$bvModal
132
- expect(bvModal.msgBoxConfirm).toBeDefined()
133
-
134
- // Should get a promise as result
135
- const p = bvModal.msgBoxConfirm('message', {
136
- static: true,
137
- id: 'test3',
138
- title: 'title'
139
- })
140
- expect(p).toBeDefined()
141
- expect(p).toBeInstanceOf(Promise)
142
-
143
- await waitNT(wrapper.vm)
144
- await waitRAF()
145
- await waitNT(wrapper.vm)
146
- await waitRAF()
147
- await waitNT(wrapper.vm)
148
- await waitRAF()
149
-
150
- // Find the modal
151
- const modal = document.querySelector('#test3')
152
- expect(modal).toBeDefined()
153
- expect(modal).not.toEqual(null)
154
- const $modal = createWrapper(modal)
155
- expect($modal.element.tagName).toBe('DIV')
156
-
157
- // Find the CANCEL button and click it
158
- expect($modal.findAll('button').length).toBe(2)
159
- const $buttons = $modal.findAll('button')
160
- expect($buttons.at(0).text()).toEqual('Cancel')
161
- expect($buttons.at(1).text()).toEqual('OK')
162
- await $buttons.at(0).trigger('click')
163
-
164
- // Promise should now resolve
165
- const result = await p
166
- expect(result).toEqual(false) // Cancel button
167
-
168
- await waitNT(wrapper.vm)
169
- await waitRAF()
170
- await waitNT(wrapper.vm)
171
- await waitRAF()
172
- await waitNT(wrapper.vm)
173
- await waitRAF()
174
-
175
- // Modal should be gone from DOM
176
- expect(document.querySelector('#test3')).toBe(null)
177
- })
178
- })
@@ -1,87 +0,0 @@
1
- # Hover
2
-
3
- > `v-b-hover` is a lightweight directive that allows you to react when an element either becomes
4
- > hovered or unhovered.
5
-
6
- ## Overview
7
-
8
- The `v-b-hover` directive can be used as an alternative to using custom CSS to handle hover states.
9
-
10
- - `v-b-hover` will call your callback method with a boolean value indicating if the element is
11
- hovered or not.
12
- - The directive can be placed on almost any element or component.
13
- - Internally, BootstrapVue uses this directive in several components.
14
-
15
- ## Directive syntax and usage
16
-
17
- ```html
18
- <div v-b-hover="callback">content</div>
19
- ```
20
-
21
- Where callback is required:
22
-
23
- - A function reference that will be called whenever hover state changes. The callback is passed a
24
- single boolean argument. `true` indicates that the element (or component) is hovered by the users
25
- pointing device, or `false` if the element is not hovered.
26
-
27
- The directive has no modifiers.
28
-
29
- ### Usage example
30
-
31
- ```html
32
- <template>
33
- <div v-b-hover="hoverHandler"> ... </div>
34
- </template>
35
-
36
- <script>
37
- export default {
38
- methods: {
39
- hoverHandler(isHovered) {
40
- if (isHovered) {
41
- // Do something
42
- } else {
43
- // Do something else
44
- }
45
- }
46
- }
47
- }
48
- </script>
49
- ```
50
-
51
- ## Live example
52
-
53
- In the following, we are swapping icons and text color depending on the hover state of the element:
54
-
55
- ```html
56
- <template>
57
- <div>
58
- <div v-b-hover="handleHover" class="border rounded py-3 px-4">
59
- <b-icon v-if="isHovered" icon="battery-full" scale="2"></b-icon>
60
- <b-icon v-else icon="battery" scale="2"></b-icon>
61
- <span class="ml-2" :class="isHovered ? 'text-danger' : ''">Hover this area</span>
62
- </div>
63
- </div>
64
- </template>
65
-
66
- <script>
67
- export default {
68
- data() {
69
- return {
70
- isHovered: false
71
- }
72
- },
73
- methods: {
74
- handleHover(hovered) {
75
- this.isHovered = hovered
76
- }
77
- }
78
- }
79
- </script>
80
-
81
- <!-- b-v-hover-example.vue -->
82
- ```
83
-
84
- ## Accessibility concerns
85
-
86
- Hover state should not be used to convey special meaning, as screen reader users and keyboard only
87
- users typically can not trigger hover state on elements.
@@ -1,54 +0,0 @@
1
- // v-b-hover directive
2
- import { IS_BROWSER } from '../../constants/env'
3
- import { EVENT_OPTIONS_NO_CAPTURE } from '../../constants/events'
4
- import { eventOnOff } from '../../utils/events'
5
- import { isFunction } from '../../utils/inspect'
6
-
7
- // --- Constants ---
8
-
9
- const PROP = '__BV_hover_handler__'
10
- const MOUSEENTER = 'mouseenter'
11
- const MOUSELEAVE = 'mouseleave'
12
-
13
- // --- Helper methods ---
14
-
15
- const createListener = handler => {
16
- const listener = event => {
17
- handler(event.type === MOUSEENTER, event)
18
- }
19
- listener.fn = handler
20
- return listener
21
- }
22
-
23
- const updateListeners = (on, el, listener) => {
24
- eventOnOff(on, el, MOUSEENTER, listener, EVENT_OPTIONS_NO_CAPTURE)
25
- eventOnOff(on, el, MOUSELEAVE, listener, EVENT_OPTIONS_NO_CAPTURE)
26
- }
27
-
28
- // --- Directive bind/unbind/update handler ---
29
-
30
- const directive = (el, { value: handler = null }) => {
31
- if (IS_BROWSER) {
32
- const listener = el[PROP]
33
- const hasListener = isFunction(listener)
34
- const handlerChanged = !(hasListener && listener.fn === handler)
35
- if (hasListener && handlerChanged) {
36
- updateListeners(false, el, listener)
37
- delete el[PROP]
38
- }
39
- if (isFunction(handler) && handlerChanged) {
40
- el[PROP] = createListener(handler)
41
- updateListeners(true, el, el[PROP])
42
- }
43
- }
44
- }
45
-
46
- // VBHover directive
47
-
48
- export const VBHover = {
49
- bind: directive,
50
- componentUpdated: directive,
51
- unbind(el) {
52
- directive(el, { value: null })
53
- }
54
- }
@@ -1,49 +0,0 @@
1
- import { mount } from '@vue/test-utils'
2
- import { VBHover } from './hover'
3
-
4
- describe('v-b-hover directive', () => {
5
- it('works', async () => {
6
- let hovered1 = false
7
- let hovered2 = false
8
- const App = {
9
- data() {
10
- return {
11
- text: 'FOO',
12
- changeHandler: false
13
- }
14
- },
15
- directives: {
16
- BHover: VBHover
17
- },
18
- methods: {
19
- handleHover1(isHovered) {
20
- hovered1 = isHovered
21
- },
22
- handleHover2(isHovered) {
23
- hovered2 = isHovered
24
- }
25
- },
26
- template: `<div v-b-hover="changeHandler ? handleHover2 : handleHover1"><span>{{ text }}</span></div>`
27
- }
28
- const wrapper = mount(App)
29
-
30
- expect(wrapper.vm).toBeDefined()
31
- expect(hovered1).toBe(false)
32
-
33
- await wrapper.trigger('mouseenter')
34
- expect(hovered1).toBe(true)
35
-
36
- await wrapper.trigger('mouseleave')
37
- expect(hovered1).toBe(false)
38
-
39
- await wrapper.setData({ text: 'BAR' })
40
- await wrapper.trigger('mouseenter')
41
- expect(hovered1).toBe(true)
42
-
43
- await wrapper.setData({ changeHandler: true })
44
- await wrapper.trigger('mouseenter')
45
- expect(hovered2).toBe(true)
46
-
47
- wrapper.destroy()
48
- })
49
- })
@@ -1,11 +0,0 @@
1
- //
2
- // VBHover
3
- //
4
- import Vue, { DirectiveOptions } from 'vue'
5
- import { BvPlugin } from '../../'
6
-
7
- // Plugin
8
- export declare const VBHoverPlugin: BvPlugin
9
-
10
- // directive: v-b-hover
11
- export declare const VBHover: DirectiveOptions
@@ -1,8 +0,0 @@
1
- import { VBHover } from './hover'
2
- import { pluginFactory } from '../../utils/plugins'
3
-
4
- const VBHoverPlugin = /*#__PURE__*/ pluginFactory({
5
- directives: { VBHover }
6
- })
7
-
8
- export { VBHoverPlugin, VBHover }
@@ -1,13 +0,0 @@
1
- {
2
- "name": "@bootstrap-vue/v-b-hover",
3
- "version": "1.0.0",
4
- "meta": {
5
- "title": "Hover",
6
- "description": "A lightweight directive that allows you to react when an element either becomes hovered or unhovered",
7
- "directive": "VBHover",
8
- "version": "2.5.0",
9
- "expression": [
10
- "Function"
11
- ]
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import { BvPlugin } from '../'
2
-
3
- // Plugin that installs all plugins
4
- export declare const directivesPlugin: BvPlugin
5
-
6
- // Named exports of all directives
7
- export * from './hover'
8
- export * from './modal'
9
- export * from './popover'
10
- export * from './scrollspy'
11
- export * from './toggle'
12
- export * from './tooltip'
13
- export * from './visible'