UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

72 lines (62 loc) 3.42 kB
import _map from "lodash/map"; import _isEmpty from "lodash/isEmpty"; import _keys from "lodash/keys"; import _last from "lodash/last"; import _initial from "lodash/initial"; function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from 'react'; import PropTypes from 'react-peek/prop-types'; import { lucidClassNames } from '../../util/style-helpers'; import { findTypes, omitProps } from '../../util/component-types'; var cx = lucidClassNames.bind('&-Breadcrumb'); var any = PropTypes.any, node = PropTypes.node; var BreadcrumbItem = function BreadcrumbItem(_props) { return null; }; BreadcrumbItem.displayName = 'Breadcrumb.Item'; BreadcrumbItem.peek = { description: "\n\t\tRenders a `li`\n\t" }; BreadcrumbItem.propName = 'Item'; BreadcrumbItem.propTypes = { children: node }; export var Breadcrumb = function Breadcrumb(props) { var className = props.className, passThroughs = _objectWithoutProperties(props, ["className"]); var items = findTypes(props, Breadcrumb.Item); var initialItems = _initial(items); var lastItem = _last(items); return /*#__PURE__*/React.createElement("nav", _extends({}, omitProps(passThroughs, undefined, _keys(Breadcrumb.propTypes)), { className: cx('&', className) }), !_isEmpty(items) ? /*#__PURE__*/React.createElement("ul", { className: cx('&-List') }, _map(initialItems, function (_ref) { var props = _ref.props, key = _ref.key; return /*#__PURE__*/React.createElement("li", _extends({}, props, { key: key, className: cx('&-Item', props.className) }), props.children, /*#__PURE__*/React.createElement("span", { className: cx('&-BreadcrumbSeparator') }, /*#__PURE__*/React.createElement("span", null), /*#__PURE__*/React.createElement("span", null))); }), /*#__PURE__*/React.createElement("li", _extends({}, lastItem.props, { key: lastItem.key, className: cx('&-Item', lastItem.props.className) }))) : null); }; Breadcrumb.displayName = 'Breadcrumb'; Breadcrumb.peek = { description: "\n\t\tNavigation component to show a user's place in a navigation hierarchy\n\t\tand provide links to return to higher points in the hierarchy\n\t", categories: ['navigation'] }; Breadcrumb.propTypes = { children: node, className: any, Item: node }; Breadcrumb.Item = BreadcrumbItem; export default Breadcrumb;