@onetype/framework 2.0.26 → 2.0.27

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 (65) hide show
  1. package/addons/core/assets/back/functions/utils/transform.js +1 -1
  2. package/addons/render/directives/front/js/functions/process/data.js +0 -1
  3. package/addons/render/transforms/addon.js +2 -0
  4. package/addons/render/transforms/functions/data.js +21 -0
  5. package/addons/render/transforms/functions/run.js +11 -0
  6. package/addons/render/transforms/item/functions/load.js +55 -0
  7. package/addons/render/transforms/item/functions/run.js +12 -0
  8. package/addons/render/transforms/items/directives/transform.js +15 -18
  9. package/lib/items/elements/global/heading/heading.css +1 -1
  10. package/lib/items/elements/global/markdown/markdown.js +207 -3
  11. package/lib/items/elements/{sections → navigation}/navbar/navbar.css +9 -9
  12. package/lib/items/elements/{sections → navigation}/navbar/navbar.js +2 -2
  13. package/lib/items/elements/navigation/sidebar/sidebar.css +101 -0
  14. package/lib/items/elements/navigation/sidebar/sidebar.js +56 -0
  15. package/lib/items/elements/{global → navigation}/tabs/tabs.css +6 -6
  16. package/lib/items/elements/{global → navigation}/tabs/tabs.js +2 -2
  17. package/lib/items/elements/sections/pricing/pricing.css +148 -0
  18. package/lib/items/elements/sections/pricing/pricing.js +76 -0
  19. package/lib/items/transforms/accordion/accordion.js +139 -141
  20. package/lib/items/transforms/chart/area.js +130 -133
  21. package/lib/items/transforms/chart/bar.js +116 -119
  22. package/lib/items/transforms/chart/bubble.js +142 -145
  23. package/lib/items/transforms/chart/doughnut.js +104 -107
  24. package/lib/items/transforms/chart/line.js +127 -130
  25. package/lib/items/transforms/chart/pie.js +102 -105
  26. package/lib/items/transforms/chart/radar.js +134 -137
  27. package/lib/items/transforms/chart/scatter.js +127 -130
  28. package/lib/items/transforms/codeflask/codeflask.js +10 -12
  29. package/lib/items/transforms/codemirror/codemirror.js +186 -189
  30. package/lib/items/transforms/comparison/comparison.js +130 -133
  31. package/lib/items/transforms/heatmap/heatmap.js +406 -407
  32. package/lib/items/transforms/interact/interact.js +240 -241
  33. package/lib/items/transforms/particles/particles.js +282 -283
  34. package/lib/items/transforms/sparkline/sparkline.js +207 -208
  35. package/lib/items/transforms/swiper/swiper.js +115 -118
  36. package/lib/items/transforms/tabs/tabs.js +383 -384
  37. package/lib/items/transforms/typed/typed.js +146 -147
  38. package/lib/load.js +8 -16
  39. package/lib/src/mixins/addons.js +10 -10
  40. package/lib/styles/variables.css +1 -1
  41. package/package.json +1 -1
  42. package/addons/render/transforms/functions/load/assets.js +0 -49
  43. /package/{addons/render/directives/front/js/items → lib/items/directives}/100-if.js +0 -0
  44. /package/{addons/render/directives/front/js/items → lib/items/directives}/1000-render.js +0 -0
  45. /package/{addons/render/directives/front/js/items → lib/items/directives}/110-show.js +0 -0
  46. /package/{addons/render/directives/front/js/items → lib/items/directives}/160-slot.js +0 -0
  47. /package/{addons/render/directives/front/js/items → lib/items/directives}/200-for.js +0 -0
  48. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-blur.js +0 -0
  49. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-change.js +0 -0
  50. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click-outside.js +0 -0
  51. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click.js +0 -0
  52. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-double-click.js +0 -0
  53. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-focus.js +0 -0
  54. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-input.js +0 -0
  55. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keydown.js +0 -0
  56. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keyup.js +0 -0
  57. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-enter.js +0 -0
  58. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-leave.js +0 -0
  59. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-move.js +0 -0
  60. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-scroll.js +0 -0
  61. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-submit.js +0 -0
  62. /package/{addons/render/directives/front/js/items → lib/items/directives}/650-fetch.js +0 -0
  63. /package/{addons/render/directives/front/js/items → lib/items/directives}/660-form.js +0 -0
  64. /package/{addons/render/directives/front/js/items → lib/items/directives}/700-text.js +0 -0
  65. /package/{addons/render/directives/front/js/items → lib/items/directives}/750-html.js +0 -0
@@ -1,460 +1,459 @@
1
- onetype.AddonReady('transforms', (transforms) =>
2
- {
3
- transforms.ItemAdd({
4
- id: 'tabs',
5
- icon: 'tab',
6
- name: 'Tabs',
7
- description: 'Tabbed interface component for organizing content. Switch between multiple panels with navigation controls.',
8
- config: {
9
- 'position': ['string', 'top'],
10
- 'alignment': ['string', 'left'],
11
- 'active-tab': ['number', 0],
12
- 'animation': ['string', 'fade'],
13
- 'animation-duration': ['number', 300],
14
- 'autoplay': ['boolean', true],
15
- 'autoplay-interval': ['number', 5000],
16
- 'autoplay-pause-on-hover': ['boolean', true],
17
- 'show-indicators': ['boolean', false],
18
- 'vertical': ['boolean', true],
19
- 'closeable': ['boolean', true],
20
- 'scrollable': ['boolean', true]
21
- },
22
- code: function(data, item, compile, node, identifier)
1
+ transforms.ItemAdd({
2
+ id: 'tabs',
3
+ icon: 'tab',
4
+ name: 'Tabs',
5
+ description: 'Tabbed interface component for organizing content. Switch between multiple panels with navigation controls.',
6
+ config: {
7
+ 'position': ['string', 'top'],
8
+ 'alignment': ['string', 'left'],
9
+ 'active-tab': ['number', 0],
10
+ 'animation': ['string', 'fade'],
11
+ 'animation-duration': ['number', 300],
12
+ 'autoplay': ['boolean', true],
13
+ 'autoplay-interval': ['number', 5000],
14
+ 'autoplay-pause-on-hover': ['boolean', true],
15
+ 'show-indicators': ['boolean', false],
16
+ 'vertical': ['boolean', true],
17
+ 'closeable': ['boolean', true],
18
+ 'scrollable': ['boolean', true]
19
+ },
20
+ code: function(data, node, transformer)
21
+ {
22
+ const id = 'tabs-' + onetype.Generate(8);
23
+
24
+ this.setup = () =>
23
25
  {
24
- this.setup = () =>
25
- {
26
- node.classList.add('tabs');
27
- node.classList.add('tabs-' + identifier);
28
- node.classList.add('tabs-position-' + data['position'].value);
26
+ node.classList.add('tabs');
27
+ node.classList.add(id);
28
+ node.classList.add('tabs-position-' + data['position']);
29
29
 
30
- const children = Array.from(node.children);
31
- const navigation = document.createElement('div');
32
- const content = document.createElement('div');
30
+ const children = Array.from(node.children);
31
+ const navigation = document.createElement('div');
32
+ const content = document.createElement('div');
33
33
 
34
- navigation.className = 'tabs-navigation';
35
- content.className = 'tabs-content';
34
+ navigation.className = 'tabs-navigation';
35
+ content.className = 'tabs-content';
36
36
 
37
- if(data['vertical'].value)
38
- {
39
- node.classList.add('tabs-vertical');
40
- }
37
+ if(data['vertical'])
38
+ {
39
+ node.classList.add('tabs-vertical');
40
+ }
41
41
 
42
- if(data['alignment'].value)
43
- {
44
- navigation.classList.add('tabs-align-' + data['alignment'].value);
45
- }
42
+ if(data['alignment'])
43
+ {
44
+ navigation.classList.add('tabs-align-' + data['alignment']);
45
+ }
46
46
 
47
- children.forEach((child, index) =>
48
- {
49
- const title = child.getAttribute('title') || child.getAttribute('data-title') || `Tab ${index + 1}`;
50
- const tabButton = document.createElement('button');
51
- const tabPane = document.createElement('div');
47
+ children.forEach((child, index) =>
48
+ {
49
+ const title = child.getAttribute('title') || child.getAttribute('data-title') || `Tab ${index + 1}`;
50
+ const tabButton = document.createElement('button');
51
+ const tabPane = document.createElement('div');
52
52
 
53
- tabButton.className = 'tab-button';
54
- tabButton.textContent = title;
55
- tabButton.setAttribute('data-tab-index', index);
53
+ tabButton.className = 'tab-button';
54
+ tabButton.textContent = title;
55
+ tabButton.setAttribute('data-tab-index', index);
56
56
 
57
- tabPane.className = 'tab-pane';
58
- tabPane.setAttribute('data-tab-index', index);
57
+ tabPane.className = 'tab-pane';
58
+ tabPane.setAttribute('data-tab-index', index);
59
59
 
60
- while(child.firstChild)
61
- {
62
- tabPane.appendChild(child.firstChild);
63
- }
60
+ while(child.firstChild)
61
+ {
62
+ tabPane.appendChild(child.firstChild);
63
+ }
64
64
 
65
- navigation.appendChild(tabButton);
66
- content.appendChild(tabPane);
67
- });
65
+ navigation.appendChild(tabButton);
66
+ content.appendChild(tabPane);
67
+ });
68
68
 
69
- node.innerHTML = '';
69
+ node.innerHTML = '';
70
70
 
71
- if(data['position'].value === 'bottom')
72
- {
73
- node.appendChild(content);
74
- node.appendChild(navigation);
75
- }
76
- else
77
- {
78
- node.appendChild(navigation);
79
- node.appendChild(content);
80
- }
81
- };
71
+ if(data['position'] === 'bottom')
72
+ {
73
+ node.appendChild(content);
74
+ node.appendChild(navigation);
75
+ }
76
+ else
77
+ {
78
+ node.appendChild(navigation);
79
+ node.appendChild(content);
80
+ }
81
+ };
82
82
 
83
- this.closeable = () =>
83
+ this.closeable = () =>
84
+ {
85
+ if(!data['closeable'])
84
86
  {
85
- if(!data['closeable'].value)
86
- {
87
- return;
88
- }
87
+ return;
88
+ }
89
89
 
90
- const buttons = node.querySelectorAll('.tab-button');
90
+ const buttons = node.querySelectorAll('.tab-button');
91
91
 
92
- buttons.forEach(button =>
92
+ buttons.forEach(button =>
93
+ {
94
+ const closeButton = document.createElement('span');
95
+ closeButton.className = 'tab-close';
96
+ closeButton.innerHTML = '×';
97
+
98
+ closeButton.addEventListener('click', (event) =>
93
99
  {
94
- const closeButton = document.createElement('span');
95
- closeButton.className = 'tab-close';
96
- closeButton.innerHTML = '×';
97
-
98
- closeButton.addEventListener('click', (event) =>
99
- {
100
- event.stopPropagation();
101
- const index = parseInt(button.getAttribute('data-tab-index'));
102
- this.removeTab(index);
103
- });
104
-
105
- button.appendChild(closeButton);
100
+ event.stopPropagation();
101
+ const index = parseInt(button.getAttribute('data-tab-index'));
102
+ this.removeTab(index);
106
103
  });
107
- };
108
104
 
109
- this.indicators = () =>
110
- {
111
- if(!data['show-indicators'].value)
112
- {
113
- return;
114
- }
105
+ button.appendChild(closeButton);
106
+ });
107
+ };
115
108
 
116
- const indicators = document.createElement('div');
117
- indicators.className = 'tabs-indicators';
109
+ this.indicators = () =>
110
+ {
111
+ if(!data['show-indicators'])
112
+ {
113
+ return;
114
+ }
118
115
 
119
- const buttons = node.querySelectorAll('.tab-button');
116
+ const indicators = document.createElement('div');
117
+ indicators.className = 'tabs-indicators';
120
118
 
121
- buttons.forEach((button, index) =>
122
- {
123
- const indicator = document.createElement('span');
124
- indicator.className = 'tab-indicator';
125
- indicator.setAttribute('data-tab-index', index);
119
+ const buttons = node.querySelectorAll('.tab-button');
126
120
 
127
- indicator.addEventListener('click', () =>
128
- {
129
- this.switchTab(index);
130
- });
121
+ buttons.forEach((button, index) =>
122
+ {
123
+ const indicator = document.createElement('span');
124
+ indicator.className = 'tab-indicator';
125
+ indicator.setAttribute('data-tab-index', index);
131
126
 
132
- indicators.appendChild(indicator);
127
+ indicator.addEventListener('click', () =>
128
+ {
129
+ this.switchTab(index);
133
130
  });
134
131
 
135
- node.appendChild(indicators);
136
- };
132
+ indicators.appendChild(indicator);
133
+ });
137
134
 
138
- this.styles = () =>
139
- {
140
- const duration = data['animation-duration'].value;
141
- const animation = data['animation'].value;
142
- const style = document.createElement('style');
135
+ node.appendChild(indicators);
136
+ };
143
137
 
144
- let animationStyles = '';
138
+ this.styles = () =>
139
+ {
140
+ const duration = data['animation-duration'];
141
+ const animation = data['animation'];
142
+ const style = document.createElement('style');
145
143
 
146
- if(animation === 'fade')
147
- {
148
- animationStyles = `
149
- .tabs-${identifier} .tab-pane {
150
- opacity: 0;
151
- transition: opacity ${duration}ms ease-in-out;
152
- }
153
- .tabs-${identifier} .tab-pane.active {
154
- opacity: 1;
155
- }
156
- `;
157
- }
158
- else if(animation === 'slide')
159
- {
160
- animationStyles = `
161
- .tabs-${identifier} .tab-pane {
162
- transform: translateX(20px);
163
- opacity: 0;
164
- transition: transform ${duration}ms ease, opacity ${duration}ms ease;
165
- }
166
- .tabs-${identifier} .tab-pane.active {
167
- transform: translateX(0);
168
- opacity: 1;
169
- }
170
- `;
171
- }
172
- else
173
- {
174
- animationStyles = `
175
- .tabs-${identifier} .tab-pane {
176
- display: none;
177
- }
178
- .tabs-${identifier} .tab-pane.active {
179
- display: block;
180
- }
181
- `;
182
- }
144
+ let animationStyles = '';
183
145
 
184
- style.textContent = `
185
- .tabs-${identifier} {
186
- display: flex;
187
- flex-direction: column;
188
- }
189
- .tabs-${identifier}.tabs-vertical {
190
- flex-direction: row;
191
- }
192
- .tabs-${identifier} .tabs-navigation {
193
- display: flex;
194
- gap: 8px;
195
- position: relative;
196
- }
197
- .tabs-${identifier}.tabs-vertical .tabs-navigation {
198
- flex-direction: column;
199
- min-width: 200px;
200
- }
201
- .tabs-${identifier} .tabs-navigation.tabs-align-center {
202
- justify-content: center;
203
- }
204
- .tabs-${identifier} .tabs-navigation.tabs-align-right {
205
- justify-content: flex-end;
206
- }
207
- .tabs-${identifier} .tab-button {
208
- padding: 10px 20px;
209
- background: transparent;
210
- border: none;
211
- cursor: pointer;
212
- transition: all ${duration}ms ease;
213
- position: relative;
214
- display: flex;
215
- align-items: center;
216
- gap: 8px;
217
- }
218
- .tabs-${identifier} .tab-button.active {
219
- background: rgba(0, 0, 0, 0.1);
220
- }
221
- .tabs-${identifier} .tab-button:hover {
222
- background: rgba(0, 0, 0, 0.05);
223
- }
224
- .tabs-${identifier} .tab-close {
225
- display: inline-block;
226
- width: 20px;
227
- height: 20px;
228
- line-height: 20px;
229
- text-align: center;
230
- border-radius: 50%;
231
- transition: all ${duration}ms ease;
232
- }
233
- .tabs-${identifier} .tab-close:hover {
234
- background: rgba(255, 0, 0, 0.1);
235
- color: red;
236
- }
237
- .tabs-${identifier} .tabs-content {
238
- position: relative;
239
- flex: 1;
240
- }
241
- ${animationStyles}
242
- .tabs-${identifier} .tabs-content .tab-pane {
243
- position: absolute;
244
- top: 0;
245
- left: 0;
246
- width: 100%;
247
- height: 100%;
146
+ if(animation === 'fade')
147
+ {
148
+ animationStyles = `
149
+ .tabs-${id} .tab-pane {
150
+ opacity: 0;
151
+ transition: opacity ${duration}ms ease-in-out;
248
152
  }
249
- .tabs-${identifier} .tabs-indicators {
250
- display: flex;
251
- gap: 6px;
252
- justify-content: center;
253
- padding: 10px;
153
+ .tabs-${id} .tab-pane.active {
154
+ opacity: 1;
254
155
  }
255
- .tabs-${identifier} .tab-indicator {
256
- width: 8px;
257
- height: 8px;
258
- border-radius: 50%;
259
- background: rgba(0, 0, 0, 0.3);
260
- cursor: pointer;
261
- transition: all ${duration}ms ease;
156
+ `;
157
+ }
158
+ else if(animation === 'slide')
159
+ {
160
+ animationStyles = `
161
+ .tabs-${id} .tab-pane {
162
+ transform: translateX(20px);
163
+ opacity: 0;
164
+ transition: transform ${duration}ms ease, opacity ${duration}ms ease;
262
165
  }
263
- .tabs-${identifier} .tab-indicator.active {
264
- background: rgba(0, 0, 0, 0.8);
265
- transform: scale(1.2);
166
+ .tabs-${id} .tab-pane.active {
167
+ transform: translateX(0);
168
+ opacity: 1;
266
169
  }
267
- .tabs-${identifier}.tabs-position-bottom {
268
- flex-direction: column-reverse;
170
+ `;
171
+ }
172
+ else
173
+ {
174
+ animationStyles = `
175
+ .tabs-${id} .tab-pane {
176
+ display: none;
269
177
  }
270
- .tabs-${identifier}.tabs-vertical.tabs-position-right {
271
- flex-direction: row-reverse;
178
+ .tabs-${id} .tab-pane.active {
179
+ display: block;
272
180
  }
273
181
  `;
182
+ }
274
183
 
275
- if(data['scrollable'].value)
276
- {
277
- style.textContent += `
278
- .tabs-${identifier} .tabs-navigation {
279
- overflow-x: auto;
280
- scrollbar-width: thin;
281
- }
282
- .tabs-${identifier}.tabs-vertical .tabs-navigation {
283
- overflow-x: visible;
284
- overflow-y: auto;
285
- }
286
- `;
184
+ style.textContent = `
185
+ .tabs-${id} {
186
+ display: flex;
187
+ flex-direction: column;
287
188
  }
189
+ .tabs-${id}.tabs-vertical {
190
+ flex-direction: row;
191
+ }
192
+ .tabs-${id} .tabs-navigation {
193
+ display: flex;
194
+ gap: 8px;
195
+ position: relative;
196
+ }
197
+ .tabs-${id}.tabs-vertical .tabs-navigation {
198
+ flex-direction: column;
199
+ min-width: 200px;
200
+ }
201
+ .tabs-${id} .tabs-navigation.tabs-align-center {
202
+ justify-content: center;
203
+ }
204
+ .tabs-${id} .tabs-navigation.tabs-align-right {
205
+ justify-content: flex-end;
206
+ }
207
+ .tabs-${id} .tab-button {
208
+ padding: 10px 20px;
209
+ background: transparent;
210
+ border: none;
211
+ cursor: pointer;
212
+ transition: all ${duration}ms ease;
213
+ position: relative;
214
+ display: flex;
215
+ align-items: center;
216
+ gap: 8px;
217
+ }
218
+ .tabs-${id} .tab-button.active {
219
+ background: rgba(0, 0, 0, 0.1);
220
+ }
221
+ .tabs-${id} .tab-button:hover {
222
+ background: rgba(0, 0, 0, 0.05);
223
+ }
224
+ .tabs-${id} .tab-close {
225
+ display: inline-block;
226
+ width: 20px;
227
+ height: 20px;
228
+ line-height: 20px;
229
+ text-align: center;
230
+ border-radius: 50%;
231
+ transition: all ${duration}ms ease;
232
+ }
233
+ .tabs-${id} .tab-close:hover {
234
+ background: rgba(255, 0, 0, 0.1);
235
+ color: red;
236
+ }
237
+ .tabs-${id} .tabs-content {
238
+ position: relative;
239
+ flex: 1;
240
+ }
241
+ ${animationStyles}
242
+ .tabs-${id} .tabs-content .tab-pane {
243
+ position: absolute;
244
+ top: 0;
245
+ left: 0;
246
+ width: 100%;
247
+ height: 100%;
248
+ }
249
+ .tabs-${id} .tabs-indicators {
250
+ display: flex;
251
+ gap: 6px;
252
+ justify-content: center;
253
+ padding: 10px;
254
+ }
255
+ .tabs-${id} .tab-indicator {
256
+ width: 8px;
257
+ height: 8px;
258
+ border-radius: 50%;
259
+ background: rgba(0, 0, 0, 0.3);
260
+ cursor: pointer;
261
+ transition: all ${duration}ms ease;
262
+ }
263
+ .tabs-${id} .tab-indicator.active {
264
+ background: rgba(0, 0, 0, 0.8);
265
+ transform: scale(1.2);
266
+ }
267
+ .tabs-${id}.tabs-position-bottom {
268
+ flex-direction: column-reverse;
269
+ }
270
+ .tabs-${id}.tabs-vertical.tabs-position-right {
271
+ flex-direction: row-reverse;
272
+ }
273
+ `;
288
274
 
289
- document.head.appendChild(style);
290
- };
291
-
292
- this.switchTab = (index) =>
275
+ if(data['scrollable'])
293
276
  {
294
- const buttons = node.querySelectorAll('.tab-button');
295
- const panes = node.querySelectorAll('.tab-pane');
296
- const indicators = node.querySelectorAll('.tab-indicator');
297
-
298
- buttons.forEach((button, buttonIndex) =>
299
- {
300
- if(buttonIndex === index)
301
- {
302
- button.classList.add('active');
277
+ style.textContent += `
278
+ .tabs-${id} .tabs-navigation {
279
+ overflow-x: auto;
280
+ scrollbar-width: thin;
303
281
  }
304
- else
305
- {
306
- button.classList.remove('active');
282
+ .tabs-${id}.tabs-vertical .tabs-navigation {
283
+ overflow-x: visible;
284
+ overflow-y: auto;
307
285
  }
308
- });
309
-
310
- panes.forEach((pane, paneIndex) =>
311
- {
312
- if(paneIndex === index)
313
- {
314
- pane.classList.add('active');
315
- }
316
- else
317
- {
318
- pane.classList.remove('active');
319
- }
320
- });
286
+ `;
287
+ }
321
288
 
322
- indicators.forEach((indicator, indicatorIndex) =>
323
- {
324
- if(indicatorIndex === index)
325
- {
326
- indicator.classList.add('active');
327
- }
328
- else
329
- {
330
- indicator.classList.remove('active');
331
- }
332
- });
289
+ document.head.appendChild(style);
290
+ };
333
291
 
334
- this.currentTab = index;
335
- };
292
+ this.switchTab = (index) =>
293
+ {
294
+ const buttons = node.querySelectorAll('.tab-button');
295
+ const panes = node.querySelectorAll('.tab-pane');
296
+ const indicators = node.querySelectorAll('.tab-indicator');
336
297
 
337
- this.removeTab = (index) =>
298
+ buttons.forEach((button, buttonIndex) =>
338
299
  {
339
- const buttons = node.querySelectorAll('.tab-button');
340
- const panes = node.querySelectorAll('.tab-pane');
341
- const indicators = node.querySelectorAll('.tab-indicator');
342
-
343
- if(buttons.length <= 1)
300
+ if(buttonIndex === index)
344
301
  {
345
- return;
302
+ button.classList.add('active');
346
303
  }
347
-
348
- buttons[index].remove();
349
- panes[index].remove();
350
-
351
- if(indicators.length)
304
+ else
352
305
  {
353
- indicators[index].remove();
306
+ button.classList.remove('active');
354
307
  }
308
+ });
355
309
 
356
- const remainingButtons = node.querySelectorAll('.tab-button');
357
- const remainingPanes = node.querySelectorAll('.tab-pane');
358
- const remainingIndicators = node.querySelectorAll('.tab-indicator');
359
-
360
- remainingButtons.forEach((button, newIndex) =>
361
- {
362
- button.setAttribute('data-tab-index', newIndex);
363
- });
364
-
365
- remainingPanes.forEach((pane, newIndex) =>
310
+ panes.forEach((pane, paneIndex) =>
311
+ {
312
+ if(paneIndex === index)
366
313
  {
367
- pane.setAttribute('data-tab-index', newIndex);
368
- });
369
-
370
- remainingIndicators.forEach((indicator, newIndex) =>
314
+ pane.classList.add('active');
315
+ }
316
+ else
371
317
  {
372
- indicator.setAttribute('data-tab-index', newIndex);
373
- });
318
+ pane.classList.remove('active');
319
+ }
320
+ });
374
321
 
375
- if(this.currentTab === index)
322
+ indicators.forEach((indicator, indicatorIndex) =>
323
+ {
324
+ if(indicatorIndex === index)
376
325
  {
377
- this.switchTab(Math.max(0, index - 1));
326
+ indicator.classList.add('active');
378
327
  }
379
- else if(this.currentTab > index)
328
+ else
380
329
  {
381
- this.currentTab--;
330
+ indicator.classList.remove('active');
382
331
  }
383
- };
332
+ });
333
+
334
+ this.currentTab = index;
335
+ };
384
336
 
385
- this.autoplay = () =>
337
+ this.removeTab = (index) =>
338
+ {
339
+ const buttons = node.querySelectorAll('.tab-button');
340
+ const panes = node.querySelectorAll('.tab-pane');
341
+ const indicators = node.querySelectorAll('.tab-indicator');
342
+
343
+ if(buttons.length <= 1)
386
344
  {
387
- if(!data['autoplay'].value)
388
- {
389
- return;
390
- }
345
+ return;
346
+ }
391
347
 
392
- const interval = data['autoplay-interval'].value;
393
- const pauseOnHover = data['autoplay-pause-on-hover'].value;
348
+ buttons[index].remove();
349
+ panes[index].remove();
394
350
 
395
- let autoplayTimer = null;
351
+ if(indicators.length)
352
+ {
353
+ indicators[index].remove();
354
+ }
396
355
 
397
- const startAutoplay = () =>
398
- {
399
- autoplayTimer = setInterval(() =>
400
- {
401
- const buttons = node.querySelectorAll('.tab-button');
402
- const nextIndex = (this.currentTab + 1) % buttons.length;
403
- this.switchTab(nextIndex);
404
- }, interval);
405
- };
406
-
407
- const stopAutoplay = () =>
408
- {
409
- if(autoplayTimer)
410
- {
411
- clearInterval(autoplayTimer);
412
- autoplayTimer = null;
413
- }
414
- };
356
+ const remainingButtons = node.querySelectorAll('.tab-button');
357
+ const remainingPanes = node.querySelectorAll('.tab-pane');
358
+ const remainingIndicators = node.querySelectorAll('.tab-indicator');
415
359
 
416
- if(pauseOnHover)
417
- {
418
- node.addEventListener('mouseenter', stopAutoplay);
419
- node.addEventListener('mouseleave', startAutoplay);
420
- }
360
+ remainingButtons.forEach((button, newIndex) =>
361
+ {
362
+ button.setAttribute('data-tab-index', newIndex);
363
+ });
421
364
 
422
- startAutoplay();
365
+ remainingPanes.forEach((pane, newIndex) =>
366
+ {
367
+ pane.setAttribute('data-tab-index', newIndex);
368
+ });
423
369
 
424
- node._tabsAutoplay = {
425
- start: startAutoplay,
426
- stop: stopAutoplay
427
- };
428
- };
370
+ remainingIndicators.forEach((indicator, newIndex) =>
371
+ {
372
+ indicator.setAttribute('data-tab-index', newIndex);
373
+ });
374
+
375
+ if(this.currentTab === index)
376
+ {
377
+ this.switchTab(Math.max(0, index - 1));
378
+ }
379
+ else if(this.currentTab > index)
380
+ {
381
+ this.currentTab--;
382
+ }
383
+ };
429
384
 
430
- this.events = () =>
385
+ this.autoplay = () =>
386
+ {
387
+ if(!data['autoplay'])
431
388
  {
432
- const buttons = node.querySelectorAll('.tab-button');
389
+ return;
390
+ }
391
+
392
+ const interval = data['autoplay-interval'];
393
+ const pauseOnHover = data['autoplay-pause-on-hover'];
394
+
395
+ let autoplayTimer = null;
433
396
 
434
- buttons.forEach(button =>
397
+ const startAutoplay = () =>
398
+ {
399
+ autoplayTimer = setInterval(() =>
435
400
  {
436
- button.addEventListener('click', () =>
437
- {
438
- const index = parseInt(button.getAttribute('data-tab-index'));
439
- this.switchTab(index);
440
- });
441
- });
401
+ const buttons = node.querySelectorAll('.tab-button');
402
+ const nextIndex = (this.currentTab + 1) % buttons.length;
403
+ this.switchTab(nextIndex);
404
+ }, interval);
442
405
  };
443
406
 
444
- this.initialize = () =>
407
+ const stopAutoplay = () =>
445
408
  {
446
- const activeIndex = Math.max(0, Math.min(data['active-tab'].value, node.querySelectorAll('.tab-button').length - 1));
447
- this.currentTab = activeIndex;
448
- this.switchTab(activeIndex);
409
+ if(autoplayTimer)
410
+ {
411
+ clearInterval(autoplayTimer);
412
+ autoplayTimer = null;
413
+ }
449
414
  };
450
415
 
451
- this.setup();
452
- this.closeable();
453
- this.indicators();
454
- this.styles();
455
- this.events();
456
- this.initialize();
457
- this.autoplay();
458
- }
459
- });
460
- });
416
+ if(pauseOnHover)
417
+ {
418
+ node.addEventListener('mouseenter', stopAutoplay);
419
+ node.addEventListener('mouseleave', startAutoplay);
420
+ }
421
+
422
+ startAutoplay();
423
+
424
+ node._tabsAutoplay = {
425
+ start: startAutoplay,
426
+ stop: stopAutoplay
427
+ };
428
+ };
429
+
430
+ this.events = () =>
431
+ {
432
+ const buttons = node.querySelectorAll('.tab-button');
433
+
434
+ buttons.forEach(button =>
435
+ {
436
+ button.addEventListener('click', () =>
437
+ {
438
+ const index = parseInt(button.getAttribute('data-tab-index'));
439
+ this.switchTab(index);
440
+ });
441
+ });
442
+ };
443
+
444
+ this.initialize = () =>
445
+ {
446
+ const activeIndex = Math.max(0, Math.min(data['active-tab'], node.querySelectorAll('.tab-button').length - 1));
447
+ this.currentTab = activeIndex;
448
+ this.switchTab(activeIndex);
449
+ };
450
+
451
+ this.setup();
452
+ this.closeable();
453
+ this.indicators();
454
+ this.styles();
455
+ this.events();
456
+ this.initialize();
457
+ this.autoplay();
458
+ }
459
+ });