@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
64 lines (63 loc) • 2.39 kB
JavaScript
"use client";
import { jsx as v } from "react/jsx-runtime";
import { d as u } from "./index.CgTHIF3K.js";
import { useState as T, useEffect as y } from "react";
import { TabList as h } from "../tablist.g_Nwu6GA.js";
import { g as m, r as E } from "./helpers.BbWkXTr3.js";
const _ = ["left", "center"], j = ["prev", "next"], S = ({
aria: a,
tabs: e,
activeTabIndex: t
}) => {
var r, i;
if (!a || typeof a != "object" || Object.keys(a).length === 0 || !a["aria-label"] && !a["aria-labelledby"] || ((r = a["aria-label"]) == null ? void 0 : r.trim()) === "" && ((i = a["aria-labelledby"]) == null ? void 0 : i.trim()) === "")
throw new Error(m("DSNavigationTabs", 'A valid "aria-label" or "aria-labelledby" property is required. Ensure the "aria" prop is a non-empty object and includes either "aria-label" or "aria-labelledby" with a non-empty string value.'));
if (Array.isArray(e)) {
if (e.length === 0)
throw new Error(m("DSNavigationTabs", "The tabs array must not be empty."));
} else throw new Error(m("DSNavigationTabs", E("tabs", "DSNavigationTabs")));
if (t != null && (t < 0 || t >= e.length))
throw new Error(m("DSNavigationTabs", `Invalid activeTabIndex: ${t}. It must be between 0 and ${e.length - 1}.`));
}, x = (a) => {
const e = u.c(19);
let t, r, i, s, o, l;
e[0] !== a ? ({
aria: r,
tabs: l,
activeTabIndex: t,
alignment: o,
className: i,
...s
} = a, e[0] = a, e[1] = t, e[2] = r, e[3] = i, e[4] = s, e[5] = o, e[6] = l) : (t = e[1], r = e[2], i = e[3], s = e[4], o = e[5], l = e[6]);
const p = o === void 0 ? "left" : o;
process.env.NODE_ENV !== "production" && S({
aria: r,
tabs: l,
activeTabIndex: t
});
const [c, N] = T(t);
let n, b;
e[7] !== t ? (n = () => {
t != null && N(t);
}, b = [t], e[7] = t, e[8] = n, e[9] = b) : (n = e[8], b = e[9]), y(n, b);
let f;
e[10] !== p || e[11] !== r || e[12] !== i || e[13] !== s || e[14] !== c || e[15] !== l ? (f = {
aria: r,
tabs: l,
setSelectedTabIndex: N,
selectedTabIndex: c,
alignment: p,
className: i,
isNavigation: !0,
...s
}, e[10] = p, e[11] = r, e[12] = i, e[13] = s, e[14] = c, e[15] = l, e[16] = f) : f = e[16];
const g = f;
let d;
return e[17] !== g ? (d = /* @__PURE__ */ v(h, { ...g }), e[17] = g, e[18] = d) : d = e[18], d;
};
export {
x as D,
_ as N,
j as a,
S as v
};