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