UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

84 lines (83 loc) 3.05 kB
"use client"; import { jsx as N, jsxs as L } from "react/jsx-runtime"; import { d as M } from "./index.CgTHIF3K.js"; import { useState as $ } from "react"; import { TabList as j } from "../tablist.g_Nwu6GA.js"; import { TabPane as B } from "../tabpane.CB-eudyw.js"; import { g as C } from "./TabPane.utils.DG16Y2uD.js"; import { g, r as O } from "./helpers.BbWkXTr3.js"; const J = ["left", "center"], K = ["prev", "next"], _ = ({ id: T, tabs: e, defaultSelectedTabIndex: r = 0 }) => { if (!T) throw new Error(g("DSTabs", 'A unique "id" prop is required. Please add a unique "id" prop to the DSTabs component.')); if (Array.isArray(e)) { if (e.length === 0) throw new Error(g("DSTabs", "The tabs array must not be empty.")); } else throw new Error(g("DSTabs", O("tabs", "DSTabs"))); if (r < 0 || r >= e.length) throw new Error(g("DSTabs", `Invalid defaultSelectedTabIndex: ${r}. It must be between 0 and ${e.length - 1}.`)); }, Q = (T) => { const e = M.c(37); let r, l, n, s, d, f, b, t, a; e[0] !== T ? ({ id: t, tabs: a, activeTabIndex: r, alignment: f, className: l, classNameTabPane: n, defaultSelectedTabIndex: b, onTabChange: s, ...d } = T, e[0] = T, e[1] = r, e[2] = l, e[3] = n, e[4] = s, e[5] = d, e[6] = f, e[7] = b, e[8] = t, e[9] = a) : (r = e[1], l = e[2], n = e[3], s = e[4], d = e[5], f = e[6], b = e[7], t = e[8], a = e[9]); const h = f === void 0 ? "left" : f, x = b === void 0 ? 0 : b; process.env.NODE_ENV !== "production" && _({ id: t, tabs: a, defaultSelectedTabIndex: x }); const [A, P] = $(r || x), p = r !== void 0, o = p ? r : A; let S; e[10] !== p || e[11] !== s ? (S = (i) => { p || P(i), s == null || s(i); }, e[10] = p, e[11] = s, e[12] = S) : S = e[12]; const D = S; let u; e[13] !== h || e[14] !== D || e[15] !== s || e[16] !== o || e[17] !== t || e[18] !== a ? (u = { id: t, tabs: a, setSelectedTabIndex: D, selectedTabIndex: o, alignment: h, onTabChange: s }, e[13] = h, e[14] = D, e[15] = s, e[16] = o, e[17] = t, e[18] = a, e[19] = u) : u = e[19]; const v = u; let c; e[20] !== v ? (c = /* @__PURE__ */ N(j, { ...v }), e[20] = v, e[21] = c) : c = e[21]; let m; if (e[22] !== n || e[23] !== o || e[24] !== t || e[25] !== a) { let i; e[27] !== n || e[28] !== o || e[29] !== t ? (i = (q, w) => { const { id: E, content: y } = q; return /* @__PURE__ */ N(B, { id: E, content: y, index: w, selectedTabIndex: o, tabListId: t, className: n }, C(t, E, w)); }, e[27] = n, e[28] = o, e[29] = t, e[30] = i) : i = e[30], m = a.map(i), e[22] = n, e[23] = o, e[24] = t, e[25] = a, e[26] = m; } else m = e[26]; let I; return e[31] !== l || e[32] !== d || e[33] !== c || e[34] !== m || e[35] !== t ? (I = /* @__PURE__ */ L("div", { className: l, id: t, ...d, children: [ c, m ] }), e[31] = l, e[32] = d, e[33] = c, e[34] = m, e[35] = t, e[36] = I) : I = e[36], I; }; export { Q as D, J as T, K as a, _ as v };