UNPKG

@elastic/eui

Version:

Elastic UI Component Library

120 lines (119 loc) 5.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EuiHeaderBreadcrumbs = void 0; var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _classnames = _interopRequireDefault(require("classnames")); var _services = require("../../../services"); var _breadcrumbs = require("../../breadcrumbs"); var _header_breadcrumbs = require("./header_breadcrumbs.styles"); var _react2 = require("@emotion/react"); var _excluded = ["className", "breadcrumbs"]; /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } var EuiHeaderBreadcrumbs = exports.EuiHeaderBreadcrumbs = function EuiHeaderBreadcrumbs(_ref) { var className = _ref.className, breadcrumbs = _ref.breadcrumbs, rest = _objectWithoutProperties(_ref, _excluded); var classes = (0, _classnames.default)('euiHeaderBreadcrumbs', className); var styles = (0, _services.useEuiMemoizedStyles)(_header_breadcrumbs.euiHeaderBreadcrumbsStyles); return (0, _react2.jsx)(_breadcrumbs.EuiBreadcrumbs, _extends({ max: 4, truncate: true, breadcrumbs: breadcrumbs, className: classes, css: styles.euiHeaderBreadcrumbs, type: "application" }, rest)); }; EuiHeaderBreadcrumbs.propTypes = { className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any, /** * Hides extra (above the max) breadcrumbs under a collapsed item as the window gets smaller. * Pass a custom {@link EuiBreadcrumbResponsiveMaxCount} object to change the number of breadcrumbs to show at the particular breakpoints. * * Pass `false` to turn this behavior off. * * Default: `{ xs: 1, s: 2, m: 4 }` */ responsive: _propTypes.default.oneOfType([_propTypes.default.bool.isRequired, _propTypes.default.any.isRequired]), /** * Forces all breadcrumbs to single line and * truncates each breadcrumb to a particular width, * except for the last item */ truncate: _propTypes.default.bool, /** * Collapses the inner items past the maximum set here * into a single ellipses item. * Omitting or passing a `0` value will show all breadcrumbs. */ max: _propTypes.default.oneOfType([_propTypes.default.number.isRequired, _propTypes.default.oneOf([null])]), /** * The array of individual {@link EuiBreadcrumb} items */ breadcrumbs: _propTypes.default.arrayOf(_propTypes.default.shape({ className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any, href: _propTypes.default.string, rel: _propTypes.default.string, onClick: _propTypes.default.func, /** * Visible label of the breadcrumb */ text: _propTypes.default.node.isRequired, /** * Force a max-width on the breadcrumb text */ truncate: _propTypes.default.bool, /** * @deprecated - if a custom color is wanted, use the `css` prop to pass custom css */ color: _propTypes.default.any, /** * Override the existing `aria-current` which defaults to `page` for the last breadcrumb */ "aria-current": _propTypes.default.any, /** * Creates a breadcrumb that toggles a popover dialog. Takes any rendered node(s), * or a render function that will pass callback allowing you to close the * breadcrumb popover from within your popover content. * * If passed, both `href` and `onClick` will be ignored - the breadcrumb's * click behavior should only trigger a popover. */ popoverContent: _propTypes.default.oneOfType([_propTypes.default.node.isRequired, _propTypes.default.func.isRequired]), /** * Allows customizing the popover if necessary. Accepts any props that * [EuiPopover](/#/layout/popover) accepts, except for props that control state. */ popoverProps: _propTypes.default.any }).isRequired).isRequired, /** * Determines breadcrumbs appearance, with `page` being the default styling. * Application breadcrumbs should only be once per page, in (e.g.) EuiHeader */ type: _propTypes.default.oneOf(["page", "application"]), /** * Whether the last breadcrumb should be semantically highlighted as the * current page. (improves accessibility for screen readers users) * Defaults to true. */ lastBreadcrumbIsCurrentPage: _propTypes.default.bool };