UNPKG

@elastic/eui

Version:

Elastic UI Component Library

112 lines (111 loc) 5.09 kB
var _excluded = ["component", "id", "title", "buttonRef", "className", "onClose", "buttonProps"]; 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; } /* * 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. */ import React from 'react'; import PropTypes from "prop-types"; import classNames from 'classnames'; import { useEuiMemoizedStyles } from '../../services'; import { EuiButtonIcon } from '../button'; import { useEuiI18n } from '../i18n'; import { euiContextMenuPanelTitleStyles } from './context_menu_panel_title.styles'; import { jsx as ___EmotionJSX } from "@emotion/react"; export var EuiContextMenuPanelTitle = function EuiContextMenuPanelTitle(props) { var _props$component = props.component, Component = _props$component === void 0 ? 'h2' : _props$component, id = props.id, title = props.title, buttonRef = props.buttonRef, className = props.className, onClose = props.onClose, buttonProps = props.buttonProps, rest = _objectWithoutProperties(props, _excluded); var classes = classNames('euiContextMenuPanelTitle', className); var styles = useEuiMemoizedStyles(euiContextMenuPanelTitleStyles); var closeButtonId = "".concat(id, "-closeButton"); var buttonAriaLabel = useEuiI18n('euiContextMenuPanelTitle.ariaLabel', 'Close current panel:'); return ___EmotionJSX("div", _extends({ className: classes, css: styles.euiContextMenuPanelTitle, "data-test-subj": "contextMenuPanelTitle" }, rest), onClose && ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiButtonIcon, _extends({ buttonRef: buttonRef, color: "text", iconType: "chevronSingleLeft", onClick: onClose, "data-test-subj": "contextMenuPanelTitleButton", id: closeButtonId, "aria-label": buttonAriaLabel // Uses aria-labelledby to combine aria-label with the panel title for screen readers. , "aria-labelledby": "".concat(closeButtonId, " ").concat(id) }, buttonProps))), ___EmotionJSX(Component, { className: "euiContextMenuPanelTitle__text", css: styles.text, id: id }, title)); }; EuiContextMenuPanelTitle.propTypes = { className: PropTypes.string, "aria-label": PropTypes.string, "data-test-subj": PropTypes.string, css: PropTypes.any, component: PropTypes.oneOf(["h1", "h2", "h3", "h4", "h5", "h6"]), id: PropTypes.string, title: PropTypes.node, buttonRef: PropTypes.any, buttonProps: PropTypes.shape({ "aria-label": PropTypes.string, "aria-labelledby": PropTypes.string, /** * Overall size of button. * Matches the sizes of other EuiButtons */ size: PropTypes.any, /** * Size of the icon only. * This will not affect the overall size of the button */ iconSize: PropTypes.any, /** * Applies the boolean state as the `aria-pressed` property to create a toggle button. * *Only use when the readable text does not change between states.* */ isSelected: PropTypes.bool, /** * Sets the display style for matching other EuiButton types. * `base` is equivalent to a typical EuiButton * `fill` is equivalent to a filled EuiButton * `empty` (default) is equivalent to an EuiButtonEmpty */ display: PropTypes.any, /** * Disables the button and changes the icon to a loading spinner */ isLoading: PropTypes.bool, className: PropTypes.string, "data-test-subj": PropTypes.string, css: PropTypes.any, /** * Controls the disabled behavior via the native `disabled` attribute. */ isDisabled: PropTypes.bool, /** * NOTE: Beta feature, may be changed or removed in the future * * Changes the native `disabled` attribute to `aria-disabled` to preserve focusability. * This results in a semantically disabled button without the default browser handling of the disabled state. * * Use e.g. when a disabled button should have a tooltip. */ hasAriaDisabled: PropTypes.bool }), onClose: PropTypes.func };