UNPKG

react-aria-components

Version:

A library of styleable components built using React Aria

83 lines (75 loc) 4.58 kB
import {useCollection as $7135fc7d473fd974$export$6cd28814d92fa9c9, useSSRCollectionNode as $7135fc7d473fd974$export$e7c29ae2353b16ea} from "./Collection.module.js"; import {useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415} from "./utils.module.js"; import {LinkContext as $4f118338184dc1d9$export$e2509388b49734e7} from "./Link.module.js"; import {filterDOMProps as $c5cc5$filterDOMProps} from "@react-aria/utils"; import $c5cc5$react, {createContext as $c5cc5$createContext, forwardRef as $c5cc5$forwardRef} from "react"; /* * Copyright 2022 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ const $778035c5624f61e7$export$65596d3621b0a4a0 = /*#__PURE__*/ (0, $c5cc5$createContext)(null); function $778035c5624f61e7$var$Breadcrumbs(props, ref) { [props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $778035c5624f61e7$export$65596d3621b0a4a0); let { portal: portal, collection: collection } = (0, $7135fc7d473fd974$export$6cd28814d92fa9c9)(props); // Render the portal first so that we have the collection by the time we render the DOM in SSR return /*#__PURE__*/ (0, $c5cc5$react).createElement((0, $c5cc5$react).Fragment, null, portal, /*#__PURE__*/ (0, $c5cc5$react).createElement($778035c5624f61e7$var$BreadcrumbsInner, { props: props, collection: collection, breadcrumbsRef: ref })); } function $778035c5624f61e7$var$BreadcrumbsInner({ props: props, collection: collection, breadcrumbsRef: ref }) { var _props_className; return /*#__PURE__*/ (0, $c5cc5$react).createElement("ol", { ref: ref, ...(0, $c5cc5$filterDOMProps)(props, { labelable: true }), slot: props.slot || undefined, style: props.style, className: (_props_className = props.className) !== null && _props_className !== void 0 ? _props_className : 'react-aria-Breadcrumbs' }, [ ...collection ].map((node, i)=>/*#__PURE__*/ (0, $c5cc5$react).createElement($778035c5624f61e7$var$BreadcrumbItem, { key: node.key, node: node, isCurrent: i === collection.size - 1, isDisabled: props.isDisabled, onAction: props.onAction }))); } /** * Breadcrumbs display a hierarchy of links to the current page or resource in an application. */ const $778035c5624f61e7$export$2dc68d50d56fbbd = /*#__PURE__*/ (0, $c5cc5$forwardRef)($778035c5624f61e7$var$Breadcrumbs); function $778035c5624f61e7$var$Breadcrumb(props, ref) { return (0, $7135fc7d473fd974$export$e7c29ae2353b16ea)('item', props, ref, props.children); } /** * A Breadcrumb represents an individual item in a `<Breadcrumbs>` list. */ const $778035c5624f61e7$export$dabcc1ec9dd9d1cc = /*#__PURE__*/ (0, $c5cc5$forwardRef)($778035c5624f61e7$var$Breadcrumb); function $778035c5624f61e7$var$BreadcrumbItem({ node: node, isCurrent: isCurrent, isDisabled: isDisabled, onAction: onAction }) { // Recreating useBreadcrumbItem because we want to use composition instead of having the link builtin. let linkProps = { 'aria-current': isCurrent ? 'page' : null, isDisabled: isDisabled || isCurrent, onPress: ()=>onAction === null || onAction === void 0 ? void 0 : onAction(node.key) }; var _node_props_className; return /*#__PURE__*/ (0, $c5cc5$react).createElement("li", { ...(0, $c5cc5$filterDOMProps)(node.props), ref: node.props.ref, style: node.props.style, className: (_node_props_className = node.props.className) !== null && _node_props_className !== void 0 ? _node_props_className : 'react-aria-Breadcrumb' }, /*#__PURE__*/ (0, $c5cc5$react).createElement((0, $4f118338184dc1d9$export$e2509388b49734e7).Provider, { value: linkProps }, node.rendered)); } export {$778035c5624f61e7$export$65596d3621b0a4a0 as BreadcrumbsContext, $778035c5624f61e7$export$2dc68d50d56fbbd as Breadcrumbs, $778035c5624f61e7$export$dabcc1ec9dd9d1cc as Breadcrumb}; //# sourceMappingURL=Breadcrumbs.module.js.map