PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / tabs / index.js

index.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/tabs/index.js

514 lines 28.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function () {
2 var el = wp.element.createElement;
3 var Fragment = wp.element.Fragment;
4 var useState = wp.element.useState;
5 var __ = wp.i18n.__;
6 var registerBlockType = wp.blocks.registerBlockType;
7 var InspectorControls = wp.blockEditor.InspectorControls;
8 var useBlockProps = wp.blockEditor.useBlockProps;
9 var RichText = wp.blockEditor.RichText;
10 var PanelBody = wp.components.PanelBody;
11 var Button = wp.components.Button;
12 var ToggleControl = wp.components.ToggleControl;
13 var RangeControl = wp.components.RangeControl;
14 var SelectControl = wp.components.SelectControl;
15 var TextControl = wp.components.TextControl;
16 var ColorPicker = wp.components.ColorPicker;
17 var Popover = wp.components.Popover;
18
19 var _tc; function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); }
20 var _tv; function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); }
21
22 // ── CSS vars builder ──────────────────────────────────────────────────────
23 function buildWrapStyle(a) {
24 var shadow = a.boxShadow === 'sm' ? '0 1px 4px rgba(0,0,0,0.10)' :
25 a.boxShadow === 'md' ? '0 4px 16px rgba(0,0,0,0.12)' :
26 a.boxShadow === 'lg' ? '0 8px 32px rgba(0,0,0,0.15)' : 'none';
27 return {
28 '--bkbg-tabs-tab-bar-bg' : a.tabBarBg,
29 '--bkbg-tabs-tab-bg' : a.tabBg,
30 '--bkbg-tabs-tab-color' : a.tabColor,
31 '--bkbg-tabs-tab-hover-bg' : a.tabHoverBg,
32 '--bkbg-tabs-tab-hover-color': a.tabHoverColor,
33 '--bkbg-tabs-tab-active-bg' : a.tabActiveBg,
34 '--bkbg-tabs-tab-active-color': a.tabActiveColor,
35 '--bkbg-tabs-indicator-color': a.indicatorColor,
36 '--bkbg-tabs-indicator-h' : a.indicatorHeight + 'px',
37 '--bkbg-tabs-tab-pad-v' : a.tabPaddingV + 'px',
38 '--bkbg-tabs-tab-pad-h' : a.tabPaddingH + 'px',
39 '--bkbg-tabs-tab-radius' : a.tabBorderRadius + 'px',
40 '--bkbg-tabs-gap' : a.tabGap + 'px',
41 '--bkbg-tabs-content-bg' : a.contentBg,
42 '--bkbg-tabs-content-color' : a.contentColor,
43 '--bkbg-tabs-content-pad' : a.contentPaddingTop + 'px ' + a.contentPaddingRight + 'px ' + a.contentPaddingBottom + 'px ' + a.contentPaddingLeft + 'px',
44 '--bkbg-tabs-content-radius' : a.contentBorderRadius + 'px',
45 '--bkbg-tabs-content-min-h' : a.contentMinHeight ? a.contentMinHeight + 'px' : 'auto',
46 '--bkbg-tabs-border-color' : a.borderColor,
47 '--bkbg-tabs-border-w' : a.borderWidth + 'px',
48 '--bkbg-tabs-wrapper-bg' : a.wrapperBg,
49 '--bkbg-tabs-wrapper-pad' : a.wrapperPaddingTop + 'px ' + a.wrapperPaddingRight + 'px ' + a.wrapperPaddingBottom + 'px ' + a.wrapperPaddingLeft + 'px',
50 '--bkbg-tabs-wrapper-radius' : a.wrapperBorderRadius + 'px',
51 '--bkbg-tabs-shadow' : shadow
52 };
53 }
54
55 // ── Color swatch helper ───────────────────────────────────────────────────
56 function renderColorControl(key, label, value, onChange, openKey, setOpenKey) {
57 var isOpen = openKey === key;
58 return el('div', { key: key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 0', gap: '8px' } },
59 el('span', { style: { fontSize: '12px', color: '#1e1e1e', flex: 1, lineHeight: 1.4 } }, label),
60 el('div', { style: { position: 'relative', flexShrink: 0 } },
61 el('button', {
62 type: 'button',
63 title: value || 'none',
64 onClick: function () { setOpenKey(isOpen ? null : key); },
65 style: {
66 width: '28px', height: '28px', borderRadius: '4px',
67 border: isOpen ? '2px solid #007cba' : '2px solid #ddd',
68 cursor: 'pointer', padding: 0, display: 'block',
69 background: value || 'transparent',
70 backgroundImage: !value ? 'repeating-linear-gradient(45deg,#ccc 0,#ccc 1px,transparent 0,transparent 50%)' : 'none',
71 backgroundSize: '4px 4px'
72 }
73 }),
74 isOpen && el(Popover, { position: 'bottom left', onClose: function () { setOpenKey(null); } },
75 el('div', { style: { padding: '8px' } },
76 el(ColorPicker, { color: value, enableAlpha: true, onChange: onChange })
77 )
78 )
79 )
80 );
81 }
82
83 // ── Item update helpers ───────────────────────────────────────────────────
84 function updateItem(items, index, field, value, setAttributes) {
85 var newItems = items.map(function (item, i) {
86 if (i !== index) return item;
87 var updated = {};
88 for (var k in item) { updated[k] = item[k]; }
89 updated[field] = value;
90 return updated;
91 });
92 setAttributes({ items: newItems });
93 }
94
95 // ── Register block ────────────────────────────────────────────────────────
96 registerBlockType('blockenberg/tabs', {
97 title: __('Tabs', 'blockenberg'),
98 icon: {
99 src: el('svg', { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', width: 24, height: 24, 'aria-hidden': true, focusable: false },
100 el('rect', { x: 2, y: 8, width: 6, height: 3, rx: 1, fill: 'currentColor' }),
101 el('rect', { x: 9, y: 8, width: 6, height: 3, rx: 1, fill: 'currentColor', opacity: 0.4 }),
102 el('rect', { x: 16, y: 8, width: 6, height: 3, rx: 1, fill: 'currentColor', opacity: 0.4 }),
103 el('rect', { x: 2, y: 12, width: 20, height: 9, rx: 1.5, fill: 'currentColor', opacity: 0.15 }),
104 el('rect', { x: 2, y: 12, width: 20, height: 9, rx: 1.5, stroke: 'currentColor', strokeWidth: 1.5, fill: 'none' })
105 )
106 },
107 category: 'bkbg-content',
108 description: __('Tabbed content panels with full WYSIWYG editing per tab.', 'blockenberg'),
109
110 edit: function (props) {
111 var a = props.attributes;
112 var setAttributes = props.setAttributes;
113
114 var openColorKeyState = useState(null);
115 var openColorKey = openColorKeyState[0];
116 var setOpenColorKey = openColorKeyState[1];
117
118 function cc(key, label, attrKey) {
119 return renderColorControl(key, label, a[attrKey], function (val) {
120 var upd = {}; upd[attrKey] = val; setAttributes(upd);
121 }, openColorKey, setOpenColorKey);
122 }
123
124 function addTab() {
125 setAttributes({
126 items: a.items.concat([{
127 title: __('New Tab', 'blockenberg'),
128 content: '<p>' + __('Tab content goes here.', 'blockenberg') + '</p>',
129 icon: 'dashicons-star-filled',
130 showIcon: true
131 }])
132 });
133 }
134
135 function removeTab(index) {
136 if (a.items.length <= 1) return;
137 var newItems = a.items.filter(function (_, i) { return i !== index; });
138 var newActive = a.activeTab >= newItems.length ? newItems.length - 1 : a.activeTab;
139 setAttributes({ items: newItems, activeTab: newActive });
140 }
141
142 function moveTab(index, dir) {
143 var newIndex = index + dir;
144 if (newIndex < 0 || newIndex >= a.items.length) return;
145 var newItems = a.items.slice();
146 var temp = newItems[index]; newItems[index] = newItems[newIndex]; newItems[newIndex] = temp;
147 setAttributes({ items: newItems });
148 }
149
150 var wrapperClass = 'bkbg-tabs-wrapper bkbg-tabs-style-' + a.tabStyle + ' bkbg-tabs-pos-' + a.tabPosition + ' bkbg-tabs-align-' + a.tabAlign;
151 var blockProps = useBlockProps((function () {
152 var _tvf = getTypoCssVars();
153 var s = Object.assign({}, buildWrapStyle(a));
154 if (_tvf) {
155 Object.assign(s, _tvf(a.tabTypo, '--bktb-tb-'));
156 Object.assign(s, _tvf(a.contentTypo, '--bktb-ct-'));
157 }
158 return { className: wrapperClass, style: s };
159 })());
160
161 // ── Inspector ─────────────────────────────────────────────────────
162 var inspector = el(InspectorControls, {},
163 // Tabs Management
164 el(PanelBody, { title: __('Tabs', 'blockenberg'), initialOpen: true },
165 a.items.map(function (item, i) {
166 return el('div', {
167 key: i,
168 style: { border: '1px solid #ddd', borderRadius: '6px', padding: '10px', marginBottom: '10px', background: i === a.activeTab ? '#f0f7ff' : '#fafafa' }
169 },
170 el('div', { style: { display: 'flex', alignItems: 'center', gap: '6px', marginBottom: '8px' } },
171 el('span', { style: { fontWeight: '600', fontSize: '12px', flex: 1 } }, (i + 1) + '. ' + (item.title || __('Tab', 'blockenberg'))),
172 el(Button, { isSmall: true, variant: 'tertiary', onClick: function () { moveTab(i, -1); }, disabled: i === 0 }, ''),
173 el(Button, { isSmall: true, variant: 'tertiary', onClick: function () { moveTab(i, 1); }, disabled: i === a.items.length - 1 }, ''),
174 el(Button, {
175 isSmall: true, variant: 'tertiary',
176 onClick: function () { setAttributes({ activeTab: i }); }
177 }, i === a.activeTab ? __('Editing', 'blockenberg') : __('Edit', 'blockenberg')),
178 el(Button, {
179 isSmall: true, isDestructive: true, variant: 'tertiary',
180 onClick: function () { removeTab(i); }, disabled: a.items.length <= 1
181 }, '')
182 ),
183 el(TextControl, {
184 label: __('Tab Label', 'blockenberg'),
185 value: item.title,
186 onChange: function (val) { updateItem(a.items, i, 'title', val, setAttributes); }
187 }),
188 a.showIcons && el(TextControl, {
189 label: __('Icon (dashicons class)', 'blockenberg'),
190 value: item.icon || '',
191 placeholder: 'dashicons-star-filled',
192 onChange: function (val) { updateItem(a.items, i, 'icon', val, setAttributes); }
193 })
194 );
195 }),
196 el(Button, { variant: 'secondary', onClick: addTab, style: { width: '100%', justifyContent: 'center' } },
197 '+ ' + __('Add Tab', 'blockenberg')
198 )
199 ),
200
201 // Layout
202 el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: false },
203 el(SelectControl, {
204 label: __('Tab Style', 'blockenberg'),
205 value: a.tabStyle,
206 options: [
207 { label: __('Underline', 'blockenberg'), value: 'underline' },
208 { label: __('Pills / Rounded', 'blockenberg'), value: 'pills' },
209 { label: __('Boxed', 'blockenberg'), value: 'boxed' },
210 { label: __('Minimal', 'blockenberg'), value: 'minimal' }
211 ],
212 onChange: function (val) { setAttributes({ tabStyle: val }); }
213 }),
214 el(SelectControl, {
215 label: __('Tab Position', 'blockenberg'),
216 value: a.tabPosition,
217 options: [
218 { label: __('Top', 'blockenberg'), value: 'top' },
219 { label: __('Left', 'blockenberg'), value: 'left' }
220 ],
221 onChange: function (val) { setAttributes({ tabPosition: val }); }
222 }),
223 a.tabPosition === 'top' && el(SelectControl, {
224 label: __('Tab Alignment', 'blockenberg'),
225 value: a.tabAlign,
226 options: [
227 { label: __('Left', 'blockenberg'), value: 'left' },
228 { label: __('Center', 'blockenberg'), value: 'center' },
229 { label: __('Right', 'blockenberg'), value: 'right' },
230 { label: __('Full Width', 'blockenberg'), value: 'full' }
231 ],
232 onChange: function (val) { setAttributes({ tabAlign: val }); }
233 }),
234 el(SelectControl, {
235 label: __('Animation', 'blockenberg'),
236 value: a.animationType,
237 options: [
238 { label: __('None', 'blockenberg'), value: 'none' },
239 { label: __('Fade', 'blockenberg'), value: 'fade' },
240 { label: __('Slide Up', 'blockenberg'), value: 'slide-up' }
241 ],
242 onChange: function (val) { setAttributes({ animationType: val }); }
243 }),
244 el(RangeControl, {
245 label: __('Tab Gap', 'blockenberg'),
246 value: a.tabGap, min: 0, max: 24,
247 onChange: function (val) { setAttributes({ tabGap: val }); }
248 }),
249 el(SelectControl, {
250 label: __('Box Shadow', 'blockenberg'),
251 value: a.boxShadow,
252 options: [
253 { label: __('None', 'blockenberg'), value: 'none' },
254 { label: __('Small', 'blockenberg'), value: 'sm' },
255 { label: __('Medium', 'blockenberg'), value: 'md' },
256 { label: __('Large', 'blockenberg'), value: 'lg' }
257 ],
258 onChange: function (val) { setAttributes({ boxShadow: val }); }
259 })
260 ),
261
262 // Icons & Labels
263 el(PanelBody, { title: __('Icons & Labels', 'blockenberg'), initialOpen: false },
264 el(ToggleControl, {
265 label: __('Show Icons', 'blockenberg'),
266 checked: a.showIcons,
267 onChange: function (val) { setAttributes({ showIcons: val }); }
268 }),
269 el(ToggleControl, {
270 label: __('Show Labels', 'blockenberg'),
271 checked: a.showLabels,
272 onChange: function (val) { setAttributes({ showLabels: val }); }
273 }),
274 (a.showIcons && a.showLabels) && el(SelectControl, {
275 label: __('Icon Position', 'blockenberg'),
276 value: a.iconPosition,
277 options: [
278 { label: __('Left of label', 'blockenberg'), value: 'left' },
279 { label: __('Right of label', 'blockenberg'), value: 'right' },
280 { label: __('Above label', 'blockenberg'), value: 'top' }
281 ],
282 onChange: function (val) { setAttributes({ iconPosition: val }); }
283 })
284 ),
285
286 // Tab Button Styles
287 el(PanelBody, { title: __('Tab Button Style', 'blockenberg'), initialOpen: false },
288 el(RangeControl, {
289 label: __('Vertical Padding (px)', 'blockenberg'),
290 value: a.tabPaddingV, min: 4, max: 32,
291 onChange: function (val) { setAttributes({ tabPaddingV: val }); }
292 }),
293 el(RangeControl, {
294 label: __('Horizontal Padding (px)', 'blockenberg'),
295 value: a.tabPaddingH, min: 8, max: 60,
296 onChange: function (val) { setAttributes({ tabPaddingH: val }); }
297 }),
298 el(RangeControl, {
299 label: __('Border Radius (px)', 'blockenberg'),
300 value: a.tabBorderRadius, min: 0, max: 50,
301 onChange: function (val) { setAttributes({ tabBorderRadius: val }); }
302 }),
303 el(RangeControl, {
304 label: __('Indicator Height (px)', 'blockenberg'),
305 value: a.indicatorHeight, min: 1, max: 8,
306 onChange: function (val) { setAttributes({ indicatorHeight: val }); }
307 }),
308 cc('tabBarBg', __('Tab Bar Background', 'blockenberg'), 'tabBarBg'),
309 cc('tabBg', __('Tab Background', 'blockenberg'), 'tabBg'),
310 cc('tabColor', __('Tab Text Color', 'blockenberg'), 'tabColor'),
311 cc('tabHoverBg', __('Tab Hover Background', 'blockenberg'), 'tabHoverBg'),
312 cc('tabHoverColor', __('Tab Hover Color', 'blockenberg'), 'tabHoverColor'),
313 cc('tabActiveBg', __('Active Tab Background', 'blockenberg'), 'tabActiveBg'),
314 cc('tabActiveColor', __('Active Tab Color', 'blockenberg'), 'tabActiveColor'),
315 cc('indicatorColor', __('Indicator / Accent Color', 'blockenberg'), 'indicatorColor')
316 ),
317
318 // Content Area
319 el(PanelBody, { title: __('Content Area', 'blockenberg'), initialOpen: false },
320 el(RangeControl, {
321 label: __('Padding Top (px)', 'blockenberg'),
322 value: a.contentPaddingTop, min: 0, max: 80,
323 onChange: function (val) { setAttributes({ contentPaddingTop: val }); }
324 }),
325 el(RangeControl, {
326 label: __('Padding Right (px)', 'blockenberg'),
327 value: a.contentPaddingRight, min: 0, max: 80,
328 onChange: function (val) { setAttributes({ contentPaddingRight: val }); }
329 }),
330 el(RangeControl, {
331 label: __('Padding Bottom (px)', 'blockenberg'),
332 value: a.contentPaddingBottom, min: 0, max: 80,
333 onChange: function (val) { setAttributes({ contentPaddingBottom: val }); }
334 }),
335 el(RangeControl, {
336 label: __('Padding Left (px)', 'blockenberg'),
337 value: a.contentPaddingLeft, min: 0, max: 80,
338 onChange: function (val) { setAttributes({ contentPaddingLeft: val }); }
339 }),
340 el(RangeControl, {
341 label: __('Border Radius (px)', 'blockenberg'),
342 value: a.contentBorderRadius, min: 0, max: 40,
343 onChange: function (val) { setAttributes({ contentBorderRadius: val }); }
344 }),
345 el(RangeControl, {
346 label: __('Min Height (px, 0 = auto)', 'blockenberg'),
347 value: a.contentMinHeight, min: 0, max: 800,
348 onChange: function (val) { setAttributes({ contentMinHeight: val }); }
349 }),
350 cc('contentBg', __('Content Background', 'blockenberg'), 'contentBg'),
351 cc('contentColor', __('Content Text Color', 'blockenberg'), 'contentColor'),
352 cc('borderColor', __('Border Color', 'blockenberg'), 'borderColor')
353 ),
354
355 // Wrapper
356 el(PanelBody, { title: __('Wrapper', 'blockenberg'), initialOpen: false },
357 el(RangeControl, {
358 label: __('Padding Top (px)', 'blockenberg'),
359 value: a.wrapperPaddingTop, min: 0, max: 100,
360 onChange: function (val) { setAttributes({ wrapperPaddingTop: val }); }
361 }),
362 el(RangeControl, {
363 label: __('Padding Right (px)', 'blockenberg'),
364 value: a.wrapperPaddingRight, min: 0, max: 100,
365 onChange: function (val) { setAttributes({ wrapperPaddingRight: val }); }
366 }),
367 el(RangeControl, {
368 label: __('Padding Bottom (px)', 'blockenberg'),
369 value: a.wrapperPaddingBottom, min: 0, max: 100,
370 onChange: function (val) { setAttributes({ wrapperPaddingBottom: val }); }
371 }),
372 el(RangeControl, {
373 label: __('Padding Left (px)', 'blockenberg'),
374 value: a.wrapperPaddingLeft, min: 0, max: 100,
375 onChange: function (val) { setAttributes({ wrapperPaddingLeft: val }); }
376 }),
377 el(RangeControl, {
378 label: __('Border Radius (px)', 'blockenberg'),
379 value: a.wrapperBorderRadius, min: 0, max: 40,
380 onChange: function (val) { setAttributes({ wrapperBorderRadius: val }); }
381 }),
382 cc('wrapperBg', __('Wrapper Background', 'blockenberg'), 'wrapperBg')
383 ),
384 el( PanelBody, { title: __( 'Typography', 'blockenberg' ), initialOpen: false },
385 getTypoControl()({ label: __('Tab Button', 'blockenberg'), value: a.tabTypo, onChange: function (v) { setAttributes({ tabTypo: v }); } }),
386 getTypoControl()({ label: __('Content', 'blockenberg'), value: a.contentTypo, onChange: function (v) { setAttributes({ contentTypo: v }); } })
387 )
388 );
389
390 // ── Block render ──────────────────────────────────────────────────
391 function renderTabIcon(item) {
392 if (!a.showIcons || !item.icon) return null;
393 return el('span', { className: 'dashicons ' + item.icon + ' bkbg-tabs-tab-icon' });
394 }
395
396 function renderTab(item, i) {
397 var isActive = i === a.activeTab;
398 var parts = [];
399 if (a.iconPosition === 'top' && a.showIcons) parts.push(renderTabIcon(item));
400 if (a.iconPosition === 'left' && a.showIcons) parts.push(renderTabIcon(item));
401 if (a.showLabels) parts.push(el('span', { key: 'lbl', className: 'bkbg-tabs-tab-label' }, item.title || __('Tab', 'blockenberg')));
402 if (a.iconPosition === 'right' && a.showIcons) parts.push(renderTabIcon(item));
403
404 return el('button', {
405 key: i,
406 type: 'button',
407 className: 'bkbg-tabs-tab' + (isActive ? ' is-active' : '') + ' bkbg-tabs-icon-pos-' + a.iconPosition,
408 onClick: function () { setAttributes({ activeTab: i }); }
409 }, parts);
410 }
411
412 var tabBar = el('div', { className: 'bkbg-tabs-tabbar', role: 'tablist' },
413 a.items.map(function (item, i) { return renderTab(item, i); })
414 );
415
416 var panels = a.items.map(function (item, i) {
417 var isActive = i === a.activeTab;
418 return el('div', {
419 key: i,
420 className: 'bkbg-tabs-panel' + (isActive ? ' is-active' : ''),
421 style: { display: isActive ? '' : 'none' }
422 },
423 el(RichText, {
424 tagName: 'div',
425 className: 'bkbg-tabs-content',
426 value: item.content,
427 onChange: function (val) { updateItem(a.items, i, 'content', val, setAttributes); },
428 placeholder: __('Write tab content here…', 'blockenberg'),
429 multiline: 'p'
430 })
431 );
432 });
433
434 return el(Fragment, {},
435 inspector,
436 el('div', blockProps,
437 el('div', { className: 'bkbg-tabs-inner bkbg-tabs-anim-' + a.animationType },
438 a.tabPosition === 'top' ? el(Fragment, {}, tabBar, el('div', { className: 'bkbg-tabs-panels' }, panels))
439 : el(Fragment, {}, el('div', { className: 'bkbg-tabs-left-layout' }, tabBar, el('div', { className: 'bkbg-tabs-panels' }, panels)))
440 )
441 )
442 );
443 },
444
445 // ── Save ─────────────────────────────────────────────────────────────
446 save: function (props) {
447 var a = props.attributes;
448
449 function renderSaveTabIcon(item) {
450 if (!a.showIcons || !item.icon) return null;
451 return el('span', { className: 'dashicons ' + item.icon + ' bkbg-tabs-tab-icon', 'aria-hidden': 'true' });
452 }
453
454 function renderSaveTab(item, i) {
455 var parts = [];
456 if (a.iconPosition === 'top' && a.showIcons) parts.push(renderSaveTabIcon(item));
457 if (a.iconPosition === 'left' && a.showIcons) parts.push(renderSaveTabIcon(item));
458 if (a.showLabels) parts.push(el('span', { key: 'lbl', className: 'bkbg-tabs-tab-label' }, item.title || ''));
459 if (a.iconPosition === 'right' && a.showIcons) parts.push(renderSaveTabIcon(item));
460
461 return el('button', {
462 key: i,
463 type: 'button',
464 role: 'tab',
465 'aria-selected': i === 0 ? 'true' : 'false',
466 'aria-controls': 'bkbg-tabs-panel-' + i,
467 id: 'bkbg-tabs-tab-' + i,
468 className: 'bkbg-tabs-tab' + (i === 0 ? ' is-active' : '') + ' bkbg-tabs-icon-pos-' + a.iconPosition,
469 tabIndex: i === 0 ? 0 : -1
470 }, parts);
471 }
472
473 var tabBar = el('div', {
474 className: 'bkbg-tabs-tabbar',
475 role: 'tablist',
476 'aria-label': 'Tabs'
477 }, a.items.map(function (item, i) { return renderSaveTab(item, i); }));
478
479 var panels = a.items.map(function (item, i) {
480 return el('div', {
481 key: i,
482 id: 'bkbg-tabs-panel-' + i,
483 role: 'tabpanel',
484 'aria-labelledby': 'bkbg-tabs-tab-' + i,
485 'aria-hidden': i === 0 ? 'false' : 'true',
486 className: 'bkbg-tabs-panel' + (i === 0 ? ' is-active' : '')
487 },
488 el(RichText.Content, { tagName: 'div', className: 'bkbg-tabs-content', value: item.content })
489 );
490 });
491
492 var wrapperClass = 'bkbg-tabs-wrapper bkbg-tabs-style-' + a.tabStyle + ' bkbg-tabs-pos-' + a.tabPosition + ' bkbg-tabs-align-' + a.tabAlign;
493
494 var _tvf = getTypoCssVars();
495 var saveStyle = Object.assign({}, buildWrapStyle(a));
496 if (_tvf) {
497 Object.assign(saveStyle, _tvf(a.tabTypo, '--bktb-tb-'));
498 Object.assign(saveStyle, _tvf(a.contentTypo, '--bktb-ct-'));
499 }
500
501 return el('div', wp.blockEditor.useBlockProps.save({ className: wrapperClass, style: saveStyle }),
502 el('div', {
503 className: 'bkbg-tabs-inner bkbg-tabs-anim-' + a.animationType,
504 'data-animation': a.animationType
505 },
506 a.tabPosition === 'top'
507 ? el(Fragment, {}, tabBar, el('div', { className: 'bkbg-tabs-panels' }, panels))
508 : el('div', { className: 'bkbg-tabs-left-layout' }, tabBar, el('div', { className: 'bkbg-tabs-panels' }, panels))
509 )
510 );
511 }
512 });
513 }() );
514