@elastic/eui
Version:
Elastic UI Component Library
93 lines (92 loc) • 4.09 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EuiNotificationEventReadButton = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _button = require("../button");
var _i18n = require("../i18n");
var _classnames = _interopRequireDefault(require("classnames"));
var _react2 = require("@emotion/react");
var _excluded = ["id", "isRead", "onClick", "eventName"];
/*
* 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.
*/
var EuiNotificationEventReadButton = function EuiNotificationEventReadButton(_ref) {
var id = _ref.id,
isRead = _ref.isRead,
onClick = _ref.onClick,
eventName = _ref.eventName,
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
var classesReadState = (0, _classnames.default)('euiNotificationEventReadButton', {
'euiNotificationEventReadButton--isRead': isRead
});
var markAsReadAria = (0, _i18n.useEuiI18n)('euiNotificationEventReadButton.markAsReadAria', 'Mark {eventName} as read', {
eventName: eventName
});
var markAsUnreadAria = (0, _i18n.useEuiI18n)('euiNotificationEventReadButton.markAsUnreadAria', 'Mark {eventName} as unread', {
eventName: eventName
});
var markAsRead = (0, _i18n.useEuiI18n)('euiNotificationEventReadButton.markAsRead', 'Mark as read');
var markAsUnread = (0, _i18n.useEuiI18n)('euiNotificationEventReadButton.markAsUnread', 'Mark as unread');
var buttonAriaLabel = isRead ? markAsUnreadAria : markAsReadAria;
var buttonTitle = isRead ? markAsUnread : markAsRead;
return (0, _react2.jsx)(_button.EuiButtonIcon, (0, _extends2.default)({
iconType: "dot",
"aria-label": buttonAriaLabel,
title: buttonTitle,
className: classesReadState,
onClick: onClick,
"data-test-subj": "".concat(id, "-notificationEventReadButton")
}, rest));
};
exports.EuiNotificationEventReadButton = EuiNotificationEventReadButton;
EuiNotificationEventReadButton.propTypes = {
/**
* Any of the named color palette options.
* **`'ghost'` is set for deprecation. Use EuiThemeProvide.colorMode = 'dark' instead.**
*/
color: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.oneOf(["ghost"])]),
"aria-label": _propTypes.default.string,
"aria-labelledby": _propTypes.default.string,
/**
* Size of the icon only.
* This will not affect the overall size of the button
*/
iconSize: _propTypes.default.any,
/**
* 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.default.any,
/**
* Disables the button and changes the icon to a loading spinner
*/
isLoading: _propTypes.default.bool,
className: _propTypes.default.string,
"data-test-subj": _propTypes.default.string,
css: _propTypes.default.any,
id: _propTypes.default.string.isRequired,
/**
* Shows an indicator of the read state of the event
*/
isRead: _propTypes.default.bool.isRequired,
/**
* Applies an `onClick` handler to the `read` indicator.
*/
onClick: _propTypes.default.func.isRequired,
/**
* A unique, human-friendly name for the event to be used in aria attributes (e.g. "alert-critical-01", "cloud-no-severity-12", etc..).
*/
eventName: _propTypes.default.string.isRequired
};