@gitlab/ui 110.0.0 → 111.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 +22 -0
- package/dist/components/base/link/link.js +254 -10
- package/dist/directives/safe_link/safe_link.js +6 -4
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utils/constants.js +3 -1
- package/dist/utils/is_slot_empty.js +1 -1
- package/package.json +7 -15
- package/src/components/base/link/link.md +109 -0
- package/src/components/base/link/link.vue +283 -18
- package/src/directives/safe_link/safe_link.js +7 -3
- package/src/scss/typography.scss +17 -0
- package/src/utils/constants.js +3 -0
- package/src/utils/is_slot_empty.js +1 -2
- package/src/vendor/bootstrap/scss/_tables.scss +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# [111.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v110.1.0...v111.0.0) (2025-03-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlLink:** Remove `BLink` from `GlLink` ([22f8323](https://gitlab.com/gitlab-org/gitlab-ui/commit/22f8323023ed9d44e2af3705c12f02ba93edd506))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **GlLink:** Removed support for the following props:
|
|
12
|
+
`append`, `event`, `exact`, `exact-path`, `exact-path-active-class`,
|
|
13
|
+
`no-prefetch`, `router-component-name`, `router-tag`.
|
|
14
|
+
Also removed support for `bv::link::clicked` global event.
|
|
15
|
+
|
|
16
|
+
# [110.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v110.0.0...v110.1.0) (2025-03-10)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* use design tokens in Bootstrap .table class styles ([1b61082](https://gitlab.com/gitlab-org/gitlab-ui/commit/1b61082c5abcbf916fedf3ae99ec7f8b14746bdb))
|
|
22
|
+
|
|
1
23
|
# [110.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v109.2.1...v110.0.0) (2025-03-07)
|
|
2
24
|
|
|
3
25
|
|
|
@@ -1,17 +1,127 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import isFunction from 'lodash/isFunction';
|
|
2
|
+
import isString from 'lodash/isString';
|
|
3
|
+
import isObject from 'lodash/isObject';
|
|
4
|
+
import toString from 'lodash/toString';
|
|
5
|
+
import isBoolean from 'lodash/isBoolean';
|
|
6
|
+
import concat from 'lodash/concat';
|
|
7
|
+
import { SafeLinkDirective, isExternalURL } from '../../../directives/safe_link/safe_link';
|
|
8
|
+
import { stopEvent } from '../../../utils/utils';
|
|
9
|
+
import { isEvent } from '../../../vendor/bootstrap-vue/src/utils/inspect';
|
|
10
|
+
import { stringifyQueryObj } from '../../../vendor/bootstrap-vue/src/utils/router';
|
|
11
|
+
import { safeVueInstance } from '../../../vendor/bootstrap-vue/src/utils/safe-vue-instance';
|
|
12
|
+
import { attemptFocus, attemptBlur } from '../../../vendor/bootstrap-vue/src/utils/dom';
|
|
13
|
+
import { linkVariantOptions, isVue3 } from '../../../utils/constants';
|
|
5
14
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
15
|
|
|
7
16
|
//
|
|
17
|
+
const ANCHOR_TAG = 'a';
|
|
18
|
+
const NUXT_LINK_TAG = 'nuxt-link';
|
|
19
|
+
const VUE_ROUTER_LINK_TAG = 'router-link';
|
|
8
20
|
var script = {
|
|
9
21
|
name: 'GlLink',
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
directives: {
|
|
23
|
+
SafeLink: SafeLinkDirective
|
|
12
24
|
},
|
|
13
|
-
mixins: [SafeLinkMixin],
|
|
14
25
|
props: {
|
|
26
|
+
/**
|
|
27
|
+
* Denotes the target URL of the link for standard links.
|
|
28
|
+
*/
|
|
29
|
+
href: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false,
|
|
32
|
+
default: undefined
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* When set to `true`, disables the component's functionality and places it in a disabled state.
|
|
36
|
+
*/
|
|
37
|
+
disabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Skips sanitization of href if true. This should be used sparingly.
|
|
44
|
+
* Consult security team before setting to true.
|
|
45
|
+
*/
|
|
46
|
+
isUnsafeLink: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
required: false,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Sets the 'rel' attribute on the rendered link.
|
|
53
|
+
*/
|
|
54
|
+
rel: {
|
|
55
|
+
type: String,
|
|
56
|
+
required: false,
|
|
57
|
+
default: null
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Sets the 'target' attribute on the rendered link.
|
|
61
|
+
*/
|
|
62
|
+
target: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: false,
|
|
65
|
+
default: null
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* When set to `true`, places the component in the active state with active styling
|
|
69
|
+
*/
|
|
70
|
+
active: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
required: false,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* <router-link> prop: Denotes the target route of the link.
|
|
77
|
+
* When clicked, the value of the to prop will be passed to `router.push()` internally,
|
|
78
|
+
* so the value can be either a string or a Location descriptor object.
|
|
79
|
+
*/
|
|
80
|
+
to: {
|
|
81
|
+
type: [Object, String],
|
|
82
|
+
required: false,
|
|
83
|
+
default: undefined
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* <router-link> prop: Configure the active CSS class applied when the link is active.
|
|
87
|
+
*/
|
|
88
|
+
activeClass: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: false,
|
|
91
|
+
default: undefined
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* <router-link> prop: Configure the active CSS class applied when the link is active with exact match.
|
|
95
|
+
*/
|
|
96
|
+
exactActiveClass: {
|
|
97
|
+
type: String,
|
|
98
|
+
required: false,
|
|
99
|
+
default: undefined
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* <router-link> prop: Setting the replace prop will call `router.replace()` instead of `router.push()`
|
|
103
|
+
* when clicked, so the navigation will not leave a history record.
|
|
104
|
+
*/
|
|
105
|
+
replace: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
required: false,
|
|
108
|
+
default: false
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* <nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport,
|
|
112
|
+
* Nuxt.js will automatically prefetch the code splitted page. Setting `prefetch` to `true` or `false` will overwrite the default value of `router.prefetchLinks`
|
|
113
|
+
*/
|
|
114
|
+
prefetch: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
required: false,
|
|
117
|
+
// Must be `null` to fall back to the value defined in the
|
|
118
|
+
// `nuxt.config.js` configuration file for `router.prefetchLinks`
|
|
119
|
+
// We convert `null` to `undefined`, so that Nuxt.js will use the
|
|
120
|
+
// compiled default
|
|
121
|
+
// Vue treats `undefined` as default of `false` for Boolean props,
|
|
122
|
+
// so we must set it as `null` here to be a true tri-state prop
|
|
123
|
+
default: null
|
|
124
|
+
},
|
|
15
125
|
/**
|
|
16
126
|
* If inline variant, controls ↗ character visibility
|
|
17
127
|
*/
|
|
@@ -31,14 +141,142 @@ var script = {
|
|
|
31
141
|
}
|
|
32
142
|
},
|
|
33
143
|
computed: {
|
|
144
|
+
safeLinkConfig() {
|
|
145
|
+
return {
|
|
146
|
+
skipSanitization: this.isUnsafeLink
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
tag() {
|
|
150
|
+
const hasRouter = Boolean(safeVueInstance(this).$router);
|
|
151
|
+
const hasNuxt = Boolean(safeVueInstance(this).$nuxt);
|
|
152
|
+
if (!hasRouter || this.disabled || !this.to) {
|
|
153
|
+
return ANCHOR_TAG;
|
|
154
|
+
}
|
|
155
|
+
return hasNuxt ? NUXT_LINK_TAG : VUE_ROUTER_LINK_TAG;
|
|
156
|
+
},
|
|
157
|
+
isRouterLink() {
|
|
158
|
+
return this.tag !== ANCHOR_TAG;
|
|
159
|
+
},
|
|
160
|
+
isVue3RouterLink() {
|
|
161
|
+
return this.tag === VUE_ROUTER_LINK_TAG && isVue3;
|
|
162
|
+
},
|
|
34
163
|
isInlineAndHasExternalIcon() {
|
|
35
|
-
return this.showExternalIcon && this.variant === 'inline' && this
|
|
164
|
+
return this.showExternalIcon && this.variant === 'inline' && this.href && isExternalURL(this.target, this.href);
|
|
165
|
+
},
|
|
166
|
+
computedHref() {
|
|
167
|
+
const fallback = '#';
|
|
168
|
+
const toFallback = '/';
|
|
169
|
+
const {
|
|
170
|
+
to
|
|
171
|
+
} = this;
|
|
172
|
+
|
|
173
|
+
// Return `href` when explicitly provided
|
|
174
|
+
if (this.href) {
|
|
175
|
+
return this.href;
|
|
176
|
+
}
|
|
177
|
+
if (isString(to)) {
|
|
178
|
+
return to || toFallback;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Fallback to `to.path' + `to.query` + `to.hash` prop (if `to` is an object)
|
|
182
|
+
if (isObject(to) && (to.path || to.query || to.hash)) {
|
|
183
|
+
const path = toString(to.path);
|
|
184
|
+
const query = stringifyQueryObj(to.query);
|
|
185
|
+
let hash = toString(to.hash);
|
|
186
|
+
hash = !hash || hash.charAt(0) === '#' ? hash : `#${hash}`;
|
|
187
|
+
return `${path}${query}${hash}` || fallback;
|
|
188
|
+
}
|
|
189
|
+
return fallback;
|
|
190
|
+
},
|
|
191
|
+
computedProps() {
|
|
192
|
+
if (this.isRouterLink) {
|
|
193
|
+
return {
|
|
194
|
+
to: this.to,
|
|
195
|
+
activeClass: this.activeClass,
|
|
196
|
+
exactActiveClass: this.exactActiveClass,
|
|
197
|
+
replace: this.replace,
|
|
198
|
+
...(isBoolean(this.prefetch) ? {
|
|
199
|
+
prefetch: this.prefetch
|
|
200
|
+
} : {})
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
disabled: this.disabled,
|
|
205
|
+
...(this.disabled ? {
|
|
206
|
+
'aria-disabled': 'true',
|
|
207
|
+
tabindex: '-1'
|
|
208
|
+
} : {}),
|
|
209
|
+
rel: this.rel,
|
|
210
|
+
target: this.target,
|
|
211
|
+
href: this.computedHref
|
|
212
|
+
};
|
|
36
213
|
},
|
|
37
|
-
|
|
214
|
+
computedListeners() {
|
|
215
|
+
const {
|
|
216
|
+
click,
|
|
217
|
+
...listenersWithoutClick
|
|
218
|
+
} = this.$listeners;
|
|
219
|
+
return listenersWithoutClick;
|
|
220
|
+
},
|
|
221
|
+
computedClass() {
|
|
38
222
|
return ['gl-link', linkVariantOptions[this.variant], {
|
|
223
|
+
disabled: this.disabled,
|
|
224
|
+
active: this.active,
|
|
39
225
|
'gl-link-inline-external': this.isInlineAndHasExternalIcon
|
|
40
226
|
}];
|
|
41
227
|
}
|
|
228
|
+
},
|
|
229
|
+
methods: {
|
|
230
|
+
onClick(event, navigate) {
|
|
231
|
+
const eventIsEvent = isEvent(event);
|
|
232
|
+
const suppliedHandler = this.$listeners.click;
|
|
233
|
+
if (eventIsEvent && this.disabled) {
|
|
234
|
+
// Stop event from bubbling up
|
|
235
|
+
// Kill the event loop attached to this specific `EventTarget`
|
|
236
|
+
// Needed to prevent `vue-router` from navigating
|
|
237
|
+
stopEvent(event, {
|
|
238
|
+
immediatePropagation: true
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
// Router links do not emit instance `click` events, so we
|
|
242
|
+
// add in an `$emit('click', event)` on its Vue instance
|
|
243
|
+
//
|
|
244
|
+
// seems not to be required for Vue3 compat build
|
|
245
|
+
if (this.isRouterLink) {
|
|
246
|
+
var _event$currentTarget$;
|
|
247
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
248
|
+
(_event$currentTarget$ = event.currentTarget.__vue__) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.$emit('click', event);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Call the suppliedHandler(s), if any provided
|
|
252
|
+
concat([], suppliedHandler).filter(h => isFunction(h)).forEach(handler => {
|
|
253
|
+
// eslint-disable-next-line prefer-rest-params
|
|
254
|
+
handler(...arguments);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// this navigate function comes from Vue 3 router
|
|
258
|
+
// See https://router.vuejs.org/guide/advanced/extending-router-link.html#Extending-RouterLink
|
|
259
|
+
if (isFunction(navigate)) {
|
|
260
|
+
navigate(event);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// TODO: Remove deprecated 'clicked::link' event
|
|
264
|
+
this.$root.$emit('clicked::link', event);
|
|
265
|
+
}
|
|
266
|
+
// Stop scroll-to-top behavior or navigation on
|
|
267
|
+
// regular links when href is just '#'
|
|
268
|
+
if (eventIsEvent && !this.isRouterLink && this.computedHref === '#') {
|
|
269
|
+
stopEvent(event, {
|
|
270
|
+
stopPropagation: false
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
focus() {
|
|
275
|
+
attemptFocus(this.$el);
|
|
276
|
+
},
|
|
277
|
+
blur() {
|
|
278
|
+
attemptBlur(this.$el);
|
|
279
|
+
}
|
|
42
280
|
}
|
|
43
281
|
};
|
|
44
282
|
|
|
@@ -46,7 +284,13 @@ var script = {
|
|
|
46
284
|
const __vue_script__ = script;
|
|
47
285
|
|
|
48
286
|
/* template */
|
|
49
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return
|
|
287
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.isVue3RouterLink)?_c(_vm.tag,_vm._b({tag:"component",attrs:{"custom":""},scopedSlots:_vm._u([{key:"default",fn:function(ref){
|
|
288
|
+
var _obj;
|
|
289
|
+
|
|
290
|
+
var routerLinkHref = ref.href;
|
|
291
|
+
var isActive = ref.isActive;
|
|
292
|
+
var isExactActive = ref.isExactActive;
|
|
293
|
+
var navigate = ref.navigate;return [_c('a',_vm._g({directives:[{name:"safe-link",rawName:"v-safe-link:[safeLinkConfig]",arg:_vm.safeLinkConfig}],class:[_vm.computedClass, ( _obj = {}, _obj[_vm.activeClass] = isActive, _obj[_vm.exactActiveClass] = isExactActive, _obj )],attrs:{"href":routerLinkHref},on:{"click":function($event){return _vm.onClick($event, navigate)}}},_vm.computedListeners),[_vm._t("default")],2)]}}],null,true)},'component',_vm.computedProps,false)):(_vm.isRouterLink)?_c(_vm.tag,_vm._g(_vm._b({directives:[{name:"safe-link",rawName:"v-safe-link:[safeLinkConfig]",arg:_vm.safeLinkConfig}],tag:"component",class:_vm.computedClass,nativeOn:{"click":function($event){return _vm.onClick.apply(null, arguments)}}},'component',_vm.computedProps,false),_vm.computedListeners),[_vm._t("default")],2):_c(_vm.tag,_vm._g(_vm._b({directives:[{name:"safe-link",rawName:"v-safe-link:[safeLinkConfig]",arg:_vm.safeLinkConfig}],tag:"component",class:_vm.computedClass,on:{"click":_vm.onClick}},'component',_vm.computedProps,false),_vm.computedListeners),[_vm._t("default")],2)};
|
|
50
294
|
var __vue_staticRenderFns__ = [];
|
|
51
295
|
|
|
52
296
|
/* style */
|
|
@@ -7,8 +7,11 @@ const getBaseURL = () => {
|
|
|
7
7
|
} = window.location;
|
|
8
8
|
return `${protocol}//${host}`;
|
|
9
9
|
};
|
|
10
|
+
const isTargetBlank = target => {
|
|
11
|
+
return target === '_blank';
|
|
12
|
+
};
|
|
10
13
|
const isExternalURL = (target, hostname) => {
|
|
11
|
-
return target
|
|
14
|
+
return isTargetBlank(target) && hostname !== window.location.hostname;
|
|
12
15
|
};
|
|
13
16
|
const secureRel = rel => {
|
|
14
17
|
const rels = rel ? rel.trim().split(' ') : [];
|
|
@@ -40,13 +43,12 @@ const transform = function (el) {
|
|
|
40
43
|
const {
|
|
41
44
|
href,
|
|
42
45
|
target,
|
|
43
|
-
rel
|
|
44
|
-
hostname
|
|
46
|
+
rel
|
|
45
47
|
} = el;
|
|
46
48
|
if (!isSafeURL(href)) {
|
|
47
49
|
el.href = 'about:blank';
|
|
48
50
|
}
|
|
49
|
-
if (
|
|
51
|
+
if (isTargetBlank(target)) {
|
|
50
52
|
el.rel = secureRel(rel);
|
|
51
53
|
}
|
|
52
54
|
};
|