q2-tecton-elements 1.10.6 → 1.10.9

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.
Files changed (189) hide show
  1. package/dist/cjs/{index-f4153f5a.js → index-a55d3c34.js} +9 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/q2-btn_2.cjs.entry.js +10 -6
  4. package/dist/cjs/q2-calendar.cjs.entry.js +2902 -6078
  5. package/dist/cjs/q2-carousel-pane.cjs.entry.js +50 -7
  6. package/dist/cjs/q2-carousel.cjs.entry.js +2719 -6513
  7. package/dist/cjs/q2-checkbox-group.cjs.entry.js +2 -2
  8. package/dist/cjs/q2-checkbox.cjs.entry.js +10 -2
  9. package/dist/cjs/q2-dropdown-item.cjs.entry.js +2 -2
  10. package/dist/cjs/q2-dropdown.cjs.entry.js +8 -2
  11. package/dist/cjs/q2-editable-field.cjs.entry.js +26 -11
  12. package/dist/cjs/q2-icon.cjs.entry.js +1 -1
  13. package/dist/cjs/q2-input.cjs.entry.js +9 -7
  14. package/dist/cjs/q2-loading-element.cjs.entry.js +1 -1
  15. package/dist/cjs/q2-loc.cjs.entry.js +1 -1
  16. package/dist/cjs/q2-message.cjs.entry.js +11 -3
  17. package/dist/cjs/q2-optgroup.cjs.entry.js +2 -2
  18. package/dist/cjs/q2-option.cjs.entry.js +3 -34
  19. package/dist/cjs/q2-radio-group.cjs.entry.js +10 -2
  20. package/dist/cjs/q2-radio.cjs.entry.js +10 -2
  21. package/dist/cjs/q2-section.cjs.entry.js +9 -3
  22. package/dist/cjs/q2-select.cjs.entry.js +175 -130
  23. package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
  24. package/dist/cjs/q2-stepper.cjs.entry.js +10 -4
  25. package/dist/cjs/q2-tab-container.cjs.entry.js +9 -11
  26. package/dist/cjs/q2-tab-pane.cjs.entry.js +2 -2
  27. package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
  28. package/dist/cjs/q2-textarea.cjs.entry.js +8 -4
  29. package/dist/cjs/tecton-tab-pane.cjs.entry.js +2 -2
  30. package/dist/collection/components/q2-avatar/index.js +1 -1
  31. package/dist/collection/components/q2-avatar/styles.css +63 -61
  32. package/dist/collection/components/q2-btn/index.js +8 -4
  33. package/dist/collection/components/q2-btn/styles.css +96 -96
  34. package/dist/collection/components/q2-calendar/helpers.js +77 -52
  35. package/dist/collection/components/q2-calendar/index.js +248 -196
  36. package/dist/collection/components/q2-calendar/styles.css +63 -84
  37. package/dist/collection/components/q2-calendar/validation.js +100 -166
  38. package/dist/collection/components/q2-carousel/index.js +204 -266
  39. package/dist/collection/components/q2-carousel/styles.css +152 -155
  40. package/dist/collection/components/q2-carousel-pane/index.js +67 -28
  41. package/dist/collection/components/q2-carousel-pane/styles.css +82 -16
  42. package/dist/collection/components/q2-checkbox/index.js +16 -2
  43. package/dist/collection/components/q2-checkbox/styles.css +152 -176
  44. package/dist/collection/components/q2-checkbox-group/index.js +1 -1
  45. package/dist/collection/components/q2-checkbox-group/styles.css +65 -81
  46. package/dist/collection/components/q2-dropdown/index.js +15 -2
  47. package/dist/collection/components/q2-dropdown/styles.css +49 -36
  48. package/dist/collection/components/q2-dropdown-item/index.js +1 -1
  49. package/dist/collection/components/q2-dropdown-item/styles.css +48 -62
  50. package/dist/collection/components/q2-editable-field/index.js +33 -12
  51. package/dist/collection/components/q2-editable-field/styles.css +49 -50
  52. package/dist/collection/components/q2-icon/styles.css +29 -29
  53. package/dist/collection/components/q2-input/index.js +9 -7
  54. package/dist/collection/components/q2-input/styles.css +211 -292
  55. package/dist/collection/components/q2-loading/index.js +1 -1
  56. package/dist/collection/components/q2-loading/skeleton/q2-loading-element/index.js +1 -1
  57. package/dist/collection/components/q2-loading/skeleton/q2-loading-element/styles.css +5 -6
  58. package/dist/collection/components/q2-loading/styles.css +130 -136
  59. package/dist/collection/components/q2-loc/index.js +1 -1
  60. package/dist/collection/components/q2-loc/styles.css +30 -31
  61. package/dist/collection/components/q2-message/index.js +18 -3
  62. package/dist/collection/components/q2-message/styles.css +32 -29
  63. package/dist/collection/components/q2-optgroup/index.js +1 -1
  64. package/dist/collection/components/q2-optgroup/styles.css +42 -47
  65. package/dist/collection/components/q2-option/index.js +4 -42
  66. package/dist/collection/components/q2-option/styles.css +29 -29
  67. package/dist/collection/components/q2-radio/index.js +16 -2
  68. package/dist/collection/components/q2-radio/styles.css +29 -29
  69. package/dist/collection/components/q2-radio-group/index.js +16 -2
  70. package/dist/collection/components/q2-radio-group/styles.css +67 -72
  71. package/dist/collection/components/q2-section/index.js +15 -3
  72. package/dist/collection/components/q2-section/styles.css +77 -77
  73. package/dist/collection/components/q2-select/index.js +182 -131
  74. package/dist/collection/components/q2-select/styles.css +33 -34
  75. package/dist/collection/components/q2-stepper/index.js +15 -3
  76. package/dist/collection/components/q2-stepper/styles.css +32 -32
  77. package/dist/collection/components/q2-stepper-pane/styles.css +29 -29
  78. package/dist/collection/components/q2-tab-container/index.js +7 -9
  79. package/dist/collection/components/q2-tab-container/styles.css +29 -29
  80. package/dist/collection/components/q2-tab-pane/index.js +2 -2
  81. package/dist/collection/components/q2-tab-pane/styles.css +34 -36
  82. package/dist/collection/components/q2-textarea/index.js +8 -4
  83. package/dist/collection/components/q2-textarea/styles.css +180 -228
  84. package/dist/collection/components/tecton-tab-pane/index.js +2 -2
  85. package/dist/collection/components/tecton-tab-pane/styles.css +50 -50
  86. package/dist/collection/utils/index.js +7 -0
  87. package/dist/esm/{index-476b86cc.js → index-ec6660af.js} +8 -1
  88. package/dist/esm/loader.js +1 -1
  89. package/dist/esm/q2-btn_2.entry.js +10 -6
  90. package/dist/esm/q2-calendar.entry.js +2902 -6078
  91. package/dist/esm/q2-carousel-pane.entry.js +51 -8
  92. package/dist/esm/q2-carousel.entry.js +2720 -6514
  93. package/dist/esm/q2-checkbox-group.entry.js +2 -2
  94. package/dist/esm/q2-checkbox.entry.js +10 -2
  95. package/dist/esm/q2-dropdown-item.entry.js +2 -2
  96. package/dist/esm/q2-dropdown.entry.js +8 -2
  97. package/dist/esm/q2-editable-field.entry.js +26 -11
  98. package/dist/esm/q2-icon.entry.js +1 -1
  99. package/dist/esm/q2-input.entry.js +9 -7
  100. package/dist/esm/q2-loading-element.entry.js +1 -1
  101. package/dist/esm/q2-loc.entry.js +1 -1
  102. package/dist/esm/q2-message.entry.js +11 -3
  103. package/dist/esm/q2-optgroup.entry.js +2 -2
  104. package/dist/esm/q2-option.entry.js +4 -35
  105. package/dist/esm/q2-radio-group.entry.js +10 -2
  106. package/dist/esm/q2-radio.entry.js +10 -2
  107. package/dist/esm/q2-section.entry.js +9 -3
  108. package/dist/esm/q2-select.entry.js +175 -130
  109. package/dist/esm/q2-stepper-pane.entry.js +1 -1
  110. package/dist/esm/q2-stepper.entry.js +10 -4
  111. package/dist/esm/q2-tab-container.entry.js +7 -9
  112. package/dist/esm/q2-tab-pane.entry.js +2 -2
  113. package/dist/esm/q2-tecton-elements.js +1 -1
  114. package/dist/esm/q2-textarea.entry.js +8 -4
  115. package/dist/esm/tecton-tab-pane.entry.js +2 -2
  116. package/dist/q2-tecton-elements/{p-4830affe.entry.js → p-07a5d703.entry.js} +1 -1
  117. package/dist/q2-tecton-elements/{p-84c05db6.entry.js → p-32ad664c.entry.js} +1 -1
  118. package/dist/q2-tecton-elements/p-37aba2a4.js +1 -0
  119. package/dist/q2-tecton-elements/p-4ae9d1f3.entry.js +1 -0
  120. package/dist/q2-tecton-elements/p-52f53e07.entry.js +1 -0
  121. package/dist/q2-tecton-elements/p-5559f126.entry.js +1 -0
  122. package/dist/q2-tecton-elements/p-6702eb4d.entry.js +1 -0
  123. package/dist/q2-tecton-elements/p-750bcd33.entry.js +1 -0
  124. package/dist/q2-tecton-elements/p-78642b7b.entry.js +1 -0
  125. package/dist/q2-tecton-elements/p-7e6fc65d.entry.js +1 -0
  126. package/dist/q2-tecton-elements/p-7eb39c90.entry.js +1 -0
  127. package/dist/q2-tecton-elements/p-81df91a1.entry.js +1 -0
  128. package/dist/q2-tecton-elements/{p-01e00610.entry.js → p-843b1ee9.entry.js} +1 -1
  129. package/dist/q2-tecton-elements/p-8509b171.entry.js +1 -0
  130. package/dist/q2-tecton-elements/p-8ea2c4f7.entry.js +1 -0
  131. package/dist/q2-tecton-elements/{p-d1d040ef.entry.js → p-95a73559.entry.js} +1 -1
  132. package/dist/q2-tecton-elements/p-96c9eb75.entry.js +1 -0
  133. package/dist/q2-tecton-elements/p-9b50c3c3.entry.js +1 -0
  134. package/dist/q2-tecton-elements/{p-a9bdd814.entry.js → p-a6f8d09a.entry.js} +1 -1
  135. package/dist/q2-tecton-elements/p-ab977515.entry.js +1 -0
  136. package/dist/q2-tecton-elements/{p-a166b9a6.entry.js → p-bb2e110a.entry.js} +1 -1
  137. package/dist/q2-tecton-elements/p-bbacb804.entry.js +1 -0
  138. package/dist/q2-tecton-elements/p-c555f1de.entry.js +1 -0
  139. package/dist/q2-tecton-elements/p-c5e55b9f.entry.js +1 -0
  140. package/dist/q2-tecton-elements/p-fa6eea5c.entry.js +1 -0
  141. package/dist/q2-tecton-elements/{p-61c0e5fd.entry.js → p-fbf7c5e6.entry.js} +1 -1
  142. package/dist/q2-tecton-elements/p-fc804ebd.entry.js +1 -0
  143. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  144. package/dist/test/helpers.js +4 -0
  145. package/dist/types/components/q2-btn/index.d.ts +1 -0
  146. package/dist/types/components/q2-calendar/helpers.d.ts +6 -6
  147. package/dist/types/components/q2-calendar/index.d.ts +16 -17
  148. package/dist/types/components/q2-calendar/types.d.ts +9 -26
  149. package/dist/types/components/q2-calendar/validation.d.ts +27 -12
  150. package/dist/types/components/q2-carousel/index.d.ts +15 -45
  151. package/dist/types/components/q2-carousel-pane/index.d.ts +5 -2
  152. package/dist/types/components/q2-checkbox/index.d.ts +2 -0
  153. package/dist/types/components/q2-dropdown/index.d.ts +1 -0
  154. package/dist/types/components/q2-editable-field/index.d.ts +5 -1
  155. package/dist/types/components/q2-input/index.d.ts +1 -1
  156. package/dist/types/components/q2-message/index.d.ts +2 -0
  157. package/dist/types/components/q2-option/index.d.ts +0 -4
  158. package/dist/types/components/q2-radio/index.d.ts +3 -0
  159. package/dist/types/components/q2-radio-group/index.d.ts +1 -0
  160. package/dist/types/components/q2-section/index.d.ts +1 -0
  161. package/dist/types/components/q2-select/index.d.ts +10 -7
  162. package/dist/types/components/q2-stepper/index.d.ts +2 -1
  163. package/dist/types/components/q2-tab-container/index.d.ts +1 -1
  164. package/dist/types/components/q2-textarea/index.d.ts +2 -1
  165. package/dist/types/components.d.ts +3 -2
  166. package/dist/types/util.d.ts +2 -1
  167. package/dist/types/utils/index.d.ts +2 -0
  168. package/dist/types/workspace/workspace/tecton-production_release_1.10.x/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +2 -1
  169. package/package.json +4 -5
  170. package/dist/q2-tecton-elements/p-1fc4e6f6.entry.js +0 -1
  171. package/dist/q2-tecton-elements/p-25a5f691.js +0 -1
  172. package/dist/q2-tecton-elements/p-27353237.entry.js +0 -1
  173. package/dist/q2-tecton-elements/p-3e100450.entry.js +0 -1
  174. package/dist/q2-tecton-elements/p-428d15fd.entry.js +0 -1
  175. package/dist/q2-tecton-elements/p-48fc317d.entry.js +0 -1
  176. package/dist/q2-tecton-elements/p-5222b792.entry.js +0 -1
  177. package/dist/q2-tecton-elements/p-5469c1e9.entry.js +0 -1
  178. package/dist/q2-tecton-elements/p-74c1a311.entry.js +0 -1
  179. package/dist/q2-tecton-elements/p-784af485.entry.js +0 -1
  180. package/dist/q2-tecton-elements/p-7c99a58b.entry.js +0 -1
  181. package/dist/q2-tecton-elements/p-7f74b629.entry.js +0 -1
  182. package/dist/q2-tecton-elements/p-831a461f.entry.js +0 -1
  183. package/dist/q2-tecton-elements/p-84c52d3b.entry.js +0 -9
  184. package/dist/q2-tecton-elements/p-997e4c7e.entry.js +0 -1
  185. package/dist/q2-tecton-elements/p-a224bc9c.entry.js +0 -1
  186. package/dist/q2-tecton-elements/p-d893fcf2.entry.js +0 -1
  187. package/dist/q2-tecton-elements/p-da7cca07.entry.js +0 -1
  188. package/dist/q2-tecton-elements/p-f17761da.entry.js +0 -1
  189. package/dist/q2-tecton-elements/p-f5e074f8.entry.js +0 -1
@@ -1,6 +1,6 @@
1
- import { Component, Prop, Watch, State, Element, Host, h, Event, Listen } from '@stencil/core';
2
- import Swiper from 'swiper';
3
- import { createGuid, loc, handleAriaLabel } from 'src/utils';
1
+ import { Component, Prop, Watch, State, Fragment, Element, Host, h, Event, Listen } from '@stencil/core';
2
+ import Swiper, { Autoplay } from 'swiper';
3
+ import { createGuid, loc, handleAriaLabel, overrideFocus, isEventFromElement } from 'src/utils';
4
4
  const carouselBreakpoint = 500; /* width in px of this host element where the layout starts to get unruly */
5
5
  export class Q2Carousel {
6
6
  constructor() {
@@ -9,110 +9,59 @@ export class Q2Carousel {
9
9
  this.fullWidthPanes = false;
10
10
  this.hidePagination = false;
11
11
  this.showNavigationArrows = false;
12
+ this.label = 'tecton.element.carousel.ariaLabel';
12
13
  this.index = 1;
13
14
  this.universalCarouselOptions = {
14
15
  centeredSlides: true,
16
+ focusableElements: 'q2-btn, a, input, select, textarea, button, video, label, option',
15
17
  autoplay: this.autoPlay,
16
- keyboard: {
17
- enabled: true,
18
- onlyInViewport: true
19
- },
18
+ modules: [Autoplay],
20
19
  on: {
21
20
  slideChange: () => {
22
21
  var _a, _b;
23
22
  this.handleSlideChange((_b = (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.activeIndex) !== null && _b !== void 0 ? _b : 0); // lazy-load causing this.swiper is null only on ios safari
24
23
  },
25
- transitionEnd: () => {
26
- if (this.applyFocus) {
27
- this.setFocusOnAppropriatePane();
28
- this.applyFocus = false;
24
+ activeIndexChange: swiper => {
25
+ this.activePaneIndex = swiper.activeIndex;
26
+ this.organizePanes();
27
+ const isPaginationFocused = document.activeElement.closest(`#q2-carousel-${this.guid} .q2-carousel-page-indicator`);
28
+ const isCarouselFocused = document.activeElement.closest(`#q2-carousel-${this.guid} q2-carousel-pane`);
29
+ if (isPaginationFocused) {
30
+ this.paginationBtns[swiper.activeIndex].focus({ preventScroll: true });
29
31
  }
32
+ else if (isCarouselFocused)
33
+ swiper.slides[swiper.activeIndex].focus({
34
+ preventScroll: true
35
+ });
30
36
  }
31
37
  }
32
38
  };
33
- this.fullWidthDisplayOptions = Object.assign({ slidesPerView: '1', spaceBetween: 100 }, this.universalCarouselOptions);
34
- this.activePaneIndex = null;
39
+ this.fullWidthDisplayOptions = Object.assign({ slidesPerView: 1, spaceBetween: 100 }, this.universalCarouselOptions);
40
+ this.activePaneIndex = this.realIndex;
35
41
  this.applyFocus = false;
36
- this.compactMode = false;
42
+ this.applyPaginationFocus = false;
37
43
  this.autoPlayInProgress = false;
44
+ this.compactMode = false;
38
45
  this.carouselWrapperWidth = 0;
39
- this.tabIndex = 0;
40
46
  // COMPUTED //
41
47
  this.guid = createGuid();
42
48
  // METHODS //
43
49
  this.setCarouselWrapperWidth = () => {
44
- this.carouselWrapperWidth = this.carouselElement.clientWidth;
45
- };
46
- this.updateActivePaneByIndex = (index, applyFocus) => {
47
- if (applyFocus) {
48
- this.applyFocus = true;
49
- }
50
- this.activePaneIndex = index;
51
- if (this.swiper) {
52
- this.organizePanes();
53
- this.swiper.slideTo(index);
54
- }
50
+ if (this.insufficientPanes)
51
+ return;
52
+ this.carouselWrapperWidth = this.carouselWrapper.clientWidth;
55
53
  };
56
54
  this.handleSlideChange = (newIndex) => {
57
55
  this.change.emit({ index: newIndex + 1 });
58
56
  };
59
- this.setFocusOnAppropriatePane = () => {
60
- this.carouselActivePane.focus();
61
- };
62
- this.passFocusToAppropriateButton = () => {
63
- if (this.hidePagination) {
64
- this.carouselAvailableNavButton.focus();
65
- }
66
- else {
67
- this.carouselPaginationActiveButton.focus();
68
- }
69
- };
70
- this.generateCarouselContainerClass = (fullWidthPanes, compactMode, insufficientPanes) => {
71
- let displayClass = insufficientPanes ? 'insufficient-panes' : '';
72
- let displayTypeClass = fullWidthPanes ? 'full-width-display' : 'content-peek-display';
73
- let sizeClass = compactMode ? 'compact' : '';
74
- return `q2-carousel-swiper-container swiper-container ${displayClass} ${displayTypeClass} ${sizeClass}`;
75
- };
76
- this.generatePaginationWrapperClass = (spaceBetweenPagination) => {
77
- let spaceBetweenClass = spaceBetweenPagination ? 'evenly-space' : '';
78
- return `q2-carousel-pagination-navigation-wrapper ${spaceBetweenClass}`;
79
- };
80
- this.generatePaginationClass = dynamicPaginationDots => {
81
- let dynamicDotsClass = dynamicPaginationDots ? 'dynamic' : '';
82
- return `q2-carousel-pagination ${dynamicDotsClass}`;
83
- };
84
- this.generatePaginationIndicatorClass = (currentIndex, dynamicPaginationDots) => {
85
- let currentIndexMatchesActiveIndex = currentIndex === this.activePaneIndex;
86
- let activeClass = currentIndexMatchesActiveIndex ? 'active-page' : '';
87
- let dynamicClass = dynamicPaginationDots ? 'dynamic' : '';
88
- let withinOneOfActive = currentIndex === this.activePaneIndex + 1 || currentIndex === this.activePaneIndex - 1;
89
- let withinOneClass = withinOneOfActive ? 'active-adjacent' : null;
90
- let withinTwoOfActive = currentIndex === this.activePaneIndex + 2 || currentIndex === this.activePaneIndex - 2;
91
- let withinTwoClass = withinTwoOfActive ? 'active-adjacent-adjacent' : null;
92
- return `q2-carousel-page-indicator q2-carousel-page-indicator-${currentIndex} ${activeClass} ${dynamicClass} ${withinOneClass} ${withinTwoClass}`;
93
- };
94
- this.generatePrevButtonClass = () => {
95
- let availableClass = this.prevPaneAvailable ? '' : 'hide-carousel-navigation-button';
96
- return `q2-carousel-navigation-button q2-carousel-navigation-button-prev ${availableClass}`;
97
- };
98
- this.generateNextButtonClass = () => {
99
- let availableClass = this.nextPaneAvailable ? '' : 'hide-carousel-navigation-button';
100
- return `q2-carousel-navigation-button q2-carousel-navigation-button-next ${availableClass}`;
101
- };
102
- this.generateInsufficientPanesDisplayClass = (fullWidthPanes, compactMode) => {
103
- let displayTypeClass = fullWidthPanes ? 'full-width-display' : 'content-peek-display';
104
- let sizeClass = compactMode ? 'compact' : '';
105
- return `insufficient-pane-feedback ${displayTypeClass} ${sizeClass}`;
106
- };
107
- this.configureCarousel = (carouselElement, carouselOptions) => {
57
+ this.configureCarousel = (carouselWrapper, carouselOptions) => {
58
+ var _a;
108
59
  if (!!this.swiper) {
109
60
  this.tearDownCarousel();
110
61
  }
111
- this.swiper = new Swiper(carouselElement, carouselOptions);
112
- this.updateActivePaneByIndex(this.realIndex, false);
113
- };
114
- this.revampCarousel = () => {
115
- this.configureCarousel(this.carouselElement, this.activeCarouselOptions);
62
+ this.autoPlayInProgress = this.autoPlay;
63
+ this.swiper = new Swiper(carouselWrapper, carouselOptions);
64
+ (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.slideTo(this.realIndex);
116
65
  };
117
66
  this.tearDownCarousel = () => {
118
67
  this.swiper.destroy();
@@ -123,33 +72,17 @@ export class Q2Carousel {
123
72
  pane.index = index;
124
73
  pane.siblingCount = this.paneCollection.length;
125
74
  pane.isActivePane = index === this.activePaneIndex;
126
- pane.hideFromScreenReader = !(index === this.activePaneIndex);
127
75
  });
128
76
  };
129
77
  this.handleAutoPlayPause = () => {
130
- if (!!this.swiper && this.autoPlayIsRunning) {
131
- this.autoPlayInProgress = false;
132
- this.swiper.autoplay.stop();
133
- }
134
- else if (!!this.swiper && !this.autoPlayIsRunning) {
135
- this.autoPlayInProgress = true;
136
- this.swiper.autoplay.start();
137
- }
138
- };
139
- this.handlePaneWrapperTab = event => {
140
- if (event.shiftKey &&
141
- event.which == 9 &&
142
- event.target.className.includes('q2-carousel-pane')) {
143
- this.carouselWrapper.focus();
144
- }
145
- };
146
- this.handleCarouselFocus = event => {
147
- if (event.which == 9 &&
148
- !event.shiftKey &&
149
- event.target.className.includes('q2-carousel-swiper-container')) {
150
- event.preventDefault();
151
- this.setFocusOnAppropriatePane();
152
- }
78
+ const { swiper: { autoplay } } = this;
79
+ if (!autoplay)
80
+ return;
81
+ if (autoplay === null || autoplay === void 0 ? void 0 : autoplay.running)
82
+ autoplay.stop();
83
+ else
84
+ autoplay.start();
85
+ this.autoPlayInProgress = autoplay.running;
153
86
  };
154
87
  this.handleCarouselNavigationSelection = (newIndex, applyFocus) => {
155
88
  if (applyFocus) {
@@ -157,58 +90,113 @@ export class Q2Carousel {
157
90
  }
158
91
  this.handleSlideChange(newIndex);
159
92
  };
160
- this.handlePaginationShiftTab = event => {
161
- if (event.shiftKey && event.which == 9) {
162
- event.preventDefault();
163
- this.carouselActivePane.focus();
93
+ this.onPaginationKeyDown = (event) => {
94
+ var _a, _b;
95
+ switch (event.key) {
96
+ case 'ArrowRight':
97
+ event.preventDefault();
98
+ this.applyFocus = false;
99
+ this.applyPaginationFocus = true;
100
+ this.swiper.slideNext();
101
+ break;
102
+ case 'ArrowLeft':
103
+ event.preventDefault();
104
+ this.applyFocus = false;
105
+ this.applyPaginationFocus = true;
106
+ this.swiper.slidePrev();
107
+ break;
108
+ case 'Home':
109
+ event.preventDefault();
110
+ this.applyFocus = false;
111
+ this.applyPaginationFocus = true;
112
+ (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.slideTo(0);
113
+ break;
114
+ case 'End':
115
+ event.preventDefault();
116
+ this.applyFocus = false;
117
+ this.applyPaginationFocus = true;
118
+ (_b = this.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(this.swiper.slides.length - 1);
119
+ break;
164
120
  }
165
121
  };
166
- this.handlePaneWrapperFocus = event => {
167
- const targetClasses = event.target.className;
168
- const relatedClasses = [
169
- 'page-indicator',
170
- 'q2-carousel-navigation-button',
171
- 'q2-carousel-swiper-container'
172
- ];
173
- const relatedTarget = event.relatedTarget;
174
- if (targetClasses.includes('carousel-pane') &&
175
- !relatedClasses.some(className => relatedTarget && relatedTarget.className.includes(className)) &&
176
- !event.target.contains(relatedTarget)) {
177
- event.preventDefault();
178
- this.passFocusToAppropriateButton();
179
- }
180
- if (targetClasses.includes('page-indicator')) {
181
- event.preventDefault();
182
- this.passFocusToAppropriateButton();
122
+ this.onWrapperKeyDown = (event) => {
123
+ var _a, _b;
124
+ switch (event.key) {
125
+ case 'ArrowRight':
126
+ event.preventDefault();
127
+ this.applyFocus = true;
128
+ this.swiper.slideNext();
129
+ break;
130
+ case 'ArrowLeft':
131
+ event.preventDefault();
132
+ this.applyFocus = true;
133
+ this.swiper.slidePrev();
134
+ break;
135
+ case 'Home':
136
+ event.preventDefault();
137
+ this.applyFocus = true;
138
+ (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.slideTo(0);
139
+ break;
140
+ case 'End':
141
+ event.preventDefault();
142
+ this.applyFocus = true;
143
+ (_b = this.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(this.swiper.slides.length - 1);
144
+ break;
183
145
  }
184
146
  };
185
147
  this.paginationArea = () => {
186
- return (h("div", { class: this.generatePaginationClass(this.dynamicPaginationDots) }, this.paneArray.map(pane => (h("button", { type: "button", class: this.generatePaginationIndicatorClass(pane.index, this.dynamicPaginationDots), onClick: () => this.handleCarouselNavigationSelection(pane.index, true) },
187
- h("span", { class: "sr-only item-count" },
188
- loc('tecton.element.carousel.itemDescription', [
189
- (pane.index + 1).toString()
190
- ]),
191
- loc('tecton.element.carousel.collectionDescription', [
148
+ let paginationContainerClasses = ['q2-carousel-pagination'];
149
+ if (this.dynamicPaginationDots)
150
+ paginationContainerClasses = [...paginationContainerClasses, 'dynamic'];
151
+ return (h("div", { class: paginationContainerClasses.join(' '), role: "tablist", "aria-label": loc('tecton.element.carousel.tabWrapperLabel') }, this.paneArray.map(pane => {
152
+ let btnClasses = [
153
+ 'q2-carousel-page-indicator',
154
+ `q2-carousel-page-indicator-${pane.index}`
155
+ ];
156
+ if (pane.isActivePane)
157
+ btnClasses = [...btnClasses, 'active-page'];
158
+ if (this.dynamicPaginationDots)
159
+ btnClasses = [...btnClasses, 'dynamic'];
160
+ let withinOneOfActive = pane.index === this.activePaneIndex + 1 ||
161
+ pane.index === this.activePaneIndex - 1;
162
+ if (withinOneOfActive)
163
+ btnClasses = [...btnClasses, 'active-adjacent'];
164
+ let withinTwoOfActive = pane.index === this.activePaneIndex + 2 ||
165
+ pane.index === this.activePaneIndex - 2;
166
+ if (withinTwoOfActive)
167
+ btnClasses = [...btnClasses, 'active-adjacent-adjacent'];
168
+ return (h("button", { type: "button", role: "tab", tabIndex: pane.isActivePane ? undefined : -1, "aria-selected": pane.isActivePane ? 'true' : 'false', class: btnClasses.join(' '), onClick: () => this.handleCarouselNavigationSelection(pane.index, true), onKeyDown: event => this.onPaginationKeyDown(event), "aria-label": loc('tecton.element.carousel.itemDescription', [
169
+ (pane.index + 1).toString(),
192
170
  this.paneCount.toString()
193
- ])),
194
- pane.index === this.activePaneIndex ? (h("span", { class: "sr-only current-slide-announcement" }, loc('tecton.element.carousel.currentSlideAnnouncement'))) : null)))));
171
+ ]) }));
172
+ })));
195
173
  };
196
- this.autoPlayButton = () => {
197
- return (h("button", { type: "button", onClick: this.handleAutoPlayPause, "aria-label": this.autopPlayControlButtonText, class: "q2-carousel-autoplay-control" },
198
- h("q2-icon", { type: this.autopPlayControlButtonIconType })));
174
+ this.autoPlayBtn = () => {
175
+ return (h("q2-btn", { type: "button", "hide-label": true, label: loc(this.autoPlayInProgress
176
+ ? 'tecton.element.carousel.pausePlayLabel'
177
+ : 'tecton.element.carousel.resumePlayLabel'), class: "q2-carousel-autoplay-control", onClick: this.handleAutoPlayPause },
178
+ h("q2-icon", { type: this.autoPlayInProgress ? 'pause' : 'play' })));
199
179
  };
200
- this.prevNavButton = () => {
201
- return (h("button", { type: "button", class: this.generatePrevButtonClass(), onClick: () => this.handleCarouselNavigationSelection(this.activePaneIndex - 1, true) },
202
- h("span", { class: "sr-only" }, loc('tecton.element.carousel.previousItemLabel')),
203
- h("q2-icon", { type: "chevron-left" })));
180
+ this.prevNavBtn = () => {
181
+ const prevPaneAvailable = this.activePaneIndex > 0;
182
+ return (h("div", null,
183
+ h("q2-btn", { type: "button", disabled: prevPaneAvailable ? undefined : true, class: "q2-carousel-navigation-button q2-carousel-navigation-button-prev", "hide-label": true, label: loc('tecton.element.carousel.previousItemLabel'), onClick: () => this.handleCarouselNavigationSelection(this.activePaneIndex - 1, true) },
184
+ h("q2-icon", { type: "chevron-left" }))));
204
185
  };
205
- this.nextNavButton = () => {
206
- return (h("button", { type: "button", class: this.generateNextButtonClass(), onClick: () => this.handleCarouselNavigationSelection(this.activePaneIndex + 1, true) },
207
- h("span", { class: "sr-only" }, loc('tecton.element.carousel.nextItemLabel')),
208
- h("q2-icon", { type: "chevron-right" })));
186
+ this.nextNavBtn = () => {
187
+ const nextPaneAvailable = this.activePaneIndex < this.paneCount - 1;
188
+ return (h("div", null,
189
+ h("q2-btn", { type: "button", disabled: nextPaneAvailable ? undefined : true, class: "q2-carousel-navigation-button q2-carousel-navigation-button-next", "hide-label": true, label: loc('tecton.element.carousel.nextItemLabel'), onClick: () => this.handleCarouselNavigationSelection(this.activePaneIndex + 1, true) },
190
+ h("q2-icon", { type: "chevron-right" }))));
209
191
  };
210
192
  this.insufficientPanesDisplay = () => {
211
- return (h("div", { class: this.generateInsufficientPanesDisplayClass(this.fullWidthPanes, this.compactMode) },
193
+ let insufficientPanesContainerClasses = [
194
+ 'insufficient-pane-feedback',
195
+ this.fullWidthPanes ? 'full-width-display' : 'content-peek-display'
196
+ ];
197
+ if (this.compactMode)
198
+ insufficientPanesContainerClasses = [...insufficientPanesContainerClasses, 'compact'];
199
+ return (h("div", { class: insufficientPanesContainerClasses.join(' ') },
212
200
  h("div", { class: "insufficient-panes-icon-wrapper" },
213
201
  h("q2-icon", { type: "warning" })),
214
202
  h("p", { class: "insufficient-panes-header" },
@@ -219,60 +207,25 @@ export class Q2Carousel {
219
207
  ariaLabelObserver() {
220
208
  handleAriaLabel(this);
221
209
  }
222
- fullWidthPanesChanged() {
223
- this.revampCarousel();
224
- }
225
- autoPlayChanged() {
226
- this.revampCarousel();
227
- }
228
210
  carouselWrapperWidthChanged() {
229
211
  this.compactMode = this.carouselWrapperWidth < carouselBreakpoint;
230
212
  }
231
- compactModeChanged() {
232
- this.revampCarousel();
233
- }
234
213
  indexChanged() {
235
- this.updateActivePaneByIndex(this.realIndex, false);
214
+ var _a;
215
+ (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.slideTo(this.realIndex);
236
216
  }
237
- get peekContentDisplayOptions() {
238
- return Object.assign({ slidesPerView: '2', spaceBetween: this.spaceBetweenPeekContentPanes, centerInsufficientSlides: false }, this.universalCarouselOptions);
217
+ revampCarousel() {
218
+ this.configureCarousel(this.carouselWrapper, this.activeCarouselOptions);
239
219
  }
240
- get spaceBetweenPeekContentPanes() {
241
- return this.compactMode ? 0 : -10;
220
+ get peekContentDisplayOptions() {
221
+ return Object.assign({ slidesPerView: 2, spaceBetween: this.compactMode ? 0 : -10, centerInsufficientSlides: false }, this.universalCarouselOptions);
242
222
  }
243
223
  get realIndex() {
244
224
  const indexNum = Number(this.index);
245
225
  return indexNum > 0 ? indexNum - 1 : 0;
246
226
  }
247
- get carouselUniqueId() {
248
- return `q2-carousel-${this.guid}`;
249
- }
250
- get carouselElement() {
251
- return this.hostElement.querySelector(`.swiper-container`);
252
- }
253
- get carouselWrapper() {
254
- return this.hostElement.querySelector(`.q2-carousel-swiper-container`);
255
- }
256
- get carouselPaneWrapperElement() {
257
- return this.hostElement.querySelector(`.q2-carousel-swiper-wrapper`);
258
- }
259
- get carouselActivePane() {
260
- return this.hostElement.querySelector(`.q2-carousel-pane-${this.activePaneIndex}`);
261
- }
262
- get carouselPaginationWrapperElement() {
263
- return this.hostElement.querySelector(`.q2-carousel-pagination-navigation-wrapper`);
264
- }
265
- get carouselPaginationActiveButton() {
266
- return this.hostElement.querySelector(`.q2-carousel-page-indicator-${this.activePaneIndex}`);
267
- }
268
- get carouselPaginationPrevButton() {
269
- return this.hostElement.querySelector('.q2-carousel-navigation-button-prev');
270
- }
271
- get carouselFirstPaginationButton() {
272
- return this.hostElement.querySelector('.q2-carousel-page-indicator');
273
- }
274
- get carouselAvailableNavButton() {
275
- return this.hostElement.querySelector(`.q2-carousel-navigation-button`);
227
+ get paginationBtns() {
228
+ return this.hostElement.querySelectorAll('.q2-carousel-page-indicator');
276
229
  }
277
230
  get activeCarouselOptions() {
278
231
  return this.fullWidthPanes ? this.fullWidthDisplayOptions : this.peekContentDisplayOptions;
@@ -280,9 +233,6 @@ export class Q2Carousel {
280
233
  get dynamicPaginationDots() {
281
234
  return this.paneCount && this.paneCount > 5;
282
235
  }
283
- get spaceBetweenPagination() {
284
- return this.showNavigationArrows;
285
- }
286
236
  get paneCollection() {
287
237
  return this.hostElement.querySelectorAll('q2-carousel-pane');
288
238
  }
@@ -295,92 +245,67 @@ export class Q2Carousel {
295
245
  get insufficientPanes() {
296
246
  return this.paneCount < 1;
297
247
  }
298
- get prevPaneAvailable() {
299
- return this.activePaneIndex > 0;
300
- }
301
- get showPagination() {
302
- return !this.hidePagination;
303
- }
304
- get nextPaneAvailable() {
305
- return this.activePaneIndex < this.paneCount - 1;
306
- }
307
- get dynamicAriaLabel() {
308
- return this.label ? loc(this.label) : loc('tecton.element.carousel.ariaLabel');
309
- }
310
- get autoPlayIsRunning() {
311
- return !!this.swiper && this.autoPlayInProgress;
312
- }
313
- get autopPlayControlButtonText() {
314
- return this.autoPlayIsRunning ? 'Pause Play' : 'Resume Play';
315
- }
316
- get autopPlayControlButtonIconType() {
317
- return this.autoPlayIsRunning ? 'skip' : 'play';
318
- }
319
- get insufficientPanesAndPaginationOn() {
320
- return this.paneCount > 1 && !this.hidePagination;
321
- }
322
248
  // HOST ELEMENT EVENTS //
323
249
  onHostElementChange(event) {
324
250
  if (event.target === this.hostElement && !this.hostElement.onchange) {
325
251
  this.index = event.detail.index;
326
252
  }
327
253
  }
254
+ carouselPaneClicked(event) {
255
+ var _a, _b;
256
+ (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.slideTo(event.detail.paneIndex);
257
+ ((_b = this.swiper) === null || _b === void 0 ? void 0 : _b.slides[event.detail.paneIndex]).focus({ preventScroll: true });
258
+ }
259
+ delegateFocus(event) {
260
+ const activePane = this.swiper.slides[this.swiper.activeIndex];
261
+ if (!isEventFromElement(event, this.hostElement) || !activePane)
262
+ return;
263
+ activePane.focus({ preventScroll: true });
264
+ }
328
265
  // LIFECYCLES //
329
266
  componentWillLoad() {
330
267
  handleAriaLabel(this);
268
+ this.organizePanes();
331
269
  window.addEventListener('resize', this.setCarouselWrapperWidth);
332
- this.updateActivePaneByIndex(this.realIndex, false);
333
- if (this.autoPlay) {
334
- this.autoPlayInProgress = true;
335
- }
336
270
  }
337
271
  componentDidLoad() {
338
272
  this.setCarouselWrapperWidth();
339
- this.carouselPaneWrapperElement.addEventListener('keydown', this.handlePaneWrapperTab, true);
340
- this.carouselPaneWrapperElement.addEventListener('focus', this.handlePaneWrapperFocus, true);
341
- this.carouselWrapper.addEventListener('keyup', this.handleCarouselFocus, true);
342
- if (this.showNavigationArrows) {
343
- this.carouselPaginationPrevButton.addEventListener('keydown', this.handlePaginationShiftTab, true);
344
- }
345
- else if (this.insufficientPanesAndPaginationOn) {
346
- this.carouselFirstPaginationButton.addEventListener('keydown', this.handlePaginationShiftTab, true);
347
- }
348
- if (this.carouselElement && !!this.paneArray.length) {
349
- this.configureCarousel(this.carouselElement, this.activeCarouselOptions);
273
+ if (this.carouselWrapper && !!this.paneArray.length) {
274
+ this.configureCarousel(this.carouselWrapper, this.activeCarouselOptions);
350
275
  }
276
+ overrideFocus(this.hostElement);
351
277
  }
352
278
  disconnectedCallback() {
353
279
  if (!!this.swiper) {
354
- this.swiper.destroy();
355
- this.swiper = null;
280
+ this.tearDownCarousel();
356
281
  }
357
282
  window.removeEventListener('resize', this.setCarouselWrapperWidth);
358
- this.carouselPaneWrapperElement.removeEventListener('keydown', this.handlePaneWrapperTab, true);
359
- this.carouselPaneWrapperElement.removeEventListener('focus', this.handlePaneWrapperFocus, true);
360
- this.carouselWrapper.removeEventListener('keyup', this.handleCarouselFocus, true);
361
- if (this.showNavigationArrows) {
362
- this.carouselPaginationPrevButton.removeEventListener('keydown', this.handlePaginationShiftTab, true);
363
- }
364
- else if (this.insufficientPanesAndPaginationOn) {
365
- this.carouselFirstPaginationButton.removeEventListener('keydown', this.handlePaginationShiftTab, true);
366
- }
367
283
  }
368
284
  render() {
369
- return (h(Host, { id: this.carouselUniqueId, class: "q2-carousel-instance" },
370
- this.insufficientPanes ? this.insufficientPanesDisplay() : null,
371
- h("div", { class: this.generateCarouselContainerClass(this.fullWidthPanes, this.compactMode, this.insufficientPanes), role: "region", tabIndex: this.tabIndex, "aria-live": "polite", "aria-label": this.dynamicAriaLabel },
372
- h("div", { class: "q2-carousel-swiper-wrapper swiper-wrapper" },
373
- h("slot", null)),
374
- this.paneCount > 1 ? (h("div", { class: this.generatePaginationWrapperClass(this.spaceBetweenPagination) },
375
- this.showNavigationArrows ? this.prevNavButton() : null,
376
- h("div", { class: "q2-carousel-control-center-tray" },
377
- this.showPagination ? this.paginationArea() : null,
378
- this.autoPlay ? this.autoPlayButton() : null),
379
- this.showNavigationArrows ? this.nextNavButton() : null)) : null)));
285
+ let carouselContainerClasses = [
286
+ 'q2-carousel-swiper-container',
287
+ 'swiper-container',
288
+ this.fullWidthPanes ? 'full-width-display' : 'content-peek-display'
289
+ ];
290
+ if (this.compactMode)
291
+ carouselContainerClasses = [...carouselContainerClasses, 'compact'];
292
+ let paginationWrapperClasses = ['q2-carousel-pagination-navigation-wrapper'];
293
+ if (this.showNavigationArrows)
294
+ paginationWrapperClasses = [...paginationWrapperClasses, 'evenly-space'];
295
+ return (h(Host, { id: `q2-carousel-${this.guid}`, class: "q2-carousel-instance" }, this.insufficientPanes ? (this.insufficientPanesDisplay()) : (h(Fragment, null,
296
+ this.paneCount > 1 && (h("div", { class: paginationWrapperClasses.join(' ') },
297
+ this.showNavigationArrows && this.prevNavBtn(),
298
+ h("div", { class: "q2-carousel-control-center-tray" },
299
+ !this.hidePagination && this.paginationArea(),
300
+ this.autoPlay && this.autoPlayBtn()),
301
+ this.showNavigationArrows && this.nextNavBtn())),
302
+ h("section", { class: carouselContainerClasses.join(' '), ref: el => (this.carouselWrapper = el), "aria-roledescription": "carousel", "aria-label": loc(this.label) },
303
+ h("div", { class: "q2-carousel-swiper-wrapper swiper-wrapper", ref: el => (this.carouselPaneWrapperElement = el), "aria-live": this.autoPlayInProgress ? 'off' : 'polite', onKeyDown: this.onWrapperKeyDown },
304
+ h("slot", null)))))));
380
305
  }
381
306
  static get is() { return "q2-carousel"; }
382
307
  static get originalStyleUrls() { return {
383
- "$": ["styles.css"]
308
+ "$": ["styles.scss"]
384
309
  }; }
385
310
  static get styleUrls() { return {
386
311
  "$": ["styles.css"]
@@ -490,7 +415,8 @@ export class Q2Carousel {
490
415
  "text": ""
491
416
  },
492
417
  "attribute": "label",
493
- "reflect": true
418
+ "reflect": true,
419
+ "defaultValue": "'tecton.element.carousel.ariaLabel'"
494
420
  },
495
421
  "index": {
496
422
  "type": "number",
@@ -516,10 +442,10 @@ export class Q2Carousel {
516
442
  "fullWidthDisplayOptions": {},
517
443
  "activePaneIndex": {},
518
444
  "applyFocus": {},
519
- "compactMode": {},
445
+ "applyPaginationFocus": {},
520
446
  "autoPlayInProgress": {},
521
- "carouselWrapperWidth": {},
522
- "tabIndex": {}
447
+ "compactMode": {},
448
+ "carouselWrapperWidth": {}
523
449
  }; }
524
450
  static get events() { return [{
525
451
  "method": "change",
@@ -541,21 +467,21 @@ export class Q2Carousel {
541
467
  static get watchers() { return [{
542
468
  "propName": "ariaLabel",
543
469
  "methodName": "ariaLabelObserver"
544
- }, {
545
- "propName": "fullWidthPanes",
546
- "methodName": "fullWidthPanesChanged"
547
- }, {
548
- "propName": "autoPlay",
549
- "methodName": "autoPlayChanged"
550
470
  }, {
551
471
  "propName": "carouselWrapperWidth",
552
472
  "methodName": "carouselWrapperWidthChanged"
553
- }, {
554
- "propName": "compactMode",
555
- "methodName": "compactModeChanged"
556
473
  }, {
557
474
  "propName": "index",
558
475
  "methodName": "indexChanged"
476
+ }, {
477
+ "propName": "fullWidthPanes",
478
+ "methodName": "revampCarousel"
479
+ }, {
480
+ "propName": "compactMode",
481
+ "methodName": "revampCarousel"
482
+ }, {
483
+ "propName": "autoPlay",
484
+ "methodName": "revampCarousel"
559
485
  }]; }
560
486
  static get listeners() { return [{
561
487
  "name": "change",
@@ -563,5 +489,17 @@ export class Q2Carousel {
563
489
  "target": undefined,
564
490
  "capture": false,
565
491
  "passive": false
492
+ }, {
493
+ "name": "clickCarouselPane",
494
+ "method": "carouselPaneClicked",
495
+ "target": undefined,
496
+ "capture": false,
497
+ "passive": false
498
+ }, {
499
+ "name": "focus",
500
+ "method": "delegateFocus",
501
+ "target": undefined,
502
+ "capture": false,
503
+ "passive": false
566
504
  }]; }
567
505
  }