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