@gitlab/ui 138.1.0 → 138.3.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/pagination/pagination.js +4 -2
- package/dist/components/base/sorting/sorting.js +27 -5
- package/dist/components/base/toggle/toggle.js +24 -1
- package/dist/components/charts/chart/chart.js +22 -0
- package/dist/config.js +14 -2
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +4 -4
- package/src/components/base/button/button.scss +9 -8
- package/src/components/base/pagination/pagination.vue +4 -2
- package/src/components/base/sorting/sorting.vue +29 -4
- package/src/components/base/toggle/toggle.vue +25 -2
- package/src/components/charts/chart/chart.vue +18 -0
- package/src/config.js +16 -1
- package/translations.js +2 -2
|
@@ -154,7 +154,8 @@ var script = {
|
|
|
154
154
|
},
|
|
155
155
|
data() {
|
|
156
156
|
return {
|
|
157
|
-
|
|
157
|
+
// Set on mount to be safe for SSR
|
|
158
|
+
breakpoint: null,
|
|
158
159
|
// If total pages count is below or equal to minTotalPagesToCollapse, collapsing is disabled
|
|
159
160
|
minTotalPagesToCollapse: 4
|
|
160
161
|
};
|
|
@@ -249,7 +250,8 @@ var script = {
|
|
|
249
250
|
return '#';
|
|
250
251
|
}
|
|
251
252
|
},
|
|
252
|
-
|
|
253
|
+
mounted() {
|
|
254
|
+
this.setBreakpoint();
|
|
253
255
|
this.resizeDebounced = debounce(this.setBreakpoint, resizeDebounceTime);
|
|
254
256
|
window.addEventListener('resize', this.resizeDebounced);
|
|
255
257
|
},
|
|
@@ -97,6 +97,15 @@ var script = {
|
|
|
97
97
|
type: Boolean,
|
|
98
98
|
required: false,
|
|
99
99
|
default: true
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* Disables the entire sorting control (both the sort-by dropdown and the
|
|
103
|
+
* sort direction toggle) while keeping it visible.
|
|
104
|
+
*/
|
|
105
|
+
disabled: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
required: false,
|
|
108
|
+
default: false
|
|
100
109
|
}
|
|
101
110
|
},
|
|
102
111
|
data() {
|
|
@@ -106,7 +115,13 @@ var script = {
|
|
|
106
115
|
};
|
|
107
116
|
},
|
|
108
117
|
computed: {
|
|
118
|
+
unavailableLabel() {
|
|
119
|
+
return translate('GlSorting.sortingUnavailable', 'Sorting is unavailable');
|
|
120
|
+
},
|
|
109
121
|
sortingListboxLabel() {
|
|
122
|
+
if (this.disabled) {
|
|
123
|
+
return this.unavailableLabel;
|
|
124
|
+
}
|
|
110
125
|
return translate('GlSorting.sortByLabel', 'Sort by:');
|
|
111
126
|
},
|
|
112
127
|
localSortDirection() {
|
|
@@ -121,18 +136,23 @@ var script = {
|
|
|
121
136
|
},
|
|
122
137
|
isDirectionToggleDisabled() {
|
|
123
138
|
var _this$selectedSortOpt3;
|
|
124
|
-
return Boolean((_this$selectedSortOpt3 = this.selectedSortOption) === null || _this$selectedSortOpt3 === void 0 ? void 0 : _this$selectedSortOpt3.directionToggleDisabled);
|
|
139
|
+
return this.disabled || Boolean((_this$selectedSortOpt3 = this.selectedSortOption) === null || _this$selectedSortOpt3 === void 0 ? void 0 : _this$selectedSortOpt3.directionToggleDisabled);
|
|
125
140
|
},
|
|
126
141
|
sortDirectionText() {
|
|
127
|
-
if (this.sortDirectionToolTip) return this.sortDirectionToolTip;
|
|
142
|
+
if (this.sortDirectionToolTip && !this.disabled) return this.sortDirectionToolTip;
|
|
128
143
|
if (this.isDirectionToggleDisabled) {
|
|
129
|
-
return this.selectedSortText ? translate('GlSorting.sortDirectionUnavailableFor', '
|
|
144
|
+
return this.selectedSortText ? translate('GlSorting.sortDirectionUnavailableFor', 'Sorting is unavailable for %{sortField}', {
|
|
130
145
|
sortField: this.selectedSortText
|
|
131
|
-
}) :
|
|
146
|
+
}) : this.unavailableLabel;
|
|
132
147
|
}
|
|
133
148
|
return this.isAscending ? translate('GlSorting.sortAscending', 'Sort direction: ascending') : translate('GlSorting.sortDescending', 'Sort direction: descending');
|
|
134
149
|
}
|
|
135
150
|
},
|
|
151
|
+
watch: {
|
|
152
|
+
disabled(isDisabled) {
|
|
153
|
+
if (isDisabled) this.$refs.listbox.close();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
136
156
|
methods: {
|
|
137
157
|
toggleSortDirection() {
|
|
138
158
|
if (this.isDirectionToggleDisabled) return;
|
|
@@ -149,6 +169,8 @@ var script = {
|
|
|
149
169
|
this.$emit('sort-direction-change', newDirection);
|
|
150
170
|
},
|
|
151
171
|
onSortByChanged(event) {
|
|
172
|
+
if (this.disabled) return;
|
|
173
|
+
|
|
152
174
|
/**
|
|
153
175
|
* Emitted when the sort field is changed.
|
|
154
176
|
*
|
|
@@ -167,7 +189,7 @@ var script = {
|
|
|
167
189
|
const __vue_script__ = script;
|
|
168
190
|
|
|
169
191
|
/* template */
|
|
170
|
-
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 gl-flex"},[_c('gl-collapsible-listbox',{staticClass:"gl-w-full",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-id":_vm.toggleId,"toggle-aria-labelled-by":(_vm.sortingListboxId + " " + _vm.toggleId)},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)};
|
|
192
|
+
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 gl-flex"},[_c('gl-collapsible-listbox',{ref:"listbox",staticClass:"gl-w-full",class:_vm.dropdownClass,attrs:{"toggle-text":_vm.text,"items":_vm.sortOptions,"selected":_vm.sortBy,"toggle-class":_vm.dropdownToggleClass,"placement":"bottom-end","block":_vm.block,"disabled":_vm.disabled,"toggle-id":_vm.toggleId,"toggle-aria-labelled-by":(_vm.sortingListboxId + " " + _vm.toggleId)},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)};
|
|
171
193
|
var __vue_staticRenderFns__ = [];
|
|
172
194
|
|
|
173
195
|
/* style */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { uniqueId } from 'lodash-es';
|
|
2
|
+
import { glToggleConfig } from '../../../config';
|
|
2
3
|
import { toggleLabelPosition } from '../../../utils/constants';
|
|
3
4
|
import GlIcon from '../icon/icon';
|
|
4
5
|
import GlLoadingIcon from '../loading_icon/loading_icon';
|
|
@@ -41,6 +42,22 @@ var script = {
|
|
|
41
42
|
required: false,
|
|
42
43
|
default: false
|
|
43
44
|
},
|
|
45
|
+
/**
|
|
46
|
+
* Keep the toggle focusable while `disabled` is `true`. Uses `aria-disabled` so the toggle stays in the tab order and is announced by assistive technology.
|
|
47
|
+
*/
|
|
48
|
+
accessibleDisabled: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
required: false,
|
|
51
|
+
default: () => glToggleConfig.accessibleDisabledToggle
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Space-separated ids of elements that describe the toggle, in addition to its help text.
|
|
55
|
+
*/
|
|
56
|
+
ariaDescribedby: {
|
|
57
|
+
type: String,
|
|
58
|
+
required: false,
|
|
59
|
+
default: undefined
|
|
60
|
+
},
|
|
44
61
|
/**
|
|
45
62
|
* Whether the toggle is in the loading state.
|
|
46
63
|
*/
|
|
@@ -108,6 +125,12 @@ var script = {
|
|
|
108
125
|
helpId() {
|
|
109
126
|
return this.shouldRenderHelp ? `toggle-help-${this.uuid}` : undefined;
|
|
110
127
|
},
|
|
128
|
+
describedBy() {
|
|
129
|
+
return [this.helpId, this.ariaDescribedby].filter(Boolean).join(' ') || undefined;
|
|
130
|
+
},
|
|
131
|
+
isNativeDisabled() {
|
|
132
|
+
return this.disabled && !this.accessibleDisabled;
|
|
133
|
+
},
|
|
111
134
|
isChecked() {
|
|
112
135
|
return this.value ? 'true' : 'false';
|
|
113
136
|
},
|
|
@@ -146,7 +169,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
|
|
|
146
169
|
'is-checked': _vm.value,
|
|
147
170
|
'is-disabled': _vm.disabled || _vm.isLoading,
|
|
148
171
|
'is-loading': _vm.isLoading,
|
|
149
|
-
},attrs:{"role":"switch","aria-checked":_vm.isChecked,"aria-labelledby":_vm.labelId,"aria-describedby":_vm.
|
|
172
|
+
},attrs:{"role":"switch","aria-checked":_vm.isChecked,"aria-labelledby":_vm.labelId,"aria-describedby":_vm.describedBy,"aria-disabled":_vm.disabled,"type":"button","disabled":_vm.isNativeDisabled},on:{"click":function($event){$event.preventDefault();return _vm.toggleFeature.apply(null, arguments)}}},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"toggle-loading",attrs:{"color":"dark"}}):_c('span',{staticClass:"toggle-icon"},[_c('gl-icon',{attrs:{"name":_vm.icon,"size":12}})],1)],1),_vm._v(" "),(_vm.shouldRenderHelp)?_c('span',{staticClass:"gl-help-label",attrs:{"id":_vm.helpId,"data-testid":"toggle-help"}},[_vm._t("help",function(){return [_vm._v(_vm._s(_vm.help))]})],2):_vm._e()])};
|
|
150
173
|
var __vue_staticRenderFns__ = [];
|
|
151
174
|
|
|
152
175
|
/* style */
|
|
@@ -73,6 +73,15 @@ var script = {
|
|
|
73
73
|
type: Boolean,
|
|
74
74
|
required: false,
|
|
75
75
|
default: true
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* A name for the chart that screen readers announce. It is added as a hidden title, which
|
|
79
|
+
* ECharts reads into the description it generates. Ignored when `options` sets a title.
|
|
80
|
+
*/
|
|
81
|
+
accessibleTitle: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: false,
|
|
84
|
+
default: ''
|
|
76
85
|
}
|
|
77
86
|
},
|
|
78
87
|
data() {
|
|
@@ -96,6 +105,14 @@ var script = {
|
|
|
96
105
|
}
|
|
97
106
|
});
|
|
98
107
|
}
|
|
108
|
+
if (this.accessibleTitle && !options.title) {
|
|
109
|
+
options = merge({}, options, {
|
|
110
|
+
title: {
|
|
111
|
+
text: this.accessibleTitle,
|
|
112
|
+
show: false
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
99
116
|
|
|
100
117
|
// Add space at the top to fit the toolbox
|
|
101
118
|
if (((_options$toolbox = options.toolbox) === null || _options$toolbox === void 0 ? void 0 : _options$toolbox.show) === true) {
|
|
@@ -116,6 +133,11 @@ var script = {
|
|
|
116
133
|
this.draw();
|
|
117
134
|
}
|
|
118
135
|
},
|
|
136
|
+
accessibleTitle() {
|
|
137
|
+
if (this.chart) {
|
|
138
|
+
this.draw();
|
|
139
|
+
}
|
|
140
|
+
},
|
|
119
141
|
width() {
|
|
120
142
|
this.setChartSize();
|
|
121
143
|
},
|
package/dist/config.js
CHANGED
|
@@ -5,6 +5,7 @@ const defaultConfig = {
|
|
|
5
5
|
firstDayOfWeek: 0 // Defaults to 0 (Sunday)
|
|
6
6
|
};
|
|
7
7
|
const glButtonConfig = {};
|
|
8
|
+
const glToggleConfig = {};
|
|
8
9
|
let configured = false;
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -15,6 +16,7 @@ let configured = false;
|
|
|
15
16
|
* @property {undefined | Object} translations Generic translations for component labels to fall back to.
|
|
16
17
|
* @property {undefined | Number} firstDayOfWeek Configured first day of the week, from 0 (Sunday) to 6 (Saturday).
|
|
17
18
|
* @property {boolean} [accessibleDisabledButton] Temporary flag to enable the accessible disabled button.
|
|
19
|
+
* @property {boolean} [accessibleDisabledToggle] Temporary flag to enable the accessible disabled toggle.
|
|
18
20
|
*
|
|
19
21
|
*/
|
|
20
22
|
const setConfigs = function () {
|
|
@@ -22,7 +24,9 @@ const setConfigs = function () {
|
|
|
22
24
|
translations = _ref.translations,
|
|
23
25
|
firstDayOfWeek = _ref.firstDayOfWeek,
|
|
24
26
|
_ref$accessibleDisabl = _ref.accessibleDisabledButton,
|
|
25
|
-
accessibleDisabledButton = _ref$accessibleDisabl === void 0 ? false : _ref$accessibleDisabl
|
|
27
|
+
accessibleDisabledButton = _ref$accessibleDisabl === void 0 ? false : _ref$accessibleDisabl,
|
|
28
|
+
_ref$accessibleDisabl2 = _ref.accessibleDisabledToggle,
|
|
29
|
+
accessibleDisabledToggle = _ref$accessibleDisabl2 === void 0 ? false : _ref$accessibleDisabl2;
|
|
26
30
|
if (configured) {
|
|
27
31
|
if (process.env.NODE_ENV === 'development') {
|
|
28
32
|
throw new Error('GitLab UI can only be configured once!');
|
|
@@ -67,6 +71,14 @@ const setConfigs = function () {
|
|
|
67
71
|
accessibleDisabledButton
|
|
68
72
|
});
|
|
69
73
|
}
|
|
74
|
+
|
|
75
|
+
// Temporary flag for the accessible disabled toggle. Once validated, aria-disabled becomes
|
|
76
|
+
// the default for disabled toggles and this flag is removed.
|
|
77
|
+
if (typeof accessibleDisabledToggle === 'boolean') {
|
|
78
|
+
Object.assign(glToggleConfig, {
|
|
79
|
+
accessibleDisabledToggle
|
|
80
|
+
});
|
|
81
|
+
}
|
|
70
82
|
};
|
|
71
83
|
|
|
72
|
-
export { setConfigs as default, defaultConfig, glButtonConfig, i18n };
|
|
84
|
+
export { setConfigs as default, defaultConfig, glButtonConfig, glToggleConfig, i18n };
|