UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

64 lines (63 loc) 2.6 kB
"use client"; import { jsx as v } from "react/jsx-runtime"; import { d as N } from "./index.cKLI89Eg.js"; import { useState as T, useEffect as h } from "react"; import { TabList as y } from "../tablist.BAm0_UIG.js"; import { g as o, r as A } from "./helpers.CexwVao7.js"; const V = ["left", "center"], M = ["prev", "next"], I = ({ aria: t, tabs: e, activeTabIndex: a }) => { if (!t || typeof t != "object" || Object.keys(t).length === 0 || !t["aria-label"] && !t["aria-labelledby"] || t["aria-label"]?.trim() === "" && t["aria-labelledby"]?.trim() === "") throw new Error(o("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(o("DSNavigationTabs", "The tabs array must not be empty.")); } else throw new Error(o("DSNavigationTabs", A("tabs", "DSNavigationTabs"))); if (a != null && (a < 0 || a >= e.length)) throw new Error(o("DSNavigationTabs", `Invalid activeTabIndex: ${a}. It must be between 0 and ${e.length - 1}.`)); e.some((r) => (r.numberIndicatorValue || r.numberIndicatorValue === "") && !r.numberIndicatorAriaLabel) && console.warn(o("DSNavigationTabs", 'For better accessibility, please provide a descriptive label via "numberIndicatorAriaLabel" when using "numberIndicatorValue".')); }, O = (t) => { const e = N.c(19); let a, i, r, l, n, s; e[0] !== t ? ({ aria: i, tabs: s, activeTabIndex: a, alignment: n, className: r, ...l } = t, e[0] = t, e[1] = a, e[2] = i, e[3] = r, e[4] = l, e[5] = n, e[6] = s) : (a = e[1], i = e[2], r = e[3], l = e[4], n = e[5], s = e[6]); const u = n === void 0 ? "left" : n; process.env.NODE_ENV !== "production" && I({ aria: i, tabs: s, activeTabIndex: a }); const [g, f] = T(a); let b, c; e[7] !== a ? (b = () => { a != null && f(a); }, c = [a], e[7] = a, e[8] = b, e[9] = c) : (b = e[8], c = e[9]), h(b, c); let d; e[10] !== u || e[11] !== i || e[12] !== r || e[13] !== l || e[14] !== g || e[15] !== s ? (d = { aria: i, tabs: s, setSelectedTabIndex: f, selectedTabIndex: g, alignment: u, className: r, isNavigation: !0, ...l }, e[10] = u, e[11] = i, e[12] = r, e[13] = l, e[14] = g, e[15] = s, e[16] = d) : d = e[16]; const p = d; let m; return e[17] !== p ? (m = /* @__PURE__ */ v(y, { ...p }), e[17] = p, e[18] = m) : m = e[18], m; }; export { O as D, V as N, M as a, I as v };