MCPcopy Create free account
hub / github.com/effector/effector / initTabs

Function initTabs

documentation/src/components/Tabs/init-tabs.ts:4–34  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

2import { getId } from "./get-id";
3
4export const initTabs = (html: string) => {
5 const root = parse(html);
6
7 const tabs = root.querySelectorAll("[role=tab]").map((tab) => {
8 return {
9 id: getId(),
10 label: tab.getAttribute("data-label"),
11 tab,
12 };
13 });
14
15 const content = tabs.map(({ tab, id }, i) => {
16 const content = tab.querySelector("div");
17
18 if (!content) {
19 return;
20 }
21
22 if (i !== 0) {
23 content.setAttribute("hidden", "");
24 }
25
26 content.setAttribute("id", `tab-panel-${id}`);
27 content.setAttribute("role", `tabpanel`);
28 content.setAttribute("aria-labelledby", `tab-${id}`);
29
30 return content;
31 });
32
33 return { tabs, content };
34};

Callers

nothing calls this directly

Calls 3

getIdFunction · 0.90
setAttributeMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…