"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SIZES = exports.EuiButtonIcon = exports.DISPLAYS = void 0; var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _classnames = _interopRequireDefault(require("classnames")); var _services = require("../../../services"); var _icon = require("../../icon"); var _loading = require("../../loading"); var _button = require("../../../themes/amsterdam/global_styling/mixins/button"); var _button_display = require("../button_display/_button_display"); var _button_icon = require("./button_icon.styles"); var _react2 = require("@emotion/react"); var _excluded = ["className", "iconType", "iconSize", "color", "isDisabled", "disabled", "href", "type", "display", "target", "rel", "size", "buttonRef", "isSelected", "isLoading"]; /* * 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(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var SIZES = ['xs', 's', 'm']; exports.SIZES = SIZES; var DISPLAYS = ['base', 'empty', 'fill']; exports.DISPLAYS = DISPLAYS; var EuiButtonIcon = function EuiButtonIcon(props) { var className = props.className, iconType = props.iconType, _props$iconSize = props.iconSize, iconSize = _props$iconSize === void 0 ? 'm' : _props$iconSize, _props$color = props.color, _color = _props$color === void 0 ? 'primary' : _props$color, _isDisabled = props.isDisabled, disabled = props.disabled, href = props.href, _props$type = props.type, type = _props$type === void 0 ? 'button' : _props$type, _props$display = props.display, display = _props$display === void 0 ? 'empty' : _props$display, target = props.target, rel = props.rel, _props$size = props.size, size = _props$size === void 0 ? 'xs' : _props$size, buttonRef = props.buttonRef, isSelected = props.isSelected, isLoading = props.isLoading, rest = _objectWithoutProperties(props, _excluded); var euiThemeContext = (0, _services.useEuiTheme)(); var isDisabled = (0, _button_display.isButtonDisabled)({ isDisabled: _isDisabled || disabled, href: href, isLoading: isLoading }); var ariaHidden = rest['aria-hidden']; var isAriaHidden = ariaHidden === 'true' || ariaHidden === true; if (!rest['aria-label'] && !rest['aria-labelledby'] && !isAriaHidden) { console.warn("EuiButtonIcon requires aria-label or aria-labelledby to be specified because icon-only\n buttons are screen-reader-inaccessible without them."); } var color = isDisabled ? 'disabled' : _color === 'ghost' ? 'text' : _color; var buttonColorStyles = (0, _button.useEuiButtonColorCSS)({ display: display }); var buttonFocusStyle = (0, _button.useEuiButtonFocusCSS)(); var styles = (0, _button_icon.euiButtonIconStyles)(euiThemeContext); var emptyHoverStyles = (0, _button_icon._emptyHoverStyles)(euiThemeContext, color); var cssStyles = [styles.euiButtonIcon, styles[size], buttonColorStyles[color], buttonFocusStyle, display === 'empty' && emptyHoverStyles, isDisabled && styles.isDisabled]; var classes = (0, _classnames.default)('euiButtonIcon', className); if (_color === 'ghost') { // INCEPTION: If `ghost`, re-implement with a wrapping dark mode theme provider return (0, _react2.jsx)(_services.EuiThemeProvider, { colorMode: "dark", wrapperProps: { cloneElement: true } }, (0, _react2.jsx)(EuiButtonIcon, _extends({}, props, { color: "text" }))); } // Add an icon to the button if one exists. var buttonIcon; if (iconType && !isLoading) { buttonIcon = (0, _react2.jsx)(_icon.EuiIcon, { className: "euiButtonIcon__icon", type: iconType, size: iconSize, "aria-hidden": "true", color: "inherit" // forces the icon to inherit its parent color }); } if (iconType && isLoading) { // `original` size doesn't exist in `EuiLoadingSpinner` // when the `iconSize` is `original` we don't pass any size to the `EuiLoadingSpinner` // so it gets the default size var loadingSize = iconSize === 'original' ? undefined : iconSize; // When the button is disabled the text gets gray // and in some buttons the background gets a light gray // for better contrast we want to change the border of the spinner // to have the same color of the text. This way we ensure the borders // are always visible. The default spinner color could be very light. var loadingSpinnerColor = isDisabled ? { border: 'currentcolor' } : undefined; buttonIcon = (0, _react2.jsx)(_loading.EuiLoadingSpinner, { size: loadingSize, color: loadingSpinnerColor }); } // elements don't respect the `disabled` attribute. So if we're disabled, we'll just pretend // this is a button and piggyback off its disabled styles. if (href && !isDisabled) { var secureRel = (0, _services.getSecureRelForTarget)({ href: href, target: target, rel: rel }); return (0, _react2.jsx)("a", _extends({ css: cssStyles, tabIndex: isAriaHidden ? -1 : undefined, className: classes, href: href, target: target, rel: secureRel, ref: buttonRef }, rest), buttonIcon); } var buttonType; return (0, _react2.jsx)("button", _extends({ css: cssStyles, tabIndex: isAriaHidden ? -1 : undefined, disabled: isDisabled, className: classes, "aria-pressed": isSelected, type: type, ref: buttonRef }, rest), buttonIcon); }; exports.EuiButtonIcon = EuiButtonIcon; EuiButtonIcon.propTypes = { type: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.oneOf(["submit", "reset", "button"])]), href: _propTypes.default.string, onClick: _propTypes.default.func, iconType: _propTypes.default.oneOfType([_propTypes.default.oneOf(["accessibility", "addDataApp", "advancedSettingsApp", "agentApp", "aggregate", "analyzeEvent", "annotation", "apmApp", "apmTrace", "appSearchApp", "apps", "arrowDown", "arrowLeft", "arrowRight", "arrowUp", "arrowStart", "arrowEnd", "article", "asterisk", "at", "auditbeatApp", "beaker", "bell", "bellSlash", "beta", "bolt", "boxesHorizontal", "boxesVertical", "branch", "branchUser", "broom", "brush", "bug", "bullseye", "calendar", "canvasApp", "casesApp", "check", "checkInCircleFilled", "cheer", "classificationJob", "clock", "cloudDrizzle", "cloudStormy", "cloudSunny", "cluster", "codeApp", "color", "compute", "console", "consoleApp", "container", "continuityAbove", "continuityAboveBelow", "continuityBelow", "continuityWithin", "controlsHorizontal", "controlsVertical", "copy", "copyClipboard", "createAdvancedJob", "createMultiMetricJob", "createPopulationJob", "createSingleMetricJob", "cross", "crossClusterReplicationApp", "crosshairs", "currency", "cut", "dashboardApp", "dataVisualizer", "database", "desktop", "devToolsApp", "discoverApp", "discuss", "document", "documentEdit", "documentation", "documents", "dot", "dotInCircle", "doubleArrowLeft", "doubleArrowRight", "download", "editorAlignCenter", "editorAlignLeft", "editorAlignRight", "editorBold", "editorChecklist", "editorCodeBlock", "editorComment", "editorDistributeHorizontal", "editorDistributeVertical", "editorHeading", "editorItalic", "editorItemAlignBottom", "editorItemAlignCenter", "editorItemAlignLeft", "editorItemAlignMiddle", "editorItemAlignRight", "editorItemAlignTop", "editorLink", "editorOrderedList", "editorPositionBottomLeft", "editorPositionBottomRight", "editorPositionTopLeft", "editorPositionTopRight", "editorRedo", "editorStrike", "editorTable", "editorUnderline", "editorUndo", "editorUnorderedList", "email", "empty", "emsApp", "eql", "eraser", "error", "exit", "expand", "expandMini", "exportAction", "eye", "eyeClosed", "faceHappy", "faceNeutral", "faceSad", "filebeatApp", "filter", "filterExclude", "filterIgnore", "filterInclude", "filterInCircle", "flag", "fleetApp", "fold", "folderCheck", "folderClosed", "folderExclamation", "folderOpen", "frameNext", "framePrevious", "fullScreen", "fullScreenExit", "function", "gear", "gisApp", "glasses", "globe", "grab", "grabHorizontal", "graphApp", "grid", "grokApp", "heart", "heartbeatApp", "heatmap", "help", "home", "iInCircle", "image", "importAction", "indexClose", "indexEdit", "indexFlush", "indexManagementApp", "indexMapping", "indexOpen", "indexPatternApp", "indexRollupApp", "indexRuntime", "indexSettings", "indexTemporary", "infinity", "inputOutput", "inspect", "invert", "ip", "key", "keyboard", "kqlField", "kqlFunction", "kqlOperand", "kqlSelector", "kqlValue", "kubernetesNode", "kubernetesPod", "launch", "layers", "lensApp", "lettering", "lineDashed", "lineDotted", "lineSolid", "link", "list", "listAdd", "lock", "lockOpen", "logoAWS", "logoAWSMono", "logoAerospike", "logoApache", "logoAppSearch", "logoAzure", "logoAzureMono", "logoBeats", "logoBusinessAnalytics", "logoCeph", "logoCloud", "logoCloudEnterprise", "logoCode", "logoCodesandbox", "logoCouchbase", "logoDocker", "logoDropwizard", "logoElastic", "logoElasticStack", "logoElasticsearch", "logoEnterpriseSearch", "logoEtcd", "logoGCP", "logoGCPMono", "logoGithub", "logoGmail", "logoGolang", "logoGoogleG", "logoHAproxy", "logoIBM", "logoIBMMono", "logoKafka", "logoKibana", "logoKubernetes", "logoLogging", "logoLogstash", "logoMaps", "logoMemcached", "logoMetrics", "logoMongodb", "logoMySQL", "logoNginx", "logoObservability", "logoOsquery", "logoPhp", "logoPostgres", "logoPrometheus", "logoRabbitmq", "logoRedis", "logoSecurity", "logoSiteSearch", "logoSketch", "logoSlack", "logoUptime", "logoVulnerabilityManagement", "logoWebhook", "logoWindows", "logoWorkplaceSearch", "logsApp", "logstashFilter", "logstashIf", "logstashInput", "logstashOutput", "logstashQueue", "machineLearningApp", "magnet", "magnifyWithExclamation", "magnifyWithMinus", "magnifyWithPlus", "managementApp", "mapMarker", "memory", "menu", "menuDown", "menuLeft", "menuRight", "menuUp", "merge", "metricbeatApp", "metricsApp", "minimize", "minus", "minusInCircle", "minusInCircleFilled", "mobile", "monitoringApp", "moon", "namespace", "nested", "node", "notebookApp", "number", "offline", "online", "outlierDetectionJob", "package", "packetbeatApp", "pageSelect", "pagesSelect", "paperClip", "partial", "pause", "payment", "pencil", "percent", "pin", "pinFilled", "pipelineApp", "pivot", "play", "playFilled", "plus", "plusInCircle", "plusInCircleFilled", "popout", "push", "questionInCircle", "quote", "recentlyViewedApp", "refresh", "regressionJob", "reporter", "reportingApp", "returnKey", "save", "savedObjectsApp", "scale", "search", "searchProfilerApp", "securityAnalyticsApp", "securityApp", "securitySignal", "securitySignalDetected", "securitySignalResolved", "sessionViewer", "shard", "share", "snowflake", "sortAscending", "sortDescending", "sortDown", "sortLeft", "sortRight", "sortUp", "sortable", "spaces", "spacesApp", "sparkles", "sqlApp", "starEmpty", "starEmptySpace", "starFilled", "starFilledSpace", "starMinusEmpty", "starMinusFilled", "starPlusEmpty", "starPlusFilled", "stats", "stop", "stopFilled", "stopSlash", "storage", "string", "submodule", "sun", "swatchInput", "symlink", "tableDensityCompact", "tableDensityExpanded", "tableDensityNormal", "tableOfContents", "tag", "tear", "temperature", "timeline", "timelineWithArrow", "timelionApp", "timeRefresh", "timeslider", "training", "trash", "unfold", "unlink", "upgradeAssistantApp", "uptimeApp", "user", "userAvatar", "users", "usersRolesApp", "vector", "videoPlayer", "visArea", "visAreaStacked", "visBarHorizontal", "visBarHorizontalStacked", "visBarVertical", "visBarVerticalStacked", "visGauge", "visGoal", "visLine", "visMapCoordinate", "visMapRegion", "visMetric", "visPie", "visTable", "visTagCloud", "visText", "visTimelion", "visVega", "visVisualBuilder", "visualizeApp", "vulnerabilityManagementApp", "warning", "alert", "watchesApp", "wordWrap", "wordWrapDisabled", "workplaceSearchApp", "wrench", "tokenAlias", "tokenAnnotation", "tokenArray", "tokenBinary", "tokenBoolean", "tokenClass", "tokenCompletionSuggester", "tokenConstant", "tokenDate", "tokenDenseVector", "tokenElement", "tokenEnum", "tokenEnumMember", "tokenEvent", "tokenException", "tokenField", "tokenFile", "tokenFlattened", "tokenFunction", "tokenGeo", "tokenHistogram", "tokenInterface", "tokenIP", "tokenJoin", "tokenKey", "tokenKeyword", "tokenMethod", "tokenMetricCounter", "tokenMetricGauge", "tokenModule", "tokenNamespace", "tokenNested", "tokenNull", "tokenNumber", "tokenObject", "tokenOperator", "tokenPackage", "tokenParameter", "tokenPercolator", "tokenProperty", "tokenRange", "tokenRankFeature", "tokenRankFeatures", "tokenRepo", "tokenSearchType", "tokenShape", "tokenString", "tokenStruct", "tokenSymbol", "tokenTag", "tokenText", "tokenTokenCount", "tokenVariable"]).isRequired, _propTypes.default.string.isRequired, _propTypes.default.elementType.isRequired]).isRequired, /** * Any of the named color palette options. * **`'ghost'` is set for deprecation. Use EuiThemeProvide.colorMode = 'dark' instead.** */ /** * 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, isDisabled: _propTypes.default.bool, /** * Overall size of button. * Matches the sizes of other EuiButtons */ /** * Overall size of button. * Matches the sizes of other EuiButtons */ size: _propTypes.default.any, /** * Size of the icon only. * This will not affect the overall size of the button */ iconSize: _propTypes.default.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.* */ /** * 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.default.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 */ /** * 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 */ /** * 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, buttonRef: _propTypes.default.any };