@elastic/eui 88.0.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.
Files changed (148) hide show
  1. package/dist/eui_charts_theme.js +9 -8
  2. package/dist/eui_charts_theme.js.map +1 -1
  3. package/dist/eui_theme_dark.css +11 -41
  4. package/dist/eui_theme_dark.min.css +1 -1
  5. package/dist/eui_theme_light.css +11 -41
  6. package/dist/eui_theme_light.min.css +1 -1
  7. package/es/components/accordion/accordion.js +34 -9
  8. package/es/components/accordion/accordion.styles.js +29 -9
  9. package/es/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +10 -2
  10. package/es/components/collapsible_nav_beta/collapsible_nav_beta.js +10 -26
  11. package/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
  12. package/es/components/datagrid/controls/keyboard_shortcuts.js +1 -0
  13. package/es/components/description_list/description_list.js +40 -3
  14. package/es/components/flyout/flyout.styles.js +1 -1
  15. package/es/components/header/header.js +120 -25
  16. package/es/components/header/header.styles.js +1 -1
  17. package/es/components/index.js +1 -0
  18. package/es/components/markdown_editor/markdown_format.styles.js +3 -6
  19. package/es/components/overlay_mask/overlay_mask.styles.js +1 -1
  20. package/es/components/page/page_sidebar/page_sidebar.js +2 -4
  21. package/es/components/page_template/page_template.js +4 -31
  22. package/es/components/text/text.styles.js +3 -6
  23. package/es/components/text_truncate/index.js +10 -0
  24. package/es/components/text_truncate/text_truncate.js +232 -0
  25. package/es/components/text_truncate/text_truncate.styles.js +49 -0
  26. package/es/components/text_truncate/utils.js +348 -0
  27. package/es/global_styling/functions/typography.js +8 -8
  28. package/es/global_styling/variables/typography.js +1 -1
  29. package/es/services/theme/context.js +3 -1
  30. package/es/services/theme/hooks.js +19 -1
  31. package/es/services/theme/index.js +1 -1
  32. package/es/services/theme/provider.js +37 -8
  33. package/es/themes/amsterdam/global_styling/variables/_typography.js +1 -0
  34. package/eui.d.ts +282 -24
  35. package/i18ntokens.json +112 -112
  36. package/lib/components/accordion/accordion.js +33 -8
  37. package/lib/components/accordion/accordion.styles.js +31 -10
  38. package/lib/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +10 -2
  39. package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +10 -26
  40. package/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
  41. package/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -0
  42. package/lib/components/description_list/description_list.js +39 -3
  43. package/lib/components/flyout/flyout.styles.js +1 -1
  44. package/lib/components/header/header.js +120 -23
  45. package/lib/components/header/header.styles.js +1 -1
  46. package/lib/components/index.js +11 -0
  47. package/lib/components/markdown_editor/markdown_format.styles.js +3 -6
  48. package/lib/components/overlay_mask/overlay_mask.styles.js +1 -1
  49. package/lib/components/page/page_sidebar/page_sidebar.js +2 -4
  50. package/lib/components/page_template/page_template.js +2 -29
  51. package/lib/components/text/text.styles.js +3 -6
  52. package/lib/components/text_truncate/index.js +25 -0
  53. package/lib/components/text_truncate/text_truncate.js +242 -0
  54. package/lib/components/text_truncate/text_truncate.styles.js +54 -0
  55. package/lib/components/text_truncate/utils.js +352 -0
  56. package/lib/global_styling/functions/typography.js +8 -8
  57. package/lib/global_styling/variables/typography.js +3 -3
  58. package/lib/services/theme/context.js +3 -1
  59. package/lib/services/theme/hooks.js +21 -2
  60. package/lib/services/theme/index.js +6 -0
  61. package/lib/services/theme/provider.js +62 -35
  62. package/lib/themes/amsterdam/global_styling/variables/_typography.js +1 -0
  63. package/optimize/es/components/accordion/accordion.js +19 -7
  64. package/optimize/es/components/accordion/accordion.styles.js +29 -9
  65. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +5 -26
  66. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
  67. package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +1 -0
  68. package/optimize/es/components/description_list/description_list.js +22 -2
  69. package/optimize/es/components/flyout/flyout.styles.js +1 -1
  70. package/optimize/es/components/header/header.js +75 -25
  71. package/optimize/es/components/header/header.styles.js +1 -1
  72. package/optimize/es/components/index.js +1 -0
  73. package/optimize/es/components/markdown_editor/markdown_format.styles.js +3 -6
  74. package/optimize/es/components/overlay_mask/overlay_mask.styles.js +1 -1
  75. package/optimize/es/components/page/page_sidebar/page_sidebar.js +2 -4
  76. package/optimize/es/components/page_template/page_template.js +4 -26
  77. package/optimize/es/components/text/text.styles.js +3 -6
  78. package/optimize/es/components/text_truncate/index.js +10 -0
  79. package/optimize/es/components/text_truncate/text_truncate.js +148 -0
  80. package/optimize/es/components/text_truncate/text_truncate.styles.js +49 -0
  81. package/optimize/es/components/text_truncate/utils.js +337 -0
  82. package/optimize/es/global_styling/functions/typography.js +8 -8
  83. package/optimize/es/global_styling/variables/typography.js +1 -1
  84. package/optimize/es/services/theme/context.js +3 -1
  85. package/optimize/es/services/theme/hooks.js +19 -1
  86. package/optimize/es/services/theme/index.js +1 -1
  87. package/optimize/es/services/theme/provider.js +37 -8
  88. package/optimize/es/themes/amsterdam/global_styling/variables/_typography.js +1 -0
  89. package/optimize/lib/components/accordion/accordion.js +18 -6
  90. package/optimize/lib/components/accordion/accordion.styles.js +31 -10
  91. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +5 -26
  92. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
  93. package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -0
  94. package/optimize/lib/components/description_list/description_list.js +22 -2
  95. package/optimize/lib/components/flyout/flyout.styles.js +1 -1
  96. package/optimize/lib/components/header/header.js +77 -24
  97. package/optimize/lib/components/header/header.styles.js +1 -1
  98. package/optimize/lib/components/index.js +11 -0
  99. package/optimize/lib/components/markdown_editor/markdown_format.styles.js +3 -6
  100. package/optimize/lib/components/overlay_mask/overlay_mask.styles.js +1 -1
  101. package/optimize/lib/components/page/page_sidebar/page_sidebar.js +2 -4
  102. package/optimize/lib/components/page_template/page_template.js +2 -24
  103. package/optimize/lib/components/text/text.styles.js +3 -6
  104. package/optimize/lib/components/text_truncate/index.js +25 -0
  105. package/optimize/lib/components/text_truncate/text_truncate.js +158 -0
  106. package/optimize/lib/components/text_truncate/text_truncate.styles.js +54 -0
  107. package/optimize/lib/components/text_truncate/utils.js +342 -0
  108. package/optimize/lib/global_styling/functions/typography.js +8 -8
  109. package/optimize/lib/global_styling/variables/typography.js +3 -3
  110. package/optimize/lib/services/theme/context.js +3 -1
  111. package/optimize/lib/services/theme/hooks.js +21 -2
  112. package/optimize/lib/services/theme/index.js +6 -0
  113. package/optimize/lib/services/theme/provider.js +62 -35
  114. package/optimize/lib/themes/amsterdam/global_styling/variables/_typography.js +1 -0
  115. package/package.json +1 -1
  116. package/src/components/datagrid/_data_grid.scss +13 -2
  117. package/src/components/datagrid/controls/_data_grid_keyboard_shortcuts.scss +1 -7
  118. package/src/components/index.scss +0 -1
  119. package/src/global_styling/mixins/_header.scss +2 -0
  120. package/test-env/components/accordion/accordion.js +28 -8
  121. package/test-env/components/accordion/accordion.styles.js +31 -10
  122. package/test-env/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +10 -2
  123. package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +10 -26
  124. package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +10 -1
  125. package/test-env/components/datagrid/controls/keyboard_shortcuts.js +1 -0
  126. package/test-env/components/description_list/description_list.js +37 -3
  127. package/test-env/components/flyout/flyout.styles.js +1 -1
  128. package/test-env/components/header/header.js +113 -23
  129. package/test-env/components/header/header.styles.js +1 -1
  130. package/test-env/components/index.js +11 -0
  131. package/test-env/components/markdown_editor/markdown_format.styles.js +3 -6
  132. package/test-env/components/overlay_mask/overlay_mask.styles.js +1 -1
  133. package/test-env/components/page/page_sidebar/page_sidebar.js +2 -4
  134. package/test-env/components/page_template/page_template.js +2 -24
  135. package/test-env/components/text/text.styles.js +3 -6
  136. package/test-env/components/text_truncate/index.js +25 -0
  137. package/test-env/components/text_truncate/text_truncate.js +236 -0
  138. package/test-env/components/text_truncate/text_truncate.styles.js +54 -0
  139. package/test-env/components/text_truncate/utils.js +342 -0
  140. package/test-env/global_styling/functions/typography.js +8 -8
  141. package/test-env/global_styling/variables/typography.js +3 -3
  142. package/test-env/services/theme/context.js +3 -1
  143. package/test-env/services/theme/hooks.js +21 -2
  144. package/test-env/services/theme/index.js +6 -0
  145. package/test-env/services/theme/provider.js +62 -35
  146. package/test-env/themes/amsterdam/global_styling/variables/_typography.js +1 -0
  147. package/src/components/accordion/_accordion_form.scss +0 -40
  148. package/src/components/accordion/_index.scss +0 -1
@@ -1,4 +1,17 @@
1
- var _excluded = ["children", "className", "sections", "position", "theme"];
1
+ 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); }
2
+ var _excluded = ["children", "className", "sections", "position", "theme"],
3
+ _excluded2 = ["children", "style"];
4
+ 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; }
5
+ 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; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ 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."); }
11
+ 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); }
12
+ 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; }
13
+ 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; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2
15
  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); }
3
16
  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; }
4
17
  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; }
@@ -10,13 +23,14 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
10
23
  * Side Public License, v 1.
11
24
  */
12
25
 
13
- import React, { useEffect } from 'react';
26
+ import React, { useEffect, useState, useMemo, useCallback } from 'react';
14
27
  import PropTypes from "prop-types";
15
28
  import classNames from 'classnames';
16
- import { useEuiTheme } from '../../services';
29
+ import { useEuiTheme, useEuiThemeCSSVariables } from '../../services';
30
+ import { mathWithUnits, logicalStyles } from '../../global_styling';
17
31
  import { EuiHeaderBreadcrumbs } from './header_breadcrumbs';
18
32
  import { EuiHeaderSectionItem, EuiHeaderSection } from './header_section';
19
- import { euiHeaderStyles } from './header.styles';
33
+ import { euiHeaderStyles, euiHeaderVariables } from './header.styles';
20
34
  import { jsx as ___EmotionJSX } from "@emotion/react";
21
35
  var createHeaderSection = function createHeaderSection(sections) {
22
36
  return sections.map(function (section, index) {
@@ -25,8 +39,6 @@ var createHeaderSection = function createHeaderSection(sections) {
25
39
  }, section);
26
40
  });
27
41
  };
28
- // Start a counter to manage the total number of fixed headers that need the body class
29
- var euiHeaderFixedCounter = 0;
30
42
  export var EuiHeader = function EuiHeader(_ref) {
31
43
  var children = _ref.children,
32
44
  className = _ref.className,
@@ -40,22 +52,6 @@ export var EuiHeader = function EuiHeader(_ref) {
40
52
  var euiTheme = useEuiTheme();
41
53
  var styles = euiHeaderStyles(euiTheme);
42
54
  var cssStyles = [styles.euiHeader, styles[position], styles[theme]];
43
- useEffect(function () {
44
- if (position === 'fixed') {
45
- // Increment fixed header counter for each fixed header
46
- euiHeaderFixedCounter++;
47
- document.body.classList.add('euiBody--headerIsFixed');
48
- document.body.dataset.fixedHeaders = String(euiHeaderFixedCounter);
49
- return function () {
50
- // Both decrement the fixed counter AND then check if there are none
51
- if (--euiHeaderFixedCounter === 0) {
52
- // If there are none, THEN remove class
53
- document.body.classList.remove('euiBody--headerIsFixed');
54
- delete document.body.dataset.fixedHeaders;
55
- }
56
- };
57
- }
58
- }, [position]);
59
55
  var contents;
60
56
  if (sections) {
61
57
  if (children) {
@@ -84,12 +80,22 @@ export var EuiHeader = function EuiHeader(_ref) {
84
80
  } else {
85
81
  contents = children;
86
82
  }
87
- return ___EmotionJSX("div", _extends({
83
+ return position === 'fixed' ? ___EmotionJSX(EuiFixedHeader, _extends({
84
+ css: cssStyles,
85
+ className: classes
86
+ }, rest), contents) : ___EmotionJSX("div", _extends({
88
87
  css: cssStyles,
89
- className: classes,
90
- "data-fixed-header": position === 'fixed' || undefined // Used by EuiFlyouts as a query selector
88
+ className: classes
91
89
  }, rest), contents);
92
90
  };
91
+
92
+ /**
93
+ * Fixed headers - logic around dynamically calculating the total
94
+ * page offset and setting the `top` position of subsequent headers
95
+ */
96
+
97
+ // Start a counter to manage the total number of fixed headers
98
+ // Exported for unit testing only
93
99
  EuiHeader.propTypes = {
94
100
  className: PropTypes.string,
95
101
  "aria-label": PropTypes.string,
@@ -126,4 +132,93 @@ EuiHeader.propTypes = {
126
132
  * Or, force the header into pseudo `dark` theme for all themes.
127
133
  */
128
134
  theme: PropTypes.oneOf(["default", "dark"])
135
+ };
136
+ export var euiFixedHeadersCount = 0;
137
+
138
+ // Exported for unit testing only
139
+ export var EuiFixedHeader = function EuiFixedHeader(_ref2) {
140
+ var children = _ref2.children,
141
+ style = _ref2.style,
142
+ rest = _objectWithoutProperties(_ref2, _excluded2);
143
+ var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
144
+ setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
145
+ var euiTheme = useEuiTheme();
146
+ var headerHeight = euiHeaderVariables(euiTheme).height;
147
+ var getHeaderOffset = useCallback(function () {
148
+ return mathWithUnits(headerHeight, function (x) {
149
+ return x * euiFixedHeadersCount;
150
+ });
151
+ }, [headerHeight]);
152
+ var _useState = useState(),
153
+ _useState2 = _slicedToArray(_useState, 2),
154
+ topPosition = _useState2[0],
155
+ setTopPosition = _useState2[1];
156
+ useEffect(function () {
157
+ // Get the top position from the offset of previous header(s)
158
+ setTopPosition(getHeaderOffset());
159
+
160
+ // Increment fixed header counter for each fixed header
161
+ euiFixedHeadersCount++;
162
+ setGlobalCSSVariables({
163
+ '--euiFixedHeadersOffset': getHeaderOffset()
164
+ });
165
+ document.body.classList.add('euiBody--headerIsFixed'); // TODO: Consider deleting this legacy className
166
+
167
+ return function () {
168
+ euiFixedHeadersCount--;
169
+ setGlobalCSSVariables({
170
+ '--euiFixedHeadersOffset': getHeaderOffset()
171
+ });
172
+ if (euiFixedHeadersCount === 0) {
173
+ document.body.classList.remove('euiBody--headerIsFixed'); // TODO: Consider deleting this legacy className
174
+ }
175
+ };
176
+ }, [getHeaderOffset, setGlobalCSSVariables]);
177
+ var inlineStyles = useMemo(function () {
178
+ return logicalStyles(_objectSpread({
179
+ top: topPosition
180
+ }, style));
181
+ }, [topPosition, style]);
182
+ return ___EmotionJSX("div", _extends({
183
+ "data-fixed-header": true // Used by EuiFlyouts as a query selector
184
+ ,
185
+ style: inlineStyles
186
+ }, rest), children);
187
+ };
188
+ EuiFixedHeader.propTypes = {
189
+ className: PropTypes.string,
190
+ "aria-label": PropTypes.string,
191
+ "data-test-subj": PropTypes.string,
192
+ css: PropTypes.any,
193
+ /**
194
+ * An array of objects to wrap in a #EuiHeaderSection.
195
+ * Each section is spaced using `space-between`.
196
+ * See #EuiHeaderSectionsProp for object details.
197
+ * This prop disregards the prop `children` if both are passed.
198
+ */
199
+ sections: PropTypes.arrayOf(PropTypes.shape({
200
+ /**
201
+ * An arry of items that will be wrapped in a #EuiHeaderSectionItem
202
+ */
203
+ items: PropTypes.arrayOf(PropTypes.node.isRequired),
204
+ /**
205
+ * Breadcrumbs in the header cannot be wrapped in a #EuiHeaderSection in order for truncation to work.
206
+ * Simply pass the array of EuiBreadcrumb objects
207
+ */
208
+ breadcrumbs: PropTypes.arrayOf(PropTypes.any.isRequired),
209
+ /**
210
+ * Other props to pass to #EuiHeaderBreadcrumbs
211
+ */
212
+ breadcrumbProps: PropTypes.any
213
+ }).isRequired),
214
+ /**
215
+ * Helper that positions the header against the window body and
216
+ * adds the correct amount of top padding to the window when in `fixed` mode
217
+ */
218
+ position: PropTypes.oneOf(["static", "fixed"]),
219
+ /**
220
+ * The `default` will inherit its coloring from the light or dark theme.
221
+ * Or, force the header into pseudo `dark` theme for all themes.
222
+ */
223
+ theme: PropTypes.oneOf(["default", "dark"])
129
224
  };
@@ -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), " &+[data-fixed-header]{", logicalCSS('top', height), ";};label:fixed;"),
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;")
@@ -88,6 +88,7 @@ export * from './basic_table';
88
88
  export * from './tabs';
89
89
  export * from './text';
90
90
  export * from './text_diff';
91
+ export * from './text_truncate';
91
92
  export * from './timeline';
92
93
  export * from './title';
93
94
  export * from './toast';
@@ -17,8 +17,8 @@ var euiScaleMarkdownFormatText = function euiScaleMarkdownFormatText(euiTheme, o
17
17
  var _euiFontSize = euiFontSize(euiTheme, 'm', options),
18
18
  fontSize = _euiFontSize.fontSize,
19
19
  lineHeight = _euiFontSize.lineHeight;
20
- var measurement = options.measurement;
21
- var lineHeightSize = measurement === 'em' ? "".concat(lineHeight, "em") : lineHeight;
20
+ var unit = options.unit;
21
+ var lineHeightSize = unit === 'em' ? "".concat(lineHeight, "em") : lineHeight;
22
22
 
23
23
  // Custom scales
24
24
  var tablePaddingVertical = mathWithUnits(fontSize, function (x) {
@@ -39,19 +39,16 @@ export var euiMarkdownFormatStyles = function euiMarkdownFormatStyles(euiTheme)
39
39
  euiMarkdownFormat: /*#__PURE__*/css(";label:euiMarkdownFormat;"),
40
40
  // Text sizes
41
41
  m: /*#__PURE__*/css(euiScaleMarkdownFormatText(euiTheme, {
42
- measurement: 'rem',
43
42
  customScale: 'm'
44
43
  }), ";;label:m;"),
45
44
  s: /*#__PURE__*/css(euiScaleMarkdownFormatText(euiTheme, {
46
- measurement: 'rem',
47
45
  customScale: 's'
48
46
  }), ";;label:s;"),
49
47
  xs: /*#__PURE__*/css(euiScaleMarkdownFormatText(euiTheme, {
50
- measurement: 'rem',
51
48
  customScale: 'xs'
52
49
  }), ";;label:xs;"),
53
50
  relative: /*#__PURE__*/css(euiScaleMarkdownFormatText(euiTheme, {
54
- measurement: 'em'
51
+ unit: 'em'
55
52
  }), ";;label:relative;")
56
53
  };
57
54
  };
@@ -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', "".concat(euiTheme.base * 3, "px")), ";;label:belowHeader;")
17
+ belowHeader: /*#__PURE__*/css("z-index:", euiTheme.levels.maskBelowHeader, ";", logicalCSS('top', 'var(--euiFixedHeadersOffset, 0)'), ";;label:belowHeader;")
18
18
  };
19
19
  };
@@ -54,10 +54,8 @@ export var EuiPageSidebar = function EuiPageSidebar(_ref) {
54
54
  useLayoutEffect(function () {
55
55
  var updatedStyles = _objectSpread(_objectSpread({}, style), logicalStyle('min-width', isResponding ? '100%' : minWidth));
56
56
  if (sticky) {
57
- var _document$body$datase;
58
- var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
59
- var offset = _typeof(sticky) === 'object' ? sticky === null || sticky === void 0 ? void 0 : sticky.offset : themeContext.euiTheme.base * 3 * euiHeaderFixedCounter;
60
- updatedStyles = _objectSpread(_objectSpread(_objectSpread({}, updatedStyles), logicalStyle('top', offset)), logicalStyle('max-height', "calc(100vh - ".concat(offset, "px)")));
57
+ var offset = _typeof(sticky) === 'object' ? "".concat(sticky === null || sticky === void 0 ? void 0 : sticky.offset, "px") : 'var(--euiFixedHeadersOffset, 0)';
58
+ updatedStyles = _objectSpread(_objectSpread(_objectSpread({}, updatedStyles), logicalStyle('top', offset)), logicalStyle('max-height', "calc(100vh - ".concat(offset, ")")));
61
59
  }
62
60
  setInlineStyles(updatedStyles);
63
61
  }, [style, sticky, themeContext.euiTheme.base, isResponding, minWidth]);
@@ -6,12 +6,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
7
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
8
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
- 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."); }
11
- 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); }
12
- 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; }
13
- 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; } }
14
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
9
  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; }
16
10
  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; }
17
11
  /*
@@ -22,7 +16,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
22
16
  * Side Public License, v 1.
23
17
  */
24
18
 
25
- import React, { createContext, useContext, useEffect, useState } from 'react';
19
+ import React, { createContext, useContext } from 'react';
26
20
  import PropTypes from "prop-types";
27
21
  import classNames from 'classnames';
28
22
  import { _EuiPageOuter as EuiPageOuter } from './outer';
@@ -30,7 +24,7 @@ import { _EuiPageInner as EuiPageInner } from './inner';
30
24
  import { _EuiPageBottomBar as EuiPageBottomBar } from './bottom_bar/page_bottom_bar';
31
25
  import { _EuiPageEmptyPrompt as EuiPageEmptyPrompt } from './empty_prompt/page_empty_prompt';
32
26
  import { EuiPageHeader, EuiPageSection, EuiPageSidebar } from '../page';
33
- import { useEuiTheme, useGeneratedHtmlId } from '../../services';
27
+ import { useGeneratedHtmlId } from '../../services';
34
28
  import { logicalStyle } from '../../global_styling';
35
29
  import { jsx as ___EmotionJSX } from "@emotion/react";
36
30
  export var TemplateContext = /*#__PURE__*/createContext({
@@ -39,14 +33,6 @@ export var TemplateContext = /*#__PURE__*/createContext({
39
33
  emptyPrompt: {},
40
34
  bottomBar: {}
41
35
  });
42
- var calculateOffset = function calculateOffset(base) {
43
- var _document$body$datase;
44
- if (typeof document === 'undefined') return 0; // SSR catch
45
-
46
- var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
47
- return base * 3 * euiHeaderFixedCounter;
48
- };
49
-
50
36
  /**
51
37
  * Consumed via `EuiPageTemplate`,
52
38
  * it controls and propogates most of the shared props per direct child
@@ -62,7 +48,7 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
62
48
  _ref$grow = _ref.grow,
63
49
  grow = _ref$grow === void 0 ? true : _ref$grow,
64
50
  bottomBorder = _ref.bottomBorder,
65
- _offset = _ref.offset,
51
+ offset = _ref.offset,
66
52
  panelled = _ref.panelled,
67
53
  contentBorder = _ref.contentBorder,
68
54
  component = _ref.component,
@@ -71,14 +57,6 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
71
57
  _ref$minHeight = _ref.minHeight,
72
58
  minHeight = _ref$minHeight === void 0 ? '460px' : _ref$minHeight,
73
59
  rest = _objectWithoutProperties(_ref, _excluded);
74
- var _useEuiTheme = useEuiTheme(),
75
- euiTheme = _useEuiTheme.euiTheme;
76
- var _useState = useState(function () {
77
- return _offset !== null && _offset !== void 0 ? _offset : calculateOffset(euiTheme.base);
78
- }),
79
- _useState2 = _slicedToArray(_useState, 2),
80
- offset = _useState2[0],
81
- setOffset = _useState2[1];
82
60
  var templateContext = useContext(TemplateContext);
83
61
 
84
62
  // Used as a target to insert the bottom bar component
@@ -86,11 +64,6 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
86
64
  prefix: 'EuiPageTemplateInner',
87
65
  conditionalId: mainProps === null || mainProps === void 0 ? void 0 : mainProps.id
88
66
  });
89
- useEffect(function () {
90
- if (_offset === undefined) {
91
- setOffset(calculateOffset(euiTheme.base));
92
- }
93
- }, [_offset, euiTheme.base]);
94
67
 
95
68
  // Sections include page header
96
69
  var sections = [];
@@ -149,7 +122,7 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
149
122
  });
150
123
  var _minHeight = grow ? "max(".concat(minHeight, ", 100vh)") : minHeight;
151
124
  var classes = classNames('euiPageTemplate', className);
152
- var pageStyle = _objectSpread(_objectSpread(_objectSpread({}, logicalStyle('min-height', _minHeight)), logicalStyle('padding-top', offset)), rest.style);
125
+ var pageStyle = _objectSpread(_objectSpread(_objectSpread({}, logicalStyle('min-height', _minHeight)), logicalStyle('padding-top', offset !== null && offset !== void 0 ? offset : 'var(--euiFixedHeadersOffset, 0)')), rest.style);
153
126
  templateContext.header = getHeaderProps();
154
127
  templateContext.section = getSectionProps();
155
128
  templateContext.emptyPrompt = {
@@ -33,9 +33,9 @@ var euiScaleText = function euiScaleText(euiThemeContext, options) {
33
33
  fontSize = _euiFontSize.fontSize,
34
34
  lineHeight = _euiFontSize.lineHeight;
35
35
  var euiTheme = euiThemeContext.euiTheme;
36
- var measurement = options.measurement,
36
+ var unit = options.unit,
37
37
  _customScale = options.customScale;
38
- var lineHeightSize = measurement === 'em' ? "".concat(lineHeight, "em") : lineHeight;
38
+ var lineHeightSize = unit === 'em' ? "".concat(lineHeight, "em") : lineHeight;
39
39
  var headings = {
40
40
  h1: euiTitle(euiThemeContext, 'l', options),
41
41
  h2: euiTitle(euiThemeContext, 'm', options),
@@ -71,19 +71,16 @@ export var euiTextStyles = function euiTextStyles(euiThemeContext) {
71
71
  constrainedWidth: /*#__PURE__*/css(logicalCSS('max-width', euiTextConstrainedMaxWidth), ";;label:constrainedWidth;"),
72
72
  // Sizes
73
73
  m: /*#__PURE__*/css(euiScaleText(euiThemeContext, {
74
- measurement: 'rem',
75
74
  customScale: 'm'
76
75
  }), ";;label:m;"),
77
76
  s: /*#__PURE__*/css(euiScaleText(euiThemeContext, {
78
- measurement: 'rem',
79
77
  customScale: 's'
80
78
  }), ";;label:s;"),
81
79
  xs: /*#__PURE__*/css(euiScaleText(euiThemeContext, {
82
- measurement: 'rem',
83
80
  customScale: 'xs'
84
81
  }), ";;label:xs;"),
85
82
  relative: /*#__PURE__*/css(euiScaleText(euiThemeContext, {
86
- measurement: 'em'
83
+ unit: 'em'
87
84
  }), ";;label:relative;")
88
85
  };
89
86
  };
@@ -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,232 @@
1
+ var _excluded = ["width"],
2
+ _excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "containerRef", "measurementRenderAPI"],
3
+ _excluded3 = ["onResize"];
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ 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."); }
6
+ 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); }
7
+ 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; }
8
+ 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; } }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ 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); }
11
+ 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; }
12
+ 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; }
13
+ /*
14
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
15
+ * or more contributor license agreements. Licensed under the Elastic License
16
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
17
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
18
+ * Side Public License, v 1.
19
+ */
20
+
21
+ import React, { useState, useMemo, useCallback } from 'react';
22
+ import PropTypes from "prop-types";
23
+ import { useCombinedRefs } from '../../services';
24
+ import { EuiResizeObserver } from '../observer/resize_observer';
25
+ import { TruncationUtilsWithDOM, TruncationUtilsWithCanvas } from './utils';
26
+ import { euiTextTruncateStyles } from './text_truncate.styles';
27
+ import { jsx as ___EmotionJSX } from "@emotion/react";
28
+ var TRUNCATION_TYPES = ['end', 'start', 'startEnd', 'middle'];
29
+ export var EuiTextTruncate = function EuiTextTruncate(_ref) {
30
+ var width = _ref.width,
31
+ props = _objectWithoutProperties(_ref, _excluded);
32
+ return width != null ? ___EmotionJSX(EuiTextTruncateWithWidth, _extends({
33
+ width: width
34
+ }, props)) : ___EmotionJSX(EuiTextTruncateWithResizeObserver, props);
35
+ };
36
+ EuiTextTruncate.propTypes = {
37
+ className: PropTypes.string,
38
+ "aria-label": PropTypes.string,
39
+ "data-test-subj": PropTypes.string,
40
+ css: PropTypes.any,
41
+ /**
42
+ * The full text string to truncate
43
+ */
44
+ text: PropTypes.string.isRequired,
45
+ /**
46
+ * The truncation type desired. Determines where the ellipses are placed.
47
+ */
48
+ truncation: PropTypes.any,
49
+ /**
50
+ * This prop **only** applies to the `start` and `end` truncation types.
51
+ * It allows preserving a certain number of characters of either the
52
+ * starting or ending text.
53
+ *
54
+ * If the passed offset is greater than the total text length,
55
+ * the offset will be ignored.
56
+ */
57
+ truncationOffset: PropTypes.number,
58
+ /**
59
+ * This prop **only** applies to the `startEnd` truncation type.
60
+ * It allows customizing the anchor position of the displayed text,
61
+ * which otherwise defaults to the middle of the text string.
62
+ *
63
+ * The primary use case for this prop for is search highlighting - e.g., if
64
+ * a user searches for a specific word in the text, pass the index of that
65
+ * found word to ensure it is always visible.
66
+ *
67
+ * This behavior will intelligently detect when positions are close to the start
68
+ * or end of the text, and omit leading or trailing ellipses when necessary.
69
+ * If the passed position is greater than the total text length,
70
+ * the truncation will simply default to `start` instead.
71
+ */
72
+ truncationPosition: PropTypes.number,
73
+ /**
74
+ * Defaults to the horizontal ellipsis character.
75
+ * Can be optionally configured to use other punctuation,
76
+ * e.g. spaces, brackets, hyphens, asterisks, etc.
77
+ */
78
+ ellipsis: PropTypes.string,
79
+ /**
80
+ * By default, EuiTextTruncate will render a resize observer to detect the
81
+ * available width it has. For performance reasons (e.g. multiple truncated
82
+ * text items within the same container), you may opt to pass in your own
83
+ * container width, which will skip initializing a resize observer.
84
+ */
85
+ width: PropTypes.number,
86
+ /**
87
+ * Optional callback that fires when the default resizer observer both mounts and
88
+ * registers a size change. This callback will **not** fire if `width` is passed.
89
+ */
90
+ onResize: PropTypes.func,
91
+ /**
92
+ * By default, EuiTextTruncate will calculate its truncation via DOM manipulation
93
+ * and measurement, which has the benefit of automatically inheriting font styles.
94
+ * However, if this approach proves to have a significant performance impact for your
95
+ * usage, consider using the `canvas` API instead, which is more performant.
96
+ *
97
+ * Please note that there are minute pixel to subpixel differences between the
98
+ * two options due to different rendering engines.
99
+ */
100
+ measurementRenderAPI: PropTypes.oneOf(["dom", "canvas"]),
101
+ /**
102
+ * By default, EuiTextTruncate will render the truncated string directly.
103
+ * You can optionally pass a render prop function to the component, which
104
+ * allows for more flexible text rendering, e.g. adding custom markup
105
+ * or highlighting
106
+ */
107
+ children: PropTypes.func
108
+ };
109
+ var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
110
+ var width = _ref2.width,
111
+ children = _ref2.children,
112
+ text = _ref2.text,
113
+ _ref2$truncation = _ref2.truncation,
114
+ _truncation = _ref2$truncation === void 0 ? 'end' : _ref2$truncation,
115
+ _ref2$truncationOffse = _ref2.truncationOffset,
116
+ _truncationOffset = _ref2$truncationOffse === void 0 ? 0 : _ref2$truncationOffse,
117
+ truncationPosition = _ref2.truncationPosition,
118
+ _ref2$ellipsis = _ref2.ellipsis,
119
+ ellipsis = _ref2$ellipsis === void 0 ? '…' : _ref2$ellipsis,
120
+ containerRef = _ref2.containerRef,
121
+ _ref2$measurementRend = _ref2.measurementRenderAPI,
122
+ measurementRenderAPI = _ref2$measurementRend === void 0 ? 'dom' : _ref2$measurementRend,
123
+ rest = _objectWithoutProperties(_ref2, _excluded2);
124
+ // Note: This needs to be a state and not a ref to trigger a rerender on mount
125
+ var _useState = useState(null),
126
+ _useState2 = _slicedToArray(_useState, 2),
127
+ containerEl = _useState2[0],
128
+ setContainerEl = _useState2[1];
129
+ var refs = useCombinedRefs([setContainerEl, containerRef]);
130
+
131
+ // Handle exceptions where we need to override the passed props
132
+ var _useMemo = useMemo(function () {
133
+ var truncation = _truncation;
134
+ var truncationOffset = 0;
135
+ if (_truncation === 'end' || _truncation === 'start') {
136
+ if (0 < _truncationOffset && _truncationOffset < text.length) {
137
+ truncationOffset = _truncationOffset;
138
+ }
139
+ } else if (_truncation === 'startEnd' && truncationPosition != null) {
140
+ if (truncationPosition <= 0) {
141
+ truncation = 'end';
142
+ } else if (truncationPosition >= text.length) {
143
+ truncation = 'start';
144
+ }
145
+ }
146
+ return {
147
+ truncation: truncation,
148
+ truncationOffset: truncationOffset
149
+ };
150
+ }, [_truncation, _truncationOffset, truncationPosition, text.length]),
151
+ truncation = _useMemo.truncation,
152
+ truncationOffset = _useMemo.truncationOffset;
153
+ var truncatedText = useMemo(function () {
154
+ var truncatedText = '';
155
+ if (!containerEl || !width) return truncatedText;
156
+ var params = {
157
+ fullText: text,
158
+ ellipsis: ellipsis,
159
+ container: containerEl,
160
+ availableWidth: width
161
+ };
162
+ var utils = measurementRenderAPI === 'canvas' ? new TruncationUtilsWithCanvas(params) : new TruncationUtilsWithDOM(params);
163
+ if (utils.checkIfTruncationIsNeeded() === false) {
164
+ truncatedText = text;
165
+ } else if (utils.checkSufficientEllipsisWidth(truncation) === false) {
166
+ truncatedText = '';
167
+ } else {
168
+ switch (truncation) {
169
+ case 'end':
170
+ truncatedText = utils.truncateEnd(truncationOffset);
171
+ break;
172
+ case 'start':
173
+ truncatedText = utils.truncateStart(truncationOffset);
174
+ break;
175
+ case 'startEnd':
176
+ if (truncationPosition == null) {
177
+ truncatedText = utils.truncateStartEndAtMiddle();
178
+ } else {
179
+ truncatedText = utils.truncateStartEndAtPosition(truncationPosition);
180
+ }
181
+ break;
182
+ case 'middle':
183
+ truncatedText = utils.truncateMiddle();
184
+ break;
185
+ }
186
+ }
187
+ if (measurementRenderAPI === 'dom') {
188
+ utils.cleanup();
189
+ }
190
+ return truncatedText;
191
+ }, [width, text, truncation, truncationOffset, truncationPosition, ellipsis, containerEl, measurementRenderAPI]);
192
+ var isTruncating = truncatedText !== text;
193
+ return ___EmotionJSX("div", _extends({
194
+ css: euiTextTruncateStyles.euiTextTruncate,
195
+ ref: refs,
196
+ title: isTruncating ? text : undefined
197
+ }, rest), isTruncating ? ___EmotionJSX(React.Fragment, null, ___EmotionJSX("span", {
198
+ css: euiTextTruncateStyles.truncatedText,
199
+ "aria-hidden": true,
200
+ "data-test-subj": "truncatedText"
201
+ }, children ? children(truncatedText) : truncatedText), ___EmotionJSX("span", {
202
+ css: euiTextTruncateStyles.fullText,
203
+ "data-test-subj": "fullText"
204
+ }, text)) : ___EmotionJSX("span", {
205
+ "data-test-subj": "fullText"
206
+ }, text));
207
+ };
208
+ EuiTextTruncateWithWidth.propTypes = {
209
+ width: PropTypes.number.isRequired,
210
+ containerRef: PropTypes.any
211
+ };
212
+ var EuiTextTruncateWithResizeObserver = function EuiTextTruncateWithResizeObserver(_ref3) {
213
+ var _onResize = _ref3.onResize,
214
+ props = _objectWithoutProperties(_ref3, _excluded3);
215
+ var _useState3 = useState(0),
216
+ _useState4 = _slicedToArray(_useState3, 2),
217
+ width = _useState4[0],
218
+ setWidth = _useState4[1];
219
+ var onResize = useCallback(function (_ref4) {
220
+ var width = _ref4.width;
221
+ setWidth(width);
222
+ _onResize === null || _onResize === void 0 ? void 0 : _onResize(width);
223
+ }, [_onResize]);
224
+ return ___EmotionJSX(EuiResizeObserver, {
225
+ onResize: onResize
226
+ }, function (ref) {
227
+ return ___EmotionJSX(EuiTextTruncateWithWidth, _extends({
228
+ width: width,
229
+ containerRef: ref
230
+ }, props));
231
+ });
232
+ };