"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.GUTTER_SIZES = exports.EuiHeaderLinks = void 0; var _react = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _classnames = _interopRequireDefault(require("classnames")); var _common = require("../../common"); var _icon = require("../../icon"); var _popover = require("../../popover"); var _i18n = require("../../i18n"); var _header_section = require("../header_section"); var _responsive = require("../../responsive"); var _react2 = require("@emotion/react"); var _excluded = ["children", "className", "gutterSize", "popoverBreakpoints", "popoverButtonProps", "popoverProps"], _excluded2 = ["onClick", "iconType"]; /* * 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 _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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 gutterSizeToClassNameMap = { xs: '--gutterXS', s: '--gutterS', m: '--gutterM', l: '--gutterL' }; var GUTTER_SIZES = (0, _common.keysOf)(gutterSizeToClassNameMap); exports.GUTTER_SIZES = GUTTER_SIZES; var EuiHeaderLinks = function EuiHeaderLinks(_ref) { var children = _ref.children, className = _ref.className, _ref$gutterSize = _ref.gutterSize, gutterSize = _ref$gutterSize === void 0 ? 's' : _ref$gutterSize, _ref$popoverBreakpoin = _ref.popoverBreakpoints, popoverBreakpoints = _ref$popoverBreakpoin === void 0 ? ['xs', 's'] : _ref$popoverBreakpoin, popoverButtonProps = _ref.popoverButtonProps, popoverProps = _ref.popoverProps, rest = _objectWithoutProperties(_ref, _excluded); var _ref2 = popoverButtonProps || {}, onClick = _ref2.onClick, _ref2$iconType = _ref2.iconType, iconType = _ref2$iconType === void 0 ? 'apps' : _ref2$iconType, popoverButtonRest = _objectWithoutProperties(_ref2, _excluded2); var _useState = (0, _react.useState)(false), _useState2 = _slicedToArray(_useState, 2), mobileMenuIsOpen = _useState2[0], setMobileMenuIsOpen = _useState2[1]; var onMenuButtonClick = (0, _react.useCallback)(function (e) { onClick === null || onClick === void 0 ? void 0 : onClick(e); setMobileMenuIsOpen(function (mobileMenuIsOpen) { return !mobileMenuIsOpen; }); }, [onClick]); var closeMenu = (0, _react.useCallback)(function () { setMobileMenuIsOpen(false); }, []); (0, _react.useEffect)(function () { window.addEventListener('resize', closeMenu); return function () { window.removeEventListener('resize', closeMenu); }; }); var classes = (0, _classnames.default)('euiHeaderLinks', className); var button = (0, _react2.jsx)(_i18n.EuiI18n, { token: "euiHeaderLinks.openNavigationMenu", default: "Open menu" }, function (openNavigationMenu) { return (0, _react2.jsx)(_header_section.EuiHeaderSectionItemButton, _extends({ "aria-label": openNavigationMenu, onClick: onMenuButtonClick }, popoverButtonRest), (0, _react2.jsx)(_icon.EuiIcon, { type: iconType, size: "m" })); }); return (0, _react2.jsx)(_i18n.EuiI18n, { token: "euiHeaderLinks.appNavigation", default: "App menu" }, function (appNavigation) { return (0, _react2.jsx)("nav", _extends({ className: classes, "aria-label": appNavigation }, rest), (0, _react2.jsx)(_responsive.EuiHideFor, { sizes: popoverBreakpoints }, (0, _react2.jsx)("div", { className: (0, _classnames.default)('euiHeaderLinks__list', ["euiHeaderLinks__list".concat(gutterSizeToClassNameMap[gutterSize])]) }, children)), (0, _react2.jsx)(_responsive.EuiShowFor, { sizes: popoverBreakpoints }, (0, _react2.jsx)(_popover.EuiPopover, _extends({ button: button, isOpen: mobileMenuIsOpen, anchorPosition: "downRight", closePopover: closeMenu, panelPaddingSize: "none", repositionOnScroll: true }, popoverProps), (0, _react2.jsx)("div", { className: (0, _classnames.default)('euiHeaderLinks__mobileList', ["euiHeaderLinks__mobileList".concat(gutterSizeToClassNameMap[gutterSize])]) }, children)))); }); }; exports.EuiHeaderLinks = EuiHeaderLinks; EuiHeaderLinks.propTypes = { className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any, /** * Spacing between direct children */ gutterSize: _propTypes.default.oneOf(["xs", "s", "m", "l"]), /** * A list of named breakpoints at which to show the popover version */ popoverBreakpoints: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.any.isRequired).isRequired, _propTypes.default.oneOf(["all", "none"])]), /** * Extend the functionality of the EuiPopover.button which is a EuiHeaderSectionItemButton. * With the addition of `iconType` to change the display icon which defaults to `apps` */ popoverButtonProps: _propTypes.default.shape({ 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]) }), /** * Extend the functionality of the EuiPopover */ popoverProps: _propTypes.default.shape({ /** * Class name passed to the direct parent of the button */ anchorClassName: _propTypes.default.string, /** * Alignment of the popover and arrow relative to the button */ anchorPosition: _propTypes.default.any, /** * Style and position alteration for arrow-less, left-aligned * attachment. Intended for use with inputs as anchors, e.g. * EuiInputPopover */ attachToAnchor: _propTypes.default.bool, buttonRef: _propTypes.default.any, /** * Restrict the popover's position within this element */ container: _propTypes.default.any, /** * CSS display type for both the popover and anchor */ display: _propTypes.default.any, /** * Object of props passed to EuiFocusTrap */ focusTrapProps: _propTypes.default.any, /** * Show arrow indicating to originating button */ hasArrow: _propTypes.default.bool, /** * Specifies what element should initially have focus; Can be a DOM * node, or a selector string (which will be passed to * document.querySelector() to find the DOM node), or a function that * returns a DOM node. * * If not passed, initial focus defaults to the popover panel. */ initialFocus: _propTypes.default.any, /** * Passed directly to EuiPortal for DOM positioning. Both properties are * required if prop is specified */ insert: _propTypes.default.shape({ sibling: _propTypes.default.any.isRequired, position: _propTypes.default.oneOf(["before", "after"]).isRequired }), /** * Visibility state of the popover */ isOpen: _propTypes.default.bool, /** * Traps tab focus within the popover contents */ ownFocus: _propTypes.default.bool, /** * Custom class added to the EuiPanel containing the popover contents */ panelClassName: _propTypes.default.string, /** * EuiPanel padding on all sides */ panelPaddingSize: _propTypes.default.any, /** * Standard DOM `style` attribute. Passed to the EuiPanel */ panelStyle: _propTypes.default.any, /** * Object of props passed to EuiPanel. See #EuiPopoverPanelProps */ panelProps: _propTypes.default.shape({ element: _propTypes.default.oneOf(["div"]), /** * Padding for all four sides */ paddingSize: _propTypes.default.any, /** * Corner border radius */ borderRadius: _propTypes.default.any, /** * When true the panel will grow in height to match `EuiFlexItem` */ grow: _propTypes.default.bool, panelRef: _propTypes.default.any, /** * Background color of the panel; * Usually a lightened form of the brand colors */ color: _propTypes.default.any, className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any }), panelRef: _propTypes.default.any, /** * Optional screen reader instructions to announce upon popover open, * in addition to EUI's default popover instructions for Escape on close. * Useful for popovers that may have additional keyboard capabilities such as * arrow navigation. */ popoverScreenReaderText: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.node.isRequired]), popoverRef: _propTypes.default.any, /** * When `true`, the popover's position is re-calculated when the user * scrolls, this supports having fixed-position popover anchors. When nesting * an `EuiPopover` in a scrollable container, `repositionOnScroll` should be `true` */ repositionOnScroll: _propTypes.default.bool, /** * Must be set to true if using `EuiDragDropContext` within a popover, * otherwise your nested drag & drop will have incorrect positioning */ hasDragDrop: _propTypes.default.bool, /** * By default, popover content inherits the z-index of the anchor * component; pass `zIndex` to override */ zIndex: _propTypes.default.number, /** * Distance away from the anchor that the popover will render */ offset: _propTypes.default.number, /** * Minimum distance between the popover and the bounding container; * Pass an array of 4 values to adjust each side differently: `[top, right, bottom, left]` * Default is 16 */ buffer: _propTypes.default.oneOfType([_propTypes.default.number.isRequired, _propTypes.default.any.isRequired]), /** * Element to pass as the child element of the arrow; * Use case is typically limited to an accompanying `EuiBeacon` */ arrowChildren: _propTypes.default.node, /** * Provide a name to the popover panel */ "aria-label": _propTypes.default.string, /** * Alternative option to `aria-label` that takes an `id`. * Usually takes the `id` of the popover title */ "aria-labelledby": _propTypes.default.string, /** * Function callback for when the popover positon changes */ onPositionChange: _propTypes.default.func, className: _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any }) };