@gitlab/ui 134.4.0 → 134.6.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/new_dropdowns/disclosure/mock_data.js +1 -1
- package/dist/components/base/sorting/sorting.js +23 -2
- package/dist/components/charts/single_stat/single_stat.js +9 -2
- package/package.json +1 -1
- package/src/components/base/new_dropdowns/disclosure/mock_data.js +1 -1
- package/src/components/base/sorting/sorting.vue +28 -1
- package/src/components/charts/single_stat/single_stat.vue +18 -2
- package/translations.js +2 -0
|
@@ -86,7 +86,7 @@ const mockGroups = [{
|
|
|
86
86
|
name: 'This project',
|
|
87
87
|
items: [{
|
|
88
88
|
text: 'New issue',
|
|
89
|
-
href: 'https://gitlab.com/gitlab-org/gitlab/-/
|
|
89
|
+
href: 'https://gitlab.com/gitlab-org/gitlab/-/work_items/new',
|
|
90
90
|
extraAttrs: {
|
|
91
91
|
target: '_blank',
|
|
92
92
|
rel: 'nofollow'
|
|
@@ -27,7 +27,11 @@ var script = {
|
|
|
27
27
|
default: ''
|
|
28
28
|
},
|
|
29
29
|
/**
|
|
30
|
-
* Sort options to display in the dropdown
|
|
30
|
+
* Sort options to display in the dropdown.
|
|
31
|
+
*
|
|
32
|
+
* Each option is `{ value, text }`. Set `directionToggleDisabled: true` on
|
|
33
|
+
* an option that has no ascending/descending meaning (e.g. "Most relevant")
|
|
34
|
+
* to disable the sort direction toggle whenever that option is selected.
|
|
31
35
|
*/
|
|
32
36
|
sortOptions: {
|
|
33
37
|
type: Array,
|
|
@@ -107,13 +111,30 @@ var script = {
|
|
|
107
111
|
localSortDirection() {
|
|
108
112
|
return this.isAscending ? 'sort-lowest' : 'sort-highest';
|
|
109
113
|
},
|
|
114
|
+
selectedSortOption() {
|
|
115
|
+
return this.sortOptions.find(option => option.value === this.sortBy);
|
|
116
|
+
},
|
|
117
|
+
selectedSortText() {
|
|
118
|
+
var _this$selectedSortOpt, _this$selectedSortOpt2;
|
|
119
|
+
return (_this$selectedSortOpt = (_this$selectedSortOpt2 = this.selectedSortOption) === null || _this$selectedSortOpt2 === void 0 ? void 0 : _this$selectedSortOpt2.text) !== null && _this$selectedSortOpt !== void 0 ? _this$selectedSortOpt : '';
|
|
120
|
+
},
|
|
121
|
+
isDirectionToggleDisabled() {
|
|
122
|
+
var _this$selectedSortOpt3;
|
|
123
|
+
return Boolean((_this$selectedSortOpt3 = this.selectedSortOption) === null || _this$selectedSortOpt3 === void 0 ? void 0 : _this$selectedSortOpt3.directionToggleDisabled);
|
|
124
|
+
},
|
|
110
125
|
sortDirectionText() {
|
|
111
126
|
if (this.sortDirectionToolTip) return this.sortDirectionToolTip;
|
|
127
|
+
if (this.isDirectionToggleDisabled) {
|
|
128
|
+
return this.selectedSortText ? translate('GlSorting.sortDirectionUnavailableFor', 'Sort direction unavailable for %{sortField}', {
|
|
129
|
+
sortField: this.selectedSortText
|
|
130
|
+
}) : translate('GlSorting.sortDirectionUnavailable', 'Sort direction unavailable');
|
|
131
|
+
}
|
|
112
132
|
return this.isAscending ? translate('GlSorting.sortAscending', 'Sort direction: ascending') : translate('GlSorting.sortDescending', 'Sort direction: descending');
|
|
113
133
|
}
|
|
114
134
|
},
|
|
115
135
|
methods: {
|
|
116
136
|
toggleSortDirection() {
|
|
137
|
+
if (this.isDirectionToggleDisabled) return;
|
|
117
138
|
const newDirection = !this.isAscending;
|
|
118
139
|
|
|
119
140
|
/**
|
|
@@ -145,7 +166,7 @@ var script = {
|
|
|
145
166
|
const __vue_script__ = script;
|
|
146
167
|
|
|
147
168
|
/* template */
|
|
148
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-button-group',{staticClass:"gl-sorting"},[_c('gl-collapsible-listbox',{class:_vm.dropdownClass,attrs:{"toggle-text":_vm.text,"items":_vm.sortOptions,"selected":_vm.sortBy,"toggle-class":_vm.dropdownToggleClass,"placement":"bottom-end","block":_vm.block,"toggle-aria-labelled-by":_vm.sortingListboxId},on:{"select":_vm.onSortByChanged}}),_vm._v(" "),_c('span',{staticClass:"gl-sr-only",attrs:{"id":_vm.sortingListboxId}},[_vm._v(_vm._s(_vm.sortingListboxLabel))]),_vm._v(" "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],class:['sorting-direction-button', _vm.sortDirectionToggleClass],attrs:{"title":_vm.sortDirectionText,"icon":_vm.localSortDirection,"aria-label":_vm.sortDirectionText},on:{"click":_vm.toggleSortDirection}})],1)};
|
|
169
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-button-group',{staticClass:"gl-sorting"},[_c('gl-collapsible-listbox',{class:_vm.dropdownClass,attrs:{"toggle-text":_vm.text,"items":_vm.sortOptions,"selected":_vm.sortBy,"toggle-class":_vm.dropdownToggleClass,"placement":"bottom-end","block":_vm.block,"toggle-aria-labelled-by":_vm.sortingListboxId},on:{"select":_vm.onSortByChanged}}),_vm._v(" "),_c('span',{staticClass:"gl-sr-only",attrs:{"id":_vm.sortingListboxId}},[_vm._v(_vm._s(_vm.sortingListboxLabel))]),_vm._v(" "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],class:['sorting-direction-button', _vm.sortDirectionToggleClass],attrs:{"title":_vm.sortDirectionText,"icon":_vm.localSortDirection,"aria-label":_vm.sortDirectionText,"disabled":_vm.isDirectionToggleDisabled,"accessible-disabled":_vm.isDirectionToggleDisabled},on:{"click":_vm.toggleSortDirection}})],1)};
|
|
149
170
|
var __vue_staticRenderFns__ = [];
|
|
150
171
|
|
|
151
172
|
/* style */
|
|
@@ -2,6 +2,7 @@ import { badgeVariantOptions, badgeVariantToIconVariantMap } from '../../../util
|
|
|
2
2
|
import GlBadge from '../../base/badge/badge';
|
|
3
3
|
import GlIcon from '../../base/icon/icon';
|
|
4
4
|
import GlAnimatedNumber from '../../utilities/animated_number/animated_number';
|
|
5
|
+
import GlTruncate from '../../utilities/truncate/truncate';
|
|
5
6
|
import { formatNumberToLocale } from '../../../utils/number_utils';
|
|
6
7
|
import { GlTooltipDirective } from '../../../directives/tooltip/tooltip';
|
|
7
8
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
@@ -11,7 +12,8 @@ var script = {
|
|
|
11
12
|
components: {
|
|
12
13
|
GlIcon,
|
|
13
14
|
GlBadge,
|
|
14
|
-
GlAnimatedNumber
|
|
15
|
+
GlAnimatedNumber,
|
|
16
|
+
GlTruncate
|
|
15
17
|
},
|
|
16
18
|
directives: {
|
|
17
19
|
GlTooltip: GlTooltipDirective
|
|
@@ -84,6 +86,11 @@ var script = {
|
|
|
84
86
|
type: Number,
|
|
85
87
|
required: false,
|
|
86
88
|
default: 0
|
|
89
|
+
},
|
|
90
|
+
description: {
|
|
91
|
+
type: String,
|
|
92
|
+
required: false,
|
|
93
|
+
default: null
|
|
87
94
|
}
|
|
88
95
|
},
|
|
89
96
|
data() {
|
|
@@ -129,7 +136,7 @@ var script = {
|
|
|
129
136
|
const __vue_script__ = script;
|
|
130
137
|
|
|
131
138
|
/* template */
|
|
132
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._g(_vm._b({staticClass:"gl-single-stat gl-flex gl-flex-col gl-p-2"},'div',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-
|
|
139
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._g(_vm._b({staticClass:"gl-single-stat gl-flex gl-flex-col gl-gap-2 gl-p-2"},'div',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-flex gl-items-center gl-text-heading"},[(_vm.showTitleIcon)?_c('gl-icon',{class:['gl-mr-2', _vm.titleIconClass],attrs:{"name":_vm.titleIcon,"data-testid":"title-icon"}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-text-base gl-font-normal",attrs:{"data-testid":"title-text"}},[_vm._v(_vm._s(_vm.title))])],1),_vm._v(" "),_c('div',{staticClass:"gl-single-stat-content gl-flex gl-items-baseline gl-font-bold gl-text-strong"},[_c('span',{staticClass:"gl-single-stat-number gl-leading-1",class:{ 'gl-mr-2': !_vm.unit },attrs:{"data-testid":"displayValue"}},[(_vm.canAnimate)?_c('gl-animated-number',{attrs:{"number":Number(_vm.value),"decimal-places":_vm.animationDecimalPlaces,"use-delimiters":_vm.useDelimiters},on:{"animating":function($event){return _vm.setHideUnits(true)},"animated":function($event){return _vm.setHideUnits(false)}}}):_c('span',{attrs:{"data-testid":"non-animated-value"}},[_vm._v(_vm._s(_vm.statValue))])],1),_vm._v(" "),(_vm.unit)?_c('span',{staticClass:"gl-mx-2 gl-text-sm gl-opacity-10 gl-transition-all",class:{ '!gl-opacity-0': _vm.hideUnits },attrs:{"data-testid":"unit"}},[_vm._v(_vm._s(_vm.unit))]):_vm._e(),_vm._v(" "),(_vm.showMetaIcon)?_c('gl-icon',{attrs:{"variant":_vm.iconVariant,"name":_vm.metaIcon,"data-testid":"meta-icon"}}):_vm._e(),_vm._v(" "),(_vm.showBadge && _vm.metaTooltip)?_c('button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip.viewport",modifiers:{"viewport":true}}],staticClass:"!gl-cursor-default gl-border-0 gl-bg-transparent gl-p-0 gl-leading-0",attrs:{"type":"button","title":_vm.metaTooltip,"data-testid":"meta-badge-button"}},[_c('gl-badge',{attrs:{"variant":_vm.variant,"icon":_vm.metaIcon,"data-testid":"meta-badge"}},[_vm._v(_vm._s(_vm.metaText))])],1):(_vm.showBadge)?_c('gl-badge',{attrs:{"variant":_vm.variant,"icon":_vm.metaIcon,"data-testid":"meta-badge"}},[_vm._v(_vm._s(_vm.metaText))]):_vm._e()],1),_vm._v(" "),_vm._t("default"),_vm._v(" "),(_vm.description)?_c('gl-truncate',{staticClass:"gl-text-sm gl-text-subtle",attrs:{"data-testid":"description","text":_vm.description,"with-tooltip":""}}):_vm._e()],2)};
|
|
133
140
|
var __vue_staticRenderFns__ = [];
|
|
134
141
|
|
|
135
142
|
/* style */
|
package/package.json
CHANGED
|
@@ -106,7 +106,7 @@ export const mockGroups = [
|
|
|
106
106
|
items: [
|
|
107
107
|
{
|
|
108
108
|
text: 'New issue',
|
|
109
|
-
href: 'https://gitlab.com/gitlab-org/gitlab/-/
|
|
109
|
+
href: 'https://gitlab.com/gitlab-org/gitlab/-/work_items/new',
|
|
110
110
|
extraAttrs: {
|
|
111
111
|
target: '_blank',
|
|
112
112
|
rel: 'nofollow',
|
|
@@ -27,7 +27,11 @@ export default {
|
|
|
27
27
|
default: '',
|
|
28
28
|
},
|
|
29
29
|
/**
|
|
30
|
-
* Sort options to display in the dropdown
|
|
30
|
+
* Sort options to display in the dropdown.
|
|
31
|
+
*
|
|
32
|
+
* Each option is `{ value, text }`. Set `directionToggleDisabled: true` on
|
|
33
|
+
* an option that has no ascending/descending meaning (e.g. "Most relevant")
|
|
34
|
+
* to disable the sort direction toggle whenever that option is selected.
|
|
31
35
|
*/
|
|
32
36
|
sortOptions: {
|
|
33
37
|
type: Array,
|
|
@@ -107,9 +111,28 @@ export default {
|
|
|
107
111
|
localSortDirection() {
|
|
108
112
|
return this.isAscending ? 'sort-lowest' : 'sort-highest';
|
|
109
113
|
},
|
|
114
|
+
selectedSortOption() {
|
|
115
|
+
return this.sortOptions.find((option) => option.value === this.sortBy);
|
|
116
|
+
},
|
|
117
|
+
selectedSortText() {
|
|
118
|
+
return this.selectedSortOption?.text ?? '';
|
|
119
|
+
},
|
|
120
|
+
isDirectionToggleDisabled() {
|
|
121
|
+
return Boolean(this.selectedSortOption?.directionToggleDisabled);
|
|
122
|
+
},
|
|
110
123
|
sortDirectionText() {
|
|
111
124
|
if (this.sortDirectionToolTip) return this.sortDirectionToolTip;
|
|
112
125
|
|
|
126
|
+
if (this.isDirectionToggleDisabled) {
|
|
127
|
+
return this.selectedSortText
|
|
128
|
+
? translate(
|
|
129
|
+
'GlSorting.sortDirectionUnavailableFor',
|
|
130
|
+
'Sort direction unavailable for %{sortField}',
|
|
131
|
+
{ sortField: this.selectedSortText },
|
|
132
|
+
)
|
|
133
|
+
: translate('GlSorting.sortDirectionUnavailable', 'Sort direction unavailable');
|
|
134
|
+
}
|
|
135
|
+
|
|
113
136
|
return this.isAscending
|
|
114
137
|
? translate('GlSorting.sortAscending', 'Sort direction: ascending')
|
|
115
138
|
: translate('GlSorting.sortDescending', 'Sort direction: descending');
|
|
@@ -117,6 +140,8 @@ export default {
|
|
|
117
140
|
},
|
|
118
141
|
methods: {
|
|
119
142
|
toggleSortDirection() {
|
|
143
|
+
if (this.isDirectionToggleDisabled) return;
|
|
144
|
+
|
|
120
145
|
const newDirection = !this.isAscending;
|
|
121
146
|
|
|
122
147
|
/**
|
|
@@ -164,6 +189,8 @@ export default {
|
|
|
164
189
|
:title="sortDirectionText"
|
|
165
190
|
:icon="localSortDirection"
|
|
166
191
|
:aria-label="sortDirectionText"
|
|
192
|
+
:disabled="isDirectionToggleDisabled"
|
|
193
|
+
:accessible-disabled="isDirectionToggleDisabled"
|
|
167
194
|
:class="['sorting-direction-button', sortDirectionToggleClass]"
|
|
168
195
|
@click="toggleSortDirection"
|
|
169
196
|
/>
|
|
@@ -3,6 +3,7 @@ import { badgeVariantOptions, badgeVariantToIconVariantMap } from '../../../util
|
|
|
3
3
|
import GlBadge from '../../base/badge/badge.vue';
|
|
4
4
|
import GlIcon from '../../base/icon/icon.vue';
|
|
5
5
|
import GlAnimatedNumber from '../../utilities/animated_number/animated_number.vue';
|
|
6
|
+
import GlTruncate from '../../utilities/truncate/truncate.vue';
|
|
6
7
|
import { formatNumberToLocale } from '../../../utils/number_utils';
|
|
7
8
|
import { GlTooltipDirective } from '../../../directives/tooltip/tooltip';
|
|
8
9
|
|
|
@@ -12,6 +13,7 @@ export default {
|
|
|
12
13
|
GlIcon,
|
|
13
14
|
GlBadge,
|
|
14
15
|
GlAnimatedNumber,
|
|
16
|
+
GlTruncate,
|
|
15
17
|
},
|
|
16
18
|
directives: {
|
|
17
19
|
GlTooltip: GlTooltipDirective,
|
|
@@ -85,6 +87,11 @@ export default {
|
|
|
85
87
|
required: false,
|
|
86
88
|
default: 0,
|
|
87
89
|
},
|
|
90
|
+
description: {
|
|
91
|
+
type: String,
|
|
92
|
+
required: false,
|
|
93
|
+
default: null,
|
|
94
|
+
},
|
|
88
95
|
},
|
|
89
96
|
data() {
|
|
90
97
|
return {
|
|
@@ -128,8 +135,8 @@ export default {
|
|
|
128
135
|
</script>
|
|
129
136
|
|
|
130
137
|
<template>
|
|
131
|
-
<div class="gl-single-stat gl-flex gl-flex-col gl-p-2" v-bind="$attrs" v-on="$listeners">
|
|
132
|
-
<div class="gl-
|
|
138
|
+
<div class="gl-single-stat gl-flex gl-flex-col gl-gap-2 gl-p-2" v-bind="$attrs" v-on="$listeners">
|
|
139
|
+
<div class="gl-flex gl-items-center gl-text-heading">
|
|
133
140
|
<gl-icon
|
|
134
141
|
v-if="showTitleIcon"
|
|
135
142
|
:name="titleIcon"
|
|
@@ -187,5 +194,14 @@ export default {
|
|
|
187
194
|
>{{ metaText }}</gl-badge
|
|
188
195
|
>
|
|
189
196
|
</div>
|
|
197
|
+
<!-- @slot Supplementary content displayed below the value. -->
|
|
198
|
+
<slot></slot>
|
|
199
|
+
<gl-truncate
|
|
200
|
+
v-if="description"
|
|
201
|
+
data-testid="description"
|
|
202
|
+
class="gl-text-sm gl-text-subtle"
|
|
203
|
+
:text="description"
|
|
204
|
+
with-tooltip
|
|
205
|
+
/>
|
|
190
206
|
</div>
|
|
191
207
|
</template>
|
package/translations.js
CHANGED
|
@@ -40,6 +40,8 @@ export default {
|
|
|
40
40
|
'GlSorting.sortAscending': 'Sort direction: ascending',
|
|
41
41
|
'GlSorting.sortByLabel': 'Sort by:',
|
|
42
42
|
'GlSorting.sortDescending': 'Sort direction: descending',
|
|
43
|
+
'GlSorting.sortDirectionUnavailable': 'Sort direction unavailable',
|
|
44
|
+
'GlSorting.sortDirectionUnavailableFor': 'Sort direction unavailable for %{sortField}',
|
|
43
45
|
'GlTabs.GlScrollableTabs.scrollLeftLabel': 'Scroll left',
|
|
44
46
|
'GlTabs.GlScrollableTabs.scrollRightLabel': 'Scroll right',
|
|
45
47
|
'GlToken.closeButtonTitle': 'Remove',
|