@gitlab/ui 41.7.0 → 41.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "41.7.0",
3
+ "version": "41.9.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -7,7 +7,11 @@ should serve a single purpose dedicated to completing the user’s task.
7
7
  You can use the `v-model` directive to control the modal’s visibility. The `v-model`
8
8
  directive interfaces with the `visible` property and the `@change` event.
9
9
 
10
- ## Modal footer
10
+ ## Deprecation Warning
11
+
12
+ We are deprecating the `modal-ok` and `modal-cancel` slots. We are also changing the way the
13
+ `modal-footer` slot content is populated. This is in order to align this component with the design
14
+ system.
11
15
 
12
16
  The `modal-footer` slot should only be populated via props: `action-primary`, `action-secondary` and
13
17
  `action-cancel`. These props allow you to handle how a primary, secondary and cancel button will
@@ -86,6 +86,22 @@ export default {
86
86
  default: '',
87
87
  },
88
88
  },
89
+ computed: {
90
+ shouldRenderModalOk() {
91
+ return Boolean(this.$slots['modal-ok']);
92
+ },
93
+ shouldRenderModalCancel() {
94
+ return Boolean(this.$slots['modal-cancel']);
95
+ },
96
+ shouldRenderModalFooter() {
97
+ return Boolean(
98
+ this.actionCancel ||
99
+ this.actionSecondary ||
100
+ this.actionPrimary ||
101
+ this.$slots['modal-footer']
102
+ );
103
+ },
104
+ },
89
105
  mounted() {
90
106
  if (!this.ariaLabel && !this.title) {
91
107
  logWarning(
@@ -152,7 +168,7 @@ export default {
152
168
  </script>
153
169
 
154
170
  <template>
155
- <!--
171
+ <!--
156
172
  Emitted when the modal visibility changes
157
173
  @event change
158
174
  -->
@@ -186,8 +202,14 @@ export default {
186
202
  <!-- @slot Content of Modal header close button. If modal-header slot is used, this slot will not be shown. -->
187
203
  <close-button ref="close-button" :label="dismissLabel" @click="close" />
188
204
  </template>
205
+ <template v-if="shouldRenderModalOk" #modal-ok>
206
+ <slot name="modal-ok"></slot>
207
+ </template>
208
+ <template v-if="shouldRenderModalCancel" #modal-cancel>
209
+ <slot name="modal-cancel"></slot>
210
+ </template>
189
211
  <!-- @slot Populated via props: modal-action-primary, modal-action-cancel and modal-action-secondary. -->
190
- <template #modal-footer>
212
+ <template v-if="shouldRenderModalFooter" #modal-footer>
191
213
  <slot name="modal-footer">
192
214
  <!--
193
215
  Emitted when clicked on modal-action-cancel
@@ -1,4 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
+ import { BTab } from 'bootstrap-vue';
2
3
  import { DEFAULT_TAB_TITLE_LINK_CLASS } from '../constants';
3
4
  import GlTab from './tab.vue';
4
5
 
@@ -6,9 +7,7 @@ describe('Tab component', () => {
6
7
  let wrapper;
7
8
 
8
9
  const createComponent = (options) => {
9
- wrapper = shallowMount(GlTab, {
10
- ...options,
11
- });
10
+ wrapper = shallowMount(GlTab, { ...options });
12
11
  };
13
12
 
14
13
  it.each`
@@ -22,14 +21,25 @@ describe('Tab component', () => {
22
21
  'computed title link class is $expectedProp when titleLinkClass is $titleLinkClass',
23
22
  ({ titleLinkClass, expectedProp }) => {
24
23
  createComponent({
25
- propsData: {
26
- titleLinkClass,
27
- },
24
+ propsData: { titleLinkClass },
28
25
  });
29
26
 
30
- expect(wrapper.html()).toBe(
31
- `<b-tab-stub tag="div" title="" titlelinkclass="${expectedProp}"></b-tab-stub>`
32
- );
27
+ expect(wrapper.findComponent(BTab).props('titleLinkClass')).toEqual(expectedProp);
33
28
  }
34
29
  );
30
+
31
+ it('passes title-link-attributes to b-tab when href is explicitly passed', () => {
32
+ const titleLinkAttributes = 'href-example';
33
+ const expectedProp = { href: titleLinkAttributes };
34
+ createComponent({
35
+ propsData: { href: titleLinkAttributes },
36
+ });
37
+ expect(wrapper.findComponent(BTab).props('titleLinkAttributes')).toEqual(expectedProp);
38
+ });
39
+
40
+ it('passes # as href to b-tab when href is not passed', () => {
41
+ const expectedProp = { href: '#' };
42
+ createComponent();
43
+ expect(wrapper.findComponent(BTab).props('titleLinkAttributes')).toEqual(expectedProp);
44
+ });
35
45
  });
@@ -24,6 +24,14 @@ export default {
24
24
  required: false,
25
25
  default: null,
26
26
  },
27
+ /**
28
+ * Provide an `href` for the tab, for example to associate the tab with the tab panel's ID
29
+ */
30
+ href: {
31
+ type: String,
32
+ required: false,
33
+ default: '#',
34
+ },
27
35
  },
28
36
  computed: {
29
37
  linkClass() {
@@ -46,6 +54,7 @@ export default {
46
54
  :title-link-class="linkClass"
47
55
  :query-param-value="queryParamValue"
48
56
  v-bind="$attrs"
57
+ :title-link-attributes="{ href }"
49
58
  v-on="$listeners"
50
59
  >
51
60
  <template v-for="slot in Object.keys($slots)" #[slot]>
@@ -226,6 +226,20 @@ WithScrollAndGrowing.parameters = {
226
226
  storyshots: { disable: true },
227
227
  };
228
228
 
229
+ export const WithHref = (_args, { argTypes }) => ({
230
+ props: Object.keys(argTypes),
231
+ components: { ...components, GlBadge },
232
+ template: wrap(`
233
+ <gl-tab href="#tab-1" title="Tab 1">
234
+ <h2 id="tab-1">Tab panel 1</h2>
235
+ <p>Some paragraph text<p>
236
+ </gl-tab>
237
+ <gl-tab href="#tab-2" title="Tab 2">
238
+ <h2 id="tab-2">Tab panel 2</h2>
239
+ <p>Some paragraph text<p>
240
+ </gl-tab>`),
241
+ });
242
+
229
243
  export default {
230
244
  title: 'base/tabs',
231
245
  component: GlTabs,
@@ -3005,6 +3005,18 @@
3005
3005
  display: grid !important;
3006
3006
  }
3007
3007
 
3008
+ .gl-sm-display-table-cell {
3009
+ @include gl-media-breakpoint-up(sm) {
3010
+ display: table-cell;
3011
+ }
3012
+ }
3013
+
3014
+ .gl-sm-display-table-cell\! {
3015
+ @include gl-media-breakpoint-up(sm) {
3016
+ display: table-cell !important;
3017
+ }
3018
+ }
3019
+
3008
3020
  .gl-md-display-table-cell {
3009
3021
  @include gl-media-breakpoint-up(md) {
3010
3022
  display: table-cell;
@@ -187,6 +187,12 @@
187
187
  display: grid;
188
188
  }
189
189
 
190
+ @mixin gl-sm-display-table-cell {
191
+ @include gl-media-breakpoint-up(sm) {
192
+ @include gl-display-table-cell;
193
+ }
194
+ }
195
+
190
196
  @mixin gl-md-display-table-cell {
191
197
  @include gl-media-breakpoint-up(md) {
192
198
  @include gl-display-table-cell;