@intility/bifrost-react
Version:
React library for Intility's design system, Bifrost.
178 lines • 4.09 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(43);
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";
let t8;
if ($[13] !== className || $[14] !== t4 || $[15] !== t5 || $[16] !== t6 || $[17] !== t7) {
t8 = classNames("bf-checkboxcard", className, {
"bf-switch-wrapper": t4,
"bf-checkboxcard-no-children": t5,
"bf-checkboxcard-left": t6,
"bf-checkbox-alert": t7
});
$[13] = className;
$[14] = t4;
$[15] = t5;
$[16] = t6;
$[17] = t7;
$[18] = t8;
} else {
t8 = $[18];
}
const t9 = type === "radio" ? "radio" : "checkbox";
let t10;
if ($[19] !== inputClassName || $[20] !== inputStyle || $[21] !== props || $[22] !== ref || $[23] !== t9) {
t10 = /*#__PURE__*/_jsx("input", {
type: t9,
...props,
ref: ref,
className: inputClassName,
style: inputStyle
});
$[19] = inputClassName;
$[20] = inputStyle;
$[21] = props;
$[22] = ref;
$[23] = t9;
$[24] = t10;
} else {
t10 = $[24];
}
let t11;
if ($[25] !== header) {
t11 = header && /*#__PURE__*/_jsx("header", {
className: "bf-checkboxcard-header",
children: header
});
$[25] = header;
$[26] = t11;
} else {
t11 = $[26];
}
let t12;
if ($[27] !== indeterminate || $[28] !== type) {
t12 = /*#__PURE__*/_jsx(CheckboxIcon, {
type: type,
indeterminate: indeterminate
});
$[27] = indeterminate;
$[28] = type;
$[29] = t12;
} else {
t12 = $[29];
}
let t13;
if ($[30] !== label || $[31] !== t12) {
t13 = /*#__PURE__*/_jsxs("span", {
className: "bf-checkboxcard-label-text",
children: [t12, label]
});
$[30] = label;
$[31] = t12;
$[32] = t13;
} else {
t13 = $[32];
}
let t14;
if ($[33] !== children || $[34] !== t13) {
t14 = /*#__PURE__*/_jsxs("div", {
className: "bf-checkboxcard-content",
children: [t13, children]
});
$[33] = children;
$[34] = t13;
$[35] = t14;
} else {
t14 = $[35];
}
let t15;
if ($[36] !== props.id || $[37] !== style || $[38] !== t10 || $[39] !== t11 || $[40] !== t14 || $[41] !== t8) {
t15 = /*#__PURE__*/_jsxs("label", {
className: t8,
htmlFor: props.id,
style: style,
children: [t10, t11, t14]
});
$[36] = props.id;
$[37] = style;
$[38] = t10;
$[39] = t11;
$[40] = t14;
$[41] = t8;
$[42] = t15;
} else {
t15 = $[42];
}
return t15;
});
CheckboxCard.displayName = "CheckboxCard";
export default CheckboxCard;