@intility/bifrost-react
Version:
React library for Intility's design system, Bifrost.
89 lines (88 loc) • 2.11 kB
JavaScript
"use client";
import { c as _c } from "react-compiler-runtime";
import { forwardRef } from "react";
import classNames from "classnames";
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons/faAngleLeft";
import Icon from "../Icon/Icon.js";
import Breadcrumbs from "../Breadcrumbs/Breadcrumbs.js";
import BreadcrumbsItem from "../Breadcrumbs/Breadcrumbs.Item.js";
import useLocale from "../../hooks/useLocale.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Display a breadcrumb link that triggers `history.back()` (can be overridden
* with `onClick`)
*
* @see https://bifrost.intility.com/react/backButton
*/
const BackButton = /*#__PURE__*/forwardRef((t0, ref) => {
const $ = _c(12);
let className;
let props;
let text;
if ($[0] !== t0) {
({
className,
text,
...props
} = t0);
$[0] = t0;
$[1] = className;
$[2] = props;
$[3] = text;
} else {
className = $[1];
props = $[2];
text = $[3];
}
const locale = useLocale();
let t1;
if ($[4] !== className) {
t1 = classNames("bf-link", className);
$[4] = className;
$[5] = t1;
} else {
t1 = $[5];
}
let t2;
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
t2 = /*#__PURE__*/_jsx(Icon, {
icon: faAngleLeft,
style: {
marginRight: 8
},
widthAuto: true
});
$[6] = t2;
} else {
t2 = $[6];
}
const t3 = text ?? locale.back;
let t4;
if ($[7] !== props || $[8] !== ref || $[9] !== t1 || $[10] !== t3) {
t4 = /*#__PURE__*/_jsx(Breadcrumbs, {
children: /*#__PURE__*/_jsx(BreadcrumbsItem, {
children: /*#__PURE__*/_jsxs("button", {
type: "button",
onClick: _temp,
...props,
className: t1,
ref: ref,
children: [t2, t3]
})
})
});
$[7] = props;
$[8] = ref;
$[9] = t1;
$[10] = t3;
$[11] = t4;
} else {
t4 = $[11];
}
return t4;
});
BackButton.displayName = "BackButton";
export default BackButton;
function _temp() {
return window.history.back();
}