@elastic/eui 88.1.0 → 88.2.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/dist/eui_charts_theme.js.map +1 -1
- package/dist/eui_theme_dark.css +9 -36
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +9 -36
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/accordion/accordion.js +34 -9
- package/es/components/accordion/accordion.styles.js +29 -9
- package/es/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +10 -2
- package/es/components/collapsible_nav_beta/collapsible_nav_beta.js +2 -25
- package/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
- package/es/components/flyout/flyout.styles.js +1 -1
- package/es/components/header/header.js +120 -25
- package/es/components/header/header.styles.js +1 -1
- package/es/components/index.js +1 -0
- package/es/components/overlay_mask/overlay_mask.styles.js +1 -1
- package/es/components/page/page_sidebar/page_sidebar.js +2 -4
- package/es/components/page_template/page_template.js +4 -31
- package/es/components/text_truncate/index.js +10 -0
- package/es/components/text_truncate/text_truncate.js +232 -0
- package/es/components/text_truncate/text_truncate.styles.js +49 -0
- package/es/components/text_truncate/utils.js +348 -0
- package/es/services/theme/context.js +3 -1
- package/es/services/theme/hooks.js +19 -1
- package/es/services/theme/index.js +1 -1
- package/es/services/theme/provider.js +37 -8
- package/eui.d.ts +246 -17
- package/i18ntokens.json +8 -8
- package/lib/components/accordion/accordion.js +33 -8
- package/lib/components/accordion/accordion.styles.js +31 -10
- package/lib/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +10 -2
- package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +2 -25
- package/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
- package/lib/components/flyout/flyout.styles.js +1 -1
- package/lib/components/header/header.js +120 -23
- package/lib/components/header/header.styles.js +1 -1
- package/lib/components/index.js +11 -0
- package/lib/components/overlay_mask/overlay_mask.styles.js +1 -1
- package/lib/components/page/page_sidebar/page_sidebar.js +2 -4
- package/lib/components/page_template/page_template.js +2 -29
- package/lib/components/text_truncate/index.js +25 -0
- package/lib/components/text_truncate/text_truncate.js +242 -0
- package/lib/components/text_truncate/text_truncate.styles.js +54 -0
- package/lib/components/text_truncate/utils.js +352 -0
- package/lib/services/theme/context.js +3 -1
- package/lib/services/theme/hooks.js +21 -2
- package/lib/services/theme/index.js +6 -0
- package/lib/services/theme/provider.js +62 -35
- package/optimize/es/components/accordion/accordion.js +19 -7
- package/optimize/es/components/accordion/accordion.styles.js +29 -9
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +2 -25
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
- package/optimize/es/components/flyout/flyout.styles.js +1 -1
- package/optimize/es/components/header/header.js +75 -25
- package/optimize/es/components/header/header.styles.js +1 -1
- package/optimize/es/components/index.js +1 -0
- package/optimize/es/components/overlay_mask/overlay_mask.styles.js +1 -1
- package/optimize/es/components/page/page_sidebar/page_sidebar.js +2 -4
- package/optimize/es/components/page_template/page_template.js +4 -26
- package/optimize/es/components/text_truncate/index.js +10 -0
- package/optimize/es/components/text_truncate/text_truncate.js +148 -0
- package/optimize/es/components/text_truncate/text_truncate.styles.js +49 -0
- package/optimize/es/components/text_truncate/utils.js +337 -0
- package/optimize/es/services/theme/context.js +3 -1
- package/optimize/es/services/theme/hooks.js +19 -1
- package/optimize/es/services/theme/index.js +1 -1
- package/optimize/es/services/theme/provider.js +37 -8
- package/optimize/lib/components/accordion/accordion.js +18 -6
- package/optimize/lib/components/accordion/accordion.styles.js +31 -10
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +2 -25
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
- package/optimize/lib/components/flyout/flyout.styles.js +1 -1
- package/optimize/lib/components/header/header.js +77 -24
- package/optimize/lib/components/header/header.styles.js +1 -1
- package/optimize/lib/components/index.js +11 -0
- package/optimize/lib/components/overlay_mask/overlay_mask.styles.js +1 -1
- package/optimize/lib/components/page/page_sidebar/page_sidebar.js +2 -4
- package/optimize/lib/components/page_template/page_template.js +2 -24
- package/optimize/lib/components/text_truncate/index.js +25 -0
- package/optimize/lib/components/text_truncate/text_truncate.js +158 -0
- package/optimize/lib/components/text_truncate/text_truncate.styles.js +54 -0
- package/optimize/lib/components/text_truncate/utils.js +342 -0
- package/optimize/lib/services/theme/context.js +3 -1
- package/optimize/lib/services/theme/hooks.js +21 -2
- package/optimize/lib/services/theme/index.js +6 -0
- package/optimize/lib/services/theme/provider.js +62 -35
- package/package.json +1 -1
- package/src/components/datagrid/_data_grid.scss +13 -2
- package/src/components/index.scss +0 -1
- package/src/global_styling/mixins/_header.scss +2 -0
- package/test-env/components/accordion/accordion.js +28 -8
- package/test-env/components/accordion/accordion.styles.js +31 -10
- package/test-env/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +10 -2
- package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +2 -25
- package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
- package/test-env/components/flyout/flyout.styles.js +1 -1
- package/test-env/components/header/header.js +113 -23
- package/test-env/components/header/header.styles.js +1 -1
- package/test-env/components/index.js +11 -0
- package/test-env/components/overlay_mask/overlay_mask.styles.js +1 -1
- package/test-env/components/page/page_sidebar/page_sidebar.js +2 -4
- package/test-env/components/page_template/page_template.js +2 -24
- package/test-env/components/text_truncate/index.js +25 -0
- package/test-env/components/text_truncate/text_truncate.js +236 -0
- package/test-env/components/text_truncate/text_truncate.styles.js +54 -0
- package/test-env/components/text_truncate/utils.js +342 -0
- package/test-env/services/theme/context.js +3 -1
- package/test-env/services/theme/hooks.js +21 -2
- package/test-env/services/theme/index.js +6 -0
- package/test-env/services/theme/provider.js +62 -35
- package/src/components/accordion/_accordion_form.scss +0 -40
- package/src/components/accordion/_index.scss +0 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children", "className", "sections", "position", "theme"]
|
|
5
|
+
var _excluded = ["children", "className", "sections", "position", "theme"],
|
|
6
|
+
_excluded2 = ["children", "style"];
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
9
|
/*
|
|
5
10
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
6
11
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -9,12 +14,13 @@ var _excluded = ["children", "className", "sections", "position", "theme"];
|
|
|
9
14
|
* Side Public License, v 1.
|
|
10
15
|
*/
|
|
11
16
|
|
|
12
|
-
import React, { useEffect } from 'react';
|
|
17
|
+
import React, { useEffect, useState, useMemo, useCallback } from 'react';
|
|
13
18
|
import classNames from 'classnames';
|
|
14
|
-
import { useEuiTheme } from '../../services';
|
|
19
|
+
import { useEuiTheme, useEuiThemeCSSVariables } from '../../services';
|
|
20
|
+
import { mathWithUnits, logicalStyles } from '../../global_styling';
|
|
15
21
|
import { EuiHeaderBreadcrumbs } from './header_breadcrumbs';
|
|
16
22
|
import { EuiHeaderSectionItem, EuiHeaderSection } from './header_section';
|
|
17
|
-
import { euiHeaderStyles } from './header.styles';
|
|
23
|
+
import { euiHeaderStyles, euiHeaderVariables } from './header.styles';
|
|
18
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
19
25
|
var createHeaderSection = function createHeaderSection(sections) {
|
|
20
26
|
return sections.map(function (section, index) {
|
|
@@ -23,8 +29,6 @@ var createHeaderSection = function createHeaderSection(sections) {
|
|
|
23
29
|
}, section);
|
|
24
30
|
});
|
|
25
31
|
};
|
|
26
|
-
// Start a counter to manage the total number of fixed headers that need the body class
|
|
27
|
-
var euiHeaderFixedCounter = 0;
|
|
28
32
|
export var EuiHeader = function EuiHeader(_ref) {
|
|
29
33
|
var children = _ref.children,
|
|
30
34
|
className = _ref.className,
|
|
@@ -38,22 +42,6 @@ export var EuiHeader = function EuiHeader(_ref) {
|
|
|
38
42
|
var euiTheme = useEuiTheme();
|
|
39
43
|
var styles = euiHeaderStyles(euiTheme);
|
|
40
44
|
var cssStyles = [styles.euiHeader, styles[position], styles[theme]];
|
|
41
|
-
useEffect(function () {
|
|
42
|
-
if (position === 'fixed') {
|
|
43
|
-
// Increment fixed header counter for each fixed header
|
|
44
|
-
euiHeaderFixedCounter++;
|
|
45
|
-
document.body.classList.add('euiBody--headerIsFixed');
|
|
46
|
-
document.body.dataset.fixedHeaders = String(euiHeaderFixedCounter);
|
|
47
|
-
return function () {
|
|
48
|
-
// Both decrement the fixed counter AND then check if there are none
|
|
49
|
-
if (--euiHeaderFixedCounter === 0) {
|
|
50
|
-
// If there are none, THEN remove class
|
|
51
|
-
document.body.classList.remove('euiBody--headerIsFixed');
|
|
52
|
-
delete document.body.dataset.fixedHeaders;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}, [position]);
|
|
57
45
|
var contents;
|
|
58
46
|
if (sections) {
|
|
59
47
|
if (children) {
|
|
@@ -82,9 +70,71 @@ export var EuiHeader = function EuiHeader(_ref) {
|
|
|
82
70
|
} else {
|
|
83
71
|
contents = children;
|
|
84
72
|
}
|
|
85
|
-
return ___EmotionJSX(
|
|
73
|
+
return position === 'fixed' ? ___EmotionJSX(EuiFixedHeader, _extends({
|
|
86
74
|
css: cssStyles,
|
|
87
|
-
className: classes
|
|
88
|
-
|
|
75
|
+
className: classes
|
|
76
|
+
}, rest), contents) : ___EmotionJSX("div", _extends({
|
|
77
|
+
css: cssStyles,
|
|
78
|
+
className: classes
|
|
89
79
|
}, rest), contents);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Fixed headers - logic around dynamically calculating the total
|
|
84
|
+
* page offset and setting the `top` position of subsequent headers
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
// Start a counter to manage the total number of fixed headers
|
|
88
|
+
// Exported for unit testing only
|
|
89
|
+
export var euiFixedHeadersCount = 0;
|
|
90
|
+
|
|
91
|
+
// Exported for unit testing only
|
|
92
|
+
export var EuiFixedHeader = function EuiFixedHeader(_ref2) {
|
|
93
|
+
var children = _ref2.children,
|
|
94
|
+
style = _ref2.style,
|
|
95
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
96
|
+
var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
|
|
97
|
+
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
98
|
+
var euiTheme = useEuiTheme();
|
|
99
|
+
var headerHeight = euiHeaderVariables(euiTheme).height;
|
|
100
|
+
var getHeaderOffset = useCallback(function () {
|
|
101
|
+
return mathWithUnits(headerHeight, function (x) {
|
|
102
|
+
return x * euiFixedHeadersCount;
|
|
103
|
+
});
|
|
104
|
+
}, [headerHeight]);
|
|
105
|
+
var _useState = useState(),
|
|
106
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
107
|
+
topPosition = _useState2[0],
|
|
108
|
+
setTopPosition = _useState2[1];
|
|
109
|
+
useEffect(function () {
|
|
110
|
+
// Get the top position from the offset of previous header(s)
|
|
111
|
+
setTopPosition(getHeaderOffset());
|
|
112
|
+
|
|
113
|
+
// Increment fixed header counter for each fixed header
|
|
114
|
+
euiFixedHeadersCount++;
|
|
115
|
+
setGlobalCSSVariables({
|
|
116
|
+
'--euiFixedHeadersOffset': getHeaderOffset()
|
|
117
|
+
});
|
|
118
|
+
document.body.classList.add('euiBody--headerIsFixed'); // TODO: Consider deleting this legacy className
|
|
119
|
+
|
|
120
|
+
return function () {
|
|
121
|
+
euiFixedHeadersCount--;
|
|
122
|
+
setGlobalCSSVariables({
|
|
123
|
+
'--euiFixedHeadersOffset': getHeaderOffset()
|
|
124
|
+
});
|
|
125
|
+
if (euiFixedHeadersCount === 0) {
|
|
126
|
+
document.body.classList.remove('euiBody--headerIsFixed'); // TODO: Consider deleting this legacy className
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}, [getHeaderOffset, setGlobalCSSVariables]);
|
|
130
|
+
var inlineStyles = useMemo(function () {
|
|
131
|
+
return logicalStyles(_objectSpread({
|
|
132
|
+
top: topPosition
|
|
133
|
+
}, style));
|
|
134
|
+
}, [topPosition, style]);
|
|
135
|
+
return ___EmotionJSX("div", _extends({
|
|
136
|
+
"data-fixed-header": true // Used by EuiFlyouts as a query selector
|
|
137
|
+
,
|
|
138
|
+
style: inlineStyles
|
|
139
|
+
}, rest), children);
|
|
90
140
|
};
|
|
@@ -32,7 +32,7 @@ export var euiHeaderStyles = function euiHeaderStyles(euiThemeContext) {
|
|
|
32
32
|
euiHeader: /*#__PURE__*/css("display:flex;justify-content:space-between;", logicalCSS('height', height), " ", logicalCSS('padding-horizontal', padding), " ", euiShadowSmall(euiThemeContext), ";;label:euiHeader;"),
|
|
33
33
|
// Position
|
|
34
34
|
static: /*#__PURE__*/css("z-index:", Number(euiTheme.levels.header) - 1, ";position:relative;;label:static;"),
|
|
35
|
-
fixed: /*#__PURE__*/css("z-index:", euiTheme.levels.header, ";position:fixed;", logicalCSS('top', 0), " ", logicalCSS('horizontal', 0), "
|
|
35
|
+
fixed: /*#__PURE__*/css("z-index:", euiTheme.levels.header, ";position:fixed;", logicalCSS('top', 0), " ", logicalCSS('horizontal', 0), ";;label:fixed;"),
|
|
36
36
|
// Theme
|
|
37
37
|
default: /*#__PURE__*/css("background-color:", euiTheme.colors.emptyShade, ";", logicalCSS('border-bottom', "".concat(euiTheme.border.width.thin, " solid ").concat(borderColor)), ";;label:default;"),
|
|
38
38
|
dark: /*#__PURE__*/css(euiHeaderDarkStyles(euiThemeContext, borderColor), ";label:dark;")
|
|
@@ -14,6 +14,6 @@ export var euiOverlayMaskStyles = function euiOverlayMaskStyles(_ref) {
|
|
|
14
14
|
return {
|
|
15
15
|
euiOverlayMask: /*#__PURE__*/css("position:fixed;", logicalCSS('top', 0), " ", logicalCSS('left', 0), " ", logicalCSS('right', 0), " ", logicalCSS('bottom', 0), " display:flex;align-items:center;justify-content:center;", logicalCSS('padding-bottom', '10vh'), " animation:", euiAnimFadeIn, " ", euiTheme.animation.fast, " ease-in;background:", transparentize(euiTheme.colors.ink, 0.5), ";;label:euiOverlayMask;"),
|
|
16
16
|
aboveHeader: /*#__PURE__*/css("z-index:", euiTheme.levels.mask, ";;label:aboveHeader;"),
|
|
17
|
-
belowHeader: /*#__PURE__*/css("z-index:", euiTheme.levels.maskBelowHeader, ";", logicalCSS('top',
|
|
17
|
+
belowHeader: /*#__PURE__*/css("z-index:", euiTheme.levels.maskBelowHeader, ";", logicalCSS('top', 'var(--euiFixedHeadersOffset, 0)'), ";;label:belowHeader;")
|
|
18
18
|
};
|
|
19
19
|
};
|
|
@@ -45,10 +45,8 @@ export var EuiPageSidebar = function EuiPageSidebar(_ref) {
|
|
|
45
45
|
useLayoutEffect(function () {
|
|
46
46
|
var updatedStyles = _objectSpread(_objectSpread({}, style), logicalStyle('min-width', isResponding ? '100%' : minWidth));
|
|
47
47
|
if (sticky) {
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
var offset = _typeof(sticky) === 'object' ? sticky === null || sticky === void 0 ? void 0 : sticky.offset : themeContext.euiTheme.base * 3 * euiHeaderFixedCounter;
|
|
51
|
-
updatedStyles = _objectSpread(_objectSpread(_objectSpread({}, updatedStyles), logicalStyle('top', offset)), logicalStyle('max-height', "calc(100vh - ".concat(offset, "px)")));
|
|
48
|
+
var offset = _typeof(sticky) === 'object' ? "".concat(sticky === null || sticky === void 0 ? void 0 : sticky.offset, "px") : 'var(--euiFixedHeadersOffset, 0)';
|
|
49
|
+
updatedStyles = _objectSpread(_objectSpread(_objectSpread({}, updatedStyles), logicalStyle('top', offset)), logicalStyle('max-height', "calc(100vh - ".concat(offset, ")")));
|
|
52
50
|
}
|
|
53
51
|
setInlineStyles(updatedStyles);
|
|
54
52
|
}, [style, sticky, themeContext.euiTheme.base, isResponding, minWidth]);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
4
|
var _excluded = ["children", "responsive", "restrictWidth", "paddingSize", "grow", "bottomBorder", "offset", "panelled", "contentBorder", "component", "mainProps", "className", "minHeight"];
|
|
6
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -13,14 +12,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
13
12
|
* Side Public License, v 1.
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
import React, { createContext, useContext
|
|
15
|
+
import React, { createContext, useContext } from 'react';
|
|
17
16
|
import classNames from 'classnames';
|
|
18
17
|
import { _EuiPageOuter as EuiPageOuter } from './outer';
|
|
19
18
|
import { _EuiPageInner as EuiPageInner } from './inner';
|
|
20
19
|
import { _EuiPageBottomBar as EuiPageBottomBar } from './bottom_bar/page_bottom_bar';
|
|
21
20
|
import { _EuiPageEmptyPrompt as EuiPageEmptyPrompt } from './empty_prompt/page_empty_prompt';
|
|
22
21
|
import { EuiPageHeader, EuiPageSection, EuiPageSidebar } from '../page';
|
|
23
|
-
import {
|
|
22
|
+
import { useGeneratedHtmlId } from '../../services';
|
|
24
23
|
import { logicalStyle } from '../../global_styling';
|
|
25
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
26
25
|
export var TemplateContext = /*#__PURE__*/createContext({
|
|
@@ -29,14 +28,6 @@ export var TemplateContext = /*#__PURE__*/createContext({
|
|
|
29
28
|
emptyPrompt: {},
|
|
30
29
|
bottomBar: {}
|
|
31
30
|
});
|
|
32
|
-
var calculateOffset = function calculateOffset(base) {
|
|
33
|
-
var _document$body$datase;
|
|
34
|
-
if (typeof document === 'undefined') return 0; // SSR catch
|
|
35
|
-
|
|
36
|
-
var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
|
|
37
|
-
return base * 3 * euiHeaderFixedCounter;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
31
|
/**
|
|
41
32
|
* Consumed via `EuiPageTemplate`,
|
|
42
33
|
* it controls and propogates most of the shared props per direct child
|
|
@@ -52,7 +43,7 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
|
|
|
52
43
|
_ref$grow = _ref.grow,
|
|
53
44
|
grow = _ref$grow === void 0 ? true : _ref$grow,
|
|
54
45
|
bottomBorder = _ref.bottomBorder,
|
|
55
|
-
|
|
46
|
+
offset = _ref.offset,
|
|
56
47
|
panelled = _ref.panelled,
|
|
57
48
|
contentBorder = _ref.contentBorder,
|
|
58
49
|
component = _ref.component,
|
|
@@ -61,14 +52,6 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
|
|
|
61
52
|
_ref$minHeight = _ref.minHeight,
|
|
62
53
|
minHeight = _ref$minHeight === void 0 ? '460px' : _ref$minHeight,
|
|
63
54
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
64
|
-
var _useEuiTheme = useEuiTheme(),
|
|
65
|
-
euiTheme = _useEuiTheme.euiTheme;
|
|
66
|
-
var _useState = useState(function () {
|
|
67
|
-
return _offset !== null && _offset !== void 0 ? _offset : calculateOffset(euiTheme.base);
|
|
68
|
-
}),
|
|
69
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
70
|
-
offset = _useState2[0],
|
|
71
|
-
setOffset = _useState2[1];
|
|
72
55
|
var templateContext = useContext(TemplateContext);
|
|
73
56
|
|
|
74
57
|
// Used as a target to insert the bottom bar component
|
|
@@ -76,11 +59,6 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
|
|
|
76
59
|
prefix: 'EuiPageTemplateInner',
|
|
77
60
|
conditionalId: mainProps === null || mainProps === void 0 ? void 0 : mainProps.id
|
|
78
61
|
});
|
|
79
|
-
useEffect(function () {
|
|
80
|
-
if (_offset === undefined) {
|
|
81
|
-
setOffset(calculateOffset(euiTheme.base));
|
|
82
|
-
}
|
|
83
|
-
}, [_offset, euiTheme.base]);
|
|
84
62
|
|
|
85
63
|
// Sections include page header
|
|
86
64
|
var sections = [];
|
|
@@ -139,7 +117,7 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
|
|
|
139
117
|
});
|
|
140
118
|
var _minHeight = grow ? "max(".concat(minHeight, ", 100vh)") : minHeight;
|
|
141
119
|
var classes = classNames('euiPageTemplate', className);
|
|
142
|
-
var pageStyle = _objectSpread(_objectSpread(_objectSpread({}, logicalStyle('min-height', _minHeight)), logicalStyle('padding-top', offset)), rest.style);
|
|
120
|
+
var pageStyle = _objectSpread(_objectSpread(_objectSpread({}, logicalStyle('min-height', _minHeight)), logicalStyle('padding-top', offset !== null && offset !== void 0 ? offset : 'var(--euiFixedHeadersOffset, 0)')), rest.style);
|
|
143
121
|
templateContext.header = getHeaderProps();
|
|
144
122
|
templateContext.section = getSectionProps();
|
|
145
123
|
templateContext.emptyPrompt = {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
5
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
|
+
* Side Public License, v 1.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { EuiTextTruncate } from './text_truncate';
|
|
10
|
+
export { TruncationUtilsWithDOM, TruncationUtilsWithCanvas } from './utils';
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["width"],
|
|
5
|
+
_excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "containerRef", "measurementRenderAPI"],
|
|
6
|
+
_excluded3 = ["onResize"];
|
|
7
|
+
/*
|
|
8
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
10
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
11
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
12
|
+
* Side Public License, v 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import React, { useState, useMemo, useCallback } from 'react';
|
|
16
|
+
import { useCombinedRefs } from '../../services';
|
|
17
|
+
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
18
|
+
import { TruncationUtilsWithDOM, TruncationUtilsWithCanvas } from './utils';
|
|
19
|
+
import { euiTextTruncateStyles } from './text_truncate.styles';
|
|
20
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
21
|
+
var TRUNCATION_TYPES = ['end', 'start', 'startEnd', 'middle'];
|
|
22
|
+
export var EuiTextTruncate = function EuiTextTruncate(_ref) {
|
|
23
|
+
var width = _ref.width,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
return width != null ? ___EmotionJSX(EuiTextTruncateWithWidth, _extends({
|
|
26
|
+
width: width
|
|
27
|
+
}, props)) : ___EmotionJSX(EuiTextTruncateWithResizeObserver, props);
|
|
28
|
+
};
|
|
29
|
+
var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
|
|
30
|
+
var width = _ref2.width,
|
|
31
|
+
children = _ref2.children,
|
|
32
|
+
text = _ref2.text,
|
|
33
|
+
_ref2$truncation = _ref2.truncation,
|
|
34
|
+
_truncation = _ref2$truncation === void 0 ? 'end' : _ref2$truncation,
|
|
35
|
+
_ref2$truncationOffse = _ref2.truncationOffset,
|
|
36
|
+
_truncationOffset = _ref2$truncationOffse === void 0 ? 0 : _ref2$truncationOffse,
|
|
37
|
+
truncationPosition = _ref2.truncationPosition,
|
|
38
|
+
_ref2$ellipsis = _ref2.ellipsis,
|
|
39
|
+
ellipsis = _ref2$ellipsis === void 0 ? '…' : _ref2$ellipsis,
|
|
40
|
+
containerRef = _ref2.containerRef,
|
|
41
|
+
_ref2$measurementRend = _ref2.measurementRenderAPI,
|
|
42
|
+
measurementRenderAPI = _ref2$measurementRend === void 0 ? 'dom' : _ref2$measurementRend,
|
|
43
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
44
|
+
// Note: This needs to be a state and not a ref to trigger a rerender on mount
|
|
45
|
+
var _useState = useState(null),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
containerEl = _useState2[0],
|
|
48
|
+
setContainerEl = _useState2[1];
|
|
49
|
+
var refs = useCombinedRefs([setContainerEl, containerRef]);
|
|
50
|
+
|
|
51
|
+
// Handle exceptions where we need to override the passed props
|
|
52
|
+
var _useMemo = useMemo(function () {
|
|
53
|
+
var truncation = _truncation;
|
|
54
|
+
var truncationOffset = 0;
|
|
55
|
+
if (_truncation === 'end' || _truncation === 'start') {
|
|
56
|
+
if (0 < _truncationOffset && _truncationOffset < text.length) {
|
|
57
|
+
truncationOffset = _truncationOffset;
|
|
58
|
+
}
|
|
59
|
+
} else if (_truncation === 'startEnd' && truncationPosition != null) {
|
|
60
|
+
if (truncationPosition <= 0) {
|
|
61
|
+
truncation = 'end';
|
|
62
|
+
} else if (truncationPosition >= text.length) {
|
|
63
|
+
truncation = 'start';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
truncation: truncation,
|
|
68
|
+
truncationOffset: truncationOffset
|
|
69
|
+
};
|
|
70
|
+
}, [_truncation, _truncationOffset, truncationPosition, text.length]),
|
|
71
|
+
truncation = _useMemo.truncation,
|
|
72
|
+
truncationOffset = _useMemo.truncationOffset;
|
|
73
|
+
var truncatedText = useMemo(function () {
|
|
74
|
+
var truncatedText = '';
|
|
75
|
+
if (!containerEl || !width) return truncatedText;
|
|
76
|
+
var params = {
|
|
77
|
+
fullText: text,
|
|
78
|
+
ellipsis: ellipsis,
|
|
79
|
+
container: containerEl,
|
|
80
|
+
availableWidth: width
|
|
81
|
+
};
|
|
82
|
+
var utils = measurementRenderAPI === 'canvas' ? new TruncationUtilsWithCanvas(params) : new TruncationUtilsWithDOM(params);
|
|
83
|
+
if (utils.checkIfTruncationIsNeeded() === false) {
|
|
84
|
+
truncatedText = text;
|
|
85
|
+
} else if (utils.checkSufficientEllipsisWidth(truncation) === false) {
|
|
86
|
+
truncatedText = '';
|
|
87
|
+
} else {
|
|
88
|
+
switch (truncation) {
|
|
89
|
+
case 'end':
|
|
90
|
+
truncatedText = utils.truncateEnd(truncationOffset);
|
|
91
|
+
break;
|
|
92
|
+
case 'start':
|
|
93
|
+
truncatedText = utils.truncateStart(truncationOffset);
|
|
94
|
+
break;
|
|
95
|
+
case 'startEnd':
|
|
96
|
+
if (truncationPosition == null) {
|
|
97
|
+
truncatedText = utils.truncateStartEndAtMiddle();
|
|
98
|
+
} else {
|
|
99
|
+
truncatedText = utils.truncateStartEndAtPosition(truncationPosition);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case 'middle':
|
|
103
|
+
truncatedText = utils.truncateMiddle();
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (measurementRenderAPI === 'dom') {
|
|
108
|
+
utils.cleanup();
|
|
109
|
+
}
|
|
110
|
+
return truncatedText;
|
|
111
|
+
}, [width, text, truncation, truncationOffset, truncationPosition, ellipsis, containerEl, measurementRenderAPI]);
|
|
112
|
+
var isTruncating = truncatedText !== text;
|
|
113
|
+
return ___EmotionJSX("div", _extends({
|
|
114
|
+
css: euiTextTruncateStyles.euiTextTruncate,
|
|
115
|
+
ref: refs,
|
|
116
|
+
title: isTruncating ? text : undefined
|
|
117
|
+
}, rest), isTruncating ? ___EmotionJSX(React.Fragment, null, ___EmotionJSX("span", {
|
|
118
|
+
css: euiTextTruncateStyles.truncatedText,
|
|
119
|
+
"aria-hidden": true,
|
|
120
|
+
"data-test-subj": "truncatedText"
|
|
121
|
+
}, children ? children(truncatedText) : truncatedText), ___EmotionJSX("span", {
|
|
122
|
+
css: euiTextTruncateStyles.fullText,
|
|
123
|
+
"data-test-subj": "fullText"
|
|
124
|
+
}, text)) : ___EmotionJSX("span", {
|
|
125
|
+
"data-test-subj": "fullText"
|
|
126
|
+
}, text));
|
|
127
|
+
};
|
|
128
|
+
var EuiTextTruncateWithResizeObserver = function EuiTextTruncateWithResizeObserver(_ref3) {
|
|
129
|
+
var _onResize = _ref3.onResize,
|
|
130
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
131
|
+
var _useState3 = useState(0),
|
|
132
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
133
|
+
width = _useState4[0],
|
|
134
|
+
setWidth = _useState4[1];
|
|
135
|
+
var onResize = useCallback(function (_ref4) {
|
|
136
|
+
var width = _ref4.width;
|
|
137
|
+
setWidth(width);
|
|
138
|
+
_onResize === null || _onResize === void 0 ? void 0 : _onResize(width);
|
|
139
|
+
}, [_onResize]);
|
|
140
|
+
return ___EmotionJSX(EuiResizeObserver, {
|
|
141
|
+
onResize: onResize
|
|
142
|
+
}, function (ref) {
|
|
143
|
+
return ___EmotionJSX(EuiTextTruncateWithWidth, _extends({
|
|
144
|
+
width: width,
|
|
145
|
+
containerRef: ref
|
|
146
|
+
}, props));
|
|
147
|
+
});
|
|
148
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
6
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
7
|
+
* Side Public License, v 1.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { css } from '@emotion/react';
|
|
11
|
+
export var euiTextTruncateStyles = {
|
|
12
|
+
euiTextTruncate: process.env.NODE_ENV === "production" ? {
|
|
13
|
+
name: "7o5qnz-euiTextTruncate",
|
|
14
|
+
styles: "position:relative;overflow:hidden;white-space:nowrap;label:euiTextTruncate;"
|
|
15
|
+
} : {
|
|
16
|
+
name: "7o5qnz-euiTextTruncate",
|
|
17
|
+
styles: "position:relative;overflow:hidden;white-space:nowrap;label:euiTextTruncate;",
|
|
18
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* The below CSS is a hack to get double clicking and selecting the *full* text
|
|
22
|
+
* instead of the truncated text (useful for copying/pasting, and mimics how
|
|
23
|
+
* `text-overflow: ellipsis` works).
|
|
24
|
+
*
|
|
25
|
+
* Real talk: I'm lowkey amazed it works and it wouldn't surprise me if we ran into
|
|
26
|
+
* cross-browser issues with this at some point. Hopefully CSS natively implements
|
|
27
|
+
* custom text truncation some day (https://github.com/w3c/csswg-drafts/issues/3937)
|
|
28
|
+
* and there'll be no need for the entire component at that point 🙏
|
|
29
|
+
*/
|
|
30
|
+
// Makes the truncated text unselectable/un-clickable
|
|
31
|
+
truncatedText: process.env.NODE_ENV === "production" ? {
|
|
32
|
+
name: "1dore6v-truncatedText",
|
|
33
|
+
styles: "user-select:none;pointer-events:none;label:truncatedText;"
|
|
34
|
+
} : {
|
|
35
|
+
name: "1dore6v-truncatedText",
|
|
36
|
+
styles: "user-select:none;pointer-events:none;label:truncatedText;",
|
|
37
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
38
|
+
},
|
|
39
|
+
// Positions the full text on top of the truncated text (so that clicking targets it)
|
|
40
|
+
// and gives it a color opacity of 0 so that it's not actually visible
|
|
41
|
+
fullText: process.env.NODE_ENV === "production" ? {
|
|
42
|
+
name: "1kxt4rj-fullText",
|
|
43
|
+
styles: "position:absolute;inset:0;overflow:hidden;color:rgba(0, 0, 0, 0);@supports (-webkit-hyphens: none){text-overflow:ellipsis;};label:fullText;"
|
|
44
|
+
} : {
|
|
45
|
+
name: "1kxt4rj-fullText",
|
|
46
|
+
styles: "position:absolute;inset:0;overflow:hidden;color:rgba(0, 0, 0, 0);@supports (-webkit-hyphens: none){text-overflow:ellipsis;};label:fullText;",
|
|
47
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
48
|
+
}
|
|
49
|
+
};
|