@primer/react
Version:
An implementation of GitHub's Primer Design System using React
62 lines (61 loc) • 2.06 kB
JavaScript
import VisuallyHidden from "../../../_VisuallyHidden.js";
import CheckboxOrRadioGroupContext from "./CheckboxOrRadioGroupContext.js";
import CheckboxOrRadioGroup_module_css_default from "./CheckboxOrRadioGroup.module.css.js";
import { Stack } from "../../../Stack/index.js";
import { c } from "react-compiler-runtime";
import { clsx } from "clsx";
import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
//#region src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.tsx
const CheckboxOrRadioGroupLabel = (t0) => {
const $ = c(12);
const { children, className, visuallyHidden: t1 } = t0;
const visuallyHidden = t1 === void 0 ? false : t1;
const { required, disabled, parentName } = React.useContext(CheckboxOrRadioGroupContext);
let t2;
if ($[0] !== className) {
t2 = clsx(className, CheckboxOrRadioGroup_module_css_default.RadioGroupLabel);
$[0] = className;
$[1] = t2;
} else t2 = $[1];
const t3 = !visuallyHidden;
const t4 = required ? "required field" : void 0;
const t5 = disabled ? "" : void 0;
const t6 = parentName ? `${parentName}.Label` : void 0;
let t7;
if ($[2] !== children || $[3] !== required) {
t7 = required ? /*#__PURE__*/ jsxs(Stack, {
direction: "horizontal",
gap: "none",
children: [/*#__PURE__*/ jsx("div", {
className: CheckboxOrRadioGroup_module_css_default.GroupLabelChildren,
children
}), /*#__PURE__*/ jsx("span", { children: "*" })]
}) : children;
$[2] = children;
$[3] = required;
$[4] = t7;
} else t7 = $[4];
let t8;
if ($[5] !== t2 || $[6] !== t3 || $[7] !== t4 || $[8] !== t5 || $[9] !== t6 || $[10] !== t7) {
t8 = /*#__PURE__*/ jsx(VisuallyHidden, {
className: t2,
isVisible: t3,
title: t4,
"data-label-disabled": t5,
"data-component": t6,
children: t7
});
$[5] = t2;
$[6] = t3;
$[7] = t4;
$[8] = t5;
$[9] = t6;
$[10] = t7;
$[11] = t8;
} else t8 = $[11];
return t8;
};
CheckboxOrRadioGroupLabel.__SLOT__ = Symbol("CheckboxOrRadioGroup.Label");
//#endregion
export { CheckboxOrRadioGroupLabel as default };