@payfit/unity-components
Version:
53 lines (52 loc) • 1.82 kB
JavaScript
import { forwardRef as e } from "react";
import { uyTv as t } from "@payfit/unity-themes";
import { jsx as n, jsxs as r } from "react/jsx-runtime";
import { Trans as i } from "react-i18next";
import { InputContext as a } from "react-aria-components/Input";
import { Label as o } from "react-aria-components/Label";
import { useSlottedContext as s } from "react-aria-components/slots";
import { mergeProps as c } from "react-aria/mergeProps";
//#region src/core/components/label/Label.tsx
var l = t({
slots: {
base: "uy:typography-body-strong uy:text-content-neutral-enabled uy:leading-[1lh]",
asterisk: "uy:text-content-danger uy:inline-block uy:ml-25",
optionalTag: "uy:typography-body uy:inline-block uy:ml-25"
},
variants: { variant: {
strong: { base: "uy:typography-body-strong" },
body: { base: "uy:typography-body" }
} },
defaultVariants: { variant: "strong" }
}), u = e(({ children: e, ...t }, u) => {
let { isRequired: d = !1, requiredVariant: f = "required", ...p } = c({ isRequired: s(a)?.["aria-required"] }, t), { base: m, asterisk: h, optionalTag: g } = l();
return /* @__PURE__ */ r(o, {
"data-dd-privacy": "allow",
...p,
ref: u,
className: m({ className: t.className }),
children: [
e,
f === "required" && d && /* @__PURE__ */ r("span", {
className: h(),
children: ["*", /* @__PURE__ */ n("span", {
className: "uy:sr-only",
children: /* @__PURE__ */ n(i, {
ns: "unity",
i18nKey: (e) => e.unity.component.label.required
})
})]
}),
f === "optional" && !d && /* @__PURE__ */ n("span", {
className: g({ className: t.className }),
children: /* @__PURE__ */ n(i, {
ns: "unity",
i18nKey: (e) => e.unity.component.label.optional
})
})
]
});
});
u.displayName = "Label";
//#endregion
export { u as Label };