UNPKG

@intility/bifrost-react

Version:

React library for Intility's design system, Bifrost.

35 lines (34 loc) 1.27 kB
"use client"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import classNames from "classnames"; import { faLock } from "@fortawesome/free-solid-svg-icons/faLock"; import Icon from "../Icon/Icon.js"; import useLocale from "../../hooks/useLocale.js"; const Label = /*#__PURE__*/ forwardRef(({ className, children, required = false, optional = false, disabled = false, readOnly = false, ...props }, ref)=>{ const locale = useLocale(); return /*#__PURE__*/ _jsxs("label", { ...props, ref: ref, className: classNames(className, "bf-label", { "bf-label-disabled": disabled }), children: [ children, (required || optional) && children && !disabled && /*#__PURE__*/ _jsxs("span", { className: "bf-label-required", children: [ "(", required ? locale.required : locale.optional, ")" ] }), (disabled || readOnly) && /*#__PURE__*/ _jsx(Icon, { icon: faLock, className: "bf-input-disabled-icon" }) ] }); }); Label.displayName = "Label"; export default Label;