UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

169 lines (159 loc) 3.84 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var reactCompilerRuntime = require('react-compiler-runtime'); var clsx = require('clsx'); var React = require('react'); var Breadcrumbs_module = require('./Breadcrumbs.module.css.js'); var BoxWithFallback = require('../internal/components/BoxWithFallback.js'); var jsxRuntime = require('react/jsx-runtime'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var React__default = /*#__PURE__*/_interopDefault(React); const SELECTED_CLASS = 'selected'; const BreadcrumbsList = t0 => { const $ = reactCompilerRuntime.c(2); const { children } = t0; let t1; if ($[0] !== children) { t1 = /*#__PURE__*/jsxRuntime.jsx("ol", { className: Breadcrumbs_module.BreadcrumbsList, children: children }); $[0] = children; $[1] = t1; } else { t1 = $[1]; } return t1; }; function Breadcrumbs(t0) { const $ = reactCompilerRuntime.c(10); const { className, children, sx: sxProp } = t0; let t1; if ($[0] !== children) { t1 = React__default.default.Children.map(children, _temp); $[0] = children; $[1] = t1; } else { t1 = $[1]; } const wrappedChildren = t1; let t2; if ($[2] !== className) { t2 = clsx.clsx(className, Breadcrumbs_module.BreadcrumbsBase); $[2] = className; $[3] = t2; } else { t2 = $[3]; } let t3; if ($[4] !== wrappedChildren) { t3 = /*#__PURE__*/jsxRuntime.jsx(BreadcrumbsList, { children: wrappedChildren }); $[4] = wrappedChildren; $[5] = t3; } else { t3 = $[5]; } let t4; if ($[6] !== sxProp || $[7] !== t2 || $[8] !== t3) { t4 = /*#__PURE__*/jsxRuntime.jsx(BoxWithFallback.BoxWithFallback, { as: "nav", className: t2, "aria-label": "Breadcrumbs", sx: sxProp, children: t3 }); $[6] = sxProp; $[7] = t2; $[8] = t3; $[9] = t4; } else { t4 = $[9]; } return t4; } function _temp(child) { return /*#__PURE__*/jsxRuntime.jsx("li", { className: Breadcrumbs_module.ItemWrapper, children: child }); } _temp.displayName = "_temp"; const BreadcrumbsItem = /*#__PURE__*/React__default.default.forwardRef((t0, ref) => { const $ = reactCompilerRuntime.c(12); let className; let rest; let selected; if ($[0] !== t0) { ({ selected, className, ...rest } = t0); $[0] = t0; $[1] = className; $[2] = rest; $[3] = selected; } else { className = $[1]; rest = $[2]; selected = $[3]; } let t1; if ($[4] !== className || $[5] !== selected) { t1 = clsx.clsx(className, Breadcrumbs_module.Item, { [SELECTED_CLASS]: selected, [Breadcrumbs_module.ItemSelected]: selected }); $[4] = className; $[5] = selected; $[6] = t1; } else { t1 = $[6]; } const t2 = selected ? "page" : undefined; let t3; if ($[7] !== ref || $[8] !== rest || $[9] !== t1 || $[10] !== t2) { t3 = /*#__PURE__*/jsxRuntime.jsx(BoxWithFallback.BoxWithFallback, { as: "a", className: t1, "aria-current": t2, ref: ref, ...rest }); $[7] = ref; $[8] = rest; $[9] = t1; $[10] = t2; $[11] = t3; } else { t3 = $[11]; } return t3; }); Breadcrumbs.displayName = 'Breadcrumbs'; BreadcrumbsItem.displayName = 'Breadcrumbs.Item'; var Breadcrumbs$1 = Object.assign(Breadcrumbs, { Item: BreadcrumbsItem }); /** * @deprecated Use the `Breadcrumbs` component instead (i.e. `<Breadcrumb>` → `<Breadcrumbs>`) */ const Breadcrumb = Object.assign(Breadcrumbs, { Item: BreadcrumbsItem }); /** * @deprecated Use the `BreadcrumbsProps` type instead */ /** * @deprecated Use the `BreadcrumbsItemProps` type instead */ exports.Breadcrumb = Breadcrumb; exports.default = Breadcrumbs$1;