@gitlab/ui 126.3.1 → 126.3.2
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/badge/badge.js +4 -1
- package/dist/components/base/button/button.js +4 -1
- package/dist/components/base/filtered_search/filtered_search.js +4 -2
- package/dist/components/base/icon/icon.js +4 -2
- package/dist/components/base/illustration/illustration.js +4 -2
- package/dist/components/base/modal/modal.js +4 -1
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +8 -4
- package/dist/components/base/new_dropdowns/listbox/listbox.js +4 -3
- package/dist/components/base/table/table.js +4 -1
- package/dist/components/base/tabs/tab/tab.js +5 -3
- package/dist/utils/utils.js +14 -7
- package/package.json +3 -3
- package/src/components/base/badge/badge.vue +2 -2
- package/src/components/base/button/button.vue +4 -4
- package/src/components/base/dropdown/dropdown.vue +2 -2
- package/src/components/base/filtered_search/filtered_search.vue +3 -2
- package/src/components/base/icon/icon.vue +2 -2
- package/src/components/base/illustration/illustration.vue +4 -2
- package/src/components/base/modal/modal.vue +8 -8
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +7 -4
- package/src/components/base/new_dropdowns/listbox/listbox.vue +3 -3
- package/src/components/base/table/table.vue +1 -1
- package/src/components/base/tabs/tab/tab.vue +5 -4
- package/src/utils/utils.js +10 -5
|
@@ -152,7 +152,10 @@ var script = {
|
|
|
152
152
|
},
|
|
153
153
|
mounted() {
|
|
154
154
|
if (this.hasIconOnly && !this.$attrs['aria-label']) {
|
|
155
|
-
logWarning('
|
|
155
|
+
logWarning('Icon-only badges require an aria-label for accessibility. The label should describe the metadata (e.g., "Due date", "Open issue"), not the icon name. See https://design.gitlab.com/components/badge#using-icon-only-badges', {
|
|
156
|
+
name: 'GlBadge',
|
|
157
|
+
element: this.$el
|
|
158
|
+
});
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
};
|
|
@@ -364,7 +364,10 @@ var script = {
|
|
|
364
364
|
mounted() {
|
|
365
365
|
// eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
|
|
366
366
|
if (!this.$slots.default && !this.$attrs['aria-label'] && !this.$props.label) {
|
|
367
|
-
logWarning('
|
|
367
|
+
logWarning('Accessible name missing. Please add inner text or aria-label.', {
|
|
368
|
+
name: 'GlButton',
|
|
369
|
+
element: this.$el
|
|
370
|
+
});
|
|
368
371
|
}
|
|
369
372
|
},
|
|
370
373
|
methods: {
|
|
@@ -2,6 +2,7 @@ import isEqual from 'lodash/isEqual';
|
|
|
2
2
|
import cloneDeep from 'lodash/cloneDeep';
|
|
3
3
|
import { PortalTarget } from 'portal-vue';
|
|
4
4
|
import { GlTooltipDirective } from '../../../directives/tooltip/tooltip';
|
|
5
|
+
import { logWarning } from '../../../utils/utils';
|
|
5
6
|
import GlIcon from '../icon/icon';
|
|
6
7
|
import GlSearchBoxByClick from '../search_box_by_click/search_box_by_click';
|
|
7
8
|
import GlFilteredSearchTerm from './filtered_search_term';
|
|
@@ -67,8 +68,9 @@ var script = {
|
|
|
67
68
|
return !token || token.__v_skip;
|
|
68
69
|
});
|
|
69
70
|
if (!isOk) {
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
logWarning('You are using Vue3. In Vue3 each token component passed to filtered search must be wrapped into markRaw', {
|
|
72
|
+
name: 'GlFilteredSearch'
|
|
73
|
+
});
|
|
72
74
|
}
|
|
73
75
|
return isOk;
|
|
74
76
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import iconsPath from '@gitlab/svgs/dist/icons.svg';
|
|
2
2
|
import iconsInfo from '@gitlab/svgs/dist/icons.json';
|
|
3
|
+
import { logWarning } from '../../../utils/utils';
|
|
3
4
|
import { iconSizeOptions, iconVariantOptions } from '../../../utils/constants';
|
|
4
5
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
6
|
|
|
@@ -37,8 +38,9 @@ var script = {
|
|
|
37
38
|
if (knownIcons.has(value)) {
|
|
38
39
|
return true;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
logWarning(`Icon '${value}' is not a known icon of @gitlab/svgs`, {
|
|
42
|
+
name: 'GlIcon'
|
|
43
|
+
});
|
|
42
44
|
return false;
|
|
43
45
|
}
|
|
44
46
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import illustrationsPath from '@gitlab/svgs/dist/illustrations.svg';
|
|
2
2
|
import illustrationsInfo from '@gitlab/svgs/dist/illustrations.json';
|
|
3
|
+
import { logWarning } from '../../../utils/utils';
|
|
3
4
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
4
5
|
|
|
5
6
|
//
|
|
@@ -25,8 +26,9 @@ var script = {
|
|
|
25
26
|
if (knownIllustrations.some(obj => obj.name === value)) {
|
|
26
27
|
return true;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
logWarning(`Illustration '${value}' is not a known illustration of @gitlab/svgs`, {
|
|
30
|
+
name: 'GlIllustration'
|
|
31
|
+
});
|
|
30
32
|
return false;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -141,7 +141,10 @@ var script = {
|
|
|
141
141
|
},
|
|
142
142
|
mounted() {
|
|
143
143
|
if (!this.ariaLabel && !this.title) {
|
|
144
|
-
logWarning('
|
|
144
|
+
logWarning('Accessible name for modal missing. Please add title prop or aria-label.', {
|
|
145
|
+
name: 'GlModal',
|
|
146
|
+
element: this.$el
|
|
147
|
+
});
|
|
145
148
|
}
|
|
146
149
|
},
|
|
147
150
|
methods: {
|
|
@@ -90,8 +90,9 @@ var script = {
|
|
|
90
90
|
default: 'bottom-start',
|
|
91
91
|
validator: value => {
|
|
92
92
|
if (['left', 'center', 'right'].includes(value)) {
|
|
93
|
-
logWarning(`
|
|
94
|
-
|
|
93
|
+
logWarning(`"${value}" placement is deprecated. Use ${dropdownPlacements[value]} instead.`, {
|
|
94
|
+
name: 'GlDisclosureDropdown/GlCollapsibleListbox'
|
|
95
|
+
});
|
|
95
96
|
}
|
|
96
97
|
return Object.keys(dropdownPlacements).includes(value);
|
|
97
98
|
}
|
|
@@ -307,8 +308,11 @@ var script = {
|
|
|
307
308
|
methods: {
|
|
308
309
|
checkToggleFocusable() {
|
|
309
310
|
if (!isElementFocusable(this.toggleElement) && !isElementTabbable(this.toggleElement)) {
|
|
310
|
-
logWarning(`
|
|
311
|
-
Use 'a' or 'button' element instead or make sure to add 'role="button"' along with 'tabindex' otherwise.`,
|
|
311
|
+
logWarning(`Toggle is missing a 'tabindex' and cannot be focused.
|
|
312
|
+
Use 'a' or 'button' element instead or make sure to add 'role="button"' along with 'tabindex' otherwise.`, {
|
|
313
|
+
name: 'GlDisclosureDropdown/GlCollapsibleListbox',
|
|
314
|
+
element: this.$el
|
|
315
|
+
});
|
|
312
316
|
}
|
|
313
317
|
},
|
|
314
318
|
getArrowOffsets(actualPlacement) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import clamp from 'lodash/clamp';
|
|
2
2
|
import uniqueId from 'lodash/uniqueId';
|
|
3
|
-
import { stopEvent } from '../../../../utils/utils';
|
|
3
|
+
import { logWarning, stopEvent } from '../../../../utils/utils';
|
|
4
4
|
import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, ARROW_UP, ENTER, ARROW_DOWN, END, HOME } from '../constants';
|
|
5
5
|
import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
|
|
6
6
|
import GlButton from '../../button/button';
|
|
@@ -550,8 +550,9 @@ var script = {
|
|
|
550
550
|
immediate: true,
|
|
551
551
|
handler(newValue) {
|
|
552
552
|
if (newValue && this.items.some(item => !isOption(item))) {
|
|
553
|
-
|
|
554
|
-
|
|
553
|
+
logWarning('When using grouped options infinite scroll can only be used on the last group.', {
|
|
554
|
+
name: 'GlCollapsibleListbox'
|
|
555
|
+
});
|
|
555
556
|
}
|
|
556
557
|
}
|
|
557
558
|
}
|
|
@@ -109,7 +109,10 @@ var script = {
|
|
|
109
109
|
// logWarning will call isDev before logging any message
|
|
110
110
|
// this additional call to isDev is being made to exit the condition early when run in production
|
|
111
111
|
if (isDev() && !shouldUseFullTable(this)) {
|
|
112
|
-
logWarning(glTableLiteWarning,
|
|
112
|
+
logWarning(glTableLiteWarning, {
|
|
113
|
+
name: 'GlTable',
|
|
114
|
+
element: this.$el
|
|
115
|
+
});
|
|
113
116
|
}
|
|
114
117
|
},
|
|
115
118
|
methods: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import isPlainObject from 'lodash/isPlainObject';
|
|
2
2
|
import { BTab } from '../../../../vendor/bootstrap-vue/src/components/tabs/tab';
|
|
3
3
|
import GlBadge from '../../badge/badge';
|
|
4
|
+
import { logWarning } from '../../../../utils/utils';
|
|
4
5
|
import { DEFAULT_TAB_TITLE_LINK_CLASS } from '../constants';
|
|
5
6
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
7
|
|
|
@@ -67,9 +68,10 @@ var script = {
|
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
70
|
created() {
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (this.hasTabCount && !this.tabCountSrText) {
|
|
72
|
+
logWarning('When using "tab-count", you should also provide "tab-count-sr-text" for screen reader accessibility. Example: :tab-count-sr-text="n__(\'%d item\', \'%d items\', count)"', {
|
|
73
|
+
name: 'GlTab'
|
|
74
|
+
});
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
};
|
package/dist/utils/utils.js
CHANGED
|
@@ -157,14 +157,21 @@ function isDev() {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Prints a warning message to the console in non-test and non-production environments.
|
|
160
|
-
* @param {string} message
|
|
161
|
-
* @param {
|
|
160
|
+
* @param {string} message Message to print to the console.
|
|
161
|
+
* @param {Object} [context] Optional object with additional context.
|
|
162
|
+
* @param {string} [context.name] The name of the context of the message. Usually the component's name.
|
|
163
|
+
* @param {HTMLElement} [context.element] The element relevant to the message.
|
|
162
164
|
*/
|
|
163
|
-
function logWarning() {
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
function logWarning(message) {
|
|
166
|
+
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
167
|
+
if (isDev()) {
|
|
168
|
+
const {
|
|
169
|
+
name,
|
|
170
|
+
element
|
|
171
|
+
} = context;
|
|
172
|
+
const formattedMessage = name ? `[${name}] ${message}` : message;
|
|
173
|
+
const args = element ? [formattedMessage, element] : [formattedMessage];
|
|
174
|
+
console.warn(...args); // eslint-disable-line no-console
|
|
168
175
|
}
|
|
169
176
|
}
|
|
170
177
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "126.3.
|
|
3
|
+
"version": "126.3.2",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -146,8 +146,8 @@
|
|
|
146
146
|
"mockdate": "^3.0.5",
|
|
147
147
|
"module-alias": "^2.2.3",
|
|
148
148
|
"pikaday": "^1.8.0",
|
|
149
|
-
"playwright": "^1.
|
|
150
|
-
"playwright-core": "^1.
|
|
149
|
+
"playwright": "^1.57.0",
|
|
150
|
+
"playwright-core": "^1.57.0",
|
|
151
151
|
"postcss": "8.5.6",
|
|
152
152
|
"postcss-loader": "8.2.0",
|
|
153
153
|
"postcss-scss": "4.0.9",
|
|
@@ -149,8 +149,8 @@ export default {
|
|
|
149
149
|
mounted() {
|
|
150
150
|
if (this.hasIconOnly && !this.$attrs['aria-label']) {
|
|
151
151
|
logWarning(
|
|
152
|
-
'
|
|
153
|
-
this.$el,
|
|
152
|
+
'Icon-only badges require an aria-label for accessibility. The label should describe the metadata (e.g., "Due date", "Open issue"), not the icon name. See https://design.gitlab.com/components/badge#using-icon-only-badges',
|
|
153
|
+
{ name: 'GlBadge', element: this.$el },
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
156
|
},
|
|
@@ -369,10 +369,10 @@ export default {
|
|
|
369
369
|
mounted() {
|
|
370
370
|
// eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
|
|
371
371
|
if (!this.$slots.default && !this.$attrs['aria-label'] && !this.$props.label) {
|
|
372
|
-
logWarning(
|
|
373
|
-
|
|
374
|
-
this.$el,
|
|
375
|
-
);
|
|
372
|
+
logWarning('Accessible name missing. Please add inner text or aria-label.', {
|
|
373
|
+
name: 'GlButton',
|
|
374
|
+
element: this.$el,
|
|
375
|
+
});
|
|
376
376
|
}
|
|
377
377
|
},
|
|
378
378
|
methods: {
|
|
@@ -247,8 +247,8 @@ export default {
|
|
|
247
247
|
isIconOnly() {
|
|
248
248
|
return Boolean(
|
|
249
249
|
this.icon &&
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
(!this.text?.length || this.textSrOnly) &&
|
|
251
|
+
!this.hasSlotContents('button-text'),
|
|
252
252
|
);
|
|
253
253
|
},
|
|
254
254
|
isIconWithText() {
|
|
@@ -3,6 +3,7 @@ import isEqual from 'lodash/isEqual';
|
|
|
3
3
|
import cloneDeep from 'lodash/cloneDeep';
|
|
4
4
|
import { PortalTarget } from 'portal-vue';
|
|
5
5
|
import { GlTooltipDirective } from '../../../directives/tooltip/tooltip';
|
|
6
|
+
import { logWarning } from '../../../utils/utils';
|
|
6
7
|
import GlIcon from '../icon/icon.vue';
|
|
7
8
|
import GlSearchBoxByClick from '../search_box_by_click/search_box_by_click.vue';
|
|
8
9
|
import GlFilteredSearchTerm from './filtered_search_term.vue';
|
|
@@ -72,9 +73,9 @@ export default {
|
|
|
72
73
|
// eslint-disable-next-line no-underscore-dangle
|
|
73
74
|
const isOk = Array.isArray(value) && value.every(({ token }) => !token || token.__v_skip);
|
|
74
75
|
if (!isOk) {
|
|
75
|
-
|
|
76
|
-
console.warn(
|
|
76
|
+
logWarning(
|
|
77
77
|
'You are using Vue3. In Vue3 each token component passed to filtered search must be wrapped into markRaw',
|
|
78
|
+
{ name: 'GlFilteredSearch' },
|
|
78
79
|
);
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<script>
|
|
3
3
|
import iconsPath from '@gitlab/svgs/dist/icons.svg';
|
|
4
4
|
import iconsInfo from '@gitlab/svgs/dist/icons.json';
|
|
5
|
+
import { logWarning } from '../../../utils/utils';
|
|
5
6
|
import { iconSizeOptions, iconVariantOptions } from '../../../utils/constants';
|
|
6
7
|
|
|
7
8
|
const knownIcons = new Set(iconsInfo.icons);
|
|
@@ -36,8 +37,7 @@ export default {
|
|
|
36
37
|
if (knownIcons.has(value)) {
|
|
37
38
|
return true;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
console.warn(`Icon '${value}' is not a known icon of @gitlab/svgs`);
|
|
40
|
+
logWarning(`Icon '${value}' is not a known icon of @gitlab/svgs`, { name: 'GlIcon' });
|
|
41
41
|
return false;
|
|
42
42
|
},
|
|
43
43
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<script>
|
|
3
3
|
import illustrationsPath from '@gitlab/svgs/dist/illustrations.svg';
|
|
4
4
|
import illustrationsInfo from '@gitlab/svgs/dist/illustrations.json';
|
|
5
|
+
import { logWarning } from '../../../utils/utils';
|
|
5
6
|
|
|
6
7
|
const knownIllustrations = illustrationsInfo.icons;
|
|
7
8
|
|
|
@@ -24,8 +25,9 @@ export default {
|
|
|
24
25
|
if (knownIllustrations.some((obj) => obj.name === value)) {
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
logWarning(`Illustration '${value}' is not a known illustration of @gitlab/svgs`, {
|
|
29
|
+
name: 'GlIllustration',
|
|
30
|
+
});
|
|
29
31
|
return false;
|
|
30
32
|
},
|
|
31
33
|
},
|
|
@@ -141,19 +141,19 @@ export default {
|
|
|
141
141
|
shouldRenderModalFooter() {
|
|
142
142
|
return Boolean(
|
|
143
143
|
this.actionCancel ||
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
this.actionSecondary ||
|
|
145
|
+
this.actionPrimary ||
|
|
146
|
+
// eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
|
|
147
|
+
this.$slots['modal-footer'],
|
|
148
148
|
);
|
|
149
149
|
},
|
|
150
150
|
},
|
|
151
151
|
mounted() {
|
|
152
152
|
if (!this.ariaLabel && !this.title) {
|
|
153
|
-
logWarning(
|
|
154
|
-
|
|
155
|
-
this.$el,
|
|
156
|
-
);
|
|
153
|
+
logWarning('Accessible name for modal missing. Please add title prop or aria-label.', {
|
|
154
|
+
name: 'GlModal',
|
|
155
|
+
element: this.$el,
|
|
156
|
+
});
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
159
|
methods: {
|
|
@@ -121,8 +121,8 @@ export default {
|
|
|
121
121
|
validator: (value) => {
|
|
122
122
|
if (['left', 'center', 'right'].includes(value)) {
|
|
123
123
|
logWarning(
|
|
124
|
-
`
|
|
125
|
-
|
|
124
|
+
`"${value}" placement is deprecated. Use ${dropdownPlacements[value]} instead.`,
|
|
125
|
+
{ name: 'GlDisclosureDropdown/GlCollapsibleListbox' },
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -347,9 +347,12 @@ export default {
|
|
|
347
347
|
checkToggleFocusable() {
|
|
348
348
|
if (!isElementFocusable(this.toggleElement) && !isElementTabbable(this.toggleElement)) {
|
|
349
349
|
logWarning(
|
|
350
|
-
`
|
|
350
|
+
`Toggle is missing a 'tabindex' and cannot be focused.
|
|
351
351
|
Use 'a' or 'button' element instead or make sure to add 'role="button"' along with 'tabindex' otherwise.`,
|
|
352
|
-
|
|
352
|
+
{
|
|
353
|
+
name: 'GlDisclosureDropdown/GlCollapsibleListbox',
|
|
354
|
+
element: this.$el,
|
|
355
|
+
},
|
|
353
356
|
);
|
|
354
357
|
}
|
|
355
358
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<script>
|
|
3
3
|
import clamp from 'lodash/clamp';
|
|
4
4
|
import uniqueId from 'lodash/uniqueId';
|
|
5
|
-
import { stopEvent } from '../../../../utils/utils';
|
|
5
|
+
import { stopEvent, logWarning } from '../../../../utils/utils';
|
|
6
6
|
import {
|
|
7
7
|
GL_DROPDOWN_SHOWN,
|
|
8
8
|
GL_DROPDOWN_HIDDEN,
|
|
@@ -587,9 +587,9 @@ export default {
|
|
|
587
587
|
immediate: true,
|
|
588
588
|
handler(newValue) {
|
|
589
589
|
if (newValue && this.items.some((item) => !isOption(item))) {
|
|
590
|
-
|
|
591
|
-
console.warn(
|
|
590
|
+
logWarning(
|
|
592
591
|
'When using grouped options infinite scroll can only be used on the last group.',
|
|
592
|
+
{ name: 'GlCollapsibleListbox' },
|
|
593
593
|
);
|
|
594
594
|
}
|
|
595
595
|
},
|
|
@@ -105,7 +105,7 @@ export default {
|
|
|
105
105
|
// logWarning will call isDev before logging any message
|
|
106
106
|
// this additional call to isDev is being made to exit the condition early when run in production
|
|
107
107
|
if (isDev() && !shouldUseFullTable(this)) {
|
|
108
|
-
logWarning(glTableLiteWarning, this.$el);
|
|
108
|
+
logWarning(glTableLiteWarning, { name: 'GlTable', element: this.$el });
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
methods: {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import isPlainObject from 'lodash/isPlainObject';
|
|
4
4
|
import { BTab } from '../../../../vendor/bootstrap-vue/src/components/tabs/tab';
|
|
5
5
|
import GlBadge from '../../badge/badge.vue';
|
|
6
|
+
import { logWarning } from '../../../../utils/utils';
|
|
6
7
|
|
|
7
8
|
import { DEFAULT_TAB_TITLE_LINK_CLASS } from '../constants';
|
|
8
9
|
|
|
@@ -63,10 +64,10 @@ export default {
|
|
|
63
64
|
},
|
|
64
65
|
},
|
|
65
66
|
created() {
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
if (this.hasTabCount && !this.tabCountSrText) {
|
|
68
|
+
logWarning(
|
|
69
|
+
'When using "tab-count", you should also provide "tab-count-sr-text" for screen reader accessibility. Example: :tab-count-sr-text="n__(\'%d item\', \'%d items\', count)"',
|
|
70
|
+
{ name: 'GlTab' },
|
|
70
71
|
);
|
|
71
72
|
}
|
|
72
73
|
},
|
package/src/utils/utils.js
CHANGED
|
@@ -173,12 +173,17 @@ export function isDev() {
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Prints a warning message to the console in non-test and non-production environments.
|
|
176
|
-
* @param {string} message
|
|
177
|
-
* @param {
|
|
176
|
+
* @param {string} message Message to print to the console.
|
|
177
|
+
* @param {Object} [context] Optional object with additional context.
|
|
178
|
+
* @param {string} [context.name] The name of the context of the message. Usually the component's name.
|
|
179
|
+
* @param {HTMLElement} [context.element] The element relevant to the message.
|
|
178
180
|
*/
|
|
179
|
-
export function logWarning(message
|
|
180
|
-
if (
|
|
181
|
-
|
|
181
|
+
export function logWarning(message, context = {}) {
|
|
182
|
+
if (isDev()) {
|
|
183
|
+
const { name, element } = context;
|
|
184
|
+
const formattedMessage = name ? `[${name}] ${message}` : message;
|
|
185
|
+
const args = element ? [formattedMessage, element] : [formattedMessage];
|
|
186
|
+
console.warn(...args); // eslint-disable-line no-console
|
|
182
187
|
}
|
|
183
188
|
}
|
|
184
189
|
|