@gitlab/ui 95.2.0 → 95.2.1

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 CHANGED
@@ -1,3 +1,14 @@
1
+ ## [95.2.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v95.2.0...v95.2.1) (2024-10-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlDatepicker:** adds tests ([21a6964](https://gitlab.com/gitlab-org/gitlab-ui/commit/21a69648b077fc93f614a89bcf1432717f2e8945))
7
+ * **GlDatepicker:** Bind correct this ([392a6cd](https://gitlab.com/gitlab-org/gitlab-ui/commit/392a6cd192d443e6ca2be6e5cccb409894492126))
8
+ * **GlDatepicker:** Fix accessibility violations ([c753967](https://gitlab.com/gitlab-org/gitlab-ui/commit/c753967ea5a0dc113182f051500983881d579c6e))
9
+ * **GlDatepicker:** format with prettier ([0af6cff](https://gitlab.com/gitlab-org/gitlab-ui/commit/0af6cfff35a997925ee830ce2a0e44b52ea1bac0))
10
+ * **GlDatepicker:** Use translate function for aria-label ([ae13b84](https://gitlab.com/gitlab-org/gitlab-ui/commit/ae13b8412a40ecedf2fbc52247f9ed7a6962b4db))
11
+
1
12
  # [95.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v95.1.1...v95.2.0) (2024-10-07)
2
13
 
3
14
 
@@ -5,6 +5,7 @@ import { areDatesEqual } from '../../../utils/datetime_utility';
5
5
  import GlButton from '../button/button';
6
6
  import GlFormInput from '../form/form_input/form_input';
7
7
  import GlIcon from '../icon/icon';
8
+ import { translate } from '../../../utils/i18n';
8
9
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
9
10
 
10
11
  //
@@ -40,6 +41,24 @@ const highlightPastDates = pikaday => {
40
41
  }
41
42
  });
42
43
  };
44
+ const addAccessibleLabels = element => {
45
+ // Pikaday sets `role="heading"`, which requires a corresponding
46
+ // `aria-level`. Ensure we have one.
47
+ const titleEl = element.querySelector('.pika-title[role="heading"]');
48
+ if (titleEl) {
49
+ titleEl.setAttribute('aria-level', 3);
50
+ }
51
+
52
+ // Add aria-label to month & year select dropdowns
53
+ const monthEl = element.querySelector('select.pika-select-month');
54
+ if (monthEl) {
55
+ monthEl.setAttribute('aria-label', translate('GlDatepicker.monthLabel', 'Month'));
56
+ }
57
+ const yearEl = element.querySelector('select.pika-select-year');
58
+ if (yearEl) {
59
+ yearEl.setAttribute('aria-label', translate('GlDatepicker.yearLabel', 'Year'));
60
+ }
61
+ };
43
62
  var script = {
44
63
  name: 'GlDatepicker',
45
64
  components: {
@@ -251,6 +270,7 @@ var script = {
251
270
  },
252
271
  mounted() {
253
272
  const $parentEl = this.$parent.$el;
273
+ const openedEvent = this.opened.bind(this);
254
274
  const drawEvent = this.draw.bind(this);
255
275
  const pikadayConfig = {
256
276
  field: this.$el.querySelector('input[type="text"]'),
@@ -272,7 +292,10 @@ var script = {
272
292
  toString: date => defaultDateFormatter(date),
273
293
  onSelect: this.selected.bind(this),
274
294
  onClose: this.closed.bind(this),
275
- onOpen: this.opened.bind(this),
295
+ onOpen: () => {
296
+ addAccessibleLabels(this.$el);
297
+ openedEvent();
298
+ },
276
299
  onDraw: pikaday => {
277
300
  highlightPastDates(pikaday);
278
301
  drawEvent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "95.2.0",
3
+ "version": "95.2.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -7,6 +7,7 @@ import { areDatesEqual } from '../../../utils/datetime_utility';
7
7
  import GlButton from '../button/button.vue';
8
8
  import GlFormInput from '../form/form_input/form_input.vue';
9
9
  import GlIcon from '../icon/icon.vue';
10
+ import { translate } from '../../../utils/i18n';
10
11
 
11
12
  export const pad = (val, len = 2) => `0${val}`.slice(-len);
12
13
 
@@ -39,6 +40,26 @@ const highlightPastDates = (pikaday) => {
39
40
  });
40
41
  };
41
42
 
43
+ const addAccessibleLabels = (element) => {
44
+ // Pikaday sets `role="heading"`, which requires a corresponding
45
+ // `aria-level`. Ensure we have one.
46
+ const titleEl = element.querySelector('.pika-title[role="heading"]');
47
+ if (titleEl) {
48
+ titleEl.setAttribute('aria-level', 3);
49
+ }
50
+
51
+ // Add aria-label to month & year select dropdowns
52
+ const monthEl = element.querySelector('select.pika-select-month');
53
+ if (monthEl) {
54
+ monthEl.setAttribute('aria-label', translate('GlDatepicker.monthLabel', 'Month'));
55
+ }
56
+
57
+ const yearEl = element.querySelector('select.pika-select-year');
58
+ if (yearEl) {
59
+ yearEl.setAttribute('aria-label', translate('GlDatepicker.yearLabel', 'Year'));
60
+ }
61
+ };
62
+
42
63
  export default {
43
64
  name: 'GlDatepicker',
44
65
  components: {
@@ -257,6 +278,7 @@ export default {
257
278
  },
258
279
  mounted() {
259
280
  const $parentEl = this.$parent.$el;
281
+ const openedEvent = this.opened.bind(this);
260
282
  const drawEvent = this.draw.bind(this);
261
283
 
262
284
  const pikadayConfig = {
@@ -280,7 +302,10 @@ export default {
280
302
  toString: (date) => defaultDateFormatter(date),
281
303
  onSelect: this.selected.bind(this),
282
304
  onClose: this.closed.bind(this),
283
- onOpen: this.opened.bind(this),
305
+ onOpen: () => {
306
+ addAccessibleLabels(this.$el);
307
+ openedEvent();
308
+ },
284
309
  onDraw: (pikaday) => {
285
310
  highlightPastDates(pikaday);
286
311
  drawEvent();
package/translations.js CHANGED
@@ -14,6 +14,8 @@ export default {
14
14
  'GlBreadcrumb.showMoreLabel': 'Show more breadcrumbs',
15
15
  'GlBroadcastMessage.closeButtonTitle': 'Dismiss',
16
16
  'GlCollapsibleListbox.srOnlyResultsLabel': null,
17
+ 'GlDatepicker.monthLabel': 'Month',
18
+ 'GlDatepicker.yearLabel': 'Year',
17
19
  'GlDuoChat.chatCancelLabel': 'Cancel',
18
20
  'GlDuoChat.chatCloseLabel': 'Close the Code Explanation',
19
21
  'GlDuoChat.chatDefaultPredefinedPromptsChangePassword': 'How do I change my password in GitLab?',