@gitlab/ui 37.10.0 → 38.0.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 +16 -0
- package/dist/components/base/filtered_search/filtered_search.js +0 -11
- package/dist/components/utilities/truncate/truncate.js +2 -2
- package/package.json +1 -1
- package/src/components/base/filtered_search/filtered_search.vue +2 -10
- package/src/components/utilities/truncate/truncate.spec.js +14 -49
- package/src/components/utilities/truncate/truncate.stories.js +1 -59
- package/src/components/utilities/truncate/truncate.vue +3 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [38.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.10.0...v38.0.0) (2022-03-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Reverts
|
|
5
|
+
|
|
6
|
+
* **GlFilteredSearch:** Allow to pass token dynamically ([0dcfb53](https://gitlab.com/gitlab-org/gitlab-ui/commit/0dcfb5300f80ee821f16ab62fd655c7e4f141ffe)), closes [/gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2715#note_878880409](https://gitlab.com//gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2715/issues/note_878880409)
|
|
7
|
+
* **GlTruncate:** add slots to surround the text ([ed4aa40](https://gitlab.com/gitlab-org/gitlab-ui/commit/ed4aa40ed8c3e748f78e78d2e312a8be9ffb9833))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* **GlFilteredSearch:** This makes the `value` prop of `GlFilteredSearch`
|
|
13
|
+
static again, so that it is only read once at mount.
|
|
14
|
+
* **GlTruncate:** This drops the before-text and after-text slots from
|
|
15
|
+
GlTruncate.
|
|
16
|
+
|
|
1
17
|
# [37.10.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.9.1...v37.10.0) (2022-03-18)
|
|
2
18
|
|
|
3
19
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _isEqual from 'lodash/isEqual';
|
|
2
1
|
import _cloneDeep from 'lodash/cloneDeep';
|
|
3
2
|
import PortalVue from 'portal-vue';
|
|
4
3
|
import Vue from 'vue';
|
|
@@ -151,16 +150,6 @@ var script = {
|
|
|
151
150
|
this.$emit('input', this.tokens);
|
|
152
151
|
},
|
|
153
152
|
|
|
154
|
-
deep: true,
|
|
155
|
-
immediate: true
|
|
156
|
-
},
|
|
157
|
-
value: {
|
|
158
|
-
handler(newValue, oldValue) {
|
|
159
|
-
if (newValue.length && !_isEqual(newValue, oldValue)) {
|
|
160
|
-
this.applyNewValue(_cloneDeep(newValue));
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
|
|
164
153
|
deep: true,
|
|
165
154
|
immediate: true
|
|
166
155
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
2
1
|
import { GlTooltipDirective } from '../../../directives/tooltip';
|
|
2
|
+
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
3
3
|
import { POSITION } from './constants';
|
|
4
4
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
5
|
|
|
@@ -84,7 +84,7 @@ var script = {
|
|
|
84
84
|
const __vue_script__ = script;
|
|
85
85
|
|
|
86
86
|
/* template */
|
|
87
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.position === _vm.$options.POSITION.START)?_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"title":_vm.text}},[
|
|
87
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.position === _vm.$options.POSITION.START)?_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{ref:"text",staticClass:"gl-truncate-start gl-text-overflow-ellipsis!"},[_vm._v(""+_vm._s(_vm.text)+"")])]):(_vm.position === _vm.$options.POSITION.MIDDLE)?_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{ref:"text",staticClass:"gl-truncate-end"},[_vm._v(_vm._s(_vm.first))]),_c('span',{staticClass:"gl-truncate-start"},[_vm._v(""+_vm._s(_vm.last)+"")])]):_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"data-testid":"truncate-end-container","title":_vm.text}},[_c('span',{ref:"text",staticClass:"gl-truncate-end"},[_vm._v(_vm._s(_vm.text))])])};
|
|
88
88
|
var __vue_staticRenderFns__ = [];
|
|
89
89
|
|
|
90
90
|
/* style */
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { cloneDeep
|
|
2
|
+
import { cloneDeep } from 'lodash';
|
|
3
3
|
import PortalVue from 'portal-vue';
|
|
4
4
|
import Vue from 'vue';
|
|
5
5
|
import { GlTooltipDirective } from '../../../directives/tooltip';
|
|
@@ -146,21 +146,13 @@ export default {
|
|
|
146
146
|
deep: true,
|
|
147
147
|
immediate: true,
|
|
148
148
|
},
|
|
149
|
-
value: {
|
|
150
|
-
handler(newValue, oldValue) {
|
|
151
|
-
if (newValue.length && !isEqual(newValue, oldValue)) {
|
|
152
|
-
this.applyNewValue(cloneDeep(newValue));
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
deep: true,
|
|
156
|
-
immediate: true,
|
|
157
|
-
},
|
|
158
149
|
},
|
|
159
150
|
mounted() {
|
|
160
151
|
if (this.value.length) {
|
|
161
152
|
this.applyNewValue(cloneDeep(this.value));
|
|
162
153
|
}
|
|
163
154
|
},
|
|
155
|
+
|
|
164
156
|
methods: {
|
|
165
157
|
applyNewValue(newValue) {
|
|
166
158
|
this.tokens = needDenormalization(newValue) ? denormalizeTokens(newValue) : newValue;
|
|
@@ -16,12 +16,10 @@ describe('Truncate component', () => {
|
|
|
16
16
|
text: 'ee/app/assets/javascripts/vue_shared/src/utils_reports/components/utils/index.js',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const createComponent = (props, slots = {}) => {
|
|
19
|
+
const createComponent = (props) => {
|
|
22
20
|
wrapper = shallowMount(
|
|
23
21
|
{ extends: Truncate, directives: { GlTooltip: createMockDirective('gl-tooltip') } },
|
|
24
|
-
{ propsData: { ...defaultProps, ...props }
|
|
22
|
+
{ propsData: { ...defaultProps, ...props } }
|
|
25
23
|
);
|
|
26
24
|
};
|
|
27
25
|
|
|
@@ -57,13 +55,12 @@ describe('Truncate component', () => {
|
|
|
57
55
|
createComponent({ position: 'start' });
|
|
58
56
|
});
|
|
59
57
|
|
|
60
|
-
it('should have the truncate-start class
|
|
61
|
-
|
|
62
|
-
expect(textSpan.classes('gl-truncate-start')).toBe(true);
|
|
58
|
+
it('should have the truncate-start class', () => {
|
|
59
|
+
expect(wrapper.find('.gl-truncate-start').exists()).toBe(true);
|
|
63
60
|
});
|
|
64
61
|
|
|
65
62
|
it('should have the special char surrounded', () => {
|
|
66
|
-
const spanTag = wrapper.
|
|
63
|
+
const spanTag = wrapper.findAll('.gl-truncate span').at(0).text();
|
|
67
64
|
|
|
68
65
|
expect(spanTag.charAt(0)).toBe('\u200E');
|
|
69
66
|
expect(spanTag.charAt(spanTag.length - 1)).toBe('\u200E');
|
|
@@ -71,27 +68,27 @@ describe('Truncate component', () => {
|
|
|
71
68
|
});
|
|
72
69
|
|
|
73
70
|
describe('middle truncation', () => {
|
|
74
|
-
let
|
|
75
|
-
let
|
|
71
|
+
let firstSpan;
|
|
72
|
+
let secondSpan;
|
|
76
73
|
|
|
77
74
|
beforeEach(() => {
|
|
78
75
|
createComponent({ position: 'middle' });
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
firstSpan = wrapper.findAll('.gl-truncate span').at(0);
|
|
77
|
+
secondSpan = wrapper.findAll('.gl-truncate span').at(1);
|
|
81
78
|
});
|
|
82
79
|
|
|
83
80
|
it('should have appropriate classes applied', () => {
|
|
84
|
-
expect(
|
|
85
|
-
expect(
|
|
81
|
+
expect(firstSpan.classes('gl-truncate-end')).toBe(true);
|
|
82
|
+
expect(secondSpan.classes('gl-truncate-start')).toBe(true);
|
|
86
83
|
});
|
|
87
84
|
|
|
88
85
|
it('should have the spans positioned correctly', () => {
|
|
89
|
-
expect(
|
|
90
|
-
expect(
|
|
86
|
+
expect(firstSpan.text()).toBe('ee/app/assets/javascripts/vue_shared/src');
|
|
87
|
+
expect(secondSpan.text()).toBe('/utils_reports/components/utils/index.js');
|
|
91
88
|
});
|
|
92
89
|
|
|
93
90
|
it('last part should have the special char surrounded', () => {
|
|
94
|
-
const lastPart =
|
|
91
|
+
const lastPart = secondSpan.text();
|
|
95
92
|
|
|
96
93
|
expect(lastPart.charAt(0)).toBe('\u200E');
|
|
97
94
|
expect(lastPart.charAt(lastPart.length - 1)).toBe('\u200E');
|
|
@@ -111,36 +108,4 @@ describe('Truncate component', () => {
|
|
|
111
108
|
expect(wrapper.find('.gl-truncate-end').exists()).toBe(true);
|
|
112
109
|
});
|
|
113
110
|
});
|
|
114
|
-
|
|
115
|
-
describe('slots', () => {
|
|
116
|
-
const beforeText = 'Before Text Slot';
|
|
117
|
-
const afterText = 'After Text Slot';
|
|
118
|
-
const slotOptions = {
|
|
119
|
-
'before-text': {
|
|
120
|
-
slot: `<span id="before-text">${beforeText}</span>`,
|
|
121
|
-
text: beforeText,
|
|
122
|
-
},
|
|
123
|
-
'after-text': {
|
|
124
|
-
slot: `<span id="after-text">${afterText}</span>`,
|
|
125
|
-
text: afterText,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
it.each`
|
|
130
|
-
position | slotType
|
|
131
|
-
${'start'} | ${'before-text'}
|
|
132
|
-
${'start'} | ${'after-text'}
|
|
133
|
-
${'middle'} | ${'before-text'}
|
|
134
|
-
${'middle'} | ${'after-text'}
|
|
135
|
-
${'end'} | ${'before-text'}
|
|
136
|
-
${'end'} | ${'after-text'}
|
|
137
|
-
`('$position truncation $slot slot', ({ position, slotType }) => {
|
|
138
|
-
const slot = { [slotType]: slotOptions[slotType].slot };
|
|
139
|
-
|
|
140
|
-
createComponent({ position }, slot);
|
|
141
|
-
|
|
142
|
-
const slotComponent = wrapper.find(`#${slotType}`);
|
|
143
|
-
expect(slotComponent.text()).toBe(slotOptions[slotType].text);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
111
|
});
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GlTruncate } from '../../../index';
|
|
2
2
|
import { POSITION } from './constants';
|
|
3
3
|
import readme from './truncate.md';
|
|
4
4
|
|
|
5
5
|
const template = '<gl-truncate :text="text" :position="position" :with-tooltip="withTooltip" />';
|
|
6
|
-
const beforeTextTemplate = `
|
|
7
|
-
<gl-truncate :text="text" :position="position" :with-tooltip="withTooltip">
|
|
8
|
-
<template #before-text><gl-icon name="container-image" /></template>
|
|
9
|
-
</gl-truncate>`;
|
|
10
|
-
const afterTextTemplate = `
|
|
11
|
-
<gl-truncate :text="text" :position="position" :with-tooltip="withTooltip">
|
|
12
|
-
<template #after-text><gl-icon name="abuse" /></template>
|
|
13
|
-
</gl-truncate>`;
|
|
14
|
-
const bothSlotsTemplate = `
|
|
15
|
-
<gl-truncate :text="text" :position="position" :with-tooltip="withTooltip">
|
|
16
|
-
<template #before-text><gl-icon name="rocket" /></template>
|
|
17
|
-
<template #after-text><gl-icon name="requirements" /></template>
|
|
18
|
-
</gl-truncate>`;
|
|
19
6
|
|
|
20
7
|
const generateProps = ({
|
|
21
8
|
text = 'src/thisIs/AVeryLongFilePath/that/needs/to/be/smartly/truncated/from/the/middle/so/we/dont/lose/important/information/here.vue',
|
|
@@ -37,51 +24,6 @@ const Template = (args, { argTypes }) => ({
|
|
|
37
24
|
export const Default = Template.bind({});
|
|
38
25
|
Default.args = generateProps();
|
|
39
26
|
|
|
40
|
-
const BeforeTextTemplate = (args, { argTypes }) => ({
|
|
41
|
-
components: { GlIcon, GlTruncate },
|
|
42
|
-
props: Object.keys(argTypes),
|
|
43
|
-
template: beforeTextTemplate,
|
|
44
|
-
});
|
|
45
|
-
export const BeforeText = BeforeTextTemplate.bind({});
|
|
46
|
-
BeforeText.args = generateProps({ position: 'start' });
|
|
47
|
-
BeforeText.parameters = {
|
|
48
|
-
docs: {
|
|
49
|
-
source: {
|
|
50
|
-
code: beforeTextTemplate,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const AfterTextTemplate = (args, { argTypes }) => ({
|
|
56
|
-
components: { GlIcon, GlTruncate },
|
|
57
|
-
props: Object.keys(argTypes),
|
|
58
|
-
template: afterTextTemplate,
|
|
59
|
-
});
|
|
60
|
-
export const AfterText = AfterTextTemplate.bind({});
|
|
61
|
-
AfterText.args = generateProps({ position: 'end' });
|
|
62
|
-
AfterText.parameters = {
|
|
63
|
-
docs: {
|
|
64
|
-
source: {
|
|
65
|
-
code: afterTextTemplate,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const BothSlotsTemplate = (args, { argTypes }) => ({
|
|
71
|
-
components: { GlIcon, GlTruncate },
|
|
72
|
-
props: Object.keys(argTypes),
|
|
73
|
-
template: bothSlotsTemplate,
|
|
74
|
-
});
|
|
75
|
-
export const BothSlots = BothSlotsTemplate.bind({});
|
|
76
|
-
BothSlots.args = generateProps();
|
|
77
|
-
BothSlots.parameters = {
|
|
78
|
-
docs: {
|
|
79
|
-
source: {
|
|
80
|
-
code: bothSlotsTemplate,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
27
|
export default {
|
|
86
28
|
title: 'utilities/truncate',
|
|
87
29
|
component: GlTruncate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
3
2
|
import { GlTooltipDirective } from '../../../directives/tooltip';
|
|
3
|
+
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
4
4
|
import { POSITION } from './constants';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -81,15 +81,9 @@ export default {
|
|
|
81
81
|
class="gl-truncate"
|
|
82
82
|
:title="text"
|
|
83
83
|
>
|
|
84
|
-
<span v-if="$scopedSlots['before-text']" class="gl-pr-3">
|
|
85
|
-
<slot name="before-text"></slot>
|
|
86
|
-
</span>
|
|
87
84
|
<span ref="text" class="gl-truncate-start gl-text-overflow-ellipsis!"
|
|
88
85
|
>‎{{ text }}‎</span
|
|
89
86
|
>
|
|
90
|
-
<span v-if="$scopedSlots['after-text']" class="gl-pl-3">
|
|
91
|
-
<slot name="after-text"></slot>
|
|
92
|
-
</span>
|
|
93
87
|
</span>
|
|
94
88
|
|
|
95
89
|
<!-- MIDDLE -->
|
|
@@ -100,14 +94,8 @@ export default {
|
|
|
100
94
|
class="gl-truncate"
|
|
101
95
|
:title="text"
|
|
102
96
|
>
|
|
103
|
-
<span
|
|
104
|
-
|
|
105
|
-
</span>
|
|
106
|
-
<span ref="text" class="gl-truncate-end" data-testid="text-beginning">{{ first }}</span
|
|
107
|
-
><span class="gl-truncate-start" data-testid="text-ending">‎{{ last }}‎</span>
|
|
108
|
-
<span v-if="$scopedSlots['after-text']" class="gl-pl-3">
|
|
109
|
-
<slot name="after-text"></slot>
|
|
110
|
-
</span>
|
|
97
|
+
<span ref="text" class="gl-truncate-end">{{ first }}</span
|
|
98
|
+
><span class="gl-truncate-start">‎{{ last }}‎</span>
|
|
111
99
|
</span>
|
|
112
100
|
|
|
113
101
|
<!-- END -->
|
|
@@ -119,12 +107,6 @@ export default {
|
|
|
119
107
|
data-testid="truncate-end-container"
|
|
120
108
|
:title="text"
|
|
121
109
|
>
|
|
122
|
-
<span v-if="$scopedSlots['before-text']" class="gl-pr-3">
|
|
123
|
-
<slot name="before-text"></slot>
|
|
124
|
-
</span>
|
|
125
110
|
<span ref="text" class="gl-truncate-end">{{ text }}</span>
|
|
126
|
-
<span v-if="$scopedSlots['after-text']" class="gl-pl-3">
|
|
127
|
-
<slot name="after-text"></slot>
|
|
128
|
-
</span>
|
|
129
111
|
</span>
|
|
130
112
|
</template>
|