@elastic/eui 114.3.0 → 115.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/basic_table/basic_table.js +3 -6
- package/es/components/basic_table/collapsed_item_actions.js +1 -3
- package/es/components/basic_table/default_item_action.js +0 -1
- package/es/components/basic_table/in_memory_table.js +3 -6
- package/es/components/color_picker/color_picker_swatch.js +1 -2
- package/es/components/datagrid/controls/display_selector.js +1 -2
- package/es/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/es/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/es/components/filter_group/filter_select_item.js +36 -17
- package/es/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/es/components/list_group/list_group_item.js +1 -2
- package/es/components/markdown_editor/markdown_editor.js +1 -1
- package/es/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
- package/es/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/es/components/markdown_editor/markdown_editor_toolbar.js +14 -10
- package/es/components/portal/portal.js +72 -117
- package/es/components/search_bar/filters/field_value_toggle_group_filter.js +42 -91
- package/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/es/components/table/table_header_cell.js +1 -2
- package/es/components/tool_tip/icon_tip.js +4 -8
- package/es/components/tool_tip/tool_tip.js +233 -261
- package/es/components/tool_tip/tool_tip.styles.js +10 -18
- package/es/components/tool_tip/tool_tip_anchor.js +3 -3
- package/es/components/tool_tip/tool_tip_manager.js +1 -0
- package/es/components/tool_tip/tool_tip_popover.js +7 -7
- package/es/test/rtl/component_helpers.d.ts +0 -3
- package/es/test/rtl/component_helpers.js +40 -62
- package/eui.d.ts +25 -96
- package/lib/components/basic_table/basic_table.js +3 -6
- package/lib/components/basic_table/collapsed_item_actions.js +1 -3
- package/lib/components/basic_table/default_item_action.js +0 -1
- package/lib/components/basic_table/in_memory_table.js +3 -6
- package/lib/components/color_picker/color_picker_swatch.js +1 -2
- package/lib/components/datagrid/controls/display_selector.js +1 -2
- package/lib/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/lib/components/filter_group/filter_select_item.js +35 -16
- package/lib/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/lib/components/list_group/list_group_item.js +1 -2
- package/lib/components/markdown_editor/markdown_editor.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
- package/lib/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_toolbar.js +12 -10
- package/lib/components/portal/portal.js +73 -118
- package/lib/components/search_bar/filters/field_value_toggle_group_filter.js +44 -93
- package/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/lib/components/table/table_header_cell.js +1 -2
- package/lib/components/tool_tip/icon_tip.js +4 -8
- package/lib/components/tool_tip/tool_tip.js +240 -266
- package/lib/components/tool_tip/tool_tip.styles.js +8 -16
- package/lib/components/tool_tip/tool_tip_anchor.js +2 -2
- package/lib/components/tool_tip/tool_tip_manager.js +1 -0
- package/lib/components/tool_tip/tool_tip_popover.js +6 -6
- package/lib/test/rtl/component_helpers.d.ts +0 -3
- package/lib/test/rtl/component_helpers.js +41 -63
- package/optimize/es/components/basic_table/collapsed_item_actions.js +1 -3
- package/optimize/es/components/basic_table/default_item_action.js +0 -1
- package/optimize/es/components/datagrid/controls/display_selector.js +1 -2
- package/optimize/es/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/optimize/es/components/filter_group/filter_select_item.js +36 -17
- package/optimize/es/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/optimize/es/components/list_group/list_group_item.js +1 -2
- package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.js +5 -2
- package/optimize/es/components/markdown_editor/markdown_editor_toolbar.js +13 -9
- package/optimize/es/components/portal/portal.js +65 -91
- package/optimize/es/components/search_bar/filters/field_value_toggle_group_filter.js +43 -66
- package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/optimize/es/components/tool_tip/icon_tip.js +3 -5
- package/optimize/es/components/tool_tip/tool_tip.js +227 -250
- package/optimize/es/components/tool_tip/tool_tip.styles.js +10 -18
- package/optimize/es/components/tool_tip/tool_tip_anchor.js +3 -3
- package/optimize/es/components/tool_tip/tool_tip_manager.js +1 -0
- package/optimize/es/components/tool_tip/tool_tip_popover.js +7 -7
- package/optimize/es/test/rtl/component_helpers.d.ts +0 -3
- package/optimize/es/test/rtl/component_helpers.js +40 -62
- package/optimize/lib/components/basic_table/collapsed_item_actions.js +1 -3
- package/optimize/lib/components/basic_table/default_item_action.js +0 -1
- package/optimize/lib/components/datagrid/controls/display_selector.js +1 -2
- package/optimize/lib/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/optimize/lib/components/filter_group/filter_select_item.js +35 -16
- package/optimize/lib/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/optimize/lib/components/list_group/list_group_item.js +1 -2
- package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.js +5 -2
- package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.js +13 -9
- package/optimize/lib/components/portal/portal.js +68 -93
- package/optimize/lib/components/search_bar/filters/field_value_toggle_group_filter.js +45 -69
- package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/optimize/lib/components/tool_tip/icon_tip.js +3 -5
- package/optimize/lib/components/tool_tip/tool_tip.js +229 -251
- package/optimize/lib/components/tool_tip/tool_tip.styles.js +8 -16
- package/optimize/lib/components/tool_tip/tool_tip_anchor.js +2 -2
- package/optimize/lib/components/tool_tip/tool_tip_manager.js +1 -0
- package/optimize/lib/components/tool_tip/tool_tip_popover.js +6 -6
- package/optimize/lib/test/rtl/component_helpers.d.ts +0 -3
- package/optimize/lib/test/rtl/component_helpers.js +41 -63
- package/package.json +2 -10
- package/test-env/components/basic_table/basic_table.js +3 -6
- package/test-env/components/basic_table/collapsed_item_actions.js +1 -3
- package/test-env/components/basic_table/default_item_action.js +0 -1
- package/test-env/components/basic_table/in_memory_table.js +3 -6
- package/test-env/components/color_picker/color_picker_swatch.js +1 -2
- package/test-env/components/datagrid/controls/display_selector.js +1 -2
- package/test-env/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/test-env/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/test-env/components/filter_group/filter_select_item.js +35 -16
- package/test-env/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/test-env/components/list_group/list_group_item.js +1 -2
- package/test-env/components/markdown_editor/markdown_editor.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
- package/test-env/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_toolbar.js +14 -10
- package/test-env/components/portal/portal.js +70 -113
- package/test-env/components/search_bar/filters/field_value_toggle_group_filter.js +44 -88
- package/test-env/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/test-env/components/table/table_header_cell.js +1 -2
- package/test-env/components/tool_tip/icon_tip.js +4 -8
- package/test-env/components/tool_tip/tool_tip.js +230 -256
- package/test-env/components/tool_tip/tool_tip.styles.js +8 -16
- package/test-env/components/tool_tip/tool_tip_anchor.js +2 -2
- package/test-env/components/tool_tip/tool_tip_manager.js +1 -0
- package/test-env/components/tool_tip/tool_tip_popover.js +6 -6
- package/test-env/test/rtl/component_helpers.js +41 -63
|
@@ -182,7 +182,7 @@ EuiTableHeaderCell.propTypes = {
|
|
|
182
182
|
*/
|
|
183
183
|
icon: PropTypes.oneOfType([PropTypes.oneOf(["accessibility", "addDataApp", "addToDashboard", "advancedSettingsApp", "agentApp", "aggregate", "alignBottom", "alignBottomLeft", "alignBottomRight", "alignCenterHorizontal", "alignCenterVertical", "alignLeft", "alignRight", "alignTop", "alignTopLeft", "alignTopRight", "alert", "analyzeEvent", "annotation", "anomalyChart", "chartAnomaly", "anomalySwimLane", "apmApp", "apmTrace", "chartWaterfall", "appSearchApp", "apps", "arrowDown", "chevronSingleDown", "arrowLeft", "chevronSingleLeft", "arrowRight", "chevronSingleRight", "arrowUp", "chevronSingleUp", "arrowStart", "chevronLimitLeft", "arrowEnd", "chevronLimitRight", "article", "asterisk", "at", "archive", "axisX", "axisYLeft", "axisYRight", "auditbeatApp", "backgroundTask", "beaker", "bell", "bellSlash", "beta", "bolt", "boxesHorizontal", "boxesVertical", "branch", "briefcase", "branchUser", "broom", "brush", "bug", "bulb", "bullseye", "calendar", "canvasApp", "casesApp", "changePointDetection", "chartChangePoint", "chartArea", "chartAreaStack", "chartBarHorizontal", "chartBarHorizontalStack", "chartBarVertical", "chartBarVerticalStack", "chartGauge", "chartHeatmap", "chartLine", "chartPie", "chartTagCloud", "chartThreshold", "check", "checkCircle", "checkInCircleFilled", "checkCircleFill", "cheer", "popper", "classificationJob", "clickLeft", "clickRight", "clock", "clockCounter", "clockControl", "cloud", "cloudDrizzle", "cloudStormy", "cloudSunny", "cluster", "code", "codeApp", "color", "paintBucket", "commandLine", "comment", "compare", "compute", "processor", "console", "consoleApp", "container", "continuityAbove", "continuityAboveBelow", "continuityBelow", "continuityWithin", "contrast", "contrastHigh", "contrastFill", "controls", "controlsHorizontal", "controlsVertical", "copy", "copyClipboard", "crossProjectSearch", "createAdvancedJob", "createGenericJob", "createGeoJob", "createMultiMetricJob", "createPopulationJob", "createSingleMetricJob", "cross", "crossClusterReplicationApp", "crossInCircle", "crossCircle", "crosshair", "crosshairs", "currency", "money", "cut", "scissors", "dashboardApp", "dashedCircle", "dataVisualizer", "database", "desktop", "display", "devToolsApp", "diff", "discoverApp", "distributeHorizontal", "distributeVertical", "download", "drag", "dragHorizontal", "dragVertical", "discuss", "document", "documentEdit", "documentation", "documents", "dot", "dotInCircle", "doubleArrowLeft", "chevronDoubleLeft", "doubleArrowRight", "chevronDoubleRight", "ellipsis", "editorAlignCenter", "textAlignCenter", "editorAlignLeft", "textAlignLeft", "editorAlignRight", "textAlignRight", "editorBold", "textBold", "editorChecklist", "listCheck", "editorCodeBlock", "editorComment", "editorDistributeHorizontal", "editorDistributeVertical", "editorHeading", "textHeading", "editorItalic", "textItalic", "editorItemAlignBottom", "editorItemAlignCenter", "editorItemAlignLeft", "editorItemAlignMiddle", "editorItemAlignRight", "editorItemAlignTop", "editorLink", "editorOrderedList", "listNumber", "editorPositionBottomLeft", "editorPositionBottomRight", "editorPositionTopLeft", "editorPositionTopRight", "editorRedo", "redo", "editorStrike", "textStrike", "editorTable", "table", "editorUnderline", "textUnderline", "editorUndo", "undo", "editorUnorderedList", "listBullet", "email", "mail", "empty", "emsApp", "endpoint", "eql", "query", "eraser", "error", "errorFilled", "errorFill", "esqlVis", "exit", "logOut", "expand", "maximize", "expandMini", "export", "exportAction", "upload", "external", "eye", "eyeClosed", "eyeSlash", "faceHappy", "faceNeutral", "faceSad", "fieldStatistics", "tableInfo", "filebeatApp", "filter", "filterExclude", "filterIgnore", "filterInclude", "filterInCircle", "flask", "flag", "fleetApp", "fold", "folder", "folderClosed", "folderClose", "folderCheck", "folderExclamation", "folderOpen", "folderOpened", "frameNext", "framePrevious", "fullScreen", "fullScreenExit", "function", "gear", "gisApp", "glasses", "globe", "grab", "grabHorizontal", "grabOmnidirectional", "gradient", "graphApp", "grid", "grokApp", "heart", "heartbeatApp", "heatmap", "help", "home", "hourglass", "if", "info", "image", "importAction", "index", "indexClose", "indexEdit", "indexFlush", "indexManagementApp", "indexMapping", "mapping", "indexOpen", "indexPatternApp", "indexRollupApp", "indexRuntime", "indexSettings", "indexTemporary", "tableTime", "infinity", "inputOutput", "inspect", "invert", "ip", "key", "keyboard", "kqlField", "queryField", "kqlFunction", "kqlOperand", "queryOperand", "kqlSelector", "querySelector", "kqlValue", "queryValue", "kubernetesNode", "kubernetesPod", "launch", "rocket", "layers", "lensApp", "lettering", "text", "lineBreak", "lineBreakSlash", "lineDash", "lineDashed", "lineDot", "lineDotted", "lineSolid", "link", "linkSlash", "list", "listAdd", "lock", "lockOpen", "logPatternAnalysis", "pattern", "logRateAnalysis", "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", "queue", "machineLearningApp", "magnet", "magnify", "magnifyExclamation", "magnifyMinus", "magnifyPlus", "magnifyWithExclamation", "magnifyWithMinus", "magnifyWithPlus", "managementApp", "map", "mapMarker", "waypoint", "megaphone", "memory", "menu", "menuDown", "menuLeft", "menuRight", "menuUp", "merge", "metricbeatApp", "metricsApp", "minimize", "minus", "minusCircle", "minusInCircle", "minusInCircleFilled", "minusInSquare", "minusSquare", "mobile", "monitoringApp", "moon", "move", "namespace", "nested", "newChat", "node", "vectorTriangle", "notebookApp", "number", "offline", "wifiSlash", "online", "wifi", "outlierDetectionJob", "package", "packetbeatApp", "pageSelect", "pagesSelect", "palette", "paperClip", "partial", "pause", "payment", "pencil", "percent", "pin", "pinFill", "pinFilled", "pipeBreaks", "pipelineApp", "pipeNoBreaks", "pivot", "play", "playFilled", "plugs", "plus", "plusCircle", "plusInCircle", "plusInCircleFilled", "plusInSquare", "plusSquare", "popout", "presentation", "productRobot", "productAgent", "productCloudInfra", "productDashboard", "productDiscover", "productML", "productStreamsClassic", "productStreamsWired", "push", "send", "question", "quote", "radar", "readOnly", "recentlyViewedApp", "refresh", "regressionJob", "reporter", "reportingApp", "return", "returnKey", "save", "savedObjectsApp", "scale", "search", "searchProfilerApp", "section", "securityAnalyticsApp", "securityApp", "securitySignal", "securitySignalDetected", "securitySignalResolved", "server", "sessionViewer", "shard", "share", "singleMetricViewer", "snowflake", "sortAscending", "sortDescending", "sortDown", "sortLeft", "sortRight", "sortUp", "sortable", "spaces", "spacesApp", "sparkles", "sqlApp", "star", "starEmpty", "starEmptySpace", "starFill", "starFilled", "starFillSpace", "starFilledSpace", "starMinusEmpty", "starMinusFill", "starMinusFilled", "starPlusEmpty", "starPlusFill", "starPlusFilled", "stats", "stop", "stopFill", "stopFilled", "stopSlash", "storage", "streamsClassic", "streamsWired", "string", "submodule", "sun", "swatchInput", "symlink", "tableDensityCompact", "tableDensityHigh", "tableDensityExpanded", "tableDensityLow", "tableDensityNormal", "tableOfContents", "tag", "tear", "temperature", "thermometer", "thumbDown", "thumbUp", "timeline", "timelineWithArrow", "timelionApp", "timeRefresh", "refreshTime", "timeslider", "training", "transitionBottomIn", "transitionBottomOut", "transitionLeftIn", "transitionLeftOut", "transitionTopIn", "transitionTopOut", "trash", "unfold", "unlink", "upgradeAssistantApp", "uptimeApp", "user", "userAvatar", "users", "usersRolesApp", "unarchive", "vector", "vectorSquare", "videoPlayer", "visArea", "visAreaStacked", "visBarHorizontal", "visBarHorizontalStacked", "visBarVertical", "visBarVerticalStacked", "visGauge", "visGoal", "visLine", "visMapCoordinate", "visMapRegion", "visMetric", "chartMetric", "visPie", "visTable", "visTagCloud", "visText", "visTimelion", "visVega", "visVisualBuilder", "visualizeApp", "vulnerabilityManagementApp", "warning", "warningFilled", "warningFill", "watchesApp", "web", "wordWrap", "wordWrapDisabled", "workflowsApp", "workflow", "workplaceSearchApp", "wrench", "tokenAlias", "tokenAnnotation", "tokenArray", "tokenBinary", "tokenBoolean", "tokenClass", "tokenCompletionSuggester", "tokenConstant", "tokenDate", "tokenDimension", "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", "tokenSemanticText", "tokenShape", "tokenString", "tokenStruct", "tokenSymbol", "tokenTag", "tokenText", "tokenTokenCount", "tokenVariable", "tokenVectorDense", "tokenDenseVector", "tokenVectorSparse"]).isRequired, PropTypes.string.isRequired, PropTypes.elementType.isRequired]),
|
|
184
184
|
/** Additional props for EuiIcon */iconProps: PropTypes.any,
|
|
185
|
-
/** Additional props for the
|
|
185
|
+
/** Additional props for the EuiToolTip */tooltipProps: PropTypes.shape({
|
|
186
186
|
/**
|
|
187
187
|
* Passes onto the span wrapping the trigger.
|
|
188
188
|
*/
|
|
@@ -244,7 +244,6 @@ EuiTableHeaderCell.propTypes = {
|
|
|
244
244
|
"aria-label": PropTypes.string,
|
|
245
245
|
"data-test-subj": PropTypes.string,
|
|
246
246
|
css: PropTypes.any,
|
|
247
|
-
delay: PropTypes.any,
|
|
248
247
|
position: PropTypes.any
|
|
249
248
|
})
|
|
250
249
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["type", "aria-label", "color", "size", "iconProps", "position"
|
|
1
|
+
var _excluded = ["type", "aria-label", "color", "size", "iconProps", "position"];
|
|
2
2
|
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); }
|
|
3
3
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
4
4
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
@@ -9,6 +9,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
9
9
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
10
10
|
* Side Public License, v 1.
|
|
11
11
|
*/
|
|
12
|
+
/* eslint-disable @elastic/eui/prefer-eui-icon-tip */
|
|
12
13
|
|
|
13
14
|
import React from 'react';
|
|
14
15
|
import PropTypes from "prop-types";
|
|
@@ -25,13 +26,10 @@ export var EuiIconTip = function EuiIconTip(_ref) {
|
|
|
25
26
|
iconProps = _ref.iconProps,
|
|
26
27
|
_ref$position = _ref.position,
|
|
27
28
|
position = _ref$position === void 0 ? 'top' : _ref$position,
|
|
28
|
-
_ref$delay = _ref.delay,
|
|
29
|
-
delay = _ref$delay === void 0 ? 'regular' : _ref$delay,
|
|
30
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
31
30
|
var defaultAriaLabel = useEuiI18n('euiIconTip.defaultAriaLabel', 'Info');
|
|
32
31
|
return ___EmotionJSX(EuiToolTip, _extends({
|
|
33
|
-
position: position
|
|
34
|
-
delay: delay
|
|
32
|
+
position: position
|
|
35
33
|
}, rest), ___EmotionJSX(EuiIcon, _extends({
|
|
36
34
|
tabIndex: 0,
|
|
37
35
|
type: type,
|
|
@@ -124,8 +122,6 @@ EuiIconTip.propTypes = {
|
|
|
124
122
|
// iconProps; however, due to TS's bivariant function arguments `type` could be
|
|
125
123
|
// passed without any error/feedback so we explicitly set it to `never` type
|
|
126
124
|
iconProps: PropTypes.any,
|
|
127
|
-
//
|
|
128
|
-
// are applied below.
|
|
129
|
-
delay: PropTypes.any,
|
|
125
|
+
// Copied from EuiToolTipProps, but made optional. Default applied below.
|
|
130
126
|
position: PropTypes.any
|
|
131
127
|
};
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "
|
|
2
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
|
+
var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "display", "repositionOnScroll", "disableScreenReaderOutput", "position", "offset", "id", "onMouseOut"];
|
|
3
2
|
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); }
|
|
3
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
4
|
+
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."); }
|
|
5
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
4
9
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
5
10
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
6
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
7
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
8
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
9
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
11
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
12
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
14
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
15
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
16
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
11
|
/*
|
|
20
12
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
21
13
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -24,12 +16,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
16
|
* Side Public License, v 1.
|
|
25
17
|
*/
|
|
26
18
|
|
|
27
|
-
import React, {
|
|
19
|
+
import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
28
20
|
import PropTypes from "prop-types";
|
|
29
21
|
import classNames from 'classnames';
|
|
30
22
|
import { findPopoverPosition, htmlIdGenerator, keys } from '../../services';
|
|
31
|
-
import {
|
|
32
|
-
import { enqueueStateChange } from '../../services/react';
|
|
23
|
+
import { getRepositionOnScroll } from '../../services/popover/reposition_on_scroll';
|
|
33
24
|
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
34
25
|
import { EuiPortal } from '../portal';
|
|
35
26
|
import { EuiComponentDefaultsContext } from '../provider/component_defaults';
|
|
@@ -41,9 +32,17 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
41
32
|
export var POSITIONS = ['top', 'right', 'bottom', 'left'];
|
|
42
33
|
var DISPLAYS = ['inlineBlock', 'block'];
|
|
43
34
|
export var DEFAULT_TOOLTIP_OFFSET = 16;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `:focus-visible` may throw in browsers that don't support the selector,
|
|
38
|
+
* fall back to treating all focus as visible so tooltips still appear.
|
|
39
|
+
*/
|
|
40
|
+
var isFocusVisible = function isFocusVisible(element) {
|
|
41
|
+
try {
|
|
42
|
+
return element.matches(':focus-visible');
|
|
43
|
+
} catch (_unused) {
|
|
44
|
+
return element.matches(':focus');
|
|
45
|
+
}
|
|
47
46
|
};
|
|
48
47
|
var DEFAULT_TOOLTIP_STYLES = {
|
|
49
48
|
// position the tooltip content near the top-left
|
|
@@ -57,251 +56,227 @@ var DEFAULT_TOOLTIP_STYLES = {
|
|
|
57
56
|
// prevent accidental mouse interaction while positioning
|
|
58
57
|
visibility: 'hidden'
|
|
59
58
|
};
|
|
60
|
-
export var EuiToolTip = /*#__PURE__*/function (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
60
|
+
var children = _ref.children,
|
|
61
|
+
className = _ref.className,
|
|
62
|
+
anchorClassName = _ref.anchorClassName,
|
|
63
|
+
anchorProps = _ref.anchorProps,
|
|
64
|
+
content = _ref.content,
|
|
65
|
+
title = _ref.title,
|
|
66
|
+
_ref$display = _ref.display,
|
|
67
|
+
display = _ref$display === void 0 ? 'inlineBlock' : _ref$display,
|
|
68
|
+
repositionOnScroll = _ref.repositionOnScroll,
|
|
69
|
+
_ref$disableScreenRea = _ref.disableScreenReaderOutput,
|
|
70
|
+
disableScreenReaderOutput = _ref$disableScreenRea === void 0 ? false : _ref$disableScreenRea,
|
|
71
|
+
_ref$position = _ref.position,
|
|
72
|
+
positionProp = _ref$position === void 0 ? 'top' : _ref$position,
|
|
73
|
+
offset = _ref.offset,
|
|
74
|
+
idProp = _ref.id,
|
|
75
|
+
onMouseOutProp = _ref.onMouseOut,
|
|
76
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
77
|
+
var componentDefaultsContext = useContext(EuiComponentDefaultsContext);
|
|
78
|
+
var _useState = useState(false),
|
|
79
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
80
|
+
visible = _useState2[0],
|
|
81
|
+
setVisible = _useState2[1];
|
|
82
|
+
var _useState3 = useState(false),
|
|
83
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
84
|
+
hasFocus = _useState4[0],
|
|
85
|
+
setHasFocus = _useState4[1];
|
|
86
|
+
var _useState5 = useState(positionProp),
|
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
+
calculatedPosition = _useState6[0],
|
|
89
|
+
setCalculatedPosition = _useState6[1];
|
|
90
|
+
var _useState7 = useState(DEFAULT_TOOLTIP_STYLES),
|
|
91
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
92
|
+
toolTipStyles = _useState8[0],
|
|
93
|
+
setToolTipStyles = _useState8[1];
|
|
94
|
+
var _useState9 = useState(undefined),
|
|
95
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
96
|
+
arrowStyles = _useState10[0],
|
|
97
|
+
setArrowStyles = _useState10[1];
|
|
98
|
+
var generatedId = useRef(htmlIdGenerator()());
|
|
99
|
+
var id = idProp !== null && idProp !== void 0 ? idProp : generatedId.current;
|
|
100
|
+
var anchorRef = useRef(null);
|
|
101
|
+
var popoverRef = useRef(null);
|
|
102
|
+
var positionToolTip = useCallback(function () {
|
|
103
|
+
if (!anchorRef.current || !popoverRef.current) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
var _findPopoverPosition = findPopoverPosition({
|
|
107
|
+
anchor: anchorRef.current,
|
|
108
|
+
popover: popoverRef.current,
|
|
109
|
+
position: positionProp,
|
|
110
|
+
offset: offset !== null && offset !== void 0 ? offset : DEFAULT_TOOLTIP_OFFSET,
|
|
111
|
+
arrowConfig: {
|
|
112
|
+
arrowWidth: 12,
|
|
113
|
+
arrowBuffer: 4
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
position = _findPopoverPosition.position,
|
|
117
|
+
left = _findPopoverPosition.left,
|
|
118
|
+
top = _findPopoverPosition.top,
|
|
119
|
+
arrow = _findPopoverPosition.arrow;
|
|
120
|
+
|
|
121
|
+
// If encroaching the right edge of the window:
|
|
122
|
+
// When `props.content` changes and is longer than `prevProps.content`, the tooltip width remains and
|
|
123
|
+
// the resizeObserver callback will fire twice (once for vertical resize caused by text line wrapping,
|
|
124
|
+
// once for a subsequent position correction) and cause a flash rerender and reposition.
|
|
125
|
+
// To prevent this, we can orient from the right so that text line wrapping does not occur, negating
|
|
126
|
+
// the second resizeObserver callback call.
|
|
127
|
+
var windowWidth = document.documentElement.clientWidth || window.innerWidth;
|
|
128
|
+
var useRightValue = windowWidth / 2 < left;
|
|
129
|
+
var newToolTipStyles = {
|
|
130
|
+
top: top,
|
|
131
|
+
left: useRightValue ? 'auto' : left,
|
|
132
|
+
right: useRightValue ? windowWidth - left - popoverRef.current.offsetWidth : 'auto'
|
|
133
|
+
};
|
|
134
|
+
setCalculatedPosition(position);
|
|
135
|
+
setToolTipStyles(newToolTipStyles);
|
|
136
|
+
setArrowStyles(arrow);
|
|
137
|
+
}, [positionProp, offset]);
|
|
138
|
+
var setAnchorRef = useCallback(function (el) {
|
|
139
|
+
anchorRef.current = el;
|
|
140
|
+
}, []);
|
|
141
|
+
var setPopoverRef = useCallback(function (el) {
|
|
142
|
+
popoverRef.current = el;
|
|
143
|
+
if (el) positionToolTip();
|
|
144
|
+
}, [positionToolTip]);
|
|
145
|
+
var hideToolTip = useCallback(function () {
|
|
146
|
+
setVisible(false);
|
|
147
|
+
setToolTipStyles(DEFAULT_TOOLTIP_STYLES);
|
|
148
|
+
setArrowStyles(undefined);
|
|
149
|
+
toolTipManager.deregisterToolTip(hideToolTip);
|
|
150
|
+
}, []);
|
|
151
|
+
var showToolTip = useCallback(function () {
|
|
152
|
+
if (!content && !title) return;
|
|
153
|
+
setVisible(true);
|
|
154
|
+
toolTipManager.registerTooltip(hideToolTip);
|
|
155
|
+
}, [content, title, hideToolTip]);
|
|
156
|
+
useImperativeHandle(ref, function () {
|
|
157
|
+
return {
|
|
158
|
+
showToolTip: showToolTip,
|
|
159
|
+
hideToolTip: hideToolTip,
|
|
160
|
+
id: id
|
|
161
|
+
};
|
|
162
|
+
}, [showToolTip, hideToolTip, id]);
|
|
163
|
+
|
|
164
|
+
// If the anchor already has focus on mount (e.g. `autoFocus`), show the tooltip.
|
|
165
|
+
// Important for StrictMode double-mount.
|
|
166
|
+
useEffect(function () {
|
|
167
|
+
var _anchorRef$current;
|
|
168
|
+
if ((_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(document.activeElement) && document.activeElement != null && isFocusVisible(document.activeElement)) {
|
|
169
|
+
setHasFocus(true);
|
|
170
|
+
showToolTip();
|
|
171
|
+
}
|
|
172
|
+
}, [showToolTip]);
|
|
173
|
+
useEffect(function () {
|
|
174
|
+
return function () {
|
|
175
|
+
toolTipManager.deregisterToolTip(hideToolTip);
|
|
176
|
+
};
|
|
177
|
+
}, [hideToolTip]);
|
|
178
|
+
|
|
179
|
+
// When the tooltip is visible, this checks if the anchor is still part of document.
|
|
180
|
+
// This fixes when the react root is removed from the DOM without unmounting
|
|
181
|
+
// See: https://github.com/elastic/eui/issues/1105
|
|
182
|
+
useEffect(function () {
|
|
183
|
+
if (!visible) return;
|
|
184
|
+
var rafId;
|
|
185
|
+
var testAnchor = function testAnchor() {
|
|
186
|
+
if (document.body.contains(anchorRef.current) === false) {
|
|
80
187
|
// the anchor is no longer part of `document`
|
|
81
|
-
|
|
188
|
+
hideToolTip();
|
|
82
189
|
} else {
|
|
83
|
-
|
|
84
|
-
// if still visible, keep checking
|
|
85
|
-
requestAnimationFrame(_this.testAnchor);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
_defineProperty(_this, "setAnchorRef", function (ref) {
|
|
90
|
-
return _this.anchor = ref;
|
|
91
|
-
});
|
|
92
|
-
_defineProperty(_this, "setPopoverRef", function (ref) {
|
|
93
|
-
return _this.popover = ref;
|
|
94
|
-
});
|
|
95
|
-
_defineProperty(_this, "showToolTip", function () {
|
|
96
|
-
if (!_this.timeoutId) {
|
|
97
|
-
_this.timeoutId = setTimeout(function () {
|
|
98
|
-
enqueueStateChange(function () {
|
|
99
|
-
_this.setState({
|
|
100
|
-
visible: true
|
|
101
|
-
});
|
|
102
|
-
toolTipManager.registerTooltip(_this.hideToolTip);
|
|
103
|
-
});
|
|
104
|
-
}, delayToMsMap[_this.props.delay]);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
_defineProperty(_this, "positionToolTip", function () {
|
|
108
|
-
var _this$props$offset;
|
|
109
|
-
var requestedPosition = _this.props.position;
|
|
110
|
-
var offset = (_this$props$offset = _this.props.offset) !== null && _this$props$offset !== void 0 ? _this$props$offset : DEFAULT_TOOLTIP_OFFSET;
|
|
111
|
-
if (!_this.anchor || !_this.popover) {
|
|
112
|
-
return;
|
|
190
|
+
rafId = requestAnimationFrame(testAnchor);
|
|
113
191
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
arrowWidth: 12,
|
|
121
|
-
arrowBuffer: 4
|
|
122
|
-
}
|
|
123
|
-
}),
|
|
124
|
-
position = _findPopoverPosition.position,
|
|
125
|
-
left = _findPopoverPosition.left,
|
|
126
|
-
top = _findPopoverPosition.top,
|
|
127
|
-
arrow = _findPopoverPosition.arrow;
|
|
192
|
+
};
|
|
193
|
+
rafId = requestAnimationFrame(testAnchor);
|
|
194
|
+
return function () {
|
|
195
|
+
cancelAnimationFrame(rafId);
|
|
196
|
+
};
|
|
197
|
+
}, [visible, hideToolTip]);
|
|
128
198
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var windowWidth = document.documentElement.clientWidth || window.innerWidth;
|
|
136
|
-
var useRightValue = windowWidth / 2 < left;
|
|
137
|
-
var toolTipStyles = {
|
|
138
|
-
top: top,
|
|
139
|
-
left: useRightValue ? 'auto' : left,
|
|
140
|
-
right: useRightValue ? windowWidth - left - _this.popover.offsetWidth : 'auto'
|
|
141
|
-
};
|
|
142
|
-
_this.setState({
|
|
143
|
-
visible: true,
|
|
144
|
-
calculatedPosition: position,
|
|
145
|
-
toolTipStyles: toolTipStyles,
|
|
146
|
-
arrowStyles: arrow
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
_defineProperty(_this, "hideToolTip", function () {
|
|
150
|
-
_this.clearAnimationTimeout();
|
|
151
|
-
enqueueStateChange(function () {
|
|
152
|
-
if (_this._isMounted) {
|
|
153
|
-
_this.setState({
|
|
154
|
-
visible: false,
|
|
155
|
-
toolTipStyles: DEFAULT_TOOLTIP_STYLES,
|
|
156
|
-
arrowStyles: undefined
|
|
157
|
-
});
|
|
158
|
-
toolTipManager.deregisterToolTip(_this.hideToolTip);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
_defineProperty(_this, "onFocus", function () {
|
|
163
|
-
_this.setState({
|
|
164
|
-
hasFocus: true
|
|
165
|
-
});
|
|
166
|
-
_this.showToolTip();
|
|
167
|
-
});
|
|
168
|
-
_defineProperty(_this, "onBlur", function () {
|
|
169
|
-
_this.setState({
|
|
170
|
-
hasFocus: false
|
|
171
|
-
});
|
|
172
|
-
_this.hideToolTip();
|
|
199
|
+
// update scroll listener
|
|
200
|
+
useEffect(function () {
|
|
201
|
+
var shouldReposition = getRepositionOnScroll({
|
|
202
|
+
repositionOnScroll: repositionOnScroll,
|
|
203
|
+
repositionFn: positionToolTip,
|
|
204
|
+
componentDefaults: componentDefaultsContext.EuiToolTip
|
|
173
205
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
_this.setState({
|
|
181
|
-
hasFocus: false
|
|
182
|
-
}); // Allows mousing over back into the tooltip to work correctly
|
|
183
|
-
_this.hideToolTip();
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
_defineProperty(_this, "onMouseOut", function (event) {
|
|
187
|
-
// Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
|
|
188
|
-
// left the anchor for a non-child.
|
|
189
|
-
if (_this.anchor === event.relatedTarget || _this.anchor != null && !_this.anchor.contains(event.relatedTarget)) {
|
|
190
|
-
if (!_this.state.hasFocus) {
|
|
191
|
-
_this.hideToolTip();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (_this.props.onMouseOut) {
|
|
195
|
-
_this.props.onMouseOut(event);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
_this.state = {
|
|
199
|
-
visible: false,
|
|
200
|
-
hasFocus: false,
|
|
201
|
-
calculatedPosition: _this.props.position,
|
|
202
|
-
toolTipStyles: DEFAULT_TOOLTIP_STYLES,
|
|
203
|
-
arrowStyles: undefined,
|
|
204
|
-
id: _this.props.id || htmlIdGenerator()()
|
|
206
|
+
if (shouldReposition) {
|
|
207
|
+
window.addEventListener('scroll', positionToolTip, true);
|
|
208
|
+
}
|
|
209
|
+
return function () {
|
|
210
|
+
window.removeEventListener('scroll', positionToolTip, true);
|
|
205
211
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
return _this;
|
|
214
|
-
}
|
|
215
|
-
_inherits(EuiToolTip, _Component);
|
|
216
|
-
return _createClass(EuiToolTip, [{
|
|
217
|
-
key: "componentDidMount",
|
|
218
|
-
value: function componentDidMount() {
|
|
219
|
-
this._isMounted = true;
|
|
220
|
-
this.repositionOnScroll.subscribe();
|
|
212
|
+
}, [repositionOnScroll, positionToolTip, componentDefaultsContext.EuiToolTip]);
|
|
213
|
+
var onFocus = useCallback(function (e) {
|
|
214
|
+
if (isFocusVisible(e.target)) {
|
|
215
|
+
setHasFocus(true);
|
|
216
|
+
showToolTip();
|
|
221
217
|
}
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
218
|
+
}, [showToolTip]);
|
|
219
|
+
var onBlur = useCallback(function () {
|
|
220
|
+
setHasFocus(false);
|
|
221
|
+
hideToolTip();
|
|
222
|
+
}, [hideToolTip]);
|
|
223
|
+
var onEscapeKey = useCallback(function (event) {
|
|
224
|
+
if (event.key === keys.ESCAPE) {
|
|
225
|
+
// when the tooltip is only visual, we don't want it to add an additional key stop
|
|
226
|
+
if (!disableScreenReaderOutput) {
|
|
227
|
+
if (visible) event.stopPropagation();
|
|
228
|
+
}
|
|
229
|
+
setHasFocus(false); // Allows mousing over back into the tooltip to work correctly
|
|
230
|
+
hideToolTip();
|
|
228
231
|
}
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
}, [disableScreenReaderOutput, visible, hideToolTip]);
|
|
233
|
+
var onMouseOut = useCallback(function (event) {
|
|
234
|
+
// Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
|
|
235
|
+
// left the anchor for a non-child.
|
|
236
|
+
if (anchorRef.current === event.relatedTarget || anchorRef.current != null && !anchorRef.current.contains(event.relatedTarget)) {
|
|
237
|
+
if (!hasFocus) {
|
|
238
|
+
hideToolTip();
|
|
234
239
|
}
|
|
235
|
-
|
|
236
|
-
// update scroll listener
|
|
237
|
-
this.repositionOnScroll.update();
|
|
238
240
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
value: function render() {
|
|
242
|
-
var _this$props = this.props,
|
|
243
|
-
children = _this$props.children,
|
|
244
|
-
className = _this$props.className,
|
|
245
|
-
anchorClassName = _this$props.anchorClassName,
|
|
246
|
-
anchorProps = _this$props.anchorProps,
|
|
247
|
-
content = _this$props.content,
|
|
248
|
-
title = _this$props.title,
|
|
249
|
-
delay = _this$props.delay,
|
|
250
|
-
display = _this$props.display,
|
|
251
|
-
repositionOnScroll = _this$props.repositionOnScroll,
|
|
252
|
-
_this$props$disableSc = _this$props.disableScreenReaderOutput,
|
|
253
|
-
disableScreenReaderOutput = _this$props$disableSc === void 0 ? false : _this$props$disableSc,
|
|
254
|
-
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
255
|
-
var _this$state = this.state,
|
|
256
|
-
arrowStyles = _this$state.arrowStyles,
|
|
257
|
-
id = _this$state.id,
|
|
258
|
-
toolTipStyles = _this$state.toolTipStyles,
|
|
259
|
-
visible = _this$state.visible,
|
|
260
|
-
calculatedPosition = _this$state.calculatedPosition;
|
|
261
|
-
var classes = classNames('euiToolTip', className);
|
|
262
|
-
var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
|
|
263
|
-
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
|
|
264
|
-
ref: this.setAnchorRef,
|
|
265
|
-
onBlur: this.onBlur,
|
|
266
|
-
onFocus: this.onFocus,
|
|
267
|
-
onKeyDown: this.onEscapeKey,
|
|
268
|
-
onMouseOver: this.showToolTip,
|
|
269
|
-
onMouseOut: this.onMouseOut
|
|
270
|
-
// `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
|
|
271
|
-
,
|
|
272
|
-
id: !disableScreenReaderOutput ? id : undefined,
|
|
273
|
-
className: anchorClasses,
|
|
274
|
-
display: display,
|
|
275
|
-
isVisible: visible
|
|
276
|
-
}), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
|
|
277
|
-
className: classes,
|
|
278
|
-
style: toolTipStyles,
|
|
279
|
-
positionToolTip: this.positionToolTip,
|
|
280
|
-
popoverRef: this.setPopoverRef,
|
|
281
|
-
title: title,
|
|
282
|
-
id: id,
|
|
283
|
-
role: "tooltip",
|
|
284
|
-
calculatedPosition: calculatedPosition
|
|
285
|
-
}, rest), ___EmotionJSX(EuiToolTipArrow, {
|
|
286
|
-
style: arrowStyles,
|
|
287
|
-
className: "euiToolTip__arrow",
|
|
288
|
-
position: calculatedPosition
|
|
289
|
-
}), ___EmotionJSX(EuiResizeObserver, {
|
|
290
|
-
onResize: this.positionToolTip
|
|
291
|
-
}, function (resizeRef) {
|
|
292
|
-
return ___EmotionJSX("div", {
|
|
293
|
-
ref: resizeRef
|
|
294
|
-
}, content);
|
|
295
|
-
}))));
|
|
241
|
+
if (onMouseOutProp) {
|
|
242
|
+
onMouseOutProp(event);
|
|
296
243
|
}
|
|
297
|
-
}]);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
244
|
+
}, [hasFocus, hideToolTip, onMouseOutProp]);
|
|
245
|
+
var classes = classNames('euiToolTip', className);
|
|
246
|
+
var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
|
|
247
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
|
|
248
|
+
ref: setAnchorRef,
|
|
249
|
+
onBlur: onBlur,
|
|
250
|
+
onFocus: onFocus,
|
|
251
|
+
onKeyDown: onEscapeKey,
|
|
252
|
+
onMouseOver: showToolTip,
|
|
253
|
+
onMouseOut: onMouseOut
|
|
254
|
+
// `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
|
|
255
|
+
,
|
|
256
|
+
id: !disableScreenReaderOutput ? id : undefined,
|
|
257
|
+
className: anchorClasses,
|
|
258
|
+
display: display,
|
|
259
|
+
isVisible: visible
|
|
260
|
+
}), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
|
|
261
|
+
className: classes,
|
|
262
|
+
style: toolTipStyles,
|
|
263
|
+
positionToolTip: positionToolTip,
|
|
264
|
+
popoverRef: setPopoverRef,
|
|
265
|
+
title: title,
|
|
266
|
+
id: id,
|
|
267
|
+
role: "tooltip",
|
|
268
|
+
calculatedPosition: calculatedPosition
|
|
269
|
+
}, rest), ___EmotionJSX(EuiToolTipArrow, {
|
|
270
|
+
style: arrowStyles,
|
|
271
|
+
className: "euiToolTip__arrow",
|
|
272
|
+
position: calculatedPosition
|
|
273
|
+
}), ___EmotionJSX(EuiResizeObserver, {
|
|
274
|
+
onResize: positionToolTip
|
|
275
|
+
}, function (resizeRef) {
|
|
276
|
+
return ___EmotionJSX("div", {
|
|
277
|
+
ref: resizeRef
|
|
278
|
+
}, content);
|
|
279
|
+
}))));
|
|
305
280
|
});
|
|
306
281
|
EuiToolTip.propTypes = {
|
|
307
282
|
/**
|
|
@@ -333,10 +308,6 @@ EuiToolTip.propTypes = {
|
|
|
333
308
|
* Common display alternatives for the anchor wrapper
|
|
334
309
|
*/
|
|
335
310
|
display: PropTypes.any,
|
|
336
|
-
/**
|
|
337
|
-
* Delay before showing tooltip. Good for repeatable items.
|
|
338
|
-
*/
|
|
339
|
-
delay: PropTypes.oneOf(["regular", "long"]).isRequired,
|
|
340
311
|
/**
|
|
341
312
|
* An optional title for your tooltip.
|
|
342
313
|
*/
|
|
@@ -348,7 +319,7 @@ EuiToolTip.propTypes = {
|
|
|
348
319
|
/**
|
|
349
320
|
* Suggested position. If there is not enough room for it this will be changed.
|
|
350
321
|
*/
|
|
351
|
-
position: PropTypes.oneOf(["top", "right", "bottom", "left"])
|
|
322
|
+
position: PropTypes.oneOf(["top", "right", "bottom", "left"]),
|
|
352
323
|
/**
|
|
353
324
|
* When `true`, the tooltip's position is re-calculated when the user
|
|
354
325
|
* scrolls. This supports having fixed-position tooltip anchors.
|
|
@@ -377,4 +348,5 @@ EuiToolTip.propTypes = {
|
|
|
377
348
|
"aria-label": PropTypes.string,
|
|
378
349
|
"data-test-subj": PropTypes.string,
|
|
379
350
|
css: PropTypes.any
|
|
380
|
-
};
|
|
351
|
+
};
|
|
352
|
+
EuiToolTip.displayName = 'EuiToolTip';
|