@gitlab/ui 134.5.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.
|
@@ -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 */
|
package/package.json
CHANGED
|
@@ -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
|
/>
|
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',
|