@gitlab/ui 42.3.0 → 42.4.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.
- package/CHANGELOG.md +21 -0
- package/dist/components/base/label/label.js +10 -2
- package/dist/components/base/token_selector/token_container.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
- package/src/components/base/label/label.scss +0 -4
- package/src/components/base/label/label.spec.js +35 -1
- package/src/components/base/label/label.stories.js +4 -0
- package/src/components/base/label/label.vue +16 -4
- package/src/components/base/token_selector/token_container.spec.js +12 -1
- package/src/components/base/token_selector/token_container.vue +1 -1
package/package.json
CHANGED
|
@@ -36,9 +36,11 @@ describe('Label component', () => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const findLink = () => wrapper.findComponent(GlLink);
|
|
39
|
+
const findContent = () => wrapper.find('.gl-label-link');
|
|
39
40
|
const findTitle = () => wrapper.find('.gl-label-text');
|
|
40
41
|
const findSubTitle = () => wrapper.find('.gl-label-text-scoped');
|
|
41
|
-
const
|
|
42
|
+
const findTooltip = () => wrapper.findComponent(GlTooltip);
|
|
43
|
+
const findTooltipText = () => findTooltip().text();
|
|
42
44
|
const findCloseButton = () => wrapper.findComponent(CloseButton);
|
|
43
45
|
|
|
44
46
|
describe('basic label', () => {
|
|
@@ -137,6 +139,22 @@ describe('Label component', () => {
|
|
|
137
139
|
expect(wrapper.emitted().close).toBeFalsy();
|
|
138
140
|
});
|
|
139
141
|
});
|
|
142
|
+
|
|
143
|
+
describe('label has no target', () => {
|
|
144
|
+
const props = { ...defaultProps, target: '' };
|
|
145
|
+
|
|
146
|
+
it('renders the label content as text', () => {
|
|
147
|
+
createComponent(props, { mountFn: mount });
|
|
148
|
+
|
|
149
|
+
expect(findContent().element.tagName.toLowerCase()).toBe('span');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('does not render a link', () => {
|
|
153
|
+
createComponent(props, { mountFn: shallowMount });
|
|
154
|
+
|
|
155
|
+
expect(findLink().exists()).toBe(false);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
140
158
|
});
|
|
141
159
|
|
|
142
160
|
describe('scoped label', () => {
|
|
@@ -220,5 +238,21 @@ describe('Label component', () => {
|
|
|
220
238
|
expect(wrapper.emitted().close).toBeFalsy();
|
|
221
239
|
});
|
|
222
240
|
});
|
|
241
|
+
|
|
242
|
+
describe('label has no target', () => {
|
|
243
|
+
const props = { ...defaultProps, target: '' };
|
|
244
|
+
|
|
245
|
+
it('renders the label content as text', () => {
|
|
246
|
+
createComponent(props, { mountFn: mount });
|
|
247
|
+
|
|
248
|
+
expect(findContent().element.tagName.toLowerCase()).toBe('span');
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('does not render a link', () => {
|
|
252
|
+
createComponent(props, { mountFn: shallowMount });
|
|
253
|
+
|
|
254
|
+
expect(findLink().exists()).toBe(false);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
223
257
|
});
|
|
224
258
|
});
|
|
@@ -54,6 +54,9 @@ Scoped.args = generateProps({ title: 'scoped::label', scoped: true });
|
|
|
54
54
|
export const WithCloseButton = Template.bind({});
|
|
55
55
|
WithCloseButton.args = generateProps({ showCloseButton: true });
|
|
56
56
|
|
|
57
|
+
export const WithoutTarget = Template.bind({});
|
|
58
|
+
WithoutTarget.args = generateProps({ target: '' });
|
|
59
|
+
|
|
57
60
|
export default {
|
|
58
61
|
title: 'base/label',
|
|
59
62
|
component: GlLabel,
|
|
@@ -70,6 +73,7 @@ export default {
|
|
|
70
73
|
},
|
|
71
74
|
size: {
|
|
72
75
|
options: labelSizeOptions,
|
|
76
|
+
control: 'select',
|
|
73
77
|
},
|
|
74
78
|
tooltipPlacement: {
|
|
75
79
|
options: tooltipPlacements,
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
target: {
|
|
42
42
|
type: String,
|
|
43
43
|
required: false,
|
|
44
|
-
default: '
|
|
44
|
+
default: '',
|
|
45
45
|
},
|
|
46
46
|
scoped: {
|
|
47
47
|
type: Boolean,
|
|
@@ -91,6 +91,12 @@ export default {
|
|
|
91
91
|
closeIconSize() {
|
|
92
92
|
return this.size === 'sm' ? 12 : 16;
|
|
93
93
|
},
|
|
94
|
+
labelComponent() {
|
|
95
|
+
return this.target ? GlLink : 'span';
|
|
96
|
+
},
|
|
97
|
+
tooltipTarget() {
|
|
98
|
+
return this.target ? this.$refs.labelTitle.$el : this.$refs.labelTitle;
|
|
99
|
+
},
|
|
94
100
|
},
|
|
95
101
|
watch: {
|
|
96
102
|
title() {
|
|
@@ -122,14 +128,20 @@ export default {
|
|
|
122
128
|
|
|
123
129
|
<template>
|
|
124
130
|
<span class="gl-label" :class="cssClasses" :style="cssVariables" v-bind="$attrs" @click="onClick">
|
|
125
|
-
<
|
|
131
|
+
<component
|
|
132
|
+
:is="labelComponent"
|
|
133
|
+
ref="labelTitle"
|
|
134
|
+
:href="target ? target : false"
|
|
135
|
+
class="gl-label-link"
|
|
136
|
+
tabindex="0"
|
|
137
|
+
>
|
|
126
138
|
<span class="gl-label-text">
|
|
127
139
|
{{ scopedKey }}
|
|
128
140
|
</span>
|
|
129
141
|
<span v-if="scoped && scopedValue" class="gl-label-text-scoped">
|
|
130
142
|
{{ scopedValue }}
|
|
131
143
|
</span>
|
|
132
|
-
</
|
|
144
|
+
</component>
|
|
133
145
|
<close-button
|
|
134
146
|
v-if="showCloseButton"
|
|
135
147
|
class="gl-label-close gl-p-0!"
|
|
@@ -140,7 +152,7 @@ export default {
|
|
|
140
152
|
/>
|
|
141
153
|
<gl-tooltip
|
|
142
154
|
v-if="description"
|
|
143
|
-
:target="() =>
|
|
155
|
+
:target="() => tooltipTarget"
|
|
144
156
|
:placement="tooltipPlacement"
|
|
145
157
|
boundary="viewport"
|
|
146
158
|
>
|
|
@@ -257,7 +257,7 @@ describe('GlTokenContainer', () => {
|
|
|
257
257
|
expect(expectedFocusedToken.element).toHaveFocus();
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
it('emits the `cancel-focus` event when tab key is pressed', async () => {
|
|
260
|
+
it('emits the `cancel-focus` event when tab key is pressed without modifiers', async () => {
|
|
261
261
|
createComponent({});
|
|
262
262
|
|
|
263
263
|
const focusedToken = findTokenByName(tokens[0].name);
|
|
@@ -267,6 +267,17 @@ describe('GlTokenContainer', () => {
|
|
|
267
267
|
|
|
268
268
|
expect(wrapper.emitted('cancel-focus')).toEqual([[]]);
|
|
269
269
|
});
|
|
270
|
+
|
|
271
|
+
it('does not emit the `cancel-focus` event when tab key is pressed with modifiers', async () => {
|
|
272
|
+
createComponent({});
|
|
273
|
+
|
|
274
|
+
const focusedToken = findTokenByName(tokens[0].name);
|
|
275
|
+
|
|
276
|
+
await focusedToken.trigger('focus');
|
|
277
|
+
await focusedToken.trigger('keydown', { key: keyboard.tab, shiftKey: true });
|
|
278
|
+
|
|
279
|
+
expect(wrapper.emitted('cancel-focus')).toBeUndefined();
|
|
280
|
+
});
|
|
270
281
|
});
|
|
271
282
|
});
|
|
272
283
|
});
|