@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
75 lines (74 loc) • 2.71 kB
JavaScript
"use client";
import { jsxs as p, jsx as i, Fragment as j } from "react/jsx-runtime";
import { c as m } from "./index.CEyLAtio.js";
import "react";
import { Asterisk as y } from "../asterisk.CR60hx8S.js";
import { DSHeading as M } from "../heading.BXFBZhKv.js";
import { D as x } from "./SystemFeedback.CyGbUCzT.js";
import { g as D } from "./helpers.BbWkXTr3.js";
import "./index.CgTHIF3K.js";
import '../assets/Fieldset.CW9dBvAo.css';const E = "ds-fieldset_root_dtiam_1", q = "ds-fieldset_child-wrapper_dtiam_98", C = "ds-fieldset_legend_dtiam_105", P = "ds-fieldset_legend--utility--m_dtiam_109", T = "ds-fieldset_description_dtiam_121", U = "ds-fieldset_description--small_dtiam_135", W = "ds-fieldset_system-feedback_dtiam_139", s = {
root: E,
childWrapper: q,
legend: C,
legendUtilityM: P,
description: T,
descriptionSmall: U,
systemFeedback: W
}, z = ({
description: a,
id: e,
legend: l,
systemFeedback: t
}) => {
if (!e && (a || t))
throw new Error(D("DSFieldset", 'A unique "id" prop is required when providing the description or systemFeedback property. Please add a unique "id" prop to the DSFieldset component.'));
if (!l)
throw new Error(D("DSFieldset", "The legend prop is required. Please add the legend prop to the DSFieldset component."));
}, G = ({
children: a,
legend: e,
className: l,
description: t,
disabled: b = !1,
id: n,
invalid: c = !1,
required: f = !1,
systemFeedback: o,
...u
}) => {
process.env.NODE_ENV !== "production" && z({
description: t,
id: n,
legend: e,
systemFeedback: o
});
let d, g, _;
const r = typeof e == "object" && e !== void 0;
r && ({
headingSize: d,
headingTag: g,
headingText: _
} = e);
const h = `${n}-feedback`, S = `${n}-description`, F = [c && o && h, t && S].filter(Boolean).join(" ") || void 0, N = !r || d === "small" || d === "small-uppercase", v = m(s.root, l), k = m(s.legend, {
[s.legendUtilityM]: !r
}), w = m(s.description, {
[s.descriptionSmall]: N
});
return /* @__PURE__ */ p("fieldset", { className: v, disabled: b, ...u, "aria-invalid": c, "aria-describedby": F, children: [
/* @__PURE__ */ i("legend", { className: k, children: r ? /* @__PURE__ */ p(M, { tag: g, size: d, children: [
_,
f && /* @__PURE__ */ i(y, {})
] }) : /* @__PURE__ */ p(j, { children: [
e,
f && /* @__PURE__ */ i(y, {})
] }) }),
t && /* @__PURE__ */ i("span", { id: S, className: w, children: t }),
c && o && /* @__PURE__ */ i(x, { id: h, variant: "error", message: o, className: s.systemFeedback }),
/* @__PURE__ */ i("div", { className: s.childWrapper, children: a })
] });
};
export {
G as D,
z as v
};