@fsegurai/marked-extended-tabs 17.0.0-beta.6 → 17.0.0-beta.8
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/dist/index.cjs +5 -229
- package/dist/index.esm.js +213 -298
- package/dist/index.umd.js +5 -229
- package/dist/styles/tabs-theme.css +273 -23
- package/dist/styles/tabs-theme.scss +287 -20
- package/dist/styles/tabs.css +43 -72
- package/dist/styles/tabs.scss +5 -31
- package/dist/types/utils/constants.d.ts +1 -13
- package/dist/types/utils/runtime.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e={value:0},t={className:`marked-extended-tabs-container`,persistSelection:!1,animation:`fade`,autoActivate:!0,template:null,customizeToken:null,onBeforeSwitch:null,onAfterSwitch:null,enableKeyboardNavigation:!0,enableFocusManagement:!0},n=`
|
|
2
|
-
<div id="{tabsContainerId}" class="{className}" data-animation="{animation}">
|
|
2
|
+
<div id="{tabsContainerId}" class="{className}" data-animation="{animation}" {runtimeAttrs}>
|
|
3
3
|
{inputsNav}
|
|
4
4
|
<div class="marked-extended-tabs-nav" role="tablist">{navList}</div>
|
|
5
5
|
<div class="marked-extended-tabs-content">{content}</div>
|
|
@@ -26,234 +26,10 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
26
26
|
from { transform: translateY(10px); opacity: 0; }
|
|
27
27
|
to { transform: translateY(0); opacity: 1; }
|
|
28
28
|
}`),r.push(`</style>`),r.join(`
|
|
29
|
-
`)}
|
|
30
|
-
/* eslint-disable no-unused-vars */
|
|
31
|
-
(function() {
|
|
32
|
-
const containerId = '${e}';
|
|
33
|
-
const storageKey = '${`marked-extended-tabs-active-${e}`}';
|
|
34
|
-
// @ts-ignore - tabIds is used in the script template
|
|
35
|
-
const tabIds = ${JSON.stringify(t.map(e=>e.id))};
|
|
36
|
-
const enableKeyboardNav = ${n};
|
|
37
|
-
const enableFocusManagement = ${r};
|
|
38
|
-
const persistSelection = ${i};
|
|
39
|
-
|
|
40
|
-
// Function to update aria-selected state
|
|
41
|
-
function updateAriaSelected(container, activeInputId) {
|
|
42
|
-
const labels = container.querySelectorAll('.marked-extended-tabs-label');
|
|
43
|
-
labels.forEach((label) => {
|
|
44
|
-
const forAttr = label.getAttribute('for');
|
|
45
|
-
const isActive = forAttr === activeInputId;
|
|
46
|
-
|
|
47
|
-
// Only update if value changes to minimize DOM operations
|
|
48
|
-
if (label.getAttribute('aria-selected') !== String(isActive)) {
|
|
49
|
-
label.setAttribute('aria-selected', isActive ? 'true' : 'false');
|
|
50
|
-
if (isActive) {
|
|
51
|
-
label.classList.add('active');
|
|
52
|
-
} else {
|
|
53
|
-
label.classList.remove('active');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (enableFocusManagement) {
|
|
58
|
-
label.setAttribute('tabindex', isActive ? '0' : '-1');
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Helper to handle tab changes (events and persistence)
|
|
64
|
-
function handleTabChange(container, actualTabId) {
|
|
65
|
-
if (persistSelection) {
|
|
66
|
-
localStorage.setItem(storageKey, actualTabId);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
container.dispatchEvent(new CustomEvent('tab-switched', {
|
|
70
|
-
detail: {
|
|
71
|
-
tabId: actualTabId,
|
|
72
|
-
timestamp: Date.now(),
|
|
73
|
-
},
|
|
74
|
-
bubbles: true,
|
|
75
|
-
cancelable: true,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Wait for DOM to be interactive or immediately if script is inline
|
|
80
|
-
function initializeTabs() {
|
|
81
|
-
const container = document.getElementById(containerId);
|
|
82
|
-
if (!container) {
|
|
83
|
-
console.warn('[marked-extended-tabs] Container #' + containerId + ' not found');
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const inputs = container.querySelectorAll('input[type="radio"]');
|
|
88
|
-
const labels = container.querySelectorAll('.marked-extended-tabs-label');
|
|
89
|
-
|
|
90
|
-
if (inputs.length === 0 || labels.length === 0) {
|
|
91
|
-
console.warn('[marked-extended-tabs] No tabs found in container');
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Update aria-selected on initial load
|
|
96
|
-
const checkedInput = container.querySelector('input[type="radio"]:checked');
|
|
97
|
-
if (checkedInput) {
|
|
98
|
-
updateAriaSelected(container, checkedInput.id);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Restore persisted selection if available
|
|
102
|
-
if (persistSelection) {
|
|
103
|
-
const savedTabId = localStorage.getItem(storageKey);
|
|
104
|
-
if (savedTabId) {
|
|
105
|
-
const savedInput = container.querySelector('#input-' + savedTabId);
|
|
106
|
-
if (savedInput) {
|
|
107
|
-
setTimeout(() => {
|
|
108
|
-
savedInput.checked = true;
|
|
109
|
-
updateAriaSelected(container, savedInput.id);
|
|
110
|
-
savedInput.dispatchEvent(new Event('change', { bubbles: true }));
|
|
111
|
-
}, 0);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Handle tab switching via label click events (this is what fires when users click tabs)
|
|
117
|
-
labels.forEach((label) => {
|
|
118
|
-
label.addEventListener('click', (e) => {
|
|
119
|
-
const forAttr = label.getAttribute('for');
|
|
120
|
-
if (!forAttr) return;
|
|
121
|
-
|
|
122
|
-
const input = document.getElementById(forAttr);
|
|
123
|
-
if (!input) return;
|
|
124
|
-
|
|
125
|
-
// Set the radio input as checked
|
|
126
|
-
input.checked = true;
|
|
127
|
-
|
|
128
|
-
// Immediately update aria-selected
|
|
129
|
-
updateAriaSelected(container, forAttr);
|
|
130
|
-
|
|
131
|
-
const actualTabId = forAttr.replace('input-', '');
|
|
132
|
-
handleTabChange(container, actualTabId);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// Also handle change events for programmatic updates
|
|
137
|
-
inputs.forEach((input) => {
|
|
138
|
-
input.addEventListener('change', (e) => {
|
|
139
|
-
const inputId = e.target.id;
|
|
140
|
-
const actualTabId = inputId.replace('input-', '');
|
|
141
|
-
|
|
142
|
-
// Update aria-selected
|
|
143
|
-
updateAriaSelected(container, inputId);
|
|
144
|
-
handleTabChange(container, actualTabId);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// Keyboard navigation
|
|
149
|
-
if (enableKeyboardNav) {
|
|
150
|
-
labels.forEach((label, index) => {
|
|
151
|
-
label.addEventListener('keydown', (e) => {
|
|
152
|
-
let targetIndex = index;
|
|
153
|
-
|
|
154
|
-
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
|
|
155
|
-
e.preventDefault();
|
|
156
|
-
targetIndex = (index + 1) % labels.length;
|
|
157
|
-
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
|
158
|
-
e.preventDefault();
|
|
159
|
-
targetIndex = (index - 1 + labels.length) % labels.length;
|
|
160
|
-
} else if (e.key === 'Home') {
|
|
161
|
-
e.preventDefault();
|
|
162
|
-
targetIndex = 0;
|
|
163
|
-
} else if (e.key === 'End') {
|
|
164
|
-
e.preventDefault();
|
|
165
|
-
targetIndex = labels.length - 1;
|
|
166
|
-
} else {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const targetLabel = labels[targetIndex];
|
|
171
|
-
if (targetLabel) {
|
|
172
|
-
const forAttr = targetLabel.getAttribute('for');
|
|
173
|
-
if (forAttr) {
|
|
174
|
-
const input = document.getElementById(forAttr);
|
|
175
|
-
if (input) {
|
|
176
|
-
input.checked = true;
|
|
177
|
-
updateAriaSelected(container, forAttr);
|
|
178
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
179
|
-
|
|
180
|
-
// Focus the label for better UX
|
|
181
|
-
setTimeout(() => {
|
|
182
|
-
targetLabel.focus();
|
|
183
|
-
}, 0);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
// Make labels keyboard accessible
|
|
190
|
-
if (enableFocusManagement) {
|
|
191
|
-
label.addEventListener('keypress', (e) => {
|
|
192
|
-
if (e.key === ' ' || e.key === 'Enter') {
|
|
193
|
-
e.preventDefault();
|
|
194
|
-
const forAttr = label.getAttribute('for');
|
|
195
|
-
if (forAttr) {
|
|
196
|
-
const input = document.getElementById(forAttr);
|
|
197
|
-
if (input) {
|
|
198
|
-
input.checked = true;
|
|
199
|
-
updateAriaSelected(container, forAttr);
|
|
200
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Enhanced focus management
|
|
210
|
-
if (enableFocusManagement) {
|
|
211
|
-
// Set initial tab index for first active or first tab
|
|
212
|
-
const activeLabel = container.querySelector('.marked-extended-tabs-label[aria-selected="true"]');
|
|
213
|
-
if (activeLabel) {
|
|
214
|
-
activeLabel.setAttribute('tabindex', '0');
|
|
215
|
-
} else if (labels.length > 0) {
|
|
216
|
-
labels[0].setAttribute('tabindex', '0');
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Update tabindex when labels receive focus
|
|
220
|
-
labels.forEach((label) => {
|
|
221
|
-
label.addEventListener('focus', () => {
|
|
222
|
-
labels.forEach((l) => l.setAttribute('tabindex', '-1'));
|
|
223
|
-
label.setAttribute('tabindex', '0');
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Watch for radio input changes to update aria-selected
|
|
229
|
-
// This is crucial for CSS to work with [aria-selected="true"]
|
|
230
|
-
const observer = new MutationObserver((mutations) => {
|
|
231
|
-
mutations.forEach((mutation) => {
|
|
232
|
-
if (mutation.type === 'attributes' && mutation.attributeName === 'checked') {
|
|
233
|
-
const checkedRadio = container.querySelector('input[type="radio"]:checked');
|
|
234
|
-
if (checkedRadio) {
|
|
235
|
-
updateAriaSelected(container, checkedRadio.id);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Observe all radio inputs for checked attribute changes
|
|
242
|
-
inputs.forEach((input) => {
|
|
243
|
-
observer.observe(input, { attributes: true, attributeFilter: ['checked'] });
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Initialize when DOM is ready
|
|
248
|
-
if (document.readyState === 'loading') {
|
|
249
|
-
document.addEventListener('DOMContentLoaded', initializeTabs);
|
|
250
|
-
} else {
|
|
251
|
-
initializeTabs();
|
|
252
|
-
}
|
|
253
|
-
})();<\/script>`}var a=/\s*(\w+)="([^"]+)"/g,o={tabBlock:{start:`::::tabs`,end:`::::tabsend`,aliases:[`:tbs`,`:tabs`],endAliases:[`:tbsend`,`:tabsend`]},tabItemBlock:{start:`:::tab`,end:`:::tabend`,aliases:[`:tab`],endAliases:[`:tabend`]}},s={tabItemBlock:[{name:`label`,defaultValue:``},{name:`active`,defaultValue:`false`},{name:`icon`,defaultValue:null}]};function c(e,t){let n=o[t];if(!n)return null;let{start:r,end:i,aliases:a=[],endAliases:s=[]}=n,c=``;if(e.startsWith(r))c=r;else for(let t of a)if(e.startsWith(t)){c=t;break}if(!c)return null;let l=c.length,u=``,d=l,f=l;for(;f<e.length&&e[f]===` `;)f++;if(f<e.length&&e[f]===`{`){let t=e.indexOf(`}`,f);t!==-1&&(u=e.substring(l,t),d=t+1)}let p=1,m=d;for(;m<e.length&&p>0;){let t=e.indexOf(r,m),n=t;for(let t of a){let r=e.indexOf(t,m);r!==-1&&(n===-1||r<n)&&(n=r)}let o=i,c=e.indexOf(i,m);for(let t of s){let n=e.indexOf(t,m);n!==-1&&(c===-1||n<c)&&(c=n,o=t)}if(c===-1)return null;if(n!==-1&&n<c){p++;let i=r;if(n===t)i=r;else for(let t of a)if(e.indexOf(t,m)===n){i=t;break}m=n+i.length;continue}if(--p===0){let t=e.substring(d,c),n=[e.substring(0,c+o.length),u,t];return n.index=0,n.input=e,n}m=c+o.length}return null}var l=(e,t)=>{if(e instanceof RegExp)return e.exec(t);switch(e){case`tabBlock`:case`tabItemBlock`:return c(t,e);default:throw Error(`Unknown element: ${e}`)}},u=(e,t)=>{let n=s[e];if(!n)throw Error(`Unknown element: ${e}`);let r={};n.forEach(e=>{r[e.name]=e.defaultValue}),a.lastIndex=0;let i;for(;(i=a.exec(t))!==null;){let[,e,t]=i;n.some(t=>t.name===e)&&(r[e]=t)}return r};function d(e,t){let{tabsContainerId:a,tabsData:o,className:s,animation:c=`fade`,template:l,enableKeyboardNavigation:u=!0,enableFocusManagement:d=!0,persistSelection:f}=e,p=l||n;if(!o||o.length===0)return`<div class="error-message">No tab content found</div>`;let m=``,h=``,g=``;for(let e of o){let{id:n,tokens:r,props:i}=e,{active:o,icon:s,label:c}=i,l=`input-${n}`,u=`label-${n}`,d=o?`checked`:``,f=o?`true`:`false`,p=s?`<span class="marked-extended-tabs-icon">${s}</span>`:``;m+=`<input type="radio" name="${a}-tabs" id="${l}" class="marked-extended-tabs-input" ${d}>`,h+=`
|
|
29
|
+
`)}var i=`.marked-extended-tabs-container[data-tabs-runtime="true"]`,a=`.marked-extended-tabs-input`,o=`.marked-extended-tabs-label`,s=(e,t)=>e===`true`?!0:e===`false`?!1:t,c=e=>({enableKeyboardNavigation:s(e.dataset.tabsEnableKeyboardNavigation,!0),enableFocusManagement:s(e.dataset.tabsEnableFocusManagement,!0),persistSelection:s(e.dataset.tabsPersistSelection,!1),storageKey:e.dataset.tabsStorageKey}),l=e=>Array.from(e.querySelectorAll(o)),u=e=>Array.from(e.querySelectorAll(a)),d=e=>{let t=l(e),n=u(e),r=e.querySelector(`${a}:checked`);!r&&n.length>0&&(r=n[0],r.checked=!0);let{enableFocusManagement:i}=c(e);return t.forEach(e=>{let t=r?e.htmlFor===r.id:!1;e.setAttribute(`aria-selected`,t?`true`:`false`),e.classList.toggle(`active`,t),i&&e.setAttribute(`tabindex`,t?`0`:`-1`)}),r},f=(e,t)=>{let{persistSelection:n,storageKey:r}=c(e);if(!(!n||!r))try{window.localStorage.setItem(r,t)}catch{}},p=(e,t)=>{e.dispatchEvent(new CustomEvent(`tab-switched`,{detail:{tabId:t,timestamp:Date.now()},bubbles:!0,cancelable:!0}))},m=e=>{let{persistSelection:t,storageKey:n}=c(e);if(!t||!n)return;let r;try{r=window.localStorage.getItem(n)}catch{return}if(!r)return;let i=`input-${r}`,a=e.querySelector(`#${i}`);a&&(a.checked=!0)},h=(e,t)=>{let n=t.htmlFor;if(!n)return;let r=e.querySelector(`#${n}`);if(!r)return;r.checked=!0,r.dispatchEvent(new Event(`change`,{bubbles:!0}));let{enableFocusManagement:i}=c(e);i&&t.focus()},g=e=>{let t=e.target;if(!x(t)||!t.matches(a))return;let n=t.closest(i);if(!n)return;let r=d(n);if(!r)return;let o=r.id.replace(/^input-/,``);f(n,o),p(n,o)},_=e=>{let t=e.target;if(!S(t)||!t.matches(o))return;let n=t.closest(i);if(!n)return;let{enableKeyboardNavigation:r}=c(n);if(!r)return;let a=l(n),s=a.indexOf(t);if(s===-1||a.length===0)return;let u;switch(e.key){case`ArrowRight`:case`ArrowDown`:u=(s+1)%a.length;break;case`ArrowLeft`:case`ArrowUp`:u=(s-1+a.length)%a.length;break;case`Home`:u=0;break;case`End`:u=a.length-1;break;case`Enter`:case` `:u=s;break;default:return}e.preventDefault();let d=a[u];d&&h(n,d)},v=e=>{let t=e.target;if(!S(t)||!t.matches(o))return;let n=t.closest(i);if(!n)return;let{enableFocusManagement:r}=c(n);r&&l(n).forEach(e=>{e.setAttribute(`tabindex`,e===t?`0`:`-1`)})},y=e=>{m(e),d(e),e.dataset.tabsInitialized=`true`},b=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.matches==`function`&&typeof t.querySelectorAll==`function`},x=e=>b(e)&&e.tagName===`INPUT`,S=e=>b(e)&&e.tagName===`LABEL`,C=e=>{b(e)&&e.matches(i)&&y(e),e.querySelectorAll(i).forEach(e=>{y(e)})},w=()=>{document.body&&new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{b(e)&&C(e)})})}).observe(document.body,{childList:!0,subtree:!0})},T=()=>{if(!(typeof window>`u`||typeof document>`u`)){if(window.__markedExtendedTabsRuntimeReady__){window.initMarkedExtendedTabs?.();return}if(window.__markedExtendedTabsRuntimeReady__=!0,document.addEventListener(`change`,g),document.addEventListener(`keydown`,_),document.addEventListener(`focusin`,v),window.initMarkedExtendedTabs=()=>{C(document)},document.readyState===`loading`){document.addEventListener(`DOMContentLoaded`,()=>{window.initMarkedExtendedTabs?.(),w()},{once:!0});return}window.initMarkedExtendedTabs(),w()}},E=/\s*(\w+)="([^"]+)"/g,D={tabBlock:{start:`::::tabs`,end:`::::tabsend`,aliases:[`:tbs`,`:tabs`],endAliases:[`:tbsend`,`:tabsend`]},tabItemBlock:{start:`:::tab`,end:`:::tabend`,aliases:[`:tab`],endAliases:[`:tabend`]}},O={tabItemBlock:[{name:`label`,defaultValue:``},{name:`active`,defaultValue:`false`},{name:`icon`,defaultValue:null}]};function k(e,t){let n=D[t];if(!n)return null;let{start:r,end:i,aliases:a=[],endAliases:o=[]}=n,s=``;if(e.startsWith(r))s=r;else for(let t of a)if(e.startsWith(t)){s=t;break}if(!s)return null;let c=s.length,l=``,u=c,d=c;for(;d<e.length&&e[d]===` `;)d++;if(d<e.length&&e[d]===`{`){let t=e.indexOf(`}`,d);t!==-1&&(l=e.substring(c,t),u=t+1)}let f=1,p=u;for(;p<e.length&&f>0;){let t=e.indexOf(r,p),n=t;for(let t of a){let r=e.indexOf(t,p);r!==-1&&(n===-1||r<n)&&(n=r)}let s=i,c=e.indexOf(i,p);for(let t of o){let n=e.indexOf(t,p);n!==-1&&(c===-1||n<c)&&(c=n,s=t)}if(c===-1)return null;if(n!==-1&&n<c){f++;let i=r;if(n===t)i=r;else for(let t of a)if(e.indexOf(t,p)===n){i=t;break}p=n+i.length;continue}if(--f===0){let t=e.substring(u,c),n=[e.substring(0,c+s.length),l,t];return n.index=0,n.input=e,n}p=c+s.length}return null}var A=(e,t)=>{if(e instanceof RegExp)return e.exec(t);switch(e){case`tabBlock`:case`tabItemBlock`:return k(t,e);default:throw Error(`Unknown element: ${e}`)}},j=(e,t)=>{let n=O[e];if(!n)throw Error(`Unknown element: ${e}`);let r={};n.forEach(e=>{r[e.name]=e.defaultValue}),E.lastIndex=0;let i;for(;(i=E.exec(t))!==null;){let[,e,t]=i;n.some(t=>t.name===e)&&(r[e]=t)}return r};function M(e,t){let{tabsContainerId:i,tabsData:a,className:o,animation:s=`fade`,template:c,enableKeyboardNavigation:l=!0,enableFocusManagement:u=!0,persistSelection:d}=e,f=c||n;if(!a||a.length===0)return`<div class="error-message">No tab content found</div>`;let p=``,m=``,h=``;for(let e of a){let{id:n,tokens:r,props:a}=e,{active:o,icon:s,label:c}=a,l=`input-${n}`,u=`label-${n}`,d=o?`checked`:``,f=o?`true`:`false`,g=s?`<span class="marked-extended-tabs-icon">${s}</span>`:``;p+=`<input type="radio" name="${i}-tabs" id="${l}" class="marked-extended-tabs-input" ${d}>`,m+=`
|
|
254
30
|
<label for="${l}" id="${u}" class="marked-extended-tabs-label" role="tab" aria-selected="${f}" data-tab-id="${n}" tabindex="${o?`0`:`-1`}">
|
|
255
|
-
${
|
|
256
|
-
</label>`;let _=r&&r.length>0?t.parse(r):``;
|
|
31
|
+
${g}<span class="tab-label">${c}</span>
|
|
32
|
+
</label>`;let _=r&&r.length>0?t.parse(r):``;h+=`
|
|
257
33
|
<div class="marked-extended-tabs-content-pane" id="${n}" role="tabpanel" aria-labelledby="${l}">
|
|
258
34
|
${_}
|
|
259
|
-
</div>`}let
|
|
35
|
+
</div>`}let g=r(i,a,s),_=[`data-tabs-runtime="true"`,`data-tabs-enable-keyboard-navigation="${l?`true`:`false`}"`,`data-tabs-enable-focus-management="${u?`true`:`false`}"`,`data-tabs-persist-selection="${d?`true`:`false`}"`,`data-tabs-storage-key="marked-extended-tabs-active-${i}"`].join(` `);return f.replace(/{tabsContainerId}/g,i).replace(/{className}/g,o).replace(/{animation}/g,s).replace(/{runtimeAttrs}/g,_).replace(/{inputsNav}/g,p).replace(/{navList}/g,m).replace(/{content}/g,h).replace(/{stylesBehavior}/g,g)}function N(t){let{animation:n,autoActivate:r,className:i,persistSelection:a,template:o,onBeforeSwitch:s,onAfterSwitch:c,enableKeyboardNavigation:l,enableFocusManagement:u}=t,d=`tabItemBlock`;return{name:`tabs`,level:`block`,tokenizer(t){let f=A(`tabBlock`,t);if(!f)return;let[p,,m]=f,h=`tabs-container-${++e.value}`,g=[],_=0,v=m;for(;v&&(v=v.trimStart(),v);){let e=A(d,v);if(!e)break;let[t,n,r]=e,i=j(d,n),a=i.label||`Tab ${_+1}`,o=i.active===`true`,s=this.lexer.blockTokens(r.trim());g.push({type:`tab-item`,raw:t,id:`${h}-tab-${_}`,props:{label:a,active:o,icon:i.icon||void 0},tokens:s}),_++,v=v.substring(t.length)}if(g.length!==0)return r&&!g.some(e=>e.props.active)&&g.length>0&&(g[0].props.active=!0),{type:`tabs`,raw:p,tokens:g,meta:{tabsContainerId:h,className:i,persistSelection:a,animation:n,autoActivate:r,template:o,onBeforeSwitch:s,onAfterSwitch:c,enableKeyboardNavigation:l,enableFocusManagement:u}}}}}function P(){return{name:`tabs`,renderer(e){let t=e;return M({...t.meta,tabsData:t.tokens},this.parser)}}}function F(e={}){e.animation&&![`fade`,`slide`,`none`].includes(e.animation)&&(console.warn(`[marked-extended-tabs] Invalid animation value: ${e.animation}. Using default 'fade'.`),e.animation=`fade`),e.onBeforeSwitch&&typeof e.onBeforeSwitch!=`function`&&(console.warn(`[marked-extended-tabs] onBeforeSwitch must be a function`),e.onBeforeSwitch=null),e.onAfterSwitch&&typeof e.onAfterSwitch!=`function`&&(console.warn(`[marked-extended-tabs] onAfterSwitch must be a function`),e.onAfterSwitch=null);let n={...t,...e};return T(),{walkTokens(e){e.type===`tabs`&&n.customizeToken&&typeof n.customizeToken==`function`&&n.customizeToken(e)},extensions:[N(n),P()]}}exports.default=F;
|