@gitlab/ui 48.1.1 → 48.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [48.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.1.2...v48.2.0) (2022-10-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * **datepicker:** add public show method for datepicker ([adc2c8f](https://gitlab.com/gitlab-org/gitlab-ui/commit/adc2c8f53016efb253b003b02e6c354eb297ddb6))
7
+
8
+ ## [48.1.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.1.1...v48.1.2) (2022-10-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **GlPagination:** Fix GlPagination accessibility ([a802cf6](https://gitlab.com/gitlab-org/gitlab-ui/commit/a802cf6752e9d29c28b0059f94f63592d10ed86d))
14
+
1
15
  ## [48.1.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.1.0...v48.1.1) (2022-10-21)
2
16
 
3
17
 
@@ -189,7 +189,7 @@ var script = {
189
189
 
190
190
  computed: {
191
191
  formattedDate() {
192
- return this.$options.pikaday.calendar && this.$options.pikaday.calendar.toString();
192
+ return 'calendar' in this && this.calendar.toString();
193
193
  },
194
194
 
195
195
  customTrigger() {
@@ -223,25 +223,25 @@ var script = {
223
223
  },
224
224
  watch: {
225
225
  value(val) {
226
- if (!areDatesEqual(val, this.$options.pikaday.calendar.getDate())) {
227
- this.$options.pikaday.calendar.setDate(val, true);
226
+ if (!areDatesEqual(val, this.calendar.getDate())) {
227
+ this.calendar.setDate(val, true);
228
228
  }
229
229
  },
230
230
 
231
231
  minDate(minDate) {
232
- this.$options.pikaday.calendar.setMinDate(minDate);
232
+ this.calendar.setMinDate(minDate);
233
233
  },
234
234
 
235
235
  maxDate(maxDate) {
236
- this.$options.pikaday.calendar.setMaxDate(maxDate);
236
+ this.calendar.setMaxDate(maxDate);
237
237
  },
238
238
 
239
239
  startRange(startRange) {
240
- this.$options.pikaday.calendar.setStartRange(startRange);
240
+ this.calendar.setStartRange(startRange);
241
241
  },
242
242
 
243
243
  endRange(endRange) {
244
- this.$options.pikaday.calendar.setEndRange(endRange);
244
+ this.calendar.setEndRange(endRange);
245
245
  }
246
246
 
247
247
  },
@@ -295,18 +295,23 @@ var script = {
295
295
  pikadayConfig.i18n = this.i18n;
296
296
  }
297
297
 
298
- this.$options.pikaday.calendar = new Pikaday(pikadayConfig);
298
+ this.calendar = new Pikaday(pikadayConfig);
299
299
 
300
300
  if (this.startOpened) {
301
- this.$options.pikaday.calendar.show();
301
+ this.calendar.show();
302
302
  }
303
303
  },
304
304
 
305
305
  beforeDestroy() {
306
- this.$options.pikaday.calendar.destroy();
306
+ this.calendar.destroy();
307
307
  },
308
308
 
309
309
  methods: {
310
+ // is used to open datepicker programmatically
311
+ show() {
312
+ this.calendar.show();
313
+ },
314
+
310
315
  selected(date) {
311
316
  /**
312
317
  * Emitted when a new date has been selected.
@@ -348,17 +353,11 @@ var script = {
348
353
  onKeydown() {
349
354
  if (this.textInput === '') {
350
355
  const resetDate = this.minDate || null;
351
- this.$options.pikaday.calendar.setDate(resetDate);
356
+ this.calendar.setDate(resetDate);
352
357
  this.selected(resetDate);
353
358
  }
354
359
  }
355
360
 
356
- },
357
- // Vue3 will make this.$options shallow-readonly
358
- // that means that in order to store anything in $options
359
- // we need an object as a container
360
- pikaday: {
361
- calendar: null
362
361
  }
363
362
  };
364
363
 
@@ -413,16 +413,16 @@ var script = {
413
413
  const __vue_script__ = script;
414
414
 
415
415
  /* template */
416
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.isVisible)?_c('ul',{staticClass:"pagination gl-pagination text-nowrap",class:_vm.wrapperClasses,attrs:{"role":"navigation","aria-label":"Pagination"}},[_c('li',{staticClass:"page-item",class:{
417
- disabled: _vm.prevPageIsDisabled,
418
- 'flex-fill': _vm.isFillAlign,
419
- },attrs:{"aria-hidden":_vm.prevPageIsDisabled}},[_c(_vm.prevPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-link page-link prev-page-item gl-display-flex",attrs:{"aria-label":_vm.prevPageAriaLabel,"href":_vm.prevPageHref},on:{"click":function($event){return _vm.handlePrevious($event, _vm.value - 1)}}},[_vm._t("previous",function(){return [_c('gl-icon',{attrs:{"name":"chevron-left"}}),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.prevText))])]},null,{ page: _vm.value - 1, disabled: _vm.prevPageIsDisabled })],2)],1),_vm._v(" "),_vm._l((_vm.visibleItems),function(item){return _c('li',{key:item.key,staticClass:"page-item",class:{
420
- disabled: item.disabled,
421
- 'flex-fill': _vm.isFillAlign,
422
- }},[_c(item.component,_vm._g(_vm._b({tag:"component",staticClass:"page-link",attrs:{"size":"md","aria-disabled":item.disabled}},'component',item.attrs,false),item.listeners),[_vm._t(item.slot,function(){return [_vm._v(_vm._s(item.content))]},null,item.slotData)],2)],1)}),_vm._v(" "),_c('li',{staticClass:"page-item",class:{
423
- disabled: _vm.nextPageIsDisabled,
424
- 'flex-fill': _vm.isFillAlign,
425
- },attrs:{"aria-hidden":_vm.nextPageIsDisabled}},[_c(_vm.nextPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-link page-link next-page-item gl-display-flex",attrs:{"aria-label":_vm.nextPageAriaLabel,"href":_vm.nextPageHref},on:{"click":function($event){return _vm.handleNext($event, _vm.value + 1)}}},[_vm._t("next",function(){return [_c('span',[_vm._v(_vm._s(_vm.nextText))]),_vm._v(" "),_c('gl-icon',{attrs:{"name":"chevron-right"}})]},null,{ page: _vm.value + 1, disabled: _vm.nextPageIsDisabled })],2)],1)],2):_vm._e()};
416
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('nav',{attrs:{"aria-label":"Pagination"}},[(_vm.isVisible)?_c('ul',{staticClass:"pagination gl-pagination text-nowrap",class:_vm.wrapperClasses},[_c('li',{staticClass:"page-item",class:{
417
+ disabled: _vm.prevPageIsDisabled,
418
+ 'flex-fill': _vm.isFillAlign,
419
+ },attrs:{"aria-hidden":_vm.prevPageIsDisabled}},[_c(_vm.prevPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-link page-link prev-page-item gl-display-flex",attrs:{"aria-label":_vm.prevPageAriaLabel,"href":_vm.prevPageHref},on:{"click":function($event){return _vm.handlePrevious($event, _vm.value - 1)}}},[_vm._t("previous",function(){return [_c('gl-icon',{attrs:{"name":"chevron-left"}}),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.prevText))])]},null,{ page: _vm.value - 1, disabled: _vm.prevPageIsDisabled })],2)],1),_vm._v(" "),_vm._l((_vm.visibleItems),function(item){return _c('li',{key:item.key,staticClass:"page-item",class:{
420
+ disabled: item.disabled,
421
+ 'flex-fill': _vm.isFillAlign,
422
+ }},[_c(item.component,_vm._g(_vm._b({tag:"component",staticClass:"page-link",attrs:{"size":"md","aria-disabled":item.disabled}},'component',item.attrs,false),item.listeners),[_vm._t(item.slot,function(){return [_vm._v(_vm._s(item.content))]},null,item.slotData)],2)],1)}),_vm._v(" "),_c('li',{staticClass:"page-item",class:{
423
+ disabled: _vm.nextPageIsDisabled,
424
+ 'flex-fill': _vm.isFillAlign,
425
+ },attrs:{"aria-hidden":_vm.nextPageIsDisabled}},[_c(_vm.nextPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-link page-link next-page-item gl-display-flex",attrs:{"aria-label":_vm.nextPageAriaLabel,"href":_vm.nextPageHref},on:{"click":function($event){return _vm.handleNext($event, _vm.value + 1)}}},[_vm._t("next",function(){return [_c('span',[_vm._v(_vm._s(_vm.nextText))]),_vm._v(" "),_c('gl-icon',{attrs:{"name":"chevron-right"}})]},null,{ page: _vm.value + 1, disabled: _vm.nextPageIsDisabled })],2)],1)],2):_vm._e()])};
426
426
  var __vue_staticRenderFns__ = [];
427
427
 
428
428
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "48.1.1",
3
+ "version": "48.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -53,7 +53,7 @@ export const Image = (args, { argTypes }) => ({
53
53
  <gl-avatar
54
54
  :size="size"
55
55
  :shape="shape"
56
- src="https://about.gitlab.com/images/press/gitlab-summit-south-africa.jpg"
56
+ src="./img/gitlab-summit-south-africa.jpg"
57
57
  />
58
58
  `,
59
59
  });
@@ -66,7 +66,7 @@ export const ResponsiveImage = (args, { argTypes }) => ({
66
66
  <gl-avatar
67
67
  :size="size"
68
68
  :shape="shape"
69
- src="https://about.gitlab.com/images/press/gitlab-summit-south-africa.jpg"
69
+ src="./img/gitlab-summit-south-africa.jpg"
70
70
  />
71
71
  `,
72
72
  });
@@ -97,7 +97,7 @@ export const WithTooltip = (args, { argTypes }) => ({
97
97
  :size="size"
98
98
  :shape="shape"
99
99
  :title="tooltipText"
100
- src="https://about.gitlab.com/images/press/gitlab-summit-south-africa.jpg"
100
+ src="./img/gitlab-summit-south-africa.jpg"
101
101
  v-gl-tooltip="{ placement }"
102
102
  />
103
103
  `,
@@ -3,11 +3,11 @@ import { avatarsInlineSizeOptions } from '../../../utils/constants';
3
3
  import readme from './avatars_inline.md';
4
4
 
5
5
  const defaultAvatars = [
6
- { src: 'https://picsum.photos/id/1005/32', alt: 'Administrator’s user avatar' },
7
- { src: 'https://picsum.photos/id/1006/32', alt: 'Ops Manager’s user avatar' },
8
- { src: 'https://picsum.photos/id/1009/32', alt: 'Developer’s user avatar' },
9
- { src: 'https://picsum.photos/id/1011/32', alt: 'Business Admin’s user avatar' },
10
- { src: 'https://picsum.photos/id/1012/32', alt: 'Product designer’s user avatar' },
6
+ { src: './img/avatar_1.png', alt: 'Administrator’s user avatar' },
7
+ { src: './img/avatar_2.png', alt: 'Ops Manager’s user avatar' },
8
+ { src: './img/avatar_3.png', alt: 'Developer’s user avatar' },
9
+ { src: './img/avatar_4.png', alt: 'Business Admin’s user avatar' },
10
+ { src: './img/avatar_5.png', alt: 'Product designer’s user avatar' },
11
11
  ];
12
12
 
13
13
  const generateProps = (
@@ -73,6 +73,14 @@ describe('datepicker component', () => {
73
73
  expect(Pikaday.prototype.show).toHaveBeenCalled();
74
74
  });
75
75
 
76
+ it('opens calendar when show method is called', () => {
77
+ const wrapper = mountWithOptions();
78
+
79
+ wrapper.vm.show();
80
+
81
+ expect(Pikaday.prototype.show).toHaveBeenCalled();
82
+ });
83
+
76
84
  describe('when `ariaLabel` prop is passed', () => {
77
85
  it('configures pikaday with the given label', () => {
78
86
  const ariaLabel = 'Meaningful description';
@@ -179,7 +179,7 @@ export default {
179
179
  },
180
180
  computed: {
181
181
  formattedDate() {
182
- return this.$options.pikaday.calendar && this.$options.pikaday.calendar.toString();
182
+ return 'calendar' in this && this.calendar.toString();
183
183
  },
184
184
  customTrigger() {
185
185
  return isString(this.target) && this.target !== '';
@@ -207,21 +207,21 @@ export default {
207
207
  },
208
208
  watch: {
209
209
  value(val) {
210
- if (!areDatesEqual(val, this.$options.pikaday.calendar.getDate())) {
211
- this.$options.pikaday.calendar.setDate(val, true);
210
+ if (!areDatesEqual(val, this.calendar.getDate())) {
211
+ this.calendar.setDate(val, true);
212
212
  }
213
213
  },
214
214
  minDate(minDate) {
215
- this.$options.pikaday.calendar.setMinDate(minDate);
215
+ this.calendar.setMinDate(minDate);
216
216
  },
217
217
  maxDate(maxDate) {
218
- this.$options.pikaday.calendar.setMaxDate(maxDate);
218
+ this.calendar.setMaxDate(maxDate);
219
219
  },
220
220
  startRange(startRange) {
221
- this.$options.pikaday.calendar.setStartRange(startRange);
221
+ this.calendar.setStartRange(startRange);
222
222
  },
223
223
  endRange(endRange) {
224
- this.$options.pikaday.calendar.setEndRange(endRange);
224
+ this.calendar.setEndRange(endRange);
225
225
  },
226
226
  },
227
227
  mounted() {
@@ -279,16 +279,21 @@ export default {
279
279
  pikadayConfig.i18n = this.i18n;
280
280
  }
281
281
 
282
- this.$options.pikaday.calendar = new Pikaday(pikadayConfig);
282
+ this.calendar = new Pikaday(pikadayConfig);
283
283
 
284
284
  if (this.startOpened) {
285
- this.$options.pikaday.calendar.show();
285
+ this.calendar.show();
286
286
  }
287
287
  },
288
288
  beforeDestroy() {
289
- this.$options.pikaday.calendar.destroy();
289
+ this.calendar.destroy();
290
290
  },
291
291
  methods: {
292
+ // is used to open datepicker programmatically
293
+ show() {
294
+ this.calendar.show();
295
+ },
296
+
292
297
  selected(date) {
293
298
  /**
294
299
  * Emitted when a new date has been selected.
@@ -324,18 +329,11 @@ export default {
324
329
  onKeydown() {
325
330
  if (this.textInput === '') {
326
331
  const resetDate = this.minDate || null;
327
- this.$options.pikaday.calendar.setDate(resetDate);
332
+ this.calendar.setDate(resetDate);
328
333
  this.selected(resetDate);
329
334
  }
330
335
  },
331
336
  },
332
-
333
- // Vue3 will make this.$options shallow-readonly
334
- // that means that in order to store anything in $options
335
- // we need an object as a container
336
- pikaday: {
337
- calendar: null,
338
- },
339
337
  };
340
338
  </script>
341
339
 
@@ -375,102 +375,98 @@ export default {
375
375
  </script>
376
376
 
377
377
  <template>
378
- <ul
379
- v-if="isVisible"
380
- role="navigation"
381
- class="pagination gl-pagination text-nowrap"
382
- :class="wrapperClasses"
383
- aria-label="Pagination"
384
- >
385
- <li
386
- class="page-item"
387
- :class="{
388
- disabled: prevPageIsDisabled,
389
- 'flex-fill': isFillAlign,
390
- }"
391
- :aria-hidden="prevPageIsDisabled"
392
- >
393
- <component
394
- :is="prevPageIsDisabled ? 'span' : 'a'"
395
- class="gl-link page-link prev-page-item gl-display-flex"
396
- :aria-label="prevPageAriaLabel"
397
- :href="prevPageHref"
398
- @click="handlePrevious($event, value - 1)"
378
+ <nav aria-label="Pagination">
379
+ <ul v-if="isVisible" class="pagination gl-pagination text-nowrap" :class="wrapperClasses">
380
+ <li
381
+ class="page-item"
382
+ :class="{
383
+ disabled: prevPageIsDisabled,
384
+ 'flex-fill': isFillAlign,
385
+ }"
386
+ :aria-hidden="prevPageIsDisabled"
399
387
  >
400
- <!--
401
- @slot Content for the "previous" button. Overrides the "prevText" prop.
388
+ <component
389
+ :is="prevPageIsDisabled ? 'span' : 'a'"
390
+ class="gl-link page-link prev-page-item gl-display-flex"
391
+ :aria-label="prevPageAriaLabel"
392
+ :href="prevPageHref"
393
+ @click="handlePrevious($event, value - 1)"
394
+ >
395
+ <!--
396
+ @slot Content for the "previous" button. Overrides the "prevText" prop.
397
+ @binding {boolean} active
398
+ @binding {boolean} disabled
399
+ @binding {number} number
400
+ -->
401
+ <slot name="previous" v-bind="{ page: value - 1, disabled: prevPageIsDisabled }">
402
+ <gl-icon name="chevron-left" />
403
+ <span>{{ prevText }}</span>
404
+ </slot>
405
+ </component>
406
+ </li>
407
+ <li
408
+ v-for="item in visibleItems"
409
+ :key="item.key"
410
+ class="page-item"
411
+ :class="{
412
+ disabled: item.disabled,
413
+ 'flex-fill': isFillAlign,
414
+ }"
415
+ >
416
+ <component
417
+ :is="item.component"
418
+ size="md"
419
+ :aria-disabled="item.disabled"
420
+ class="page-link"
421
+ v-bind="item.attrs"
422
+ v-on="item.listeners"
423
+ >
424
+ <!--
425
+ Content for page number buttons.
426
+ @slot page-number
402
427
  @binding {boolean} active
403
428
  @binding {boolean} disabled
404
429
  @binding {number} number
405
430
  -->
406
- <slot name="previous" v-bind="{ page: value - 1, disabled: prevPageIsDisabled }">
407
- <gl-icon name="chevron-left" />
408
- <span>{{ prevText }}</span>
409
- </slot>
410
- </component>
411
- </li>
412
- <li
413
- v-for="item in visibleItems"
414
- :key="item.key"
415
- class="page-item"
416
- :class="{
417
- disabled: item.disabled,
418
- 'flex-fill': isFillAlign,
419
- }"
420
- >
421
- <component
422
- :is="item.component"
423
- size="md"
424
- :aria-disabled="item.disabled"
425
- class="page-link"
426
- v-bind="item.attrs"
427
- v-on="item.listeners"
428
- >
429
- <!--
430
- Content for page number buttons.
431
- @slot page-number
432
- @binding {boolean} active
433
- @binding {boolean} disabled
434
- @binding {number} number
435
- -->
436
- <!--
437
- Content for the left ellipsis. Overrides the "ellipsisText" prop.
438
- @slot ellipsis-left
439
- -->
440
- <!--
441
- Content for the right ellipsis. Overrides the "ellipsisText" prop.
442
- @slot ellipsis-right
443
- -->
444
- <slot :name="item.slot" v-bind="item.slotData">{{ item.content }}</slot>
445
- </component>
446
- </li>
431
+ <!--
432
+ Content for the left ellipsis. Overrides the "ellipsisText" prop.
433
+ @slot ellipsis-left
434
+ -->
435
+ <!--
436
+ Content for the right ellipsis. Overrides the "ellipsisText" prop.
437
+ @slot ellipsis-right
438
+ -->
439
+ <slot :name="item.slot" v-bind="item.slotData">{{ item.content }}</slot>
440
+ </component>
441
+ </li>
447
442
 
448
- <li
449
- class="page-item"
450
- :class="{
451
- disabled: nextPageIsDisabled,
452
- 'flex-fill': isFillAlign,
453
- }"
454
- :aria-hidden="nextPageIsDisabled"
455
- >
456
- <component
457
- :is="nextPageIsDisabled ? 'span' : 'a'"
458
- class="gl-link page-link next-page-item gl-display-flex"
459
- :aria-label="nextPageAriaLabel"
460
- :href="nextPageHref"
461
- @click="handleNext($event, value + 1)"
443
+ <li
444
+ class="page-item"
445
+ :class="{
446
+ disabled: nextPageIsDisabled,
447
+ 'flex-fill': isFillAlign,
448
+ }"
449
+ :aria-hidden="nextPageIsDisabled"
462
450
  >
463
- <!--
464
- @slot Content for the "next" button. Overrides the "nextText" prop.
465
- @binding {boolean} active
466
- @binding {boolean} disabled
467
- @binding {number} number
468
- -->
469
- <slot name="next" v-bind="{ page: value + 1, disabled: nextPageIsDisabled }">
470
- <span>{{ nextText }}</span>
471
- <gl-icon name="chevron-right" />
472
- </slot>
473
- </component>
474
- </li>
475
- </ul>
451
+ <component
452
+ :is="nextPageIsDisabled ? 'span' : 'a'"
453
+ class="gl-link page-link next-page-item gl-display-flex"
454
+ :aria-label="nextPageAriaLabel"
455
+ :href="nextPageHref"
456
+ @click="handleNext($event, value + 1)"
457
+ >
458
+ <!--
459
+ @slot Content for the "next" button. Overrides the "nextText" prop.
460
+ @binding {boolean} active
461
+ @binding {boolean} disabled
462
+ @binding {number} number
463
+ -->
464
+ <slot name="next" v-bind="{ page: value + 1, disabled: nextPageIsDisabled }">
465
+ <span>{{ nextText }}</span>
466
+ <gl-icon name="chevron-right" />
467
+ </slot>
468
+ </component>
469
+ </li>
470
+ </ul>
471
+ </nav>
476
472
  </template>