@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
@@ -62,10 +62,8 @@ var EuiPageSidebar = function EuiPageSidebar(_ref) {
62
62
  (0, _react.useLayoutEffect)(function () {
63
63
  var updatedStyles = _objectSpread(_objectSpread({}, style), (0, _global_styling.logicalStyle)('min-width', isResponding ? '100%' : minWidth));
64
64
  if (sticky) {
65
- var _document$body$datase;
66
- var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
67
- var offset = _typeof(sticky) === 'object' ? sticky === null || sticky === void 0 ? void 0 : sticky.offset : themeContext.euiTheme.base * 3 * euiHeaderFixedCounter;
68
- updatedStyles = _objectSpread(_objectSpread(_objectSpread({}, updatedStyles), (0, _global_styling.logicalStyle)('top', offset)), (0, _global_styling.logicalStyle)('max-height', "calc(100vh - ".concat(offset, "px)")));
65
+ var offset = _typeof(sticky) === 'object' ? "".concat(sticky === null || sticky === void 0 ? void 0 : sticky.offset, "px") : 'var(--euiFixedHeadersOffset, 0)';
66
+ updatedStyles = _objectSpread(_objectSpread(_objectSpread({}, updatedStyles), (0, _global_styling.logicalStyle)('top', offset)), (0, _global_styling.logicalStyle)('max-height', "calc(100vh - ".concat(offset, ")")));
69
67
  }
70
68
  setInlineStyles(updatedStyles);
71
69
  }, [style, sticky, themeContext.euiTheme.base, isResponding, minWidth]);
@@ -33,12 +33,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
33
33
  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; }
34
34
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
35
35
  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); }
36
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
37
- 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."); }
38
- 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); }
39
- 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; }
40
- 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; } }
41
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
42
36
  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; }
43
37
  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; }
44
38
  var TemplateContext = /*#__PURE__*/(0, _react.createContext)({
@@ -48,14 +42,6 @@ var TemplateContext = /*#__PURE__*/(0, _react.createContext)({
48
42
  bottomBar: {}
49
43
  });
50
44
  exports.TemplateContext = TemplateContext;
51
- var calculateOffset = function calculateOffset(base) {
52
- var _document$body$datase;
53
- if (typeof document === 'undefined') return 0; // SSR catch
54
-
55
- var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
56
- return base * 3 * euiHeaderFixedCounter;
57
- };
58
-
59
45
  /**
60
46
  * Consumed via `EuiPageTemplate`,
61
47
  * it controls and propogates most of the shared props per direct child
@@ -71,7 +57,7 @@ var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
71
57
  _ref$grow = _ref.grow,
72
58
  grow = _ref$grow === void 0 ? true : _ref$grow,
73
59
  bottomBorder = _ref.bottomBorder,
74
- _offset = _ref.offset,
60
+ offset = _ref.offset,
75
61
  panelled = _ref.panelled,
76
62
  contentBorder = _ref.contentBorder,
77
63
  component = _ref.component,
@@ -80,14 +66,6 @@ var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
80
66
  _ref$minHeight = _ref.minHeight,
81
67
  minHeight = _ref$minHeight === void 0 ? '460px' : _ref$minHeight,
82
68
  rest = _objectWithoutProperties(_ref, _excluded);
83
- var _useEuiTheme = (0, _services.useEuiTheme)(),
84
- euiTheme = _useEuiTheme.euiTheme;
85
- var _useState = (0, _react.useState)(function () {
86
- return _offset !== null && _offset !== void 0 ? _offset : calculateOffset(euiTheme.base);
87
- }),
88
- _useState2 = _slicedToArray(_useState, 2),
89
- offset = _useState2[0],
90
- setOffset = _useState2[1];
91
69
  var templateContext = (0, _react.useContext)(TemplateContext);
92
70
 
93
71
  // Used as a target to insert the bottom bar component
@@ -95,11 +73,6 @@ var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
95
73
  prefix: 'EuiPageTemplateInner',
96
74
  conditionalId: mainProps === null || mainProps === void 0 ? void 0 : mainProps.id
97
75
  });
98
- (0, _react.useEffect)(function () {
99
- if (_offset === undefined) {
100
- setOffset(calculateOffset(euiTheme.base));
101
- }
102
- }, [_offset, euiTheme.base]);
103
76
 
104
77
  // Sections include page header
105
78
  var sections = [];
@@ -158,7 +131,7 @@ var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
158
131
  });
159
132
  var _minHeight = grow ? "max(".concat(minHeight, ", 100vh)") : minHeight;
160
133
  var classes = (0, _classnames.default)('euiPageTemplate', className);
161
- var pageStyle = _objectSpread(_objectSpread(_objectSpread({}, (0, _global_styling.logicalStyle)('min-height', _minHeight)), (0, _global_styling.logicalStyle)('padding-top', offset)), rest.style);
134
+ var pageStyle = _objectSpread(_objectSpread(_objectSpread({}, (0, _global_styling.logicalStyle)('min-height', _minHeight)), (0, _global_styling.logicalStyle)('padding-top', offset !== null && offset !== void 0 ? offset : 'var(--euiFixedHeadersOffset, 0)')), rest.style);
162
135
  templateContext.header = getHeaderProps();
163
136
  templateContext.section = getSectionProps();
164
137
  templateContext.emptyPrompt = {
@@ -40,9 +40,9 @@ var euiScaleText = function euiScaleText(euiThemeContext, options) {
40
40
  fontSize = _euiFontSize.fontSize,
41
41
  lineHeight = _euiFontSize.lineHeight;
42
42
  var euiTheme = euiThemeContext.euiTheme;
43
- var measurement = options.measurement,
43
+ var unit = options.unit,
44
44
  _customScale = options.customScale;
45
- var lineHeightSize = measurement === 'em' ? "".concat(lineHeight, "em") : lineHeight;
45
+ var lineHeightSize = unit === 'em' ? "".concat(lineHeight, "em") : lineHeight;
46
46
  var headings = {
47
47
  h1: (0, _title.euiTitle)(euiThemeContext, 'l', options),
48
48
  h2: (0, _title.euiTitle)(euiThemeContext, 'm', options),
@@ -78,19 +78,16 @@ var euiTextStyles = function euiTextStyles(euiThemeContext) {
78
78
  constrainedWidth: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('max-width', euiTextConstrainedMaxWidth), ";;label:constrainedWidth;"),
79
79
  // Sizes
80
80
  m: /*#__PURE__*/(0, _react.css)(euiScaleText(euiThemeContext, {
81
- measurement: 'rem',
82
81
  customScale: 'm'
83
82
  }), ";;label:m;"),
84
83
  s: /*#__PURE__*/(0, _react.css)(euiScaleText(euiThemeContext, {
85
- measurement: 'rem',
86
84
  customScale: 's'
87
85
  }), ";;label:s;"),
88
86
  xs: /*#__PURE__*/(0, _react.css)(euiScaleText(euiThemeContext, {
89
- measurement: 'rem',
90
87
  customScale: 'xs'
91
88
  }), ";;label:xs;"),
92
89
  relative: /*#__PURE__*/(0, _react.css)(euiScaleText(euiThemeContext, {
93
- measurement: 'em'
90
+ unit: 'em'
94
91
  }), ";;label:relative;")
95
92
  };
96
93
  };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EuiTextTruncate", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _text_truncate.EuiTextTruncate;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "TruncationUtilsWithCanvas", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _utils.TruncationUtilsWithCanvas;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "TruncationUtilsWithDOM", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _utils.TruncationUtilsWithDOM;
22
+ }
23
+ });
24
+ var _text_truncate = require("./text_truncate");
25
+ var _utils = require("./utils");
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.EuiTextTruncate = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _services = require("../../services");
11
+ var _resize_observer = require("../observer/resize_observer");
12
+ var _utils = require("./utils");
13
+ var _text_truncate = require("./text_truncate.styles");
14
+ var _react2 = require("@emotion/react");
15
+ var _excluded = ["width"],
16
+ _excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "containerRef", "measurementRenderAPI"],
17
+ _excluded3 = ["onResize"];
18
+ /*
19
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
20
+ * or more contributor license agreements. Licensed under the Elastic License
21
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
22
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
23
+ * Side Public License, v 1.
24
+ */
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+ 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."); }
30
+ 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); }
31
+ 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; }
32
+ 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; } }
33
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
+ 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); }
35
+ 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; }
36
+ 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; }
37
+ var TRUNCATION_TYPES = ['end', 'start', 'startEnd', 'middle'];
38
+ var EuiTextTruncate = function EuiTextTruncate(_ref) {
39
+ var width = _ref.width,
40
+ props = _objectWithoutProperties(_ref, _excluded);
41
+ return width != null ? (0, _react2.jsx)(EuiTextTruncateWithWidth, _extends({
42
+ width: width
43
+ }, props)) : (0, _react2.jsx)(EuiTextTruncateWithResizeObserver, props);
44
+ };
45
+ exports.EuiTextTruncate = EuiTextTruncate;
46
+ EuiTextTruncate.propTypes = {
47
+ className: _propTypes.default.string,
48
+ "aria-label": _propTypes.default.string,
49
+ "data-test-subj": _propTypes.default.string,
50
+ css: _propTypes.default.any,
51
+ /**
52
+ * The full text string to truncate
53
+ */
54
+ text: _propTypes.default.string.isRequired,
55
+ /**
56
+ * The truncation type desired. Determines where the ellipses are placed.
57
+ */
58
+ truncation: _propTypes.default.any,
59
+ /**
60
+ * This prop **only** applies to the `start` and `end` truncation types.
61
+ * It allows preserving a certain number of characters of either the
62
+ * starting or ending text.
63
+ *
64
+ * If the passed offset is greater than the total text length,
65
+ * the offset will be ignored.
66
+ */
67
+ truncationOffset: _propTypes.default.number,
68
+ /**
69
+ * This prop **only** applies to the `startEnd` truncation type.
70
+ * It allows customizing the anchor position of the displayed text,
71
+ * which otherwise defaults to the middle of the text string.
72
+ *
73
+ * The primary use case for this prop for is search highlighting - e.g., if
74
+ * a user searches for a specific word in the text, pass the index of that
75
+ * found word to ensure it is always visible.
76
+ *
77
+ * This behavior will intelligently detect when positions are close to the start
78
+ * or end of the text, and omit leading or trailing ellipses when necessary.
79
+ * If the passed position is greater than the total text length,
80
+ * the truncation will simply default to `start` instead.
81
+ */
82
+ truncationPosition: _propTypes.default.number,
83
+ /**
84
+ * Defaults to the horizontal ellipsis character.
85
+ * Can be optionally configured to use other punctuation,
86
+ * e.g. spaces, brackets, hyphens, asterisks, etc.
87
+ */
88
+ ellipsis: _propTypes.default.string,
89
+ /**
90
+ * By default, EuiTextTruncate will render a resize observer to detect the
91
+ * available width it has. For performance reasons (e.g. multiple truncated
92
+ * text items within the same container), you may opt to pass in your own
93
+ * container width, which will skip initializing a resize observer.
94
+ */
95
+ width: _propTypes.default.number,
96
+ /**
97
+ * Optional callback that fires when the default resizer observer both mounts and
98
+ * registers a size change. This callback will **not** fire if `width` is passed.
99
+ */
100
+ onResize: _propTypes.default.func,
101
+ /**
102
+ * By default, EuiTextTruncate will calculate its truncation via DOM manipulation
103
+ * and measurement, which has the benefit of automatically inheriting font styles.
104
+ * However, if this approach proves to have a significant performance impact for your
105
+ * usage, consider using the `canvas` API instead, which is more performant.
106
+ *
107
+ * Please note that there are minute pixel to subpixel differences between the
108
+ * two options due to different rendering engines.
109
+ */
110
+ measurementRenderAPI: _propTypes.default.oneOf(["dom", "canvas"]),
111
+ /**
112
+ * By default, EuiTextTruncate will render the truncated string directly.
113
+ * You can optionally pass a render prop function to the component, which
114
+ * allows for more flexible text rendering, e.g. adding custom markup
115
+ * or highlighting
116
+ */
117
+ children: _propTypes.default.func
118
+ };
119
+ var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
120
+ var width = _ref2.width,
121
+ children = _ref2.children,
122
+ text = _ref2.text,
123
+ _ref2$truncation = _ref2.truncation,
124
+ _truncation = _ref2$truncation === void 0 ? 'end' : _ref2$truncation,
125
+ _ref2$truncationOffse = _ref2.truncationOffset,
126
+ _truncationOffset = _ref2$truncationOffse === void 0 ? 0 : _ref2$truncationOffse,
127
+ truncationPosition = _ref2.truncationPosition,
128
+ _ref2$ellipsis = _ref2.ellipsis,
129
+ ellipsis = _ref2$ellipsis === void 0 ? '…' : _ref2$ellipsis,
130
+ containerRef = _ref2.containerRef,
131
+ _ref2$measurementRend = _ref2.measurementRenderAPI,
132
+ measurementRenderAPI = _ref2$measurementRend === void 0 ? 'dom' : _ref2$measurementRend,
133
+ rest = _objectWithoutProperties(_ref2, _excluded2);
134
+ // Note: This needs to be a state and not a ref to trigger a rerender on mount
135
+ var _useState = (0, _react.useState)(null),
136
+ _useState2 = _slicedToArray(_useState, 2),
137
+ containerEl = _useState2[0],
138
+ setContainerEl = _useState2[1];
139
+ var refs = (0, _services.useCombinedRefs)([setContainerEl, containerRef]);
140
+
141
+ // Handle exceptions where we need to override the passed props
142
+ var _useMemo = (0, _react.useMemo)(function () {
143
+ var truncation = _truncation;
144
+ var truncationOffset = 0;
145
+ if (_truncation === 'end' || _truncation === 'start') {
146
+ if (0 < _truncationOffset && _truncationOffset < text.length) {
147
+ truncationOffset = _truncationOffset;
148
+ }
149
+ } else if (_truncation === 'startEnd' && truncationPosition != null) {
150
+ if (truncationPosition <= 0) {
151
+ truncation = 'end';
152
+ } else if (truncationPosition >= text.length) {
153
+ truncation = 'start';
154
+ }
155
+ }
156
+ return {
157
+ truncation: truncation,
158
+ truncationOffset: truncationOffset
159
+ };
160
+ }, [_truncation, _truncationOffset, truncationPosition, text.length]),
161
+ truncation = _useMemo.truncation,
162
+ truncationOffset = _useMemo.truncationOffset;
163
+ var truncatedText = (0, _react.useMemo)(function () {
164
+ var truncatedText = '';
165
+ if (!containerEl || !width) return truncatedText;
166
+ var params = {
167
+ fullText: text,
168
+ ellipsis: ellipsis,
169
+ container: containerEl,
170
+ availableWidth: width
171
+ };
172
+ var utils = measurementRenderAPI === 'canvas' ? new _utils.TruncationUtilsWithCanvas(params) : new _utils.TruncationUtilsWithDOM(params);
173
+ if (utils.checkIfTruncationIsNeeded() === false) {
174
+ truncatedText = text;
175
+ } else if (utils.checkSufficientEllipsisWidth(truncation) === false) {
176
+ truncatedText = '';
177
+ } else {
178
+ switch (truncation) {
179
+ case 'end':
180
+ truncatedText = utils.truncateEnd(truncationOffset);
181
+ break;
182
+ case 'start':
183
+ truncatedText = utils.truncateStart(truncationOffset);
184
+ break;
185
+ case 'startEnd':
186
+ if (truncationPosition == null) {
187
+ truncatedText = utils.truncateStartEndAtMiddle();
188
+ } else {
189
+ truncatedText = utils.truncateStartEndAtPosition(truncationPosition);
190
+ }
191
+ break;
192
+ case 'middle':
193
+ truncatedText = utils.truncateMiddle();
194
+ break;
195
+ }
196
+ }
197
+ if (measurementRenderAPI === 'dom') {
198
+ utils.cleanup();
199
+ }
200
+ return truncatedText;
201
+ }, [width, text, truncation, truncationOffset, truncationPosition, ellipsis, containerEl, measurementRenderAPI]);
202
+ var isTruncating = truncatedText !== text;
203
+ return (0, _react2.jsx)("div", _extends({
204
+ css: _text_truncate.euiTextTruncateStyles.euiTextTruncate,
205
+ ref: refs,
206
+ title: isTruncating ? text : undefined
207
+ }, rest), isTruncating ? (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
208
+ css: _text_truncate.euiTextTruncateStyles.truncatedText,
209
+ "aria-hidden": true,
210
+ "data-test-subj": "truncatedText"
211
+ }, children ? children(truncatedText) : truncatedText), (0, _react2.jsx)("span", {
212
+ css: _text_truncate.euiTextTruncateStyles.fullText,
213
+ "data-test-subj": "fullText"
214
+ }, text)) : (0, _react2.jsx)("span", {
215
+ "data-test-subj": "fullText"
216
+ }, text));
217
+ };
218
+ EuiTextTruncateWithWidth.propTypes = {
219
+ width: _propTypes.default.number.isRequired,
220
+ containerRef: _propTypes.default.any
221
+ };
222
+ var EuiTextTruncateWithResizeObserver = function EuiTextTruncateWithResizeObserver(_ref3) {
223
+ var _onResize = _ref3.onResize,
224
+ props = _objectWithoutProperties(_ref3, _excluded3);
225
+ var _useState3 = (0, _react.useState)(0),
226
+ _useState4 = _slicedToArray(_useState3, 2),
227
+ width = _useState4[0],
228
+ setWidth = _useState4[1];
229
+ var onResize = (0, _react.useCallback)(function (_ref4) {
230
+ var width = _ref4.width;
231
+ setWidth(width);
232
+ _onResize === null || _onResize === void 0 ? void 0 : _onResize(width);
233
+ }, [_onResize]);
234
+ return (0, _react2.jsx)(_resize_observer.EuiResizeObserver, {
235
+ onResize: onResize
236
+ }, function (ref) {
237
+ return (0, _react2.jsx)(EuiTextTruncateWithWidth, _extends({
238
+ width: width,
239
+ containerRef: ref
240
+ }, props));
241
+ });
242
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.euiTextTruncateStyles = void 0;
7
+ var _react = require("@emotion/react");
8
+ 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)."; } /*
9
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
+ * or more contributor license agreements. Licensed under the Elastic License
11
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
12
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
13
+ * Side Public License, v 1.
14
+ */
15
+ var euiTextTruncateStyles = {
16
+ euiTextTruncate: process.env.NODE_ENV === "production" ? {
17
+ name: "7o5qnz-euiTextTruncate",
18
+ styles: "position:relative;overflow:hidden;white-space:nowrap;label:euiTextTruncate;"
19
+ } : {
20
+ name: "7o5qnz-euiTextTruncate",
21
+ styles: "position:relative;overflow:hidden;white-space:nowrap;label:euiTextTruncate;",
22
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
23
+ },
24
+ /**
25
+ * The below CSS is a hack to get double clicking and selecting the *full* text
26
+ * instead of the truncated text (useful for copying/pasting, and mimics how
27
+ * `text-overflow: ellipsis` works).
28
+ *
29
+ * Real talk: I'm lowkey amazed it works and it wouldn't surprise me if we ran into
30
+ * cross-browser issues with this at some point. Hopefully CSS natively implements
31
+ * custom text truncation some day (https://github.com/w3c/csswg-drafts/issues/3937)
32
+ * and there'll be no need for the entire component at that point 🙏
33
+ */
34
+ // Makes the truncated text unselectable/un-clickable
35
+ truncatedText: process.env.NODE_ENV === "production" ? {
36
+ name: "1dore6v-truncatedText",
37
+ styles: "user-select:none;pointer-events:none;label:truncatedText;"
38
+ } : {
39
+ name: "1dore6v-truncatedText",
40
+ styles: "user-select:none;pointer-events:none;label:truncatedText;",
41
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
42
+ },
43
+ // Positions the full text on top of the truncated text (so that clicking targets it)
44
+ // and gives it a color opacity of 0 so that it's not actually visible
45
+ fullText: process.env.NODE_ENV === "production" ? {
46
+ name: "1kxt4rj-fullText",
47
+ styles: "position:absolute;inset:0;overflow:hidden;color:rgba(0, 0, 0, 0);@supports (-webkit-hyphens: none){text-overflow:ellipsis;};label:fullText;"
48
+ } : {
49
+ name: "1kxt4rj-fullText",
50
+ styles: "position:absolute;inset:0;overflow:hidden;color:rgba(0, 0, 0, 0);@supports (-webkit-hyphens: none){text-overflow:ellipsis;};label:fullText;",
51
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
52
+ }
53
+ };
54
+ exports.euiTextTruncateStyles = euiTextTruncateStyles;