@materializecss/materialize 2.0.1-alpha → 2.0.3-alpha

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 (117) hide show
  1. package/Gruntfile.js +5 -2
  2. package/dist/css/materialize.css +1510 -288
  3. package/dist/css/materialize.min.css +2 -2
  4. package/dist/js/materialize.js +2782 -2688
  5. package/dist/js/materialize.min.js +2 -8967
  6. package/dist/js/materialize.min.js.map +1 -1
  7. package/dist/src/autocomplete.d.ts +143 -0
  8. package/dist/src/autocomplete.d.ts.map +1 -0
  9. package/dist/src/bounding.d.ts +7 -0
  10. package/dist/src/bounding.d.ts.map +1 -0
  11. package/dist/src/buttons.d.ts +65 -0
  12. package/dist/src/buttons.d.ts.map +1 -0
  13. package/dist/src/cards.d.ts +4 -0
  14. package/dist/src/cards.d.ts.map +1 -0
  15. package/dist/src/carousel.d.ts +131 -0
  16. package/dist/src/carousel.d.ts.map +1 -0
  17. package/dist/src/characterCounter.d.ts +37 -0
  18. package/dist/src/characterCounter.d.ts.map +1 -0
  19. package/dist/src/chips.d.ts +131 -0
  20. package/dist/src/chips.d.ts.map +1 -0
  21. package/dist/src/collapsible.d.ts +74 -0
  22. package/dist/src/collapsible.d.ts.map +1 -0
  23. package/dist/src/component.d.ts +74 -0
  24. package/dist/src/component.d.ts.map +1 -0
  25. package/dist/src/datepicker.d.ts +248 -0
  26. package/dist/src/datepicker.d.ts.map +1 -0
  27. package/dist/src/dropdown.d.ts +148 -0
  28. package/dist/src/dropdown.d.ts.map +1 -0
  29. package/dist/src/edges.d.ts +7 -0
  30. package/dist/src/edges.d.ts.map +1 -0
  31. package/dist/src/forms.d.ts +12 -0
  32. package/dist/src/forms.d.ts.map +1 -0
  33. package/dist/src/global.d.ts +60 -0
  34. package/dist/src/global.d.ts.map +1 -0
  35. package/dist/src/index.d.ts +27 -0
  36. package/dist/src/index.d.ts.map +1 -0
  37. package/dist/src/materialbox.d.ts +92 -0
  38. package/dist/src/materialbox.d.ts.map +1 -0
  39. package/dist/src/modal.d.ts +119 -0
  40. package/dist/src/modal.d.ts.map +1 -0
  41. package/dist/src/parallax.d.ts +40 -0
  42. package/dist/src/parallax.d.ts.map +1 -0
  43. package/dist/src/pushpin.d.ts +52 -0
  44. package/dist/src/pushpin.d.ts.map +1 -0
  45. package/dist/src/range.d.ts +41 -0
  46. package/dist/src/range.d.ts.map +1 -0
  47. package/dist/src/scrollspy.d.ts +62 -0
  48. package/dist/src/scrollspy.d.ts.map +1 -0
  49. package/dist/src/select.d.ts +77 -0
  50. package/dist/src/select.d.ts.map +1 -0
  51. package/dist/src/sidenav.d.ts +122 -0
  52. package/dist/src/sidenav.d.ts.map +1 -0
  53. package/dist/src/slider.d.ts +103 -0
  54. package/dist/src/slider.d.ts.map +1 -0
  55. package/dist/src/tabs.d.ts +80 -0
  56. package/dist/src/tabs.d.ts.map +1 -0
  57. package/dist/src/tapTarget.d.ts +59 -0
  58. package/dist/src/tapTarget.d.ts.map +1 -0
  59. package/dist/src/timepicker.d.ts +208 -0
  60. package/dist/src/timepicker.d.ts.map +1 -0
  61. package/dist/src/toasts.d.ts +90 -0
  62. package/dist/src/toasts.d.ts.map +1 -0
  63. package/dist/src/tooltip.d.ts +112 -0
  64. package/dist/src/tooltip.d.ts.map +1 -0
  65. package/dist/src/utils.d.ts +97 -0
  66. package/dist/src/utils.d.ts.map +1 -0
  67. package/dist/src/waves.d.ts +16 -0
  68. package/dist/src/waves.d.ts.map +1 -0
  69. package/package.json +4 -1
  70. package/sass/components/_cards.scss +1 -1
  71. package/sass/components/_collapsible.scss +0 -41
  72. package/sass/components/_global.scss +53 -2
  73. package/sass/components/_grid.scss +28 -47
  74. package/sass/components/_icons-material-design.scss +2 -1
  75. package/sass/components/_navbar.scss +30 -27
  76. package/sass/components/_pulse.scss +1 -0
  77. package/sass/components/_sidenav.scss +63 -45
  78. package/sass/components/_theme_variables.scss +29 -49
  79. package/sass/components/_typography.scss +2 -2
  80. package/sass/components/_variables.scss +2 -0
  81. package/sass/components/colors.module.scss +180 -0
  82. package/sass/components/forms/_input-fields.scss +4 -10
  83. package/sass/components/theme.dark.module.scss +32 -0
  84. package/sass/components/theme.light.module.scss +32 -0
  85. package/sass/components/tokens.module.scss +272 -0
  86. package/sass/components/typography.module.scss +150 -0
  87. package/sass/materialize.scss +6 -4
  88. package/src/autocomplete.ts +188 -94
  89. package/src/buttons.ts +225 -260
  90. package/src/cards.ts +5 -6
  91. package/src/carousel.ts +611 -542
  92. package/src/characterCounter.ts +50 -21
  93. package/src/chips.ts +152 -63
  94. package/src/collapsible.ts +97 -32
  95. package/src/component.ts +99 -10
  96. package/src/datepicker.ts +905 -726
  97. package/src/dropdown.ts +573 -484
  98. package/src/edges.ts +4 -4
  99. package/src/forms.ts +36 -24
  100. package/src/global.ts +57 -328
  101. package/src/index.ts +26 -0
  102. package/src/materialbox.ts +354 -298
  103. package/src/modal.ts +296 -211
  104. package/src/parallax.ts +129 -105
  105. package/src/pushpin.ts +148 -103
  106. package/src/range.ts +166 -150
  107. package/src/scrollspy.ts +214 -174
  108. package/src/select.ts +434 -398
  109. package/src/sidenav.ts +447 -381
  110. package/src/slider.ts +421 -362
  111. package/src/tabs.ts +276 -222
  112. package/src/tapTarget.ts +246 -213
  113. package/src/timepicker.ts +738 -614
  114. package/src/toasts.ts +254 -230
  115. package/src/tooltip.ts +315 -252
  116. package/src/utils.ts +271 -0
  117. package/src/waves.ts +10 -10
package/src/tabs.ts CHANGED
@@ -1,107 +1,153 @@
1
- import { Component } from "./component";
2
- import { Carousel } from "./carousel";
3
1
  import anim from "animejs";
4
2
 
5
- let _defaults = {
3
+ import { Carousel } from "./carousel";
4
+ import { Component, BaseOptions, InitElements, MElement } from "./component";
5
+
6
+ export interface TabsOptions extends BaseOptions {
7
+ /**
8
+ * Transition duration in milliseconds.
9
+ * @default 300
10
+ */
11
+ duration: number;
12
+ /**
13
+ * Callback for when a new tab content is shown.
14
+ * @default null
15
+ */
16
+ onShow: (newContent: Element) => void;
17
+ /**
18
+ * Set to true to enable swipeable tabs.
19
+ * This also uses the responsiveThreshold option.
20
+ * @default false
21
+ */
22
+ swipeable: boolean;
23
+ /**
24
+ * The maximum width of the screen, in pixels,
25
+ * where the swipeable functionality initializes.
26
+ * @default infinity
27
+ */
28
+ responsiveThreshold: number;
29
+ };
30
+
31
+ let _defaults: TabsOptions = {
6
32
  duration: 300,
7
33
  onShow: null,
8
34
  swipeable: false,
9
- responsiveThreshold: Infinity, // breakpoint for swipeable
35
+ responsiveThreshold: Infinity // breakpoint for swipeable
10
36
  };
11
37
 
12
- export class Tabs extends Component {
13
- el: HTMLElement;
14
- _tabLinks: any;
38
+ export class Tabs extends Component<TabsOptions> {
39
+ _tabLinks: NodeListOf<HTMLAnchorElement>;
15
40
  _index: number;
16
41
  _indicator: any;
17
- _handleWindowResizeBound: (this: Window, ev: UIEvent) => any;
18
- _handleTabClickBound: (this: Window, ev: UIEvent) => any;
19
42
  _tabWidth: number;
20
43
  _tabsWidth: number;
21
44
  _tabsCarousel: any;
22
45
  _activeTabLink: any;
23
46
  _content: any;
24
47
 
25
- constructor(el, options: any) {
26
- super(Tabs, el, options);
27
- (this.el as any).M_Tabs = this;
28
-
29
- this.options = {...Tabs.defaults, ...options};
30
- this._tabLinks = this.el.querySelectorAll('li.tab > a');
31
- this._index = 0;
32
- this._setupActiveTabLink();
33
- if (this.options.swipeable) {
34
- this._setupSwipeableTabs();
35
- } else {
36
- this._setupNormalTabs();
37
- }
38
- // Setup tabs indicator after content to ensure accurate widths
39
- this._setTabsAndTabWidth();
40
- this._createIndicator();
41
- this._setupEventHandlers();
48
+ constructor(el: HTMLElement, options: Partial<TabsOptions>) {
49
+ super(el, options, Tabs);
50
+ (this.el as any).M_Tabs = this;
51
+
52
+ this.options = {
53
+ ...Tabs.defaults,
54
+ ...options
55
+ };
56
+
57
+ this._tabLinks = this.el.querySelectorAll('li.tab > a');
58
+ this._index = 0;
59
+ this._setupActiveTabLink();
60
+ if (this.options.swipeable) {
61
+ this._setupSwipeableTabs();
62
+ } else {
63
+ this._setupNormalTabs();
42
64
  }
65
+ // Setup tabs indicator after content to ensure accurate widths
66
+ this._setTabsAndTabWidth();
67
+ this._createIndicator();
68
+ this._setupEventHandlers();
69
+ }
43
70
 
44
- static get defaults() {
45
- return _defaults;
46
- }
71
+ static get defaults(): TabsOptions {
72
+ return _defaults;
73
+ }
47
74
 
48
- static init(els, options) {
49
- return super.init(this, els, options);
50
- }
75
+ /**
76
+ * Initializes instance of Tabs.
77
+ * @param el HTML element.
78
+ * @param options Component options.
79
+ */
80
+ static init(el: HTMLElement, options?: Partial<TabsOptions>): Tabs;
81
+ /**
82
+ * Initializes instances of Tabs.
83
+ * @param els HTML elements.
84
+ * @param options Component options.
85
+ */
86
+ static init(els: InitElements<MElement>, options?: Partial<TabsOptions>): Tabs[];
87
+ /**
88
+ * Initializes instances of Tabs.
89
+ * @param els HTML elements.
90
+ * @param options Component options.
91
+ */
92
+ static init(els: HTMLElement | InitElements<MElement>, options: Partial<TabsOptions> = {}): Tabs | Tabs[] {
93
+ return super.init(els, options, Tabs);
94
+ }
51
95
 
52
- static getInstance(el) {
53
- const domElem = !!el.jquery ? el[0] : el;
54
- return domElem.M_Tabs;
55
- }
96
+ static getInstance(el: HTMLElement): Tabs {
97
+ return (el as any).M_Tabs;
98
+ }
56
99
 
57
- destroy() {
58
- this._removeEventHandlers();
59
- this._indicator.parentNode.removeChild(this._indicator);
60
- if (this.options.swipeable) {
61
- this._teardownSwipeableTabs();
62
- }
63
- else {
64
- this._teardownNormalTabs();
65
- }
66
- (this.el as any).M_Tabs = undefined;
100
+ destroy() {
101
+ this._removeEventHandlers();
102
+ this._indicator.parentNode.removeChild(this._indicator);
103
+ if (this.options.swipeable) {
104
+ this._teardownSwipeableTabs();
67
105
  }
68
-
69
- _setupEventHandlers() {
70
- this._handleWindowResizeBound = this._handleWindowResize.bind(this);
71
- window.addEventListener('resize', this._handleWindowResizeBound);
72
- this._handleTabClickBound = this._handleTabClick.bind(this);
73
- this.el.addEventListener('click', this._handleTabClickBound);
106
+ else {
107
+ this._teardownNormalTabs();
74
108
  }
109
+ (this.el as any).M_Tabs = undefined;
110
+ }
75
111
 
76
- _removeEventHandlers() {
77
- window.removeEventListener('resize', this._handleWindowResizeBound);
78
- this.el.removeEventListener('click', this._handleTabClickBound);
79
- }
112
+ /**
113
+ * The index of tab that is currently shown.
114
+ */
115
+ get index(){ return this._index; }
80
116
 
81
- _handleWindowResize() {
82
- this._setTabsAndTabWidth();
83
- if (this._tabWidth !== 0 && this._tabsWidth !== 0) {
84
- this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
85
- this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
86
- }
117
+ _setupEventHandlers() {
118
+ window.addEventListener('resize', this._handleWindowResize);
119
+ this.el.addEventListener('click', this._handleTabClick);
120
+ }
121
+
122
+ _removeEventHandlers() {
123
+ window.removeEventListener('resize', this._handleWindowResize);
124
+ this.el.removeEventListener('click', this._handleTabClick);
125
+ }
126
+
127
+ _handleWindowResize = () => {
128
+ this._setTabsAndTabWidth();
129
+ if (this._tabWidth !== 0 && this._tabsWidth !== 0) {
130
+ this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
131
+ this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
87
132
  }
133
+ }
88
134
 
89
- _handleTabClick(e) {
90
- const tabLink = e.target;
91
- const tab = tabLink.parentElement;
92
- // Handle click on tab link only
93
- if (!tabLink || !tab.classList.contains('tab')) return;
94
- // is disabled?
95
- if (tab.classList.contains('disabled')) {
96
- e.preventDefault();
97
- return;
98
- }
99
- // Act as regular link if target attribute is specified.
100
- if (tabLink.hasAttribute('target')) return;
101
- // Make the old tab inactive.
102
- this._activeTabLink.classList.remove('active');
103
- const _oldContent = this._content;
104
- // Update the variables with the new link and content
135
+ _handleTabClick = (e: MouseEvent) => {
136
+ const tabLink = e.target as HTMLAnchorElement;
137
+ const tab = tabLink.parentElement;
138
+ // Handle click on tab link only
139
+ if (!tabLink || !tab.classList.contains('tab')) return;
140
+ // is disabled?
141
+ if (tab.classList.contains('disabled')) {
142
+ e.preventDefault();
143
+ return;
144
+ }
145
+ // Act as regular link if target attribute is specified.
146
+ if (tabLink.hasAttribute('target')) return;
147
+ // Make the old tab inactive.
148
+ this._activeTabLink.classList.remove('active');
149
+ const _oldContent = this._content;
150
+ // Update the variables with the new link and content
105
151
 
106
152
  this._activeTabLink = tabLink;
107
153
  if (tabLink.hash)
@@ -112,53 +158,53 @@ export class Tabs extends Component {
112
158
  const prevIndex = this._index;
113
159
  this._index = Math.max(Array.from(this._tabLinks).indexOf(tabLink), 0);
114
160
 
115
- // Swap content
116
- if (this.options.swipeable) {
117
- if (this._tabsCarousel) {
118
- this._tabsCarousel.set(this._index, () => {
119
- if (typeof this.options.onShow === 'function')
120
- this.options.onShow.call(this, this._content);
121
- });
122
- }
123
- } else {
124
- if (this._content) {
125
- this._content.style.display = 'block';
126
- this._content.classList.add('active');
161
+ // Swap content
162
+ if (this.options.swipeable) {
163
+ if (this._tabsCarousel) {
164
+ this._tabsCarousel.set(this._index, () => {
127
165
  if (typeof this.options.onShow === 'function')
128
166
  this.options.onShow.call(this, this._content);
129
- if (_oldContent && _oldContent !== this._content) {
130
- _oldContent.style.display = 'none';
131
- _oldContent.classList.remove('active');
132
- }
167
+ });
168
+ }
169
+ } else {
170
+ if (this._content) {
171
+ this._content.style.display = 'block';
172
+ this._content.classList.add('active');
173
+ if (typeof this.options.onShow === 'function')
174
+ this.options.onShow.call(this, this._content);
175
+ if (_oldContent && _oldContent !== this._content) {
176
+ _oldContent.style.display = 'none';
177
+ _oldContent.classList.remove('active');
133
178
  }
134
179
  }
135
- // Update widths after content is swapped (scrollbar bugfix)
136
- this._setTabsAndTabWidth();
137
- this._animateIndicator(prevIndex);
138
- e.preventDefault();
139
180
  }
181
+ // Update widths after content is swapped (scrollbar bugfix)
182
+ this._setTabsAndTabWidth();
183
+ this._animateIndicator(prevIndex);
184
+ e.preventDefault();
185
+ }
140
186
 
141
- _createIndicator() {
142
- const indicator = document.createElement('li');
143
- indicator.classList.add('indicator');
144
- this.el.appendChild(indicator);
145
- this._indicator = indicator;
146
- this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
147
- this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
148
- }
187
+ _createIndicator() {
188
+ const indicator = document.createElement('li');
189
+ indicator.classList.add('indicator');
190
+ this.el.appendChild(indicator);
191
+ this._indicator = indicator;
192
+ this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
193
+ this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
194
+ }
149
195
 
150
- _setupActiveTabLink() {
151
- // If the location.hash matches one of the links, use that as the active tab.
152
- this._activeTabLink = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === location.hash);
153
- // If no match is found, use the first link or any with class 'active' as the initial active tab.
154
- if (!this._activeTabLink) {
155
- this._activeTabLink = this.el.querySelector('li.tab a.active');
156
- }
157
- if (this._activeTabLink.length === 0) {
158
- this._activeTabLink = this.el.querySelector('li.tab a');
159
- }
160
- Array.from(this._tabLinks).forEach((a: HTMLAnchorElement) => a.classList.remove('active'));
161
- this._activeTabLink.classList.add('active');
196
+ _setupActiveTabLink() {
197
+ // If the location.hash matches one of the links, use that as the active tab.
198
+ this._activeTabLink = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === location.hash);
199
+ // If no match is found, use the first link or any with class 'active' as the initial active tab.
200
+ if (!this._activeTabLink) {
201
+ this._activeTabLink = this.el.querySelector('li.tab a.active');
202
+ }
203
+ if (this._activeTabLink.length === 0) {
204
+ this._activeTabLink = this.el.querySelector('li.tab a');
205
+ }
206
+ Array.from(this._tabLinks).forEach((a: HTMLAnchorElement) => a.classList.remove('active'));
207
+ this._activeTabLink.classList.add('active');
162
208
 
163
209
  this._index = Math.max(Array.from(this._tabLinks).indexOf(this._activeTabLink), 0);
164
210
  if (this._activeTabLink && this._activeTabLink.hash) {
@@ -167,10 +213,10 @@ export class Tabs extends Component {
167
213
  }
168
214
  }
169
215
 
170
- _setupSwipeableTabs() {
171
- // Change swipeable according to responsive threshold
172
- if (window.innerWidth > this.options.responsiveThreshold)
173
- this.options.swipeable = false;
216
+ _setupSwipeableTabs() {
217
+ // Change swipeable according to responsive threshold
218
+ if (window.innerWidth > this.options.responsiveThreshold)
219
+ this.options.swipeable = false;
174
220
 
175
221
  const tabsContent = [];
176
222
  this._tabLinks.forEach(a => {
@@ -181,113 +227,121 @@ export class Tabs extends Component {
181
227
  }
182
228
  });
183
229
 
184
- // Create Carousel-Wrapper around Tab-Contents
185
- const tabsWrapper = document.createElement('div');
186
- tabsWrapper.classList.add('tabs-content', 'carousel', 'carousel-slider');
187
-
188
- // Wrap around
189
- tabsContent[0].parentElement.insertBefore(tabsWrapper, tabsContent[0]);
190
- tabsContent.forEach(tabContent => {
191
- tabsWrapper.appendChild(tabContent);
192
- tabContent.style.display = '';
193
- });
194
-
195
- // Keep active tab index to set initial carousel slide
196
- const tab = this._activeTabLink.parentElement;
197
- const activeTabIndex = Array.from(tab.parentNode.children).indexOf(tab);
198
-
199
- this._tabsCarousel = Carousel.init(tabsWrapper, {
200
- fullWidth: true,
201
- noWrap: true,
202
- onCycleTo: (item) => {
203
- const prevIndex = this._index;
204
- this._index = Array.from(item.parentNode.children).indexOf(item);
205
- this._activeTabLink.classList.remove('active');
206
- this._activeTabLink = Array.from(this._tabLinks)[this._index];
207
- this._activeTabLink.classList.add('active');
208
- this._animateIndicator(prevIndex);
209
- if (typeof this.options.onShow === 'function')
210
- this.options.onShow.call(this, this._content);
211
- }
212
- });
213
- // Set initial carousel slide to active tab
214
- this._tabsCarousel.set(activeTabIndex);
215
- }
230
+ // Create Carousel-Wrapper around Tab-Contents
231
+ const tabsWrapper = document.createElement('div');
232
+ tabsWrapper.classList.add('tabs-content', 'carousel', 'carousel-slider');
233
+
234
+ // Wrap around
235
+ tabsContent[0].parentElement.insertBefore(tabsWrapper, tabsContent[0]);
236
+ tabsContent.forEach(tabContent => {
237
+ tabsWrapper.appendChild(tabContent);
238
+ tabContent.style.display = '';
239
+ });
240
+
241
+ // Keep active tab index to set initial carousel slide
242
+ const tab = this._activeTabLink.parentElement;
243
+ const activeTabIndex = Array.from(tab.parentNode.children).indexOf(tab);
244
+
245
+ this._tabsCarousel = Carousel.init(tabsWrapper, {
246
+ fullWidth: true,
247
+ noWrap: true,
248
+ onCycleTo: (item) => {
249
+ const prevIndex = this._index;
250
+ this._index = Array.from(item.parentNode.children).indexOf(item);
251
+ this._activeTabLink.classList.remove('active');
252
+ this._activeTabLink = Array.from(this._tabLinks)[this._index];
253
+ this._activeTabLink.classList.add('active');
254
+ this._animateIndicator(prevIndex);
255
+ if (typeof this.options.onShow === 'function')
256
+ this.options.onShow.call(this, this._content);
257
+ }
258
+ });
259
+ // Set initial carousel slide to active tab
260
+ this._tabsCarousel.set(activeTabIndex);
261
+ }
216
262
 
217
- _teardownSwipeableTabs() {
218
- const tabsWrapper = this._tabsCarousel.el;
219
- this._tabsCarousel.destroy();
220
- // Unwrap
221
- tabsWrapper.after(tabsWrapper.children);
222
- tabsWrapper.remove();
223
- }
263
+ _teardownSwipeableTabs() {
264
+ const tabsWrapper = this._tabsCarousel.el;
265
+ this._tabsCarousel.destroy();
266
+ // Unwrap
267
+ tabsWrapper.after(tabsWrapper.children);
268
+ tabsWrapper.remove();
269
+ }
224
270
 
225
- _setupNormalTabs() {
226
- // Hide Tabs Content
227
- Array.from(this._tabLinks).forEach(a => {
228
- if (a === this._activeTabLink) return;
229
- if ((<HTMLAnchorElement>a).hash) {
230
- const currContent = document.querySelector((<HTMLAnchorElement>a).hash);
231
- if (currContent) (<HTMLElement>currContent).style.display = 'none';
232
- }
233
- });
234
- }
271
+ _setupNormalTabs() {
272
+ // Hide Tabs Content
273
+ Array.from(this._tabLinks).forEach((a) => {
274
+ if (a === this._activeTabLink) return;
275
+ if ((<HTMLAnchorElement>a).hash) {
276
+ const currContent = document.querySelector((<HTMLAnchorElement>a).hash);
277
+ if (currContent) (<HTMLElement>currContent).style.display = 'none';
278
+ }
279
+ });
280
+ }
235
281
 
236
- _teardownNormalTabs() {
237
- // show Tabs Content
238
- this._tabLinks.forEach(a => {
239
- if (a.hash) {
240
- const currContent = document.querySelector(a.hash);
241
- if (currContent) currContent.style.display = '';
242
- }
243
- });
244
- }
282
+ _teardownNormalTabs() {
283
+ // show Tabs Content
284
+ this._tabLinks.forEach((a) => {
285
+ if (a.hash) {
286
+ const currContent = document.querySelector(a.hash) as HTMLElement;
287
+ if (currContent) currContent.style.display = '';
288
+ }
289
+ });
290
+ }
245
291
 
246
- _setTabsAndTabWidth() {
247
- this._tabsWidth = this.el.getBoundingClientRect().width;
248
- this._tabWidth = Math.max(this._tabsWidth, this.el.scrollWidth) / this._tabLinks.length;
249
- }
292
+ _setTabsAndTabWidth() {
293
+ this._tabsWidth = this.el.getBoundingClientRect().width;
294
+ this._tabWidth = Math.max(this._tabsWidth, this.el.scrollWidth) / this._tabLinks.length;
295
+ }
250
296
 
251
- _calcRightPos(el) {
252
- return Math.ceil(this._tabsWidth - el.offsetLeft - el.getBoundingClientRect().width);
253
- }
297
+ _calcRightPos(el) {
298
+ return Math.ceil(this._tabsWidth - el.offsetLeft - el.getBoundingClientRect().width);
299
+ }
254
300
 
255
- _calcLeftPos(el) {
256
- return Math.floor(el.offsetLeft);
257
- }
301
+ _calcLeftPos(el) {
302
+ return Math.floor(el.offsetLeft);
303
+ }
258
304
 
259
- updateTabIndicator() {
260
- this._setTabsAndTabWidth();
261
- this._animateIndicator(this._index);
262
- }
305
+ /**
306
+ * Recalculate tab indicator position. This is useful when
307
+ * the indicator position is not correct.
308
+ */
309
+ updateTabIndicator() {
310
+ this._setTabsAndTabWidth();
311
+ this._animateIndicator(this._index);
312
+ }
263
313
 
264
- _animateIndicator(prevIndex) {
265
- let leftDelay = 0, rightDelay = 0;
266
-
267
- if (this._index - prevIndex >= 0)
268
- leftDelay = 90;
269
- else
270
- rightDelay = 90;
271
-
272
- const animOptions = {
273
- targets: this._indicator,
274
- left: {
275
- value: this._calcLeftPos(this._activeTabLink),
276
- delay: leftDelay
277
- },
278
- right: {
279
- value: this._calcRightPos(this._activeTabLink),
280
- delay: rightDelay
281
- },
282
- duration: this.options.duration,
283
- easing: 'easeOutQuad'
284
- };
285
- anim.remove(this._indicator);
286
- anim(animOptions);
287
- }
314
+ _animateIndicator(prevIndex) {
315
+ let leftDelay = 0, rightDelay = 0;
316
+
317
+ if (this._index - prevIndex >= 0)
318
+ leftDelay = 90;
319
+ else
320
+ rightDelay = 90;
321
+
322
+ const animOptions = {
323
+ targets: this._indicator,
324
+ left: {
325
+ value: this._calcLeftPos(this._activeTabLink),
326
+ delay: leftDelay
327
+ },
328
+ right: {
329
+ value: this._calcRightPos(this._activeTabLink),
330
+ delay: rightDelay
331
+ },
332
+ duration: this.options.duration,
333
+ easing: 'easeOutQuad'
334
+ };
335
+ anim.remove(this._indicator);
336
+ anim(animOptions);
337
+ }
288
338
 
289
- select(tabId) {
290
- const tab = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === '#'+tabId);
291
- if (tab) (<HTMLAnchorElement>tab).click();
292
- }
339
+ /**
340
+ * Show tab content that corresponds to the tab with the id.
341
+ * @param tabId The id of the tab that you want to switch to.
342
+ */
343
+ select(tabId: string) {
344
+ const tab = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === '#'+tabId);
345
+ if (tab) (<HTMLAnchorElement>tab).click();
293
346
  }
347
+ }