UNPKG

@elastic/eui

Version:

Elastic UI Component Library

65 lines (64 loc) 2.72 kB
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); } /* * 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 { EuiButtonIcon } from '../button/button_icon'; import { keysOf } from '../common'; import { useEuiI18n } from '../i18n'; import { useEuiTheme } from '../../services'; import { EuiToolTip } from '../tool_tip'; import { euiPaginationButtonStyles } from './pagination_button.styles'; import { jsx as ___EmotionJSX } from "@emotion/react"; var typeToIconTypeMap = { first: 'chevronLimitLeft', previous: 'chevronSingleLeft', next: 'chevronSingleRight', last: 'chevronLimitRight' }; export var TYPES = keysOf(typeToIconTypeMap); export var EuiPaginationButtonArrow = function EuiPaginationButtonArrow(_ref) { var className = _ref.className, type = _ref.type, disabled = _ref.disabled, ariaControls = _ref.ariaControls, onClick = _ref.onClick; var euiTheme = useEuiTheme(); var styles = euiPaginationButtonStyles(euiTheme); var labels = { first: useEuiI18n('euiPaginationButtonArrow.firstPage', 'First page'), previous: useEuiI18n('euiPaginationButtonArrow.previousPage', 'Previous page'), next: useEuiI18n('euiPaginationButtonArrow.nextPage', 'Next page'), last: useEuiI18n('euiPaginationButtonArrow.lastPage', 'Last page') }; var buttonProps = {}; if (ariaControls && !disabled) { buttonProps.href = "#".concat(ariaControls); buttonProps['aria-controls'] = ariaControls; } var button = ___EmotionJSX(EuiButtonIcon, _extends({ css: styles.euiPaginationButton, className: classNames('euiPaginationArrowButton', className), color: "text", "aria-label": labels[type], isDisabled: disabled, onClick: onClick, "data-test-subj": "pagination-button-".concat(type), iconType: typeToIconTypeMap[type] }, buttonProps)); return disabled ? button : ___EmotionJSX(EuiToolTip, { content: labels[type], disableScreenReaderOutput: true }, button); }; EuiPaginationButtonArrow.propTypes = { type: PropTypes.any.isRequired, disabled: PropTypes.bool, ariaControls: PropTypes.string };