UNPKG

@elastic/eui

Version:

Elastic UI Component Library

59 lines (58 loc) 2.32 kB
import _extends from "@babel/runtime/helpers/extends"; /* * 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 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); };