@intility/bifrost-react
Version:
React library for Intility's design system, Bifrost.
184 lines • 4.31 kB
JavaScript
import { c as _c } from "react-compiler-runtime";
import { forwardRef } from "react";
import classNames from "classnames";
import CheckboxIcon from "../common/CheckboxIcon.internal.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* A card rendered as a Checkbox or Radio button
*
* @see https://bifrost.intility.com/react/checkboxCard
*/
const CheckboxCard = /*#__PURE__*/forwardRef((t0, ref) => {
const $ = _c(45);
let children;
let className;
let header;
let indeterminate;
let inputClassName;
let inputStyle;
let label;
let props;
let style;
let t1;
let t2;
let t3;
if ($[0] !== t0) {
({
type: t1,
align: t2,
state: t3,
label,
children,
style,
className,
header,
inputClassName,
inputStyle,
indeterminate,
...props
} = t0);
$[0] = t0;
$[1] = children;
$[2] = className;
$[3] = header;
$[4] = indeterminate;
$[5] = inputClassName;
$[6] = inputStyle;
$[7] = label;
$[8] = props;
$[9] = style;
$[10] = t1;
$[11] = t2;
$[12] = t3;
} else {
children = $[1];
className = $[2];
header = $[3];
indeterminate = $[4];
inputClassName = $[5];
inputStyle = $[6];
label = $[7];
props = $[8];
style = $[9];
t1 = $[10];
t2 = $[11];
t3 = $[12];
}
const type = t1 === undefined ? "checkbox" : t1;
const align = t2 === undefined ? "right" : t2;
const state = t3 === undefined ? "default" : t3;
const t4 = type === "switch";
const t5 = !children;
const t6 = align === "left";
const t7 = state === "alert";
const t8 = state === "inactive";
let t9;
if ($[13] !== className || $[14] !== t4 || $[15] !== t5 || $[16] !== t6 || $[17] !== t7 || $[18] !== t8) {
t9 = classNames("bf-checkboxcard", className, {
"bf-switch-wrapper": t4,
"bf-checkboxcard-no-children": t5,
"bf-checkboxcard-left": t6,
"bf-checkbox-alert": t7,
"bf-checkbox-inactive": t8
});
$[13] = className;
$[14] = t4;
$[15] = t5;
$[16] = t6;
$[17] = t7;
$[18] = t8;
$[19] = t9;
} else {
t9 = $[19];
}
const t10 = type === "radio" ? "radio" : "checkbox";
const t11 = state === "inactive" || undefined;
let t12;
if ($[20] !== inputClassName || $[21] !== inputStyle || $[22] !== props || $[23] !== ref || $[24] !== t10 || $[25] !== t11) {
t12 = /*#__PURE__*/_jsx("input", {
type: t10,
"aria-disabled": t11,
...props,
ref: ref,
className: inputClassName,
style: inputStyle
});
$[20] = inputClassName;
$[21] = inputStyle;
$[22] = props;
$[23] = ref;
$[24] = t10;
$[25] = t11;
$[26] = t12;
} else {
t12 = $[26];
}
let t13;
if ($[27] !== header) {
t13 = header && /*#__PURE__*/_jsx("header", {
className: "bf-checkboxcard-header",
children: header
});
$[27] = header;
$[28] = t13;
} else {
t13 = $[28];
}
let t14;
if ($[29] !== indeterminate || $[30] !== type) {
t14 = /*#__PURE__*/_jsx(CheckboxIcon, {
type: type,
indeterminate: indeterminate
});
$[29] = indeterminate;
$[30] = type;
$[31] = t14;
} else {
t14 = $[31];
}
let t15;
if ($[32] !== label || $[33] !== t14) {
t15 = /*#__PURE__*/_jsxs("span", {
className: "bf-checkboxcard-label-text",
children: [t14, label]
});
$[32] = label;
$[33] = t14;
$[34] = t15;
} else {
t15 = $[34];
}
let t16;
if ($[35] !== children || $[36] !== t15) {
t16 = /*#__PURE__*/_jsxs("div", {
className: "bf-checkboxcard-content",
children: [t15, children]
});
$[35] = children;
$[36] = t15;
$[37] = t16;
} else {
t16 = $[37];
}
let t17;
if ($[38] !== props.id || $[39] !== style || $[40] !== t12 || $[41] !== t13 || $[42] !== t16 || $[43] !== t9) {
t17 = /*#__PURE__*/_jsxs("label", {
className: t9,
htmlFor: props.id,
style: style,
children: [t12, t13, t16]
});
$[38] = props.id;
$[39] = style;
$[40] = t12;
$[41] = t13;
$[42] = t16;
$[43] = t9;
$[44] = t17;
} else {
t17 = $[44];
}
return t17;
});
CheckboxCard.displayName = "CheckboxCard";
export default CheckboxCard;