@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
63 lines (62 loc) • 2.33 kB
JavaScript
"use client";
import { jsx as v } from "react/jsx-runtime";
import { d as u } from "./index.D-sRdssb.js";
import { useState as T, useEffect as y } from "react";
import { TabList as h } from "../tablist.BFE6RAPD.js";
import { g as m, r as E } from "./helpers.CexwVao7.js";
const _ = ["left", "center"], j = ["prev", "next"], S = ({
aria: a,
tabs: e,
activeTabIndex: t
}) => {
if (!a || typeof a != "object" || Object.keys(a).length === 0 || !a["aria-label"] && !a["aria-labelledby"] || a["aria-label"]?.trim() === "" && a["aria-labelledby"]?.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, l, s, o, i;
e[0] !== a ? ({
aria: r,
tabs: i,
activeTabIndex: t,
alignment: o,
className: l,
...s
} = a, e[0] = a, e[1] = t, e[2] = r, e[3] = l, e[4] = s, e[5] = o, e[6] = i) : (t = e[1], r = e[2], l = e[3], s = e[4], o = e[5], i = e[6]);
const p = o === void 0 ? "left" : o;
process.env.NODE_ENV !== "production" && S({
aria: r,
tabs: i,
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] !== l || e[13] !== s || e[14] !== c || e[15] !== i ? (f = {
aria: r,
tabs: i,
setSelectedTabIndex: N,
selectedTabIndex: c,
alignment: p,
className: l,
isNavigation: !0,
...s
}, e[10] = p, e[11] = r, e[12] = l, e[13] = s, e[14] = c, e[15] = i, 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
};