kmaterialize 2.0.0 → 2.3.3-1.0.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.
Files changed (150) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +55 -91
  3. package/components/appbar/_navbar.old.scss +223 -0
  4. package/components/appbar/appbar.css +235 -0
  5. package/components/appbar/appbar.mjs +54 -0
  6. package/components/appbar/appbar.test.mjs +9 -0
  7. package/components/atomic/atomic.mjs +19 -0
  8. package/components/atomic/component.mjs +67 -0
  9. package/components/badge/_badges.scss +75 -0
  10. package/components/badge/badge.mjs +11 -0
  11. package/components/breadcrumb/_breadcrumb.scss +27 -0
  12. package/components/button/_buttons.scss +352 -0
  13. package/components/button/button.mjs +11 -0
  14. package/components/button/buttons.stories.ts +150 -0
  15. package/components/button/buttons.ts +282 -0
  16. package/components/button/examples.iso.js +18 -0
  17. package/components/button/fabSpec.js +65 -0
  18. package/components/button/test-button.mjs +16 -0
  19. package/components/card/_cards.scss +229 -0
  20. package/components/card/card.mjs +10 -0
  21. package/components/card/cards.ts +185 -0
  22. package/components/card/cardsSpec.js +269 -0
  23. package/components/carousel/_carousel.scss +93 -0
  24. package/components/carousel/_slider.scss +119 -0
  25. package/components/carousel/carousel.ts +693 -0
  26. package/components/carousel/carouselSpec.js +61 -0
  27. package/components/carousel/slider.ts +431 -0
  28. package/components/carousel/sliderSpec.js +99 -0
  29. package/components/checkbox/_checkboxes.scss +281 -0
  30. package/components/checkbox/checkbox.mdx +24 -0
  31. package/components/checkbox/checkbox.stories.ts +120 -0
  32. package/components/chip/chip.mjs +37 -0
  33. package/components/chip/chip.test.mjs +10 -0
  34. package/components/chip/chips.css +126 -0
  35. package/components/chip/chips.mdx +33 -0
  36. package/components/chip/chips.ts +440 -0
  37. package/components/chip/chipsSpec.js +165 -0
  38. package/components/chip/readme.md +323 -0
  39. package/components/collapsible/_collapsible.scss +82 -0
  40. package/components/collapsible/collapsible.ts +230 -0
  41. package/components/collapsible/collapsibleSpec.js +240 -0
  42. package/components/datepicker/_datepicker.scss +268 -0
  43. package/components/datepicker/datepicker.ts +1450 -0
  44. package/components/datepicker/datepickerSpec.js +162 -0
  45. package/components/dialog/_materialbox.scss +42 -0
  46. package/components/dialog/_modal.scss +79 -0
  47. package/components/dialog/materialbox.ts +446 -0
  48. package/components/dialog/materialboxSpec.js +37 -0
  49. package/components/dialog/modal.ts +111 -0
  50. package/components/dialog/modalSpec.js +83 -0
  51. package/components/dialog/readme.md +5 -0
  52. package/components/divider/readme.md +15 -0
  53. package/components/dropdown/_dropdown.scss +83 -0
  54. package/components/dropdown/dropdown.ts +653 -0
  55. package/components/dropdown/dropdownSpec.js +108 -0
  56. package/components/list/_collection.scss +114 -0
  57. package/components/list/_list.scss +6 -0
  58. package/components/list/list.mjs +58 -0
  59. package/components/list/list.test.mjs +16 -0
  60. package/components/loading/loading.mjs +26 -0
  61. package/components/loading/loading.test.mjs +10 -0
  62. package/components/navigation-bar/_old +582 -0
  63. package/components/navigation-bar/navigation-bar.mdx +20 -0
  64. package/components/navigation-bar/navigation-bar.stories.ts +39 -0
  65. package/components/navigation-drawer/_sidenav.scss +247 -0
  66. package/components/navigation-drawer/sidenav.ts +546 -0
  67. package/components/navigation-drawer/sidenavSpec.js +124 -0
  68. package/components/pagination/_pagination.scss +47 -0
  69. package/components/progress/_preloader.scss +416 -0
  70. package/components/radio-button/_radio-buttons.scss +112 -0
  71. package/components/radio-button/radio-buttons.mdx +28 -0
  72. package/components/radio-button/radio-buttons.stories.ts +51 -0
  73. package/components/search/autocomplete.ts +620 -0
  74. package/components/search/autocompleteSpec.js +321 -0
  75. package/components/slider/_range.scss +157 -0
  76. package/components/slider/range.ts +216 -0
  77. package/components/snackbar/_toast.scss +68 -0
  78. package/components/snackbar/toastSpec.js +132 -0
  79. package/components/snackbar/toasts.ts +312 -0
  80. package/components/switch/_switches.scss +121 -0
  81. package/components/tabs/_tabs.scss +171 -0
  82. package/components/tabs/tabs.mjs +31 -0
  83. package/components/tabs/tabs.ts +358 -0
  84. package/components/tabs/tabsSpec.js +180 -0
  85. package/components/textfield/_file-input.scss +41 -0
  86. package/components/textfield/_input-fields.scss +368 -0
  87. package/components/textfield/_select.scss +104 -0
  88. package/components/textfield/formfields.css +311 -0
  89. package/components/textfield/forms.ts +182 -0
  90. package/components/textfield/formsSpec.js +142 -0
  91. package/components/textfield/select.ts +472 -0
  92. package/components/textfield/selectSpec.js +390 -0
  93. package/components/textfield/textfield.mjs +29 -0
  94. package/components/textfield/textfield.test.mjs +10 -0
  95. package/components/timepicker/_timepicker.scss +362 -0
  96. package/components/timepicker/timepicker.ts +905 -0
  97. package/components/tooltip/_tooltip.scss +40 -0
  98. package/components/tooltip/tooltip.ts +380 -0
  99. package/components/tooltip/tooltipSpec.js +145 -0
  100. package/dist/css/materialize.colors.min.css +6 -0
  101. package/dist/css/materialize.css +7578 -6326
  102. package/dist/css/materialize.min.css +6 -13
  103. package/dist/css/materialize.min.css.map +1 -0
  104. package/dist/js/materialize.cjs.js +8410 -0
  105. package/dist/js/materialize.d.ts +2625 -0
  106. package/dist/js/materialize.js +8415 -12374
  107. package/dist/js/materialize.min.js +6 -6
  108. package/dist/js/materialize.mjs +8382 -0
  109. package/package.json +82 -47
  110. package/sass/_colors.scss +417 -0
  111. package/sass/_global.scss +490 -0
  112. package/sass/_grid.scss +172 -0
  113. package/sass/_table_of_contents.scss +28 -0
  114. package/sass/_tapTarget.scss +102 -0
  115. package/sass/_typography.scss +58 -0
  116. package/sass/_variables.scss +56 -0
  117. package/sass/materialize.scss +51 -0
  118. package/sass/mixins.module.scss +168 -0
  119. package/extras/noUiSlider/nouislider.css +0 -406
  120. package/extras/noUiSlider/nouislider.js +0 -2147
  121. package/extras/noUiSlider/nouislider.min.js +0 -1
  122. package/js/anime.min.js +0 -34
  123. package/js/autocomplete.js +0 -448
  124. package/js/buttons.js +0 -354
  125. package/js/cards.js +0 -40
  126. package/js/carousel.js +0 -717
  127. package/js/cash.js +0 -960
  128. package/js/characterCounter.js +0 -136
  129. package/js/chips.js +0 -481
  130. package/js/collapsible.js +0 -275
  131. package/js/component.js +0 -44
  132. package/js/datepicker.js +0 -975
  133. package/js/dropdown.js +0 -635
  134. package/js/forms.js +0 -275
  135. package/js/global.js +0 -444
  136. package/js/materialbox.js +0 -453
  137. package/js/modal.js +0 -382
  138. package/js/parallax.js +0 -138
  139. package/js/pushpin.js +0 -148
  140. package/js/range.js +0 -263
  141. package/js/scrollspy.js +0 -295
  142. package/js/select.js +0 -450
  143. package/js/sidenav.js +0 -580
  144. package/js/slider.js +0 -359
  145. package/js/tabs.js +0 -402
  146. package/js/tapTarget.js +0 -314
  147. package/js/timepicker.js +0 -647
  148. package/js/toasts.js +0 -310
  149. package/js/tooltip.js +0 -303
  150. package/js/waves.js +0 -335
@@ -0,0 +1,171 @@
1
+ @use '../../sass/variables' as *;
2
+
3
+ .tabs {
4
+ padding-left: 0;
5
+ list-style-type: none;
6
+ position: relative;
7
+ overflow-x: auto;
8
+ overflow-y: hidden;
9
+ width: 100%;
10
+ background-color: var(--md-sys-color-surface);
11
+ margin: 0 auto;
12
+ white-space: nowrap;
13
+ scrollbar-width: none;
14
+
15
+ &.tabs-transparent {
16
+ background-color: transparent;
17
+
18
+ .tab a {
19
+ color: var(--font-on-primary-color-medium);
20
+ }
21
+
22
+ .tab.disabled a,
23
+ .tab.disabled a:hover,
24
+ .tab.disabled a:focus {
25
+ color: rgba(255, 255, 255, 0.38);
26
+ }
27
+
28
+ .tab a:hover {
29
+ background-color: rgba(0, 0, 0, 0.04);
30
+ }
31
+
32
+ .tab a.active,
33
+ .tab a:focus {
34
+ background-color: transparent;
35
+ }
36
+
37
+ .tab a:hover,
38
+ .tab a.active,
39
+ .tab a:focus {
40
+ color: var(--md-sys-color-on-primary);
41
+ }
42
+
43
+ .indicator {
44
+ background-color: var(--md-sys-color-on-primary);
45
+ }
46
+ }
47
+
48
+ &.tabs-fixed-width {
49
+ display: flex;
50
+
51
+ .tab {
52
+ flex-grow: 1;
53
+ }
54
+ }
55
+
56
+ .tab {
57
+ padding-left: 0;
58
+ list-style-type: none;
59
+ display: inline-block;
60
+ text-align: center;
61
+ line-height: 48px;
62
+ padding: 0;
63
+ margin: 0;
64
+
65
+ i.material-icons {
66
+ position: relative;
67
+ top: 8px;
68
+ vertical-align: middle;
69
+ }
70
+
71
+ span {
72
+ height: 24px;
73
+ line-height: 20px;
74
+ }
75
+
76
+ a {
77
+ color: var(--md-sys-color-on-surface-variant);
78
+ display: flex;
79
+ flex-direction: column;
80
+ width: 100%;
81
+ height: 100%;
82
+ min-height: 48px; //needed for only-icons tabs
83
+ padding: 0 24px;
84
+ font-size: 14px;
85
+ text-overflow: ellipsis;
86
+ user-select: none;
87
+ overflow: hidden;
88
+ transition:
89
+ color 0.28s ease,
90
+ background-color 0.28s ease;
91
+
92
+ &.active {
93
+ background-color: transparent;
94
+ }
95
+
96
+ &.active,
97
+ &:focus,
98
+ &:hover {
99
+ color: var(--md-sys-color-primary);
100
+ }
101
+
102
+ &:hover {
103
+ background-color: color-mix(in srgb, transparent, var(--md-sys-color-primary) 6%);
104
+ }
105
+
106
+ &:focus {
107
+ background-color: var(--md-sys-color-primary-container);
108
+ }
109
+
110
+ &.active {
111
+ background-color: color-mix(in srgb, transparent, var(--md-sys-color-primary) 18%);
112
+ }
113
+
114
+ &:focus,
115
+ &.active {
116
+ outline: none;
117
+ }
118
+ }
119
+
120
+ &.disabled a,
121
+ &.disabled a:hover {
122
+ color: var(--md-sys-color-on-surface);
123
+ cursor: default;
124
+ background-color: transparent;
125
+
126
+ &:not(:focus) {
127
+ background-color: transparent;
128
+ }
129
+ }
130
+ }
131
+
132
+ .indicator {
133
+ position: absolute;
134
+ bottom: 0;
135
+ height: 3px;
136
+ background-color: var(--md-sys-color-primary);
137
+ will-change: left, right;
138
+ border-radius: 3px 3px 0 0;
139
+ }
140
+
141
+ &.tabs-horizontal .tab {
142
+ height: 48px;
143
+
144
+ a {
145
+ display: block;
146
+ }
147
+
148
+ i.material-icons {
149
+ padding: 0 4px;
150
+ position: relative;
151
+ top: -2px;
152
+ vertical-align: middle;
153
+ }
154
+ }
155
+ }
156
+
157
+ /* Fixed Sidenav hide on smaller */
158
+
159
+ @media #{$medium-and-down} {
160
+ .tabs {
161
+ display: flex;
162
+
163
+ .tab {
164
+ flex-grow: 1;
165
+
166
+ a {
167
+ padding: 0 12px;
168
+ }
169
+ }
170
+ }
171
+ }
@@ -0,0 +1,31 @@
1
+ import { Component } from '../atomic/component.mjs';
2
+
3
+ /*
4
+ <ul class="tabs">
5
+ <li class="tab"><a href="#test1">Test 1</a></li>
6
+ <li class="tab"><a class="active" href="#test2">Test 2</a></li>
7
+ <li class="tab disabled"><a href="#test3">Disabled Tab</a></li>
8
+ <li class="tab"><a href="#test4">Test 4</a></li>
9
+ </ul>
10
+
11
+ <div id="test1">Test 1</div>
12
+ <div id="test2">Test 2</div>
13
+ <div id="test3">Test 3</div>
14
+ <div id="test4">Test 4</div>
15
+ */
16
+
17
+ class Tabs extends Component {
18
+ #tabs = [];
19
+
20
+ constructor(options) {
21
+ super(options);
22
+ this.setTagName('ul');
23
+ this.addClassname('tabs');
24
+ }
25
+
26
+ getBodyHtml() {}
27
+ }
28
+
29
+ // TODO: TabHeader and TabBody
30
+
31
+ export { Tabs };
@@ -0,0 +1,358 @@
1
+ import { Carousel } from '../carousel/carousel';
2
+ import { Component, BaseOptions, InitElements, MElement } from '../../src/component';
3
+
4
+ export interface TabsOptions extends BaseOptions {
5
+ /**
6
+ * Transition duration in milliseconds.
7
+ * @default 300
8
+ */
9
+ duration: number;
10
+ /**
11
+ * Callback for when a new tab content is shown.
12
+ * @default null
13
+ */
14
+ onShow: (newContent: Element) => void;
15
+ /**
16
+ * Set to true to enable swipeable tabs.
17
+ * This also uses the responsiveThreshold option.
18
+ * @default false
19
+ */
20
+ swipeable: boolean;
21
+ /**
22
+ * The maximum width of the screen, in pixels,
23
+ * where the swipeable functionality initializes.
24
+ * @default infinity
25
+ */
26
+ responsiveThreshold: number;
27
+ }
28
+
29
+ const _defaults: TabsOptions = {
30
+ duration: 300,
31
+ onShow: null,
32
+ swipeable: false,
33
+ responsiveThreshold: Infinity // breakpoint for swipeable
34
+ };
35
+
36
+ export class Tabs extends Component<TabsOptions> {
37
+ _tabLinks: NodeListOf<HTMLAnchorElement>;
38
+ _index: number;
39
+ _indicator: HTMLLIElement;
40
+ _tabWidth: number;
41
+ _tabsWidth: number;
42
+ _tabsCarousel: Carousel;
43
+ _activeTabLink: HTMLAnchorElement;
44
+ _content: HTMLElement;
45
+
46
+ constructor(el: HTMLElement, options: Partial<TabsOptions>) {
47
+ super(el, options, Tabs);
48
+ this.el['M_Tabs'] = this;
49
+
50
+ this.options = {
51
+ ...Tabs.defaults,
52
+ ...options
53
+ };
54
+
55
+ this._tabLinks = this.el.querySelectorAll('li.tab > a');
56
+ this._index = 0;
57
+ this._setupActiveTabLink();
58
+ if (this.options.swipeable) {
59
+ this._setupSwipeableTabs();
60
+ } else {
61
+ this._setupNormalTabs();
62
+ }
63
+ // Setup tabs indicator after content to ensure accurate widths
64
+ this._setTabsAndTabWidth();
65
+ this._createIndicator();
66
+ this._setupEventHandlers();
67
+ }
68
+
69
+ static get defaults(): TabsOptions {
70
+ return _defaults;
71
+ }
72
+
73
+ /**
74
+ * Initializes instance of Tabs.
75
+ * @param el HTML element.
76
+ * @param options Component options.
77
+ */
78
+ static init(el: HTMLElement, options?: Partial<TabsOptions>): Tabs;
79
+ /**
80
+ * Initializes instances of Tabs.
81
+ * @param els HTML elements.
82
+ * @param options Component options.
83
+ */
84
+ static init(els: InitElements<MElement>, options?: Partial<TabsOptions>): Tabs[];
85
+ /**
86
+ * Initializes instances of Tabs.
87
+ * @param els HTML elements.
88
+ * @param options Component options.
89
+ */
90
+ static init(
91
+ els: HTMLElement | InitElements<MElement>,
92
+ options: Partial<TabsOptions> = {}
93
+ ): Tabs | Tabs[] {
94
+ return super.init(els, options, Tabs);
95
+ }
96
+
97
+ static getInstance(el: HTMLElement): Tabs {
98
+ return el['M_Tabs'];
99
+ }
100
+
101
+ destroy() {
102
+ this._removeEventHandlers();
103
+ this._indicator.parentNode.removeChild(this._indicator);
104
+ if (this.options.swipeable) {
105
+ this._teardownSwipeableTabs();
106
+ } else {
107
+ this._teardownNormalTabs();
108
+ }
109
+ this.el['M_Tabs'] = undefined;
110
+ }
111
+
112
+ /**
113
+ * The index of tab that is currently shown.
114
+ */
115
+ get index() {
116
+ return this._index;
117
+ }
118
+
119
+ _setupEventHandlers() {
120
+ window.addEventListener('resize', this._handleWindowResize);
121
+ this.el.addEventListener('click', this._handleTabClick);
122
+ // map vertical scrolling to horizontal scrolling because no scrollbar is shown on desktop
123
+ this.el.addEventListener('wheel', (event) => {
124
+ if (event.deltaY !== 0) {
125
+ event.preventDefault();
126
+ this.el.scrollLeft += event.deltaY * 1;
127
+ }
128
+ });
129
+ }
130
+
131
+ _removeEventHandlers() {
132
+ window.removeEventListener('resize', this._handleWindowResize);
133
+ this.el.removeEventListener('click', this._handleTabClick);
134
+ }
135
+
136
+ _handleWindowResize = () => {
137
+ this._setTabsAndTabWidth();
138
+ if (this._tabWidth !== 0 && this._tabsWidth !== 0) {
139
+ this._indicator.style.left = this._calcLeftPos(this._activeTabLink) + 'px';
140
+ this._indicator.style.right = this._calcRightPos(this._activeTabLink) + 'px';
141
+ }
142
+ };
143
+
144
+ _handleTabClick = (e: MouseEvent) => {
145
+ let tabLink = e.target as HTMLAnchorElement;
146
+
147
+ if (!tabLink) return;
148
+ let tab = tabLink.parentElement;
149
+ while (tab && !tab.classList.contains('tab')) {
150
+ tabLink = tabLink.parentElement as HTMLAnchorElement;
151
+ tab = tab.parentElement;
152
+ }
153
+
154
+ // Handle click on tab link only
155
+ if (!tabLink || !tab.classList.contains('tab')) return;
156
+ // is disabled?
157
+ if (tab.classList.contains('disabled')) {
158
+ e.preventDefault();
159
+ return;
160
+ }
161
+ // Act as regular link if target attribute is specified.
162
+ if (tabLink.hasAttribute('target')) return;
163
+ // Make the old tab inactive.
164
+ this._activeTabLink.classList.remove('active');
165
+ const _oldContent = this._content;
166
+ // Update the variables with the new link and content
167
+
168
+ this._activeTabLink = tabLink;
169
+ if (tabLink.hash) this._content = document.querySelector(tabLink.hash);
170
+ this._tabLinks = this.el.querySelectorAll('li.tab > a');
171
+ // Make the tab active
172
+ this._activeTabLink.classList.add('active');
173
+ const prevIndex = this._index;
174
+ this._index = Math.max(Array.from(this._tabLinks).indexOf(tabLink), 0);
175
+
176
+ // Swap content
177
+ if (this.options.swipeable) {
178
+ if (this._tabsCarousel) {
179
+ this._tabsCarousel.set(this._index, () => {
180
+ if (typeof this.options.onShow === 'function')
181
+ this.options.onShow.call(this, this._content);
182
+ });
183
+ }
184
+ } else {
185
+ if (this._content) {
186
+ this._content.style.display = 'block';
187
+ this._content.classList.add('active');
188
+ if (typeof this.options.onShow === 'function')
189
+ this.options.onShow.call(this, this._content);
190
+ if (_oldContent && _oldContent !== this._content) {
191
+ _oldContent.style.display = 'none';
192
+ _oldContent.classList.remove('active');
193
+ }
194
+ }
195
+ }
196
+ // Update widths after content is swapped (scrollbar bugfix)
197
+ this._setTabsAndTabWidth();
198
+ this._animateIndicator(prevIndex);
199
+ e.preventDefault();
200
+ };
201
+
202
+ _createIndicator() {
203
+ const indicator = document.createElement('li');
204
+ indicator.classList.add('indicator');
205
+ this.el.appendChild(indicator);
206
+ this._indicator = indicator;
207
+ this._indicator.style.left = this._calcLeftPos(this._activeTabLink) + 'px';
208
+ this._indicator.style.right = this._calcRightPos(this._activeTabLink) + 'px';
209
+ }
210
+
211
+ _setupActiveTabLink() {
212
+ // If the location.hash matches one of the links, use that as the active tab.
213
+ this._activeTabLink = Array.from(this._tabLinks).find(
214
+ (a: HTMLAnchorElement) => a.getAttribute('href') === location.hash
215
+ );
216
+ // If no match is found, use the first link or any with class 'active' as the initial active tab.
217
+ if (!this._activeTabLink) {
218
+ let activeTabLink = this.el.querySelector('li.tab a.active');
219
+ if (!activeTabLink) {
220
+ activeTabLink = this.el.querySelector('li.tab a');
221
+ }
222
+ this._activeTabLink = activeTabLink as HTMLAnchorElement;
223
+ }
224
+ Array.from(this._tabLinks).forEach((a: HTMLAnchorElement) => a.classList.remove('active'));
225
+ this._activeTabLink.classList.add('active');
226
+
227
+ this._index = Math.max(Array.from(this._tabLinks).indexOf(this._activeTabLink), 0);
228
+ if (this._activeTabLink && this._activeTabLink.hash) {
229
+ this._content = document.querySelector(this._activeTabLink.hash);
230
+ if (this._content) this._content.classList.add('active');
231
+ }
232
+ }
233
+
234
+ _setupSwipeableTabs() {
235
+ // Change swipeable according to responsive threshold
236
+ if (window.innerWidth > this.options.responsiveThreshold) this.options.swipeable = false;
237
+
238
+ const tabsContent = [];
239
+ this._tabLinks.forEach((a) => {
240
+ if (a.hash) {
241
+ const currContent = document.querySelector(a.hash);
242
+ currContent.classList.add('carousel-item');
243
+ tabsContent.push(currContent);
244
+ }
245
+ });
246
+
247
+ // Create Carousel-Wrapper around Tab-Contents
248
+ const tabsWrapper = document.createElement('div');
249
+ tabsWrapper.classList.add('tabs-content', 'carousel', 'carousel-slider');
250
+
251
+ // Wrap around
252
+ tabsContent[0].parentElement.insertBefore(tabsWrapper, tabsContent[0]);
253
+ tabsContent.forEach((tabContent) => {
254
+ tabsWrapper.appendChild(tabContent);
255
+ tabContent.style.display = '';
256
+ });
257
+
258
+ // Keep active tab index to set initial carousel slide
259
+ const tab = this._activeTabLink.parentElement;
260
+ const activeTabIndex = Array.from(tab.parentNode.children).indexOf(tab);
261
+
262
+ this._tabsCarousel = Carousel.init(tabsWrapper, {
263
+ fullWidth: true,
264
+ noWrap: true,
265
+ onCycleTo: (item) => {
266
+ const prevIndex = this._index;
267
+ this._index = Array.from(item.parentNode.children).indexOf(item);
268
+ this._activeTabLink.classList.remove('active');
269
+ this._activeTabLink = Array.from(this._tabLinks)[this._index];
270
+ this._activeTabLink.classList.add('active');
271
+ this._animateIndicator(prevIndex);
272
+ if (typeof this.options.onShow === 'function')
273
+ this.options.onShow.call(this, this._content);
274
+ }
275
+ });
276
+ // Set initial carousel slide to active tab
277
+ this._tabsCarousel.set(activeTabIndex);
278
+ }
279
+
280
+ _teardownSwipeableTabs() {
281
+ const tabsWrapper = this._tabsCarousel.el;
282
+ this._tabsCarousel.destroy();
283
+ // Unwrap
284
+ tabsWrapper.append(tabsWrapper.parentElement);
285
+ tabsWrapper.remove();
286
+ }
287
+
288
+ _setupNormalTabs() {
289
+ // Hide Tabs Content
290
+ Array.from(this._tabLinks).forEach((a) => {
291
+ if (a === this._activeTabLink) return;
292
+ if ((<HTMLAnchorElement>a).hash) {
293
+ const currContent = document.querySelector((<HTMLAnchorElement>a).hash);
294
+ if (currContent) (<HTMLElement>currContent).style.display = 'none';
295
+ }
296
+ });
297
+ }
298
+
299
+ _teardownNormalTabs() {
300
+ // show Tabs Content
301
+ this._tabLinks.forEach((a) => {
302
+ if (a.hash) {
303
+ const currContent = document.querySelector(a.hash) as HTMLElement;
304
+ if (currContent) currContent.style.display = '';
305
+ }
306
+ });
307
+ }
308
+
309
+ _setTabsAndTabWidth() {
310
+ this._tabsWidth = this.el.getBoundingClientRect().width;
311
+ this._tabWidth = Math.max(this._tabsWidth, this.el.scrollWidth) / this._tabLinks.length;
312
+ }
313
+
314
+ _calcRightPos(el: HTMLElement) {
315
+ return Math.ceil(this._tabsWidth - el.offsetLeft - el.getBoundingClientRect().width);
316
+ }
317
+
318
+ _calcLeftPos(el: HTMLElement) {
319
+ return Math.floor(el.offsetLeft);
320
+ }
321
+
322
+ /**
323
+ * Recalculate tab indicator position. This is useful when
324
+ * the indicator position is not correct.
325
+ */
326
+ updateTabIndicator() {
327
+ this._setTabsAndTabWidth();
328
+ this._animateIndicator(this._index);
329
+ }
330
+
331
+ _animateIndicator(prevIndex: number) {
332
+ let leftDelay = 0,
333
+ rightDelay = 0;
334
+
335
+ const isMovingLeftOrStaying = this._index - prevIndex >= 0;
336
+ if (isMovingLeftOrStaying) leftDelay = 90;
337
+ else rightDelay = 90;
338
+
339
+ // in v1: easeOutQuad
340
+ this._indicator.style.transition = `
341
+ left ${this.options.duration}ms ease-out ${leftDelay}ms,
342
+ right ${this.options.duration}ms ease-out ${rightDelay}ms`;
343
+
344
+ this._indicator.style.left = this._calcLeftPos(this._activeTabLink) + 'px';
345
+ this._indicator.style.right = this._calcRightPos(this._activeTabLink) + 'px';
346
+ }
347
+
348
+ /**
349
+ * Show tab content that corresponds to the tab with the id.
350
+ * @param tabId The id of the tab that you want to switch to.
351
+ */
352
+ select(tabId: string) {
353
+ const tab = Array.from(this._tabLinks).find(
354
+ (a: HTMLAnchorElement) => a.getAttribute('href') === '#' + tabId
355
+ );
356
+ if (tab) (<HTMLAnchorElement>tab).click();
357
+ }
358
+ }