@gitlab/ui 42.13.0 → 42.15.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/CHANGELOG.md +26 -0
- package/dist/components/base/card/card.js +1 -1
- package/dist/components/base/token_selector/token_container.js +9 -2
- package/dist/components/base/token_selector/token_selector.js +24 -2
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +3 -3
- package/src/components/base/card/card.vue +2 -2
- package/src/components/base/token_selector/token_container.spec.js +23 -0
- package/src/components/base/token_selector/token_container.vue +17 -2
- package/src/components/base/token_selector/token_selector.spec.js +16 -4
- package/src/components/base/token_selector/token_selector.vue +25 -3
- package/src/scss/utilities.scss +6 -0
- package/src/scss/utility-mixins/spacing.scss +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.15.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"@arkweid/lefthook": "0.7.7",
|
|
82
82
|
"@babel/core": "^7.10.2",
|
|
83
83
|
"@babel/preset-env": "^7.10.2",
|
|
84
|
-
"@gitlab/eslint-plugin": "
|
|
84
|
+
"@gitlab/eslint-plugin": "13.0.0",
|
|
85
85
|
"@gitlab/stylelint-config": "4.1.0",
|
|
86
|
-
"@gitlab/svgs": "2.
|
|
86
|
+
"@gitlab/svgs": "2.26.0",
|
|
87
87
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
88
88
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
89
89
|
"@rollup/plugin-replace": "^2.3.2",
|
|
@@ -32,7 +32,7 @@ export default {
|
|
|
32
32
|
|
|
33
33
|
<template>
|
|
34
34
|
<div class="gl-card">
|
|
35
|
-
<div v-if="$
|
|
35
|
+
<div v-if="$scopedSlots.header" class="gl-card-header" :class="headerClass">
|
|
36
36
|
<!-- @slot The card's header content. -->
|
|
37
37
|
<slot name="header"></slot>
|
|
38
38
|
</div>
|
|
@@ -40,7 +40,7 @@ export default {
|
|
|
40
40
|
<!-- @slot The card's main content. -->
|
|
41
41
|
<slot></slot>
|
|
42
42
|
</div>
|
|
43
|
-
<div v-if="$
|
|
43
|
+
<div v-if="$scopedSlots.footer" class="gl-card-footer" :class="footerClass">
|
|
44
44
|
<!-- @slot The card's footer content. -->
|
|
45
45
|
<slot name="footer"></slot>
|
|
46
46
|
</div>
|
|
@@ -71,6 +71,29 @@ describe('GlTokenContainer', () => {
|
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
describe('clearing all tokens', () => {
|
|
75
|
+
const findClearAllButton = () => wrapper.find('[data-testid="clear-all-button"]');
|
|
76
|
+
|
|
77
|
+
it('does not render `Clear all` button by default', () => {
|
|
78
|
+
createComponent();
|
|
79
|
+
|
|
80
|
+
expect(findClearAllButton().exists()).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('renders `Clear all` button when `showClearAllButton` prop is true', () => {
|
|
84
|
+
createComponent({ propsData: { showClearAllButton: true } });
|
|
85
|
+
|
|
86
|
+
expect(findClearAllButton().exists()).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('emits `clear-all` event when `Clear all` button is clicked', () => {
|
|
90
|
+
createComponent({ propsData: { showClearAllButton: true } });
|
|
91
|
+
findClearAllButton().vm.$emit('click', new MouseEvent('click'));
|
|
92
|
+
|
|
93
|
+
expect(wrapper.emitted('clear-all')).toEqual([[]]);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
74
97
|
describe('state', () => {
|
|
75
98
|
describe('when `state` is `false`', () => {
|
|
76
99
|
it('adds `aria-invalid="true"` attribute`', () => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import GlToken from '../token/token.vue';
|
|
3
|
+
import GlButton from '../button/button.vue';
|
|
3
4
|
import { tokensValidator } from './helpers';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
name: 'GlTokenContainer',
|
|
7
|
-
components: { GlToken },
|
|
8
|
+
components: { GlToken, GlButton },
|
|
8
9
|
props: {
|
|
9
10
|
tokens: {
|
|
10
11
|
type: Array,
|
|
@@ -26,6 +27,11 @@ export default {
|
|
|
26
27
|
required: false,
|
|
27
28
|
default: false,
|
|
28
29
|
},
|
|
30
|
+
showClearAllButton: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
required: false,
|
|
33
|
+
default: false,
|
|
34
|
+
},
|
|
29
35
|
},
|
|
30
36
|
data() {
|
|
31
37
|
return {
|
|
@@ -124,7 +130,7 @@ export default {
|
|
|
124
130
|
<template>
|
|
125
131
|
<div
|
|
126
132
|
ref="tokenContainer"
|
|
127
|
-
class="gl-display-flex gl-flex-wrap gl-align-items-center gl-my-n1 gl-mx-n1"
|
|
133
|
+
class="gl-display-flex gl-flex-wrap gl-align-items-center gl-my-n1 gl-mx-n1 gl-w-full"
|
|
128
134
|
role="listbox"
|
|
129
135
|
aria-multiselectable="false"
|
|
130
136
|
aria-orientation="horizontal"
|
|
@@ -162,5 +168,14 @@ export default {
|
|
|
162
168
|
</gl-token>
|
|
163
169
|
</div>
|
|
164
170
|
<slot name="text-input"></slot>
|
|
171
|
+
<gl-button
|
|
172
|
+
v-if="showClearAllButton"
|
|
173
|
+
size="small"
|
|
174
|
+
aria-label="Clear all"
|
|
175
|
+
icon="clear"
|
|
176
|
+
category="tertiary"
|
|
177
|
+
data-testid="clear-all-button"
|
|
178
|
+
@click.stop="$emit('clear-all')"
|
|
179
|
+
/>
|
|
165
180
|
</div>
|
|
166
181
|
</template>
|
|
@@ -86,6 +86,8 @@ describe('GlTokenSelector', () => {
|
|
|
86
86
|
|
|
87
87
|
const findContainer = () => wrapper.findComponent({ ref: 'container' });
|
|
88
88
|
|
|
89
|
+
const findTokenContainer = () => wrapper.findComponent(GlTokenContainer);
|
|
90
|
+
|
|
89
91
|
beforeAll(() => {
|
|
90
92
|
if (!HTMLElement.prototype.scrollIntoView) {
|
|
91
93
|
HTMLElement.prototype.scrollIntoView = jest.fn();
|
|
@@ -149,7 +151,7 @@ describe('GlTokenSelector', () => {
|
|
|
149
151
|
});
|
|
150
152
|
|
|
151
153
|
it('passes `viewOnly` prop to GlTokenContainer', () => {
|
|
152
|
-
expect(
|
|
154
|
+
expect(findTokenContainer().props('viewOnly')).toBe(true);
|
|
153
155
|
});
|
|
154
156
|
|
|
155
157
|
it('disables input field if viewOnly is true', () => {
|
|
@@ -159,6 +161,16 @@ describe('GlTokenSelector', () => {
|
|
|
159
161
|
});
|
|
160
162
|
});
|
|
161
163
|
|
|
164
|
+
describe('when there are tokens and `allowClearAll` is true', () => {
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
createComponent({ propsData: { allowClearAll: true, selectedTokens: tokens } });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('passes `showClearAllButton` prop as `true` to token-container', () => {
|
|
170
|
+
expect(findTokenContainer().props('showClearAllButton')).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
162
174
|
describe('containerClass', () => {
|
|
163
175
|
it('renders passed CSS classes', () => {
|
|
164
176
|
createComponent({
|
|
@@ -290,7 +302,7 @@ describe('GlTokenSelector', () => {
|
|
|
290
302
|
},
|
|
291
303
|
});
|
|
292
304
|
|
|
293
|
-
expect(
|
|
305
|
+
expect(findTokenContainer().props('state')).toBe(true);
|
|
294
306
|
});
|
|
295
307
|
});
|
|
296
308
|
|
|
@@ -589,7 +601,7 @@ describe('GlTokenSelector', () => {
|
|
|
589
601
|
propsData: { selectedTokens: [token] },
|
|
590
602
|
});
|
|
591
603
|
|
|
592
|
-
|
|
604
|
+
findTokenContainer().vm.$emit('token-remove', token);
|
|
593
605
|
|
|
594
606
|
await nextTick();
|
|
595
607
|
});
|
|
@@ -631,7 +643,7 @@ describe('GlTokenSelector', () => {
|
|
|
631
643
|
selectedTokens: tokens,
|
|
632
644
|
});
|
|
633
645
|
|
|
634
|
-
|
|
646
|
+
findTokenContainer().vm.$emit('cancel-focus');
|
|
635
647
|
|
|
636
648
|
await nextTick();
|
|
637
649
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { uniqueId } from 'lodash';
|
|
3
|
-
|
|
4
3
|
import { tokensValidator } from './helpers';
|
|
5
4
|
import GlTokenContainer from './token_container.vue';
|
|
6
5
|
import GlTokenSelectorDropdown from './token_selector_dropdown.vue';
|
|
@@ -8,7 +7,10 @@ import GlTokenSelectorDropdown from './token_selector_dropdown.vue';
|
|
|
8
7
|
export default {
|
|
9
8
|
name: 'GlTokenSelector',
|
|
10
9
|
componentId: uniqueId('token-selector'),
|
|
11
|
-
components: {
|
|
10
|
+
components: {
|
|
11
|
+
GlTokenContainer,
|
|
12
|
+
GlTokenSelectorDropdown,
|
|
13
|
+
},
|
|
12
14
|
model: {
|
|
13
15
|
prop: 'selectedTokens',
|
|
14
16
|
event: 'input',
|
|
@@ -121,6 +123,14 @@ export default {
|
|
|
121
123
|
required: false,
|
|
122
124
|
default: false,
|
|
123
125
|
},
|
|
126
|
+
/**
|
|
127
|
+
* Allows user to bulk delete tokens when enabled
|
|
128
|
+
*/
|
|
129
|
+
allowClearAll: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
required: false,
|
|
132
|
+
default: false,
|
|
133
|
+
},
|
|
124
134
|
},
|
|
125
135
|
data() {
|
|
126
136
|
return {
|
|
@@ -173,8 +183,14 @@ export default {
|
|
|
173
183
|
? 'is-valid gl-inset-border-1-gray-400!'
|
|
174
184
|
: 'is-invalid gl-inset-border-1-red-500!';
|
|
175
185
|
},
|
|
186
|
+
hasSelectedTokens() {
|
|
187
|
+
return this.selectedTokens.length > 0;
|
|
188
|
+
},
|
|
176
189
|
showEmptyPlaceholder() {
|
|
177
|
-
return this.
|
|
190
|
+
return !this.hasSelectedTokens && !this.inputFocused;
|
|
191
|
+
},
|
|
192
|
+
showClearAllButton() {
|
|
193
|
+
return this.hasSelectedTokens && this.allowClearAll;
|
|
178
194
|
},
|
|
179
195
|
},
|
|
180
196
|
watch: {
|
|
@@ -357,6 +373,10 @@ export default {
|
|
|
357
373
|
registerFocusOnToken(focusOnToken) {
|
|
358
374
|
this.focusOnToken = focusOnToken;
|
|
359
375
|
},
|
|
376
|
+
clearAll() {
|
|
377
|
+
this.$emit('input', []);
|
|
378
|
+
this.focusTextInput();
|
|
379
|
+
},
|
|
360
380
|
},
|
|
361
381
|
};
|
|
362
382
|
</script>
|
|
@@ -377,8 +397,10 @@ export default {
|
|
|
377
397
|
:state="state"
|
|
378
398
|
:register-focus-on-token="registerFocusOnToken"
|
|
379
399
|
:view-only="viewOnly"
|
|
400
|
+
:show-clear-all-button="showClearAllButton"
|
|
380
401
|
@token-remove="removeToken"
|
|
381
402
|
@cancel-focus="cancelTokenFocus"
|
|
403
|
+
@clear-all="clearAll"
|
|
382
404
|
>
|
|
383
405
|
<template #token-content="{ token }">
|
|
384
406
|
<!-- @slot Content to pass to the token component slot. Can be used
|
package/src/scss/utilities.scss
CHANGED
|
@@ -5704,6 +5704,12 @@
|
|
|
5704
5704
|
.gl-mr-7\! {
|
|
5705
5705
|
margin-right: $gl-spacing-scale-7 !important;
|
|
5706
5706
|
}
|
|
5707
|
+
.gl-mb-auto {
|
|
5708
|
+
margin-bottom: auto;
|
|
5709
|
+
}
|
|
5710
|
+
.gl-mb-auto\! {
|
|
5711
|
+
margin-bottom: auto !important;
|
|
5712
|
+
}
|
|
5707
5713
|
.gl-mb-0 {
|
|
5708
5714
|
margin-bottom: 0;
|
|
5709
5715
|
}
|