@gitlab/ui 112.2.2 → 112.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 (182) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/bin/migrate_custom_utils_to_tw.bundled.mjs +209 -32
  3. package/dist/components/base/accordion/accordion.js +1 -1
  4. package/dist/components/base/accordion/accordion_item.js +1 -1
  5. package/dist/components/base/alert/alert.js +1 -1
  6. package/dist/components/base/animated_icon/animated_chevron_down_up_icon.js +1 -1
  7. package/dist/components/base/animated_icon/animated_chevron_lg_down_up_icon.js +1 -1
  8. package/dist/components/base/animated_icon/animated_chevron_lg_right_down_icon.js +1 -1
  9. package/dist/components/base/animated_icon/animated_chevron_right_down_icon.js +1 -1
  10. package/dist/components/base/animated_icon/animated_duo_chat_icon.js +1 -1
  11. package/dist/components/base/animated_icon/animated_loader_icon.js +1 -1
  12. package/dist/components/base/animated_icon/animated_notifications_icon.js +1 -1
  13. package/dist/components/base/animated_icon/animated_sidebar_icon.js +1 -1
  14. package/dist/components/base/animated_icon/animated_smile_icon.js +1 -1
  15. package/dist/components/base/animated_icon/animated_sort_icon.js +1 -1
  16. package/dist/components/base/animated_icon/animated_star_icon.js +1 -1
  17. package/dist/components/base/animated_icon/animated_todo_icon.js +1 -1
  18. package/dist/components/base/animated_icon/animated_upload_icon.js +1 -1
  19. package/dist/components/base/animated_icon/base_animated_icon.js +1 -1
  20. package/dist/components/base/avatar/avatar.js +1 -1
  21. package/dist/components/base/avatar_labeled/avatar_labeled.js +1 -1
  22. package/dist/components/base/avatar_link/avatar_link.js +1 -1
  23. package/dist/components/base/avatars_inline/avatars_inline.js +1 -1
  24. package/dist/components/base/badge/badge.js +1 -1
  25. package/dist/components/base/banner/banner.js +1 -1
  26. package/dist/components/base/breadcrumb/breadcrumb.js +1 -1
  27. package/dist/components/base/breadcrumb/breadcrumb_item.js +1 -1
  28. package/dist/components/base/broadcast_message/broadcast_message.js +1 -1
  29. package/dist/components/base/button/button.js +1 -1
  30. package/dist/components/base/button_group/button_group.js +1 -1
  31. package/dist/components/base/card/card.js +1 -1
  32. package/dist/components/base/collapse/collapse.js +1 -1
  33. package/dist/components/base/datepicker/datepicker.js +1 -2
  34. package/dist/components/base/daterange_picker/daterange_picker.js +1 -1
  35. package/dist/components/base/drawer/drawer.js +1 -1
  36. package/dist/components/base/dropdown/dropdown.js +1 -2
  37. package/dist/components/base/dropdown/dropdown_divider.js +1 -1
  38. package/dist/components/base/dropdown/dropdown_form.js +1 -1
  39. package/dist/components/base/dropdown/dropdown_item.js +1 -1
  40. package/dist/components/base/dropdown/dropdown_section_header.js +1 -1
  41. package/dist/components/base/dropdown/dropdown_text.js +1 -1
  42. package/dist/components/base/filtered_search/filtered_search.js +2 -2
  43. package/dist/components/base/filtered_search/filtered_search_suggestion.js +1 -1
  44. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +1 -1
  45. package/dist/components/base/filtered_search/filtered_search_term.js +1 -1
  46. package/dist/components/base/filtered_search/filtered_search_token.js +1 -1
  47. package/dist/components/base/filtered_search/filtered_search_token_segment.js +1 -1
  48. package/dist/components/base/form/form.js +1 -1
  49. package/dist/components/base/form/form_character_count/form_character_count.js +1 -1
  50. package/dist/components/base/form/form_checkbox/form_checkbox.js +1 -1
  51. package/dist/components/base/form/form_checkbox/form_checkbox_group.js +1 -1
  52. package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +1 -1
  53. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +1 -1
  54. package/dist/components/base/form/form_combobox/form_combobox.js +1 -1
  55. package/dist/components/base/form/form_date/form_date.js +1 -1
  56. package/dist/components/base/form/form_fields/form_field_validator.js +1 -1
  57. package/dist/components/base/form/form_fields/form_fields.js +1 -1
  58. package/dist/components/base/form/form_group/form_group.js +1 -1
  59. package/dist/components/base/form/form_input/form_input.js +1 -1
  60. package/dist/components/base/form/form_input_group/form_input_group.js +1 -1
  61. package/dist/components/base/form/form_radio/form_radio.js +1 -1
  62. package/dist/components/base/form/form_radio_group/form_radio_group.js +1 -1
  63. package/dist/components/base/form/form_select/form_select.js +1 -1
  64. package/dist/components/base/form/form_textarea/form_textarea.js +1 -1
  65. package/dist/components/base/form/input_group_text/input_group_text.js +1 -1
  66. package/dist/components/base/icon/icon.js +1 -1
  67. package/dist/components/base/infinite_scroll/infinite_scroll.js +1 -2
  68. package/dist/components/base/keyset_pagination/keyset_pagination.js +1 -1
  69. package/dist/components/base/label/label.js +1 -1
  70. package/dist/components/base/link/link.js +1 -1
  71. package/dist/components/base/loading_icon/loading_icon.js +1 -1
  72. package/dist/components/base/markdown/markdown.js +1 -1
  73. package/dist/components/base/modal/modal.js +1 -1
  74. package/dist/components/base/nav/nav.js +90 -6
  75. package/dist/components/base/nav/nav_item.js +1 -1
  76. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +1 -2
  77. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +1 -2
  78. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +1 -2
  79. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +1 -2
  80. package/dist/components/base/new_dropdowns/listbox/listbox.js +1 -2
  81. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +1 -1
  82. package/dist/components/base/new_dropdowns/listbox/listbox_item.js +1 -1
  83. package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +1 -1
  84. package/dist/components/base/pagination/pagination.js +1 -1
  85. package/dist/components/base/path/path.js +1 -1
  86. package/dist/components/base/popover/popover.js +1 -1
  87. package/dist/components/base/progress_bar/progress_bar.js +1 -1
  88. package/dist/components/base/search_box_by_click/search_box_by_click.js +2 -2
  89. package/dist/components/base/search_box_by_type/search_box_by_type.js +1 -1
  90. package/dist/components/base/segmented_control/segmented_control.js +1 -1
  91. package/dist/components/base/skeleton_loader/skeleton_loader.js +1 -1
  92. package/dist/components/base/sorting/sorting.js +1 -1
  93. package/dist/components/base/table/table.js +2 -2
  94. package/dist/components/base/table_lite/table_lite.js +1 -1
  95. package/dist/components/base/tabs/tab/tab.js +1 -1
  96. package/dist/components/base/tabs/tabs/scrollable_tabs.js +1 -1
  97. package/dist/components/base/tabs/tabs/tabs.js +1 -1
  98. package/dist/components/base/toast/toast.js +1 -1
  99. package/dist/components/base/toggle/toggle.js +1 -1
  100. package/dist/components/base/token/token.js +1 -1
  101. package/dist/components/base/token_selector/token_container.js +1 -1
  102. package/dist/components/base/token_selector/token_selector.js +1 -1
  103. package/dist/components/base/token_selector/token_selector_dropdown.js +1 -1
  104. package/dist/components/base/tooltip/tooltip.js +1 -1
  105. package/dist/components/charts/area/area.js +1 -1
  106. package/dist/components/charts/bar/bar.js +1 -1
  107. package/dist/components/charts/chart/chart.js +1 -1
  108. package/dist/components/charts/column/column.js +1 -1
  109. package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -1
  110. package/dist/components/charts/gauge/gauge.js +2 -2
  111. package/dist/components/charts/heatmap/heatmap.js +1 -1
  112. package/dist/components/charts/legend/legend.js +1 -1
  113. package/dist/components/charts/line/line.js +1 -1
  114. package/dist/components/charts/series_label/series_label.js +1 -1
  115. package/dist/components/charts/shared/tooltip/tooltip.js +1 -1
  116. package/dist/components/charts/shared/tooltip/tooltip_default_format/tooltip_default_format.js +1 -1
  117. package/dist/components/charts/single_stat/single_stat.js +1 -1
  118. package/dist/components/charts/sparkline/sparkline.js +1 -1
  119. package/dist/components/charts/stacked_column/stacked_column.js +1 -1
  120. package/dist/components/dashboards/dashboard_panel/dashboard_panel.js +1 -1
  121. package/dist/components/experimental/experiment_badge/experiment_badge.js +1 -2
  122. package/dist/components/mixins/tooltip_mixin.js +1 -1
  123. package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +1 -1
  124. package/dist/components/regions/empty_state/empty_state.js +1 -1
  125. package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +1 -1
  126. package/dist/components/shared_components/close_button/close_button.js +1 -1
  127. package/dist/components/utilities/animated_number/animated_number.js +1 -1
  128. package/dist/components/utilities/friendly_wrap/friendly_wrap.js +1 -1
  129. package/dist/components/utilities/intersection_observer/intersection_observer.js +1 -1
  130. package/dist/components/utilities/intersperse/intersperse.js +1 -1
  131. package/dist/components/utilities/sprintf/sprintf.js +1 -1
  132. package/dist/components/utilities/truncate/truncate.js +1 -1
  133. package/dist/components/utilities/truncate_text/truncate_text.js +1 -1
  134. package/dist/config.js +1 -2
  135. package/dist/index.css +2 -2
  136. package/dist/index.css.map +1 -1
  137. package/dist/tailwind.css +1 -1
  138. package/dist/tokens/build/js/tokens.dark.js +80 -80
  139. package/dist/tokens/build/js/tokens.js +179 -179
  140. package/dist/tokens/css/tokens.css +50 -50
  141. package/dist/tokens/css/tokens.dark.css +25 -25
  142. package/dist/tokens/js/tokens.dark.js +80 -80
  143. package/dist/tokens/js/tokens.js +179 -179
  144. package/dist/tokens/json/tokens.dark.json +130 -130
  145. package/dist/tokens/json/tokens.json +229 -229
  146. package/dist/tokens/scss/_tokens.dark.scss +25 -25
  147. package/dist/tokens/scss/_tokens.scss +50 -50
  148. package/dist/tokens/tailwind/tokens.cjs +47 -47
  149. package/dist/tokens/tokens_story.js +1 -1
  150. package/dist/tokens/tokens_table.js +1 -1
  151. package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -3
  152. package/dist/vendor/bootstrap-vue/src/utils/cache.js +1 -1
  153. package/dist/vendor/bootstrap-vue/src/utils/props.js +1 -1
  154. package/dist/vendor/bootstrap-vue/src/utils/router.js +1 -1
  155. package/package.json +2 -2
  156. package/src/components/base/nav/nav.md +182 -4
  157. package/src/components/base/nav/nav.vue +60 -7
  158. package/src/components/base/search_box_by_click/search_box_by_click.vue +9 -3
  159. package/src/tokens/build/css/tokens.css +50 -50
  160. package/src/tokens/build/css/tokens.dark.css +25 -25
  161. package/src/tokens/build/figma/constants.tokens.json +25 -25
  162. package/src/tokens/build/figma/deprecated.tokens.json +25 -25
  163. package/src/tokens/build/js/tokens.dark.js +80 -80
  164. package/src/tokens/build/js/tokens.js +179 -179
  165. package/src/tokens/build/json/tokens.dark.json +130 -130
  166. package/src/tokens/build/json/tokens.json +229 -229
  167. package/src/tokens/build/scss/_tokens.dark.scss +25 -25
  168. package/src/tokens/build/scss/_tokens.scss +50 -50
  169. package/src/tokens/build/tailwind/tokens.cjs +47 -47
  170. package/src/tokens/constant/color.tokens.json +25 -25
  171. package/src/tokens/deprecated/deprecated.color.tokens.json +25 -25
  172. package/src/vendor/bootstrap-vue/src/constants/components.js +0 -2
  173. package/dist/vendor/bootstrap-vue/src/components/collapse/collapse.js +0 -207
  174. package/dist/vendor/bootstrap-vue/src/components/collapse/helpers/bv-collapse.js +0 -90
  175. package/dist/vendor/bootstrap-vue/src/components/collapse/index.js +0 -1
  176. package/src/vendor/bootstrap-vue/src/components/collapse/MODIFICATIONS.md +0 -14
  177. package/src/vendor/bootstrap-vue/src/components/collapse/README.md +0 -321
  178. package/src/vendor/bootstrap-vue/src/components/collapse/collapse.js +0 -207
  179. package/src/vendor/bootstrap-vue/src/components/collapse/collapse.spec.js +0 -426
  180. package/src/vendor/bootstrap-vue/src/components/collapse/helpers/bv-collapse.js +0 -88
  181. package/src/vendor/bootstrap-vue/src/components/collapse/index.js +0 -3
  182. package/src/vendor/bootstrap-vue/src/components/collapse/package.json +0 -104
@@ -1,321 +0,0 @@
1
- # Collapse
2
-
3
- > Easily toggle visibility of almost any content on your pages in a vertically collapsing container.
4
- > Includes support for making accordions. Visibility can be easily toggled with our
5
- > [`v-b-toggle` directive](/docs/directives/toggle), or via `v-model`.
6
-
7
- ```html
8
- <div>
9
- <b-button v-b-toggle.collapse-1 variant="primary">Toggle Collapse</b-button>
10
- <b-collapse id="collapse-1" class="mt-2">
11
- <b-card>
12
- <p class="card-text">Collapse contents Here</p>
13
- <b-button v-b-toggle.collapse-1-inner size="sm">Toggle Inner Collapse</b-button>
14
- <b-collapse id="collapse-1-inner" class="mt-2">
15
- <b-card>Hello!</b-card>
16
- </b-collapse>
17
- </b-card>
18
- </b-collapse>
19
- </div>
20
-
21
- <!-- b-collapse.vue -->
22
- ```
23
-
24
- ## Usage
25
-
26
- Other elements can easily toggle `<b-collapse>` components using the
27
- [`v-b-toggle` directive](/docs/directives/toggle).
28
-
29
- ```html
30
- <div>
31
- <!-- Using modifiers -->
32
- <b-button v-b-toggle.collapse-2 class="m-1">Toggle Collapse</b-button>
33
-
34
- <!-- Using value -->
35
- <b-button v-b-toggle="'collapse-2'" class="m-1">Toggle Collapse</b-button>
36
-
37
- <!-- Element to collapse -->
38
- <b-collapse id="collapse-2">
39
- <b-card>I am collapsible content!</b-card>
40
- </b-collapse>
41
- </div>
42
-
43
- <!-- b-collapse-usage.vue -->
44
- ```
45
-
46
- See the [`v-b-toggle` directive documentation](/docs/directives/toggle) for detailed usage
47
- information.
48
-
49
- ## Initial visibility (start expanded)
50
-
51
- To make the `<b-collapse>` show initially, set the `visible` prop:
52
-
53
- ```html
54
- <div>
55
- <b-button v-b-toggle.collapse-3 class="m-1">Toggle Collapse</b-button>
56
- <b-collapse visible id="collapse-3">
57
- <b-card>I should start open!</b-card>
58
- </b-collapse>
59
- </div>
60
-
61
- <!-- b-collapse-visible.vue -->
62
- ```
63
-
64
- By default, an initially visible collapse will not animate on mount. To enable the collapse
65
- expanding animation on mount (when `visible` or `v-model` is `true`), set the `appear` prop on
66
- `<b-collapse>`.
67
-
68
- ## `v-model` support
69
-
70
- The component's collapsed (visible) state can also be set with `v-model` which binds internally to
71
- the `visible` prop.
72
-
73
- Note, when using `v-model` to control `<b-collapse>`, the `aria-*` attributes and class `collapsed`
74
- are not automatically placed on the trigger button (as is the case when using the `v-b-toggle`
75
- directive). In this example we **must control the attributes ourselves** for proper accessibility
76
- support.
77
-
78
- ```html
79
- <template>
80
- <div>
81
- <b-button
82
- :class="visible ? null : 'collapsed'"
83
- :aria-expanded="visible ? 'true' : 'false'"
84
- aria-controls="collapse-4"
85
- @click="visible = !visible"
86
- >
87
- Toggle Collapse
88
- </b-button>
89
- <b-collapse id="collapse-4" v-model="visible" class="mt-2">
90
- <b-card>I should start open!</b-card>
91
- </b-collapse>
92
- </div>
93
- </template>
94
-
95
- <script>
96
- export default {
97
- data() {
98
- return {
99
- visible: true
100
- }
101
- }
102
- }
103
- </script>
104
-
105
- <!-- b-collapse-v-model.vue -->
106
- ```
107
-
108
- ## Trigger multiple collapse elements
109
-
110
- You can even collapse multiple `<b-collapse>` components via a single `v-b-toggle` by providing
111
- multiple target IDs using _modifiers_.
112
-
113
- You can also pass multiple target IDs via the directive _value_ in BootstrapVue release v2.14.0+.
114
-
115
- ```html
116
- <div>
117
- <!-- Via multiple directive modifiers -->
118
- <b-button v-b-toggle.collapse-a.collapse-b>Toggle Collapse A and B</b-button>
119
-
120
- <!-- Via space separated string of IDs passed to directive value -->
121
- <b-button v-b-toggle="'collapse-a collapse-b'">Toggle Collapse A and B</b-button>
122
-
123
- <!-- Via array of string IDs passed to directive value -->
124
- <b-button v-b-toggle="['collapse-a', 'collapse-b']">Toggle Collapse A and B</b-button>
125
-
126
- <!-- Elements to collapse -->
127
- <b-collapse id="collapse-a" class="mt-2">
128
- <b-card>I am collapsible content A!</b-card>
129
- </b-collapse>
130
- <b-collapse id="collapse-b" class="mt-2">
131
- <b-card>I am collapsible content B!</b-card>
132
- </b-collapse>
133
- </div>
134
-
135
- <!-- b-collapse-trigger-multiple.vue -->
136
- ```
137
-
138
- ## Accordion support
139
-
140
- Turn a group of `<b-collapse>` components into an accordion by supplying an accordion group
141
- identifier via the `accordion` prop. Note that only one collapse in an accordion group can be open
142
- at a time.
143
-
144
- ```html
145
- <template>
146
- <div class="accordion" role="tablist">
147
- <b-card no-body class="mb-1">
148
- <b-card-header header-tag="header" class="p-1" role="tab">
149
- <b-button block v-b-toggle.accordion-1 variant="info">Accordion 1</b-button>
150
- </b-card-header>
151
- <b-collapse id="accordion-1" visible accordion="my-accordion" role="tabpanel">
152
- <b-card-body>
153
- <b-card-text>I start opened because <code>visible</code> is <code>true</code></b-card-text>
154
- <b-card-text>{{ text }}</b-card-text>
155
- </b-card-body>
156
- </b-collapse>
157
- </b-card>
158
-
159
- <b-card no-body class="mb-1">
160
- <b-card-header header-tag="header" class="p-1" role="tab">
161
- <b-button block v-b-toggle.accordion-2 variant="info">Accordion 2</b-button>
162
- </b-card-header>
163
- <b-collapse id="accordion-2" accordion="my-accordion" role="tabpanel">
164
- <b-card-body>
165
- <b-card-text>{{ text }}</b-card-text>
166
- </b-card-body>
167
- </b-collapse>
168
- </b-card>
169
-
170
- <b-card no-body class="mb-1">
171
- <b-card-header header-tag="header" class="p-1" role="tab">
172
- <b-button block v-b-toggle.accordion-3 variant="info">Accordion 3</b-button>
173
- </b-card-header>
174
- <b-collapse id="accordion-3" accordion="my-accordion" role="tabpanel">
175
- <b-card-body>
176
- <b-card-text>{{ text }}</b-card-text>
177
- </b-card-body>
178
- </b-collapse>
179
- </b-card>
180
- </div>
181
- </template>
182
-
183
- <script>
184
- export default {
185
- data() {
186
- return {
187
- text: `
188
- Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry
189
- richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor
190
- brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon
191
- tempor, sunt aliqua put a bird on it squid single-origin coffee nulla
192
- assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore
193
- wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher
194
- vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic
195
- synth nesciunt you probably haven't heard of them accusamus labore VHS.
196
- `
197
- }
198
- }
199
- }
200
- </script>
201
-
202
- <!-- b-accordion.vue -->
203
- ```
204
-
205
- **Notes:**
206
-
207
- - When using accordion mode, make sure you place the trigger elements and `<b-collapse>` components
208
- inside an element with `role="tablist"` and set `role="tab"` on each trigger element's container
209
- (each trigger element should be wrapped) in order to help screen reader users navigate the
210
- accordion group.
211
- - If using the `v-model` feature of `<b-collapse>` in accordion mode, do not bind the `v-model` or
212
- `visible` prop of all the collapses in the accordion group to the same variable!
213
- - Ensure, at most, only one `<b-collapse>` in the accordion group has the `visible` prop and/or
214
- `v-model` set to `true`. Only one collapse in an accordion group can be open at a time.
215
-
216
- ## Hiding and showing content in the toggle button based on collapse state
217
-
218
- When using the `v-b-toggle` directive, the class `collapsed` will automatically be placed on the
219
- trigger element when the collapse is closed, and removed when open. You can use this class to
220
- display or hide content within the toggle via custom CSS. As of BootstrapVue 2.14.0, the class
221
- `not-collapsed` will be applied when the target(s) are not closed.
222
-
223
- **Example HTML markup:**
224
-
225
- ```html
226
- <div>
227
- <b-button v-b-toggle:my-collapse>
228
- <span class="when-open">Close</span><span class="when-closed">Open</span> My Collapse
229
- </b-button>
230
- <b-collapse id="my-collapse">
231
- <!-- Content here -->
232
- </b-collapse>
233
- </div>
234
- ```
235
-
236
- **Example Custom CSS:**
237
-
238
- ```css
239
- .collapsed > .when-open,
240
- .not-collapsed > .when-closed {
241
- display: none;
242
- }
243
- ```
244
-
245
- ## 'Global' \$root instance events
246
-
247
- Using `$root` instance it is possible to emit and listen events somewhere out of a component, where
248
- `<b-collapse>` is used. In short, `$root` behaves like a global event emitters and listener. Details
249
- about `$root` instance can be found in
250
- [the official Vue docs](https://vuejs.org/v2/guide/components-edge-cases.html#Accessing-the-Root-Instance).
251
-
252
- ### Listening to collapses state changes via \$root events
253
-
254
- To listen to any collapse state changes, use:
255
-
256
- ```js
257
- export default {
258
- mounted() {
259
- this.$root.$on('bv::collapse::state', (collapseId, isJustShown) => {
260
- console.log('collapseId:', collapseId)
261
- console.log('isJustShown:', isJustShown)
262
- })
263
- }
264
- }
265
- ```
266
-
267
- where `collapseId` is collapse id which changed its state; `isJustShown` is true/false, i.e.
268
- shown/hidden collapse.
269
-
270
- ### Toggling collapses via \$root events
271
-
272
- To toggle (open/close) a **specific collapse**, pass the collapse `id`:
273
-
274
- ```js
275
- this.$root.$emit('bv::toggle::collapse', 'my-collapse-id')
276
- ```
277
-
278
- ## Optionally scoped default slot
279
-
280
- <span class="badge badge-info small">New in v2.2.0</span>
281
-
282
- The default slot can be optionally scoped. The following scope properties are available:
283
-
284
- | Property | Type | Description |
285
- | --------- | -------- | ------------------------------------ |
286
- | `visible` | Boolean | Visible state of the collapse |
287
- | `close` | Function | When called, will close the collapse |
288
-
289
- ## Accessibility
290
-
291
- The `v-b-toggle` directive will automatically add the ARIA attributes `aria-controls` and
292
- `aria-expanded` to the component that the directive appears on (as well as add the class `collapsed`
293
- when not expanded). `aria-expanded` will reflect the state of the target `<b-collapse>` component,
294
- while `aria-controls` will be set to the ID(s) of the target `<b-collapse>` component(s).
295
-
296
- If using `v-model` to set the visible state instead of the directive `v-b-toggle`, you will be
297
- required to, on the toggle element, add the `aria-controls` and other appropriate attributes and
298
- classes yourself.
299
-
300
- While the `v-b-toggle` directive can be placed on almost any HTML element or Vue component, it is
301
- recommended to use a button or link (or similar component) to act as your toggler. Otherwise your
302
- trigger elements may be inaccessible to keyboard or screen reader users. If you do place them on
303
- something other than a button or link (or similar component), you should add the attributes
304
- `tabindex="0"` and `role="button"` to allow users of assistive technology to reach your trigger
305
- element.
306
-
307
- When using accordion mode, make sure you place the trigger elements and `<b-collapse>` components
308
- inside an element with `role="tablist"` and set `role="tab"` on each trigger element's container in
309
- order to help screen reader users navigate the accordion group. Unfortunately, BootstrapVue cannot
310
- apply those roles for you automatically, as it depends on your final document markup.
311
-
312
- **Note:** The animation effect of this component is dependent on the `prefers-reduced-motion` media
313
- query. See the
314
- [reduced motion section of our accessibility documentation](?path=/docs/base-tooltip--docs#accessibility)
315
- for additional details.
316
-
317
- ## See also
318
-
319
- - [`v-b-toggle` directive](/docs/directives/toggle)
320
-
321
- <!-- Component reference added automatically from component package.json -->
@@ -1,207 +0,0 @@
1
- import { extend } from '../../vue'
2
- import { NAME_COLLAPSE } from '../../constants/components'
3
- import {
4
- EVENT_NAME_HIDDEN,
5
- EVENT_NAME_HIDE,
6
- EVENT_NAME_SHOW,
7
- EVENT_NAME_SHOWN
8
- } from '../../constants/events'
9
- import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../../constants/props'
10
- import { SLOT_NAME_DEFAULT } from '../../constants/slots'
11
- import { getRootActionEventName, getRootEventName } from '../../utils/events'
12
- import { makeModelMixin } from '../../utils/model'
13
- import { sortKeys } from '../../utils/object'
14
- import { makeProp, makePropsConfigurable } from '../../utils/props'
15
- import { idMixin, props as idProps } from '../../mixins/id'
16
- import { listenOnRootMixin } from '../../mixins/listen-on-root'
17
- import { normalizeSlotMixin } from '../../mixins/normalize-slot'
18
- import { BVCollapse } from './helpers/bv-collapse'
19
-
20
- // --- Constants ---
21
- const ROOT_ACTION_EVENT_NAME_TOGGLE = getRootActionEventName(NAME_COLLAPSE, 'toggle')
22
- const ROOT_ACTION_EVENT_NAME_REQUEST_STATE = getRootActionEventName(NAME_COLLAPSE, 'request-state')
23
-
24
- const ROOT_EVENT_NAME_ACCORDION = getRootEventName(NAME_COLLAPSE, 'accordion')
25
- const ROOT_EVENT_NAME_STATE = getRootEventName(NAME_COLLAPSE, 'state')
26
- const ROOT_EVENT_NAME_SYNC_STATE = getRootEventName(NAME_COLLAPSE, 'sync-state')
27
-
28
- const {
29
- mixin: modelMixin,
30
- props: modelProps,
31
- prop: MODEL_PROP_NAME,
32
- event: MODEL_EVENT_NAME
33
- } = makeModelMixin('visible', { type: PROP_TYPE_BOOLEAN, defaultValue: false })
34
-
35
- // --- Props ---
36
-
37
- export const props = makePropsConfigurable(
38
- sortKeys({
39
- ...idProps,
40
- ...modelProps,
41
- // If `true` (and `visible` is `true` on mount), animate initially visible
42
- accordion: makeProp(PROP_TYPE_STRING),
43
- appear: makeProp(PROP_TYPE_BOOLEAN, false),
44
- tag: makeProp(PROP_TYPE_STRING, 'div')
45
- }),
46
- NAME_COLLAPSE
47
- )
48
-
49
- // --- Main component ---
50
-
51
- // @vue/component
52
- export const BCollapse = /*#__PURE__*/ extend({
53
- name: NAME_COLLAPSE,
54
- mixins: [idMixin, modelMixin, normalizeSlotMixin, listenOnRootMixin],
55
- props,
56
- data() {
57
- return {
58
- show: this[MODEL_PROP_NAME],
59
- transitioning: false
60
- }
61
- },
62
- computed: {
63
- classObject() {
64
- const { transitioning } = this
65
-
66
- return {
67
- collapse: !transitioning,
68
- show: this.show && !transitioning
69
- }
70
- },
71
- slotScope() {
72
- return {
73
- visible: this.show,
74
- close: () => {
75
- this.show = false
76
- }
77
- }
78
- }
79
- },
80
- watch: {
81
- [MODEL_PROP_NAME](newValue) {
82
- if (newValue !== this.show) {
83
- this.show = newValue
84
- }
85
- },
86
- show(newValue, oldValue) {
87
- if (newValue !== oldValue) {
88
- this.emitState()
89
- }
90
- }
91
- },
92
- created() {
93
- this.show = this[MODEL_PROP_NAME]
94
- },
95
- mounted() {
96
- this.show = this[MODEL_PROP_NAME]
97
- // Listen for toggle events to open/close us
98
- this.listenOnRoot(ROOT_ACTION_EVENT_NAME_TOGGLE, this.handleToggleEvent)
99
- // Listen to other collapses for accordion events
100
- this.listenOnRoot(ROOT_EVENT_NAME_ACCORDION, this.handleAccordionEvent)
101
- this.$nextTick(() => {
102
- this.emitState()
103
- })
104
- // Listen for "Sync state" requests from `v-b-toggle`
105
- this.listenOnRoot(ROOT_ACTION_EVENT_NAME_REQUEST_STATE, id => {
106
- if (id === this.safeId()) {
107
- this.$nextTick(this.emitSync)
108
- }
109
- })
110
- },
111
- updated() {
112
- // Emit a private event every time this component updates to ensure
113
- // the toggle button is in sync with the collapse's state
114
- // It is emitted regardless if the visible state changes
115
- this.emitSync()
116
- },
117
- beforeDestroy() {
118
- // Trigger state emit if needed
119
- this.show = false
120
- },
121
- methods: {
122
- toggle() {
123
- this.show = !this.show
124
- },
125
- onEnter() {
126
- this.transitioning = true
127
- // This should be moved out so we can add cancellable events
128
- this.$emit(EVENT_NAME_SHOW)
129
- },
130
- onAfterEnter() {
131
- this.transitioning = false
132
- this.$emit(EVENT_NAME_SHOWN)
133
- },
134
- onLeave() {
135
- this.transitioning = true
136
- // This should be moved out so we can add cancellable events
137
- this.$emit(EVENT_NAME_HIDE)
138
- },
139
- onAfterLeave() {
140
- this.transitioning = false
141
- this.$emit(EVENT_NAME_HIDDEN)
142
- },
143
- emitState() {
144
- const { show, accordion } = this
145
- const id = this.safeId()
146
-
147
- this.$emit(MODEL_EVENT_NAME, show)
148
-
149
- // Let `v-b-toggle` know the state of this collapse
150
- this.emitOnRoot(ROOT_EVENT_NAME_STATE, id, show)
151
- if (accordion && show) {
152
- // Tell the other collapses in this accordion to close
153
- this.emitOnRoot(ROOT_EVENT_NAME_ACCORDION, id, accordion)
154
- }
155
- },
156
- emitSync() {
157
- // Emit a private event every time this component updates to ensure
158
- // the toggle button is in sync with the collapse's state
159
- // It is emitted regardless if the visible state changes
160
- this.emitOnRoot(ROOT_EVENT_NAME_SYNC_STATE, this.safeId(), this.show)
161
- },
162
- handleToggleEvent(id) {
163
- if (id === this.safeId()) {
164
- this.toggle()
165
- }
166
- },
167
- handleAccordionEvent(openedId, openAccordion) {
168
- const { accordion, show } = this
169
- if (!accordion || accordion !== openAccordion) {
170
- return
171
- }
172
- const isThis = openedId === this.safeId()
173
- // Open this collapse if not shown or
174
- // close this collapse if shown
175
- if ((isThis && !show) || (!isThis && show)) {
176
- this.toggle()
177
- }
178
- }
179
- },
180
- render(h) {
181
- const { appear } = this
182
-
183
- const $content = h(
184
- this.tag,
185
- {
186
- class: this.classObject,
187
- directives: [{ name: 'show', value: this.show }],
188
- attrs: { id: this.safeId() }
189
- },
190
- this.normalizeSlot(SLOT_NAME_DEFAULT, this.slotScope)
191
- )
192
-
193
- return h(
194
- BVCollapse,
195
- {
196
- props: { appear },
197
- on: {
198
- enter: this.onEnter,
199
- afterEnter: this.onAfterEnter,
200
- leave: this.onLeave,
201
- afterLeave: this.onAfterLeave
202
- }
203
- },
204
- [$content]
205
- )
206
- }
207
- })