@gitlab/ui 124.1.1 → 124.2.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/dist/components/base/breadcrumb/breadcrumb.js +33 -2
- package/dist/components/index.js +1 -0
- package/dist/components/shared_components/clipboard_button/clipboard_button.js +100 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
- package/src/components/base/breadcrumb/breadcrumb.scss +6 -1
- package/src/components/base/breadcrumb/breadcrumb.vue +53 -9
- package/src/components/index.js +3 -0
- package/src/components/shared_components/clipboard_button/clipboard_button.vue +78 -0
- package/translations.js +3 -0
|
@@ -4,6 +4,7 @@ import GlAvatar from '../avatar/avatar';
|
|
|
4
4
|
import GlDisclosureDropdown from '../new_dropdowns/disclosure/disclosure_dropdown';
|
|
5
5
|
import { GlTooltipDirective } from '../../../directives/tooltip/tooltip';
|
|
6
6
|
import { breadCrumbSizeOptions } from '../../../utils/constants';
|
|
7
|
+
import ClipboardButton from '../../shared_components/clipboard_button/clipboard_button';
|
|
7
8
|
import GlBreadcrumbItem from './breadcrumb_item';
|
|
8
9
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
9
10
|
|
|
@@ -14,7 +15,8 @@ var script = {
|
|
|
14
15
|
components: {
|
|
15
16
|
GlBreadcrumbItem,
|
|
16
17
|
GlAvatar,
|
|
17
|
-
GlDisclosureDropdown
|
|
18
|
+
GlDisclosureDropdown,
|
|
19
|
+
ClipboardButton
|
|
18
20
|
},
|
|
19
21
|
directives: {
|
|
20
22
|
GlTooltip: GlTooltipDirective
|
|
@@ -67,6 +69,30 @@ var script = {
|
|
|
67
69
|
required: false,
|
|
68
70
|
default: breadCrumbSizeOptions.sm,
|
|
69
71
|
validator: value => Object.keys(breadCrumbSizeOptions).includes(value)
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Copy to clipboard button for breadcrumbs path.
|
|
75
|
+
*/
|
|
76
|
+
showClipboardButton: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
required: false,
|
|
79
|
+
default: false
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Custom path for copy to clipboard button. By default, it resolves to all items text values with `/` separator.
|
|
83
|
+
*/
|
|
84
|
+
pathToCopy: {
|
|
85
|
+
type: String,
|
|
86
|
+
required: false,
|
|
87
|
+
default: null
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Custom tooltip text for clipboard button.
|
|
91
|
+
*/
|
|
92
|
+
clipboardTooltipText: {
|
|
93
|
+
type: String,
|
|
94
|
+
required: false,
|
|
95
|
+
default: null
|
|
70
96
|
}
|
|
71
97
|
},
|
|
72
98
|
data() {
|
|
@@ -104,6 +130,11 @@ var script = {
|
|
|
104
130
|
},
|
|
105
131
|
avatarSize() {
|
|
106
132
|
return this.size === 'sm' ? 16 : 24;
|
|
133
|
+
},
|
|
134
|
+
clipboardButtonText() {
|
|
135
|
+
if (this.pathToCopy) return this.pathToCopy;
|
|
136
|
+
const items = Array.from(this.items, item => item.text);
|
|
137
|
+
return items.join('/');
|
|
107
138
|
}
|
|
108
139
|
},
|
|
109
140
|
watch: {
|
|
@@ -206,7 +237,7 @@ var script = {
|
|
|
206
237
|
const __vue_script__ = script;
|
|
207
238
|
|
|
208
239
|
/* template */
|
|
209
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('nav',{staticClass:"gl-breadcrumbs",style:(_vm.breadcrumbStyle),attrs:{"aria-label":_vm.ariaLabel}},[_c('ol',_vm._g(_vm._b({staticClass:"gl-breadcrumb-list breadcrumb"},'ol',_vm.$attrs,false),_vm.$listeners),[(_vm.hasCollapsible || !_vm.resizeDone)?_c('li',{ref:"dropdown",class:("gl-breadcrumb-item gl-breadcrumb-item-" + _vm.size)},[_c('gl-disclosure-dropdown',{attrs:{"items":_vm.overflowingItems,"toggle-text":_vm.showMoreLabel,"fluid-width":"","text-sr-only":"","no-caret":"","icon":"ellipsis_h","size":_vm.dropdownSize}})],1):_vm._e(),_vm._v(" "),_vm._l((_vm.fittingItems),function(item,index){return _c('gl-breadcrumb-item',{key:index,ref:"breadcrumbs",refInFor:true,class:[_vm.hideItemClass(item), _vm.itemClass],attrs:{"text":item.text,"href":item.href,"to":item.to,"size":_vm.size,"aria-current":_vm.getAriaCurrentAttr(index)}
|
|
240
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('nav',{staticClass:"gl-breadcrumbs",style:(_vm.breadcrumbStyle),attrs:{"aria-label":_vm.ariaLabel}},[_c('ol',_vm._g(_vm._b({staticClass:"gl-breadcrumb-list breadcrumb"},'ol',_vm.$attrs,false),_vm.$listeners),[(_vm.hasCollapsible || !_vm.resizeDone)?_c('li',{ref:"dropdown",class:("gl-breadcrumb-item gl-breadcrumb-item-" + _vm.size)},[_c('gl-disclosure-dropdown',{attrs:{"items":_vm.overflowingItems,"toggle-text":_vm.showMoreLabel,"fluid-width":"","text-sr-only":"","no-caret":"","icon":"ellipsis_h","size":_vm.dropdownSize}})],1):_vm._e(),_vm._v(" "),_vm._l((_vm.fittingItems),function(item,index){return _c('gl-breadcrumb-item',{key:index,ref:"breadcrumbs",refInFor:true,class:[_vm.hideItemClass(item), _vm.itemClass],attrs:{"text":item.text,"href":item.href,"to":item.to,"size":_vm.size,"aria-current":_vm.getAriaCurrentAttr(index)},scopedSlots:_vm._u([{key:"default",fn:function(){return [(item.avatarPath)?_c('gl-avatar',{staticClass:"gl-breadcrumb-avatar-tile gl-border gl-mr-2 !gl-rounded-default",attrs:{"src":item.avatarPath,"size":_vm.avatarSize,"aria-hidden":"true","shape":"rect","data-testid":"avatar"}}):_vm._e(),_c('span',{staticClass:"gl-align-middle"},[_vm._v(_vm._s(item.text))])]},proxy:true}],null,true)})}),_vm._v(" "),(_vm.showClipboardButton)?_c('li',{staticClass:"gl-breadcrumb-clipboard-button"},[_c('clipboard-button',_vm._b({staticClass:"gl-ml-2",attrs:{"data-testid":"copy-to-clipboard-button","text":_vm.clipboardButtonText,"size":_vm.dropdownSize}},'clipboard-button',_vm.clipboardTooltipText ? { title: _vm.clipboardTooltipText } : {},false))],1):_vm._e()],2)])};
|
|
210
241
|
var __vue_staticRenderFns__ = [];
|
|
211
242
|
|
|
212
243
|
/* style */
|
package/dist/components/index.js
CHANGED
|
@@ -94,6 +94,7 @@ export { default as GlAccordionItem } from './base/accordion/accordion_item';
|
|
|
94
94
|
export { default as GlDashboardLayout } from './dashboards/dashboard_layout/dashboard_layout';
|
|
95
95
|
export { default as GlDashboardPanel } from './dashboards/dashboard_panel/dashboard_panel';
|
|
96
96
|
export { default as GlExperimentBadge } from './experimental/experiment_badge/experiment_badge';
|
|
97
|
+
export { default as GlClipboardButton } from './shared_components/clipboard_button/clipboard_button';
|
|
97
98
|
export { default as GlAnimatedNumber } from './utilities/animated_number/animated_number';
|
|
98
99
|
export { default as GlFriendlyWrap } from './utilities/friendly_wrap/friendly_wrap';
|
|
99
100
|
export { default as GlIntersectionObserver } from './utilities/intersection_observer/intersection_observer';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { GlTooltipDirective } from '../../../directives/tooltip/tooltip';
|
|
2
|
+
import GlButton from '../../base/button/button';
|
|
3
|
+
import { translate } from '../../../utils/i18n';
|
|
4
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
|
+
|
|
6
|
+
var script = {
|
|
7
|
+
name: 'ClipboardButton',
|
|
8
|
+
components: {
|
|
9
|
+
GlButton
|
|
10
|
+
},
|
|
11
|
+
directives: {
|
|
12
|
+
GlTooltip: GlTooltipDirective
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
/**
|
|
16
|
+
* The text to copy to clipboard
|
|
17
|
+
*/
|
|
18
|
+
text: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* The tooltip text shown on hover
|
|
24
|
+
*/
|
|
25
|
+
title: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: false,
|
|
28
|
+
default: () => translate('ClipboardButton.title', 'Copy to clipboard')
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Button size
|
|
32
|
+
*/
|
|
33
|
+
size: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: false,
|
|
36
|
+
default: 'medium'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
localTitle: this.title,
|
|
42
|
+
titleTimeout: null
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
methods: {
|
|
46
|
+
updateTooltip(title) {
|
|
47
|
+
this.localTitle = title;
|
|
48
|
+
clearTimeout(this.titleTimeout);
|
|
49
|
+
this.titleTimeout = setTimeout(() => {
|
|
50
|
+
this.localTitle = this.title;
|
|
51
|
+
}, 1000);
|
|
52
|
+
},
|
|
53
|
+
async handleClick() {
|
|
54
|
+
try {
|
|
55
|
+
await navigator.clipboard.writeText(this.text);
|
|
56
|
+
this.updateTooltip(translate('ClipboardButton.copied', 'Copied'));
|
|
57
|
+
} catch {
|
|
58
|
+
this.updateTooltip(translate('ClipboardButton.error', 'Copy failed'));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/* script */
|
|
65
|
+
const __vue_script__ = script;
|
|
66
|
+
|
|
67
|
+
/* template */
|
|
68
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip.hover.focus.top",modifiers:{"hover":true,"focus":true,"top":true}}],attrs:{"variant":"default","category":"tertiary","icon":"copy-to-clipboard","size":_vm.size,"title":_vm.localTitle,"aria-label":_vm.localTitle},on:{"click":_vm.handleClick}})};
|
|
69
|
+
var __vue_staticRenderFns__ = [];
|
|
70
|
+
|
|
71
|
+
/* style */
|
|
72
|
+
const __vue_inject_styles__ = undefined;
|
|
73
|
+
/* scoped */
|
|
74
|
+
const __vue_scope_id__ = undefined;
|
|
75
|
+
/* module identifier */
|
|
76
|
+
const __vue_module_identifier__ = undefined;
|
|
77
|
+
/* functional template */
|
|
78
|
+
const __vue_is_functional_template__ = false;
|
|
79
|
+
/* style inject */
|
|
80
|
+
|
|
81
|
+
/* style inject SSR */
|
|
82
|
+
|
|
83
|
+
/* style inject shadow dom */
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
|
|
88
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
89
|
+
__vue_inject_styles__,
|
|
90
|
+
__vue_script__,
|
|
91
|
+
__vue_scope_id__,
|
|
92
|
+
__vue_is_functional_template__,
|
|
93
|
+
__vue_module_identifier__,
|
|
94
|
+
false,
|
|
95
|
+
undefined,
|
|
96
|
+
undefined,
|
|
97
|
+
undefined
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export { __vue_component__ as default };
|