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