juxscript 1.1.32 → 1.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/tabs.d.ts +8 -9
- package/lib/components/tabs.d.ts.map +1 -1
- package/lib/components/tabs.js +39 -47
- package/lib/components/tabs.ts +46 -50
- package/package.json +1 -1
package/lib/components/tabs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
|
2
2
|
export interface Tab {
|
|
3
3
|
id: string;
|
|
4
4
|
label: string;
|
|
5
|
-
content: string
|
|
5
|
+
content: string;
|
|
6
6
|
icon?: string;
|
|
7
7
|
}
|
|
8
8
|
export interface TabsOptions {
|
|
@@ -25,22 +25,21 @@ export declare class Tabs extends BaseComponent<TabsState> {
|
|
|
25
25
|
update(prop: string, value: any): void;
|
|
26
26
|
private _updateActiveTab;
|
|
27
27
|
private _rebuildTabs;
|
|
28
|
-
/**
|
|
29
|
-
* ✅ NEW: Smart content rendering
|
|
30
|
-
* Handles strings, DOM elements, and component instances
|
|
31
|
-
*/
|
|
32
|
-
private _renderTabContent;
|
|
33
28
|
tabs(value: Tab[]): this;
|
|
34
29
|
addTab(tab: Tab): this;
|
|
35
30
|
removeTab(tabId: string): this;
|
|
36
31
|
activeTab(value: string): this;
|
|
37
32
|
variant(value: 'default' | 'pills' | 'underline'): this;
|
|
38
33
|
/**
|
|
39
|
-
*
|
|
34
|
+
* Update content of a specific tab by ID
|
|
35
|
+
*/
|
|
36
|
+
updateTabContent(tabId: string, content: string): this;
|
|
37
|
+
/**
|
|
38
|
+
* Get tab by ID
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
getTab(tabId: string): Tab | undefined;
|
|
42
41
|
/**
|
|
43
|
-
*
|
|
42
|
+
* Get current active tab
|
|
44
43
|
*/
|
|
45
44
|
getCurrentTab(): Tab | undefined;
|
|
46
45
|
render(targetId?: string): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMnE,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMnE,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG,SAAS,GAAG;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChD,OAAO,CAAC,YAAY,CAA4B;gBAEpC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAUjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAuBtC,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,YAAY;IA6DpB,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI;IAKxB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAKtB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAW9B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,IAAI;IAKvD;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAetD;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAItC;;OAEG;IACH,aAAa,IAAI,GAAG,GAAG,SAAS;IAQhC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAuEhC;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
|
package/lib/components/tabs.js
CHANGED
|
@@ -23,7 +23,7 @@ export class Tabs extends BaseComponent {
|
|
|
23
23
|
* REACTIVE UPDATE
|
|
24
24
|
* ═════════════════════════════════════════════════════════════════ */
|
|
25
25
|
update(prop, value) {
|
|
26
|
-
super.update(prop, value);
|
|
26
|
+
super.update(prop, value);
|
|
27
27
|
if (!this._tabsWrapper)
|
|
28
28
|
return;
|
|
29
29
|
switch (prop) {
|
|
@@ -45,14 +45,20 @@ export class Tabs extends BaseComponent {
|
|
|
45
45
|
if (!this._tabsWrapper)
|
|
46
46
|
return;
|
|
47
47
|
// Update button states
|
|
48
|
-
this.
|
|
49
|
-
btn.
|
|
48
|
+
this.state.tabs.forEach(tab => {
|
|
49
|
+
const btn = document.getElementById(`${this._id}-${tab.id}-button`);
|
|
50
|
+
if (btn) {
|
|
51
|
+
btn.classList.toggle('jux-tabs-button-active', tab.id === tabId);
|
|
52
|
+
}
|
|
50
53
|
});
|
|
51
54
|
// Update panel visibility
|
|
52
|
-
this.
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
this.state.tabs.forEach(tab => {
|
|
56
|
+
const panel = document.getElementById(`${this._id}-${tab.id}-panel`);
|
|
57
|
+
if (panel) {
|
|
58
|
+
const isActive = tab.id === tabId;
|
|
59
|
+
panel.classList.toggle('jux-tabs-panel-active', isActive);
|
|
60
|
+
panel.style.display = isActive ? 'block' : 'none';
|
|
61
|
+
}
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
64
|
_rebuildTabs() {
|
|
@@ -67,10 +73,11 @@ export class Tabs extends BaseComponent {
|
|
|
67
73
|
tabPanels.innerHTML = '';
|
|
68
74
|
// Rebuild
|
|
69
75
|
this.state.tabs.forEach(tab => {
|
|
70
|
-
// Button
|
|
76
|
+
// Button with unique ID
|
|
71
77
|
const tabButton = document.createElement('button');
|
|
78
|
+
tabButton.id = `${this._id}-${tab.id}-button`;
|
|
72
79
|
tabButton.className = 'jux-tabs-button';
|
|
73
|
-
tabButton.setAttribute('data-tab', tab.id);
|
|
80
|
+
tabButton.setAttribute('data-tab-id', tab.id);
|
|
74
81
|
if (tab.id === this.state.activeTab) {
|
|
75
82
|
tabButton.classList.add('jux-tabs-button-active');
|
|
76
83
|
}
|
|
@@ -86,40 +93,21 @@ export class Tabs extends BaseComponent {
|
|
|
86
93
|
this._triggerCallback('tabChange', tab.id);
|
|
87
94
|
});
|
|
88
95
|
tabList.appendChild(tabButton);
|
|
89
|
-
// Panel
|
|
96
|
+
// Panel with unique ID
|
|
90
97
|
const tabPanel = document.createElement('div');
|
|
98
|
+
tabPanel.id = `${this._id}-${tab.id}-panel`;
|
|
91
99
|
tabPanel.className = 'jux-tabs-panel';
|
|
92
|
-
tabPanel.setAttribute('data-tab', tab.id);
|
|
100
|
+
tabPanel.setAttribute('data-tab-id', tab.id);
|
|
93
101
|
if (tab.id === this.state.activeTab) {
|
|
94
102
|
tabPanel.classList.add('jux-tabs-panel-active');
|
|
95
103
|
}
|
|
96
104
|
else {
|
|
97
105
|
tabPanel.style.display = 'none';
|
|
98
106
|
}
|
|
99
|
-
|
|
100
|
-
this._renderTabContent(tabPanel, tab.content);
|
|
107
|
+
tabPanel.innerHTML = tab.content;
|
|
101
108
|
tabPanels.appendChild(tabPanel);
|
|
102
109
|
});
|
|
103
110
|
}
|
|
104
|
-
/**
|
|
105
|
-
* ✅ NEW: Smart content rendering
|
|
106
|
-
* Handles strings, DOM elements, and component instances
|
|
107
|
-
*/
|
|
108
|
-
_renderTabContent(panel, content) {
|
|
109
|
-
if (typeof content === 'string') {
|
|
110
|
-
panel.innerHTML = content;
|
|
111
|
-
}
|
|
112
|
-
else if (content instanceof HTMLElement) {
|
|
113
|
-
panel.appendChild(content);
|
|
114
|
-
}
|
|
115
|
-
else if (content && typeof content.render === 'function') {
|
|
116
|
-
// It's a component instance - create a container and render into it
|
|
117
|
-
const componentContainer = document.createElement('div');
|
|
118
|
-
componentContainer.id = `${panel.getAttribute('data-tab')}-content`;
|
|
119
|
-
panel.appendChild(componentContainer);
|
|
120
|
-
content.render(`#${componentContainer.id}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
111
|
/* ═════════════════════════════════════════════════════════════════
|
|
124
112
|
* FLUENT API
|
|
125
113
|
* ═════════════════════════════════════════════════════════════════ */
|
|
@@ -148,25 +136,28 @@ export class Tabs extends BaseComponent {
|
|
|
148
136
|
return this;
|
|
149
137
|
}
|
|
150
138
|
/**
|
|
151
|
-
*
|
|
139
|
+
* Update content of a specific tab by ID
|
|
152
140
|
*/
|
|
153
141
|
updateTabContent(tabId, content) {
|
|
154
142
|
const tab = this.state.tabs.find(t => t.id === tabId);
|
|
155
143
|
if (!tab)
|
|
156
144
|
return this;
|
|
157
145
|
tab.content = content;
|
|
158
|
-
// Update DOM if
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
panel.innerHTML = ''; // Clear existing content
|
|
163
|
-
this._renderTabContent(panel, content);
|
|
164
|
-
}
|
|
146
|
+
// Update DOM if rendered
|
|
147
|
+
const panel = document.getElementById(`${this._id}-${tabId}-panel`);
|
|
148
|
+
if (panel) {
|
|
149
|
+
panel.innerHTML = content;
|
|
165
150
|
}
|
|
166
151
|
return this;
|
|
167
152
|
}
|
|
168
153
|
/**
|
|
169
|
-
*
|
|
154
|
+
* Get tab by ID
|
|
155
|
+
*/
|
|
156
|
+
getTab(tabId) {
|
|
157
|
+
return this.state.tabs.find(t => t.id === tabId);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get current active tab
|
|
170
161
|
*/
|
|
171
162
|
getCurrentTab() {
|
|
172
163
|
return this.state.tabs.find(t => t.id === this.state.activeTab);
|
|
@@ -189,10 +180,11 @@ export class Tabs extends BaseComponent {
|
|
|
189
180
|
const tabPanels = document.createElement('div');
|
|
190
181
|
tabPanels.className = 'jux-tabs-panels';
|
|
191
182
|
tabs.forEach(tab => {
|
|
192
|
-
// Tab button
|
|
183
|
+
// Tab button with unique ID
|
|
193
184
|
const tabButton = document.createElement('button');
|
|
185
|
+
tabButton.id = `${this._id}-${tab.id}-button`;
|
|
194
186
|
tabButton.className = 'jux-tabs-button';
|
|
195
|
-
tabButton.setAttribute('data-tab', tab.id);
|
|
187
|
+
tabButton.setAttribute('data-tab-id', tab.id);
|
|
196
188
|
if (tab.id === activeTab) {
|
|
197
189
|
tabButton.classList.add('jux-tabs-button-active');
|
|
198
190
|
}
|
|
@@ -208,18 +200,18 @@ export class Tabs extends BaseComponent {
|
|
|
208
200
|
this._triggerCallback('tabChange', tab.id);
|
|
209
201
|
});
|
|
210
202
|
tabList.appendChild(tabButton);
|
|
211
|
-
// Tab panel
|
|
203
|
+
// Tab panel with unique ID
|
|
212
204
|
const tabPanel = document.createElement('div');
|
|
205
|
+
tabPanel.id = `${this._id}-${tab.id}-panel`;
|
|
213
206
|
tabPanel.className = 'jux-tabs-panel';
|
|
214
|
-
tabPanel.setAttribute('data-tab', tab.id);
|
|
207
|
+
tabPanel.setAttribute('data-tab-id', tab.id);
|
|
215
208
|
if (tab.id === activeTab) {
|
|
216
209
|
tabPanel.classList.add('jux-tabs-panel-active');
|
|
217
210
|
}
|
|
218
211
|
else {
|
|
219
212
|
tabPanel.style.display = 'none';
|
|
220
213
|
}
|
|
221
|
-
|
|
222
|
-
this._renderTabContent(tabPanel, tab.content);
|
|
214
|
+
tabPanel.innerHTML = tab.content;
|
|
223
215
|
tabPanels.appendChild(tabPanel);
|
|
224
216
|
});
|
|
225
217
|
wrapper.appendChild(tabList);
|
package/lib/components/tabs.ts
CHANGED
|
@@ -7,7 +7,7 @@ const CALLBACK_EVENTS = ['tabChange'] as const;
|
|
|
7
7
|
export interface Tab {
|
|
8
8
|
id: string;
|
|
9
9
|
label: string;
|
|
10
|
-
content: string
|
|
10
|
+
content: string; // ✅ Only static HTML strings for now
|
|
11
11
|
icon?: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -51,7 +51,7 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
51
51
|
* ═════════════════════════════════════════════════════════════════ */
|
|
52
52
|
|
|
53
53
|
update(prop: string, value: any): void {
|
|
54
|
-
super.update(prop, value);
|
|
54
|
+
super.update(prop, value);
|
|
55
55
|
|
|
56
56
|
if (!this._tabsWrapper) return;
|
|
57
57
|
|
|
@@ -77,15 +77,21 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
77
77
|
if (!this._tabsWrapper) return;
|
|
78
78
|
|
|
79
79
|
// Update button states
|
|
80
|
-
this.
|
|
81
|
-
btn.
|
|
80
|
+
this.state.tabs.forEach(tab => {
|
|
81
|
+
const btn = document.getElementById(`${this._id}-${tab.id}-button`);
|
|
82
|
+
if (btn) {
|
|
83
|
+
btn.classList.toggle('jux-tabs-button-active', tab.id === tabId);
|
|
84
|
+
}
|
|
82
85
|
});
|
|
83
86
|
|
|
84
87
|
// Update panel visibility
|
|
85
|
-
this.
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
this.state.tabs.forEach(tab => {
|
|
89
|
+
const panel = document.getElementById(`${this._id}-${tab.id}-panel`);
|
|
90
|
+
if (panel) {
|
|
91
|
+
const isActive = tab.id === tabId;
|
|
92
|
+
panel.classList.toggle('jux-tabs-panel-active', isActive);
|
|
93
|
+
panel.style.display = isActive ? 'block' : 'none';
|
|
94
|
+
}
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
|
|
@@ -103,10 +109,12 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
103
109
|
|
|
104
110
|
// Rebuild
|
|
105
111
|
this.state.tabs.forEach(tab => {
|
|
106
|
-
// Button
|
|
112
|
+
// Button with unique ID
|
|
107
113
|
const tabButton = document.createElement('button');
|
|
114
|
+
tabButton.id = `${this._id}-${tab.id}-button`;
|
|
108
115
|
tabButton.className = 'jux-tabs-button';
|
|
109
|
-
tabButton.setAttribute('data-tab', tab.id);
|
|
116
|
+
tabButton.setAttribute('data-tab-id', tab.id);
|
|
117
|
+
|
|
110
118
|
if (tab.id === this.state.activeTab) {
|
|
111
119
|
tabButton.classList.add('jux-tabs-button-active');
|
|
112
120
|
}
|
|
@@ -119,6 +127,7 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
tabButton.appendChild(document.createTextNode(tab.label));
|
|
130
|
+
|
|
122
131
|
tabButton.addEventListener('click', () => {
|
|
123
132
|
this.state.activeTab = tab.id;
|
|
124
133
|
this._triggerCallback('tabChange', tab.id);
|
|
@@ -126,10 +135,11 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
126
135
|
|
|
127
136
|
tabList.appendChild(tabButton);
|
|
128
137
|
|
|
129
|
-
// Panel
|
|
138
|
+
// Panel with unique ID
|
|
130
139
|
const tabPanel = document.createElement('div');
|
|
140
|
+
tabPanel.id = `${this._id}-${tab.id}-panel`;
|
|
131
141
|
tabPanel.className = 'jux-tabs-panel';
|
|
132
|
-
tabPanel.setAttribute('data-tab', tab.id);
|
|
142
|
+
tabPanel.setAttribute('data-tab-id', tab.id);
|
|
133
143
|
|
|
134
144
|
if (tab.id === this.state.activeTab) {
|
|
135
145
|
tabPanel.classList.add('jux-tabs-panel-active');
|
|
@@ -137,31 +147,11 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
137
147
|
tabPanel.style.display = 'none';
|
|
138
148
|
}
|
|
139
149
|
|
|
140
|
-
|
|
141
|
-
this._renderTabContent(tabPanel, tab.content);
|
|
142
|
-
|
|
150
|
+
tabPanel.innerHTML = tab.content;
|
|
143
151
|
tabPanels.appendChild(tabPanel);
|
|
144
152
|
});
|
|
145
153
|
}
|
|
146
154
|
|
|
147
|
-
/**
|
|
148
|
-
* ✅ NEW: Smart content rendering
|
|
149
|
-
* Handles strings, DOM elements, and component instances
|
|
150
|
-
*/
|
|
151
|
-
private _renderTabContent(panel: HTMLElement, content: string | HTMLElement | BaseComponent<any>): void {
|
|
152
|
-
if (typeof content === 'string') {
|
|
153
|
-
panel.innerHTML = content;
|
|
154
|
-
} else if (content instanceof HTMLElement) {
|
|
155
|
-
panel.appendChild(content);
|
|
156
|
-
} else if (content && typeof (content as any).render === 'function') {
|
|
157
|
-
// It's a component instance - create a container and render into it
|
|
158
|
-
const componentContainer = document.createElement('div');
|
|
159
|
-
componentContainer.id = `${panel.getAttribute('data-tab')}-content`;
|
|
160
|
-
panel.appendChild(componentContainer);
|
|
161
|
-
(content as BaseComponent<any>).render(`#${componentContainer.id}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
155
|
/* ═════════════════════════════════════════════════════════════════
|
|
166
156
|
* FLUENT API
|
|
167
157
|
* ═════════════════════════════════════════════════════════════════ */
|
|
@@ -198,28 +188,32 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
198
188
|
}
|
|
199
189
|
|
|
200
190
|
/**
|
|
201
|
-
*
|
|
191
|
+
* Update content of a specific tab by ID
|
|
202
192
|
*/
|
|
203
|
-
updateTabContent(tabId: string, content: string
|
|
193
|
+
updateTabContent(tabId: string, content: string): this {
|
|
204
194
|
const tab = this.state.tabs.find(t => t.id === tabId);
|
|
205
195
|
if (!tab) return this;
|
|
206
196
|
|
|
207
197
|
tab.content = content;
|
|
208
198
|
|
|
209
|
-
// Update DOM if
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
panel.innerHTML = ''; // Clear existing content
|
|
214
|
-
this._renderTabContent(panel as HTMLElement, content);
|
|
215
|
-
}
|
|
199
|
+
// Update DOM if rendered
|
|
200
|
+
const panel = document.getElementById(`${this._id}-${tabId}-panel`);
|
|
201
|
+
if (panel) {
|
|
202
|
+
panel.innerHTML = content;
|
|
216
203
|
}
|
|
217
204
|
|
|
218
205
|
return this;
|
|
219
206
|
}
|
|
220
207
|
|
|
221
208
|
/**
|
|
222
|
-
*
|
|
209
|
+
* Get tab by ID
|
|
210
|
+
*/
|
|
211
|
+
getTab(tabId: string): Tab | undefined {
|
|
212
|
+
return this.state.tabs.find(t => t.id === tabId);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Get current active tab
|
|
223
217
|
*/
|
|
224
218
|
getCurrentTab(): Tab | undefined {
|
|
225
219
|
return this.state.tabs.find(t => t.id === this.state.activeTab);
|
|
@@ -247,10 +241,12 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
247
241
|
tabPanels.className = 'jux-tabs-panels';
|
|
248
242
|
|
|
249
243
|
tabs.forEach(tab => {
|
|
250
|
-
// Tab button
|
|
244
|
+
// Tab button with unique ID
|
|
251
245
|
const tabButton = document.createElement('button');
|
|
246
|
+
tabButton.id = `${this._id}-${tab.id}-button`;
|
|
252
247
|
tabButton.className = 'jux-tabs-button';
|
|
253
|
-
tabButton.setAttribute('data-tab', tab.id);
|
|
248
|
+
tabButton.setAttribute('data-tab-id', tab.id);
|
|
249
|
+
|
|
254
250
|
if (tab.id === activeTab) {
|
|
255
251
|
tabButton.classList.add('jux-tabs-button-active');
|
|
256
252
|
}
|
|
@@ -263,6 +259,7 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
263
259
|
}
|
|
264
260
|
|
|
265
261
|
tabButton.appendChild(document.createTextNode(tab.label));
|
|
262
|
+
|
|
266
263
|
tabButton.addEventListener('click', () => {
|
|
267
264
|
this.state.activeTab = tab.id;
|
|
268
265
|
this._triggerCallback('tabChange', tab.id);
|
|
@@ -270,10 +267,11 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
270
267
|
|
|
271
268
|
tabList.appendChild(tabButton);
|
|
272
269
|
|
|
273
|
-
// Tab panel
|
|
270
|
+
// Tab panel with unique ID
|
|
274
271
|
const tabPanel = document.createElement('div');
|
|
272
|
+
tabPanel.id = `${this._id}-${tab.id}-panel`;
|
|
275
273
|
tabPanel.className = 'jux-tabs-panel';
|
|
276
|
-
tabPanel.setAttribute('data-tab', tab.id);
|
|
274
|
+
tabPanel.setAttribute('data-tab-id', tab.id);
|
|
277
275
|
|
|
278
276
|
if (tab.id === activeTab) {
|
|
279
277
|
tabPanel.classList.add('jux-tabs-panel-active');
|
|
@@ -281,9 +279,7 @@ export class Tabs extends BaseComponent<TabsState> {
|
|
|
281
279
|
tabPanel.style.display = 'none';
|
|
282
280
|
}
|
|
283
281
|
|
|
284
|
-
|
|
285
|
-
this._renderTabContent(tabPanel, tab.content);
|
|
286
|
-
|
|
282
|
+
tabPanel.innerHTML = tab.content;
|
|
287
283
|
tabPanels.appendChild(tabPanel);
|
|
288
284
|
});
|
|
289
285
|
|