@elastic/eui 88.5.0 → 88.5.2

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 (107) hide show
  1. package/dist/eui_theme_dark.css +8 -21
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +8 -21
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/collapsible_nav_beta/collapsible_nav_beta.js +20 -6
  6. package/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +4 -14
  7. package/es/components/collapsible_nav_beta/collapsible_nav_body_footer.js +57 -0
  8. package/es/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +25 -0
  9. package/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +156 -0
  10. package/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +19 -0
  11. package/es/components/collapsible_nav_beta/collapsible_nav_group/index.js +9 -0
  12. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +3 -7
  13. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +3 -7
  14. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +4 -8
  15. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +16 -63
  16. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +2 -10
  17. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +122 -41
  18. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -3
  19. package/es/components/combo_box/combo_box.js +12 -25
  20. package/es/components/combo_box/combo_box_input/combo_box_input.js +61 -54
  21. package/es/components/text_truncate/index.js +1 -1
  22. package/es/components/text_truncate/utils.js +88 -138
  23. package/es/services/canvas/canvas_text_utils.js +64 -0
  24. package/es/services/canvas/index.js +9 -0
  25. package/es/services/index.js +1 -0
  26. package/eui.d.ts +186 -105
  27. package/i18ntokens.json +8 -8
  28. package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +20 -6
  29. package/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +11 -19
  30. package/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.js +67 -0
  31. package/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +33 -0
  32. package/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +166 -0
  33. package/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +26 -0
  34. package/lib/components/collapsible_nav_beta/collapsible_nav_group/index.js +12 -0
  35. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +3 -7
  36. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +3 -7
  37. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +4 -8
  38. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +14 -61
  39. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +1 -9
  40. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +122 -39
  41. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -4
  42. package/lib/components/combo_box/combo_box.js +12 -25
  43. package/lib/components/combo_box/combo_box_input/combo_box_input.js +60 -53
  44. package/lib/components/text_truncate/index.js +0 -6
  45. package/lib/components/text_truncate/utils.js +97 -148
  46. package/lib/services/canvas/canvas_text_utils.js +70 -0
  47. package/lib/services/canvas/index.js +12 -0
  48. package/lib/services/index.js +8 -0
  49. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +17 -3
  50. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +4 -14
  51. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_body_footer.js +56 -0
  52. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +25 -0
  53. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +48 -0
  54. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +19 -0
  55. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_group/index.js +9 -0
  56. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +7 -33
  57. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +2 -10
  58. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +54 -21
  59. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -3
  60. package/optimize/es/components/combo_box/combo_box.js +12 -25
  61. package/optimize/es/components/combo_box/combo_box_input/combo_box_input.js +61 -53
  62. package/optimize/es/components/text_truncate/index.js +1 -1
  63. package/optimize/es/components/text_truncate/utils.js +87 -137
  64. package/optimize/es/services/canvas/canvas_text_utils.js +60 -0
  65. package/optimize/es/services/canvas/index.js +9 -0
  66. package/optimize/es/services/index.js +1 -0
  67. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +15 -1
  68. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +11 -19
  69. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.js +66 -0
  70. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +33 -0
  71. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +58 -0
  72. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +26 -0
  73. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_group/index.js +12 -0
  74. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +5 -31
  75. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +1 -9
  76. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +54 -20
  77. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -4
  78. package/optimize/lib/components/combo_box/combo_box.js +12 -25
  79. package/optimize/lib/components/combo_box/combo_box_input/combo_box_input.js +60 -52
  80. package/optimize/lib/components/text_truncate/index.js +0 -6
  81. package/optimize/lib/components/text_truncate/utils.js +96 -147
  82. package/optimize/lib/services/canvas/canvas_text_utils.js +67 -0
  83. package/optimize/lib/services/canvas/index.js +12 -0
  84. package/optimize/lib/services/index.js +8 -0
  85. package/package.json +2 -5
  86. package/src/components/combo_box/_combo_box.scss +12 -19
  87. package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +20 -6
  88. package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +11 -19
  89. package/test-env/components/collapsible_nav_beta/collapsible_nav_body_footer.js +66 -0
  90. package/test-env/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +33 -0
  91. package/test-env/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +165 -0
  92. package/test-env/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +26 -0
  93. package/test-env/components/collapsible_nav_beta/collapsible_nav_group/index.js +12 -0
  94. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +3 -7
  95. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +3 -7
  96. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +4 -8
  97. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +14 -61
  98. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +1 -9
  99. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +122 -39
  100. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -4
  101. package/test-env/components/combo_box/combo_box.js +12 -25
  102. package/test-env/components/combo_box/combo_box_input/combo_box_input.js +60 -53
  103. package/test-env/components/text_truncate/index.js +0 -6
  104. package/test-env/components/text_truncate/utils.js +96 -147
  105. package/test-env/services/canvas/canvas_text_utils.js +30 -0
  106. package/test-env/services/canvas/index.js +12 -0
  107. package/test-env/services/index.js +8 -0
@@ -4,101 +4,50 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TruncationUtils = exports.CanvasTextUtils = void 0;
7
+ exports.TruncationUtils = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
12
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
13
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
12
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
15
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
16
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
+ var _canvas = require("../../services/canvas");
18
19
  var _excluded = ["fullText", "ellipsis", "availableWidth"];
19
20
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
20
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
- /*
22
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
- * or more contributor license agreements. Licensed under the Elastic License
24
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
25
- * in compliance with, at your election, the Elastic License 2.0 or the Server
26
- * Side Public License, v 1.
27
- */
28
- /**
29
- * Under the hood, a temporary Canvas element is created for manipulating text
30
- * & determining text width.
31
- *
32
- * To accurately measure text, canvas rendering requires either a container to
33
- * compute/derive font styles from, or a static font string (useful for usage
34
- * outside the DOM). Particular care should be applied when fallback fonts are
35
- * used, as more fallback fonts can lead to less precision.
36
- *
37
- * Please note that while canvas is more significantly more performant than DOM
38
- * measurement, there are subpixel to single digit pixel differences between
39
- * DOM and canvas measurement due to the different rendering engines used.
40
- */
41
- var CanvasTextUtils = /*#__PURE__*/function () {
42
- function CanvasTextUtils(_ref) {
43
- var _this = this;
44
- var font = _ref.font,
45
- container = _ref.container;
46
- (0, _classCallCheck2.default)(this, CanvasTextUtils);
47
- (0, _defineProperty2.default)(this, "context", void 0);
48
- (0, _defineProperty2.default)(this, "currentText", '');
49
- (0, _defineProperty2.default)(this, "computeFontFromElement", function (element) {
50
- var computedStyles = window.getComputedStyle(element);
51
- // TODO: font-stretch is not included even though it potentially should be
52
- // @see https://developer.mozilla.org/en-US/docs/Web/CSS/font#constituent_properties
53
- // It appears to be unsupported and/or breaks font computation in canvas
54
- return ['font-style', 'font-variant', 'font-weight', 'font-size', 'font-family'].map(function (prop) {
55
- return computedStyles.getPropertyValue(prop);
56
- }).join(' ').trim();
57
- });
58
- (0, _defineProperty2.default)(this, "setTextToCheck", function (text) {
59
- _this.currentText = text;
60
- });
61
- this.context = document.createElement('canvas').getContext('2d');
62
-
63
- // Set the canvas font to ensure text width calculations are correct
64
- if (font) {
65
- this.context.font = font;
66
- } else if (container) {
67
- this.context.font = this.computeFontFromElement(container);
68
- }
69
- }
70
- (0, _createClass2.default)(CanvasTextUtils, [{
71
- key: "textWidth",
72
- get: function get() {
73
- return this.context.measureText(this.currentText).width;
74
- }
75
- }]);
76
- return CanvasTextUtils;
77
- }();
21
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /*
22
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
+ * or more contributor license agreements. Licensed under the Elastic License
24
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
25
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
26
+ * Side Public License, v 1.
27
+ */
78
28
  /**
79
29
  * Utilities for truncating types at various positions, as well as
80
30
  * determining whether truncation is possible or even necessary.
81
31
  */
82
- exports.CanvasTextUtils = CanvasTextUtils;
83
32
  var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
84
33
  (0, _inherits2.default)(TruncationUtils, _CanvasTextUtils);
85
34
  var _super = _createSuper(TruncationUtils);
86
- function TruncationUtils(_ref2) {
87
- var _this2;
88
- var fullText = _ref2.fullText,
89
- ellipsis = _ref2.ellipsis,
90
- _availableWidth = _ref2.availableWidth,
91
- rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
35
+ function TruncationUtils(_ref) {
36
+ var _this;
37
+ var fullText = _ref.fullText,
38
+ ellipsis = _ref.ellipsis,
39
+ _availableWidth = _ref.availableWidth,
40
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
92
41
  (0, _classCallCheck2.default)(this, TruncationUtils);
93
- _this2 = _super.call(this, rest);
94
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "fullText", void 0);
95
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "ellipsis", void 0);
96
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "availableWidth", void 0);
42
+ _this = _super.call(this, rest);
43
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fullText", void 0);
44
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "ellipsis", void 0);
45
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "availableWidth", void 0);
97
46
  /**
98
47
  * Performance utilities
99
48
  */
100
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "debugPerformance", false);
101
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "debugCounter", 0);
49
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "debugPerformance", false);
50
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "debugCounter", 0);
102
51
  /**
103
52
  * Internal utils for calculating a ratio based on the passed available width
104
53
  * vs the full text width.
@@ -106,21 +55,21 @@ var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
106
55
  * be slightly over the available width, which we can then remove from
107
56
  * character-by-character until the text just fits within the available width.
108
57
  */
109
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "widthRatio", 0);
110
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "setTextWidthRatio", function () {
111
- var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this2.fullText;
58
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "widthRatio", 0);
59
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setTextWidthRatio", function () {
60
+ var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.fullText;
112
61
  var textToOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
113
62
  // Account for reduced available width due to (e.g.) truncation offset
114
- var availableWidth = _this2.availableWidth;
63
+ var availableWidth = _this.availableWidth;
115
64
  if (textToOffset) {
116
- _this2.setTextToCheck(textToOffset);
117
- availableWidth = availableWidth - _this2.textWidth;
65
+ _this.setTextToCheck(textToOffset);
66
+ availableWidth = availableWidth - _this.textWidth;
118
67
  }
119
- _this2.setTextToCheck(text);
120
- _this2.widthRatio = availableWidth / _this2.textWidth;
68
+ _this.setTextToCheck(text);
69
+ _this.widthRatio = availableWidth / _this.textWidth;
121
70
  });
122
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "getTextFromRatio", function (text, type) {
123
- var characterRatio = Math.ceil(text.length * _this2.widthRatio);
71
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getTextFromRatio", function (text, type) {
72
+ var characterRatio = Math.ceil(text.length * _this.widthRatio);
124
73
  var index = type === 'start' ? text.length - characterRatio : characterRatio;
125
74
  var _splitText$at = splitText(text).at(index),
126
75
  _splitText$at2 = (0, _slicedToArray2.default)(_splitText$at, 2),
@@ -131,24 +80,24 @@ var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
131
80
  /**
132
81
  * Early return checks
133
82
  */
134
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "checkIfTruncationIsNeeded", function () {
135
- _this2.setTextToCheck(_this2.fullText);
136
- if (_this2.availableWidth >= _this2.textWidth) {
83
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "checkIfTruncationIsNeeded", function () {
84
+ _this.setTextToCheck(_this.fullText);
85
+ if (_this.availableWidth >= _this.textWidth) {
137
86
  return false;
138
87
  }
139
88
  });
140
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "checkSufficientEllipsisWidth", function (truncation) {
141
- var textToCheck = truncation === 'startEnd' ? "".concat(_this2.ellipsis, " ").concat(_this2.ellipsis) // startEnd needs a little more space
142
- : _this2.ellipsis;
143
- _this2.setTextToCheck(textToCheck);
144
- if (_this2.textWidth >= _this2.availableWidth * 0.9) {
89
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "checkSufficientEllipsisWidth", function (truncation) {
90
+ var textToCheck = truncation === 'startEnd' ? "".concat(_this.ellipsis, " ").concat(_this.ellipsis) // startEnd needs a little more space
91
+ : _this.ellipsis;
92
+ _this.setTextToCheck(textToCheck);
93
+ if (_this.textWidth >= _this.availableWidth * 0.9) {
145
94
  console.error('The truncation ellipsis is larger than the available width. No text can be rendered.');
146
95
  return false;
147
96
  }
148
97
  });
149
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "checkTruncationOffsetWidth", function (text) {
150
- _this2.setTextToCheck(text);
151
- if (_this2.textWidth > _this2.availableWidth) {
98
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "checkTruncationOffsetWidth", function (text) {
99
+ _this.setTextToCheck(text);
100
+ if (_this.textWidth > _this.availableWidth) {
152
101
  console.error('The passed truncationOffset is too large for the available width. Truncating the offset instead.');
153
102
  return false;
154
103
  }
@@ -156,19 +105,19 @@ var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
156
105
  /**
157
106
  * Truncation types logic. This is where the magic happens
158
107
  */
159
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "truncateStart", function (truncationOffset) {
160
- var truncatedText = _this2.fullText;
108
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "truncateStart", function (truncationOffset) {
109
+ var truncatedText = _this.fullText;
161
110
  var leadingText = '';
162
111
  var combinedText = function combinedText() {
163
112
  return leadingText + truncatedText;
164
113
  };
165
114
  if (truncationOffset) {
166
- var _splitText$at3 = splitText(_this2.fullText).at(truncationOffset);
115
+ var _splitText$at3 = splitText(_this.fullText).at(truncationOffset);
167
116
  var _splitText$at4 = (0, _slicedToArray2.default)(_splitText$at3, 2);
168
117
  leadingText = _splitText$at4[0];
169
118
  truncatedText = _splitText$at4[1];
170
- var widthCheck = leadingText + _this2.ellipsis;
171
- if (_this2.checkTruncationOffsetWidth(widthCheck) === false) {
119
+ var widthCheck = leadingText + _this.ellipsis;
120
+ if (_this.checkTruncationOffsetWidth(widthCheck) === false) {
172
121
  truncatedText = leadingText;
173
122
  leadingText = '';
174
123
  }
@@ -176,30 +125,30 @@ var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
176
125
 
177
126
  // Get text width ratio width accounting for any truncation offset text,
178
127
  // and guesstimate an initial truncated string
179
- _this2.setTextWidthRatio(truncatedText, leadingText);
180
- truncatedText = _this2.getTextFromRatio(truncatedText, 'start');
181
- leadingText += _this2.ellipsis;
182
- _this2.setTextToCheck(combinedText());
183
- while (_this2.textWidth > _this2.availableWidth) {
128
+ _this.setTextWidthRatio(truncatedText, leadingText);
129
+ truncatedText = _this.getTextFromRatio(truncatedText, 'start');
130
+ leadingText += _this.ellipsis;
131
+ _this.setTextToCheck(combinedText());
132
+ while (_this.textWidth > _this.availableWidth) {
184
133
  truncatedText = removeFirstCharacter(truncatedText);
185
- _this2.setTextToCheck(combinedText());
134
+ _this.setTextToCheck(combinedText());
186
135
  }
187
136
  return combinedText();
188
137
  });
189
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "truncateEnd", function (truncationOffset) {
190
- var truncatedText = _this2.fullText;
138
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "truncateEnd", function (truncationOffset) {
139
+ var truncatedText = _this.fullText;
191
140
  var trailingText = '';
192
141
  var combinedText = function combinedText() {
193
142
  return truncatedText + trailingText;
194
143
  };
195
144
  if (truncationOffset) {
196
- var index = _this2.fullText.length - truncationOffset;
197
- var _splitText$at5 = splitText(_this2.fullText).at(index);
145
+ var index = _this.fullText.length - truncationOffset;
146
+ var _splitText$at5 = splitText(_this.fullText).at(index);
198
147
  var _splitText$at6 = (0, _slicedToArray2.default)(_splitText$at5, 2);
199
148
  truncatedText = _splitText$at6[0];
200
149
  trailingText = _splitText$at6[1];
201
- var widthCheck = _this2.ellipsis + trailingText;
202
- if (_this2.checkTruncationOffsetWidth(widthCheck) === false) {
150
+ var widthCheck = _this.ellipsis + trailingText;
151
+ if (_this.checkTruncationOffsetWidth(widthCheck) === false) {
203
152
  truncatedText = trailingText;
204
153
  trailingText = '';
205
154
  }
@@ -207,78 +156,78 @@ var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
207
156
 
208
157
  // Get text width ratio width accounting for any truncation offset text,
209
158
  // and guesstimate an initial truncated string
210
- _this2.setTextWidthRatio(truncatedText, trailingText);
211
- truncatedText = _this2.getTextFromRatio(truncatedText, 'end');
212
- trailingText = _this2.ellipsis + trailingText;
213
- _this2.setTextToCheck(combinedText());
214
- while (_this2.textWidth > _this2.availableWidth) {
159
+ _this.setTextWidthRatio(truncatedText, trailingText);
160
+ truncatedText = _this.getTextFromRatio(truncatedText, 'end');
161
+ trailingText = _this.ellipsis + trailingText;
162
+ _this.setTextToCheck(combinedText());
163
+ while (_this.textWidth > _this.availableWidth) {
215
164
  truncatedText = removeLastCharacter(truncatedText);
216
- _this2.setTextToCheck(combinedText());
165
+ _this.setTextToCheck(combinedText());
217
166
  }
218
167
  return combinedText();
219
168
  });
220
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "truncateStartEndAtPosition", function (truncationPosition) {
169
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "truncateStartEndAtPosition", function (truncationPosition) {
221
170
  // Split the text from the anchor position, using the width ratio
222
171
  // to get the starting and ending indices from the position
223
- _this2.setTextWidthRatio();
224
- var characterRatio = Math.floor(_this2.fullText.length * _this2.widthRatio / 2);
172
+ _this.setTextWidthRatio();
173
+ var characterRatio = Math.floor(_this.fullText.length * _this.widthRatio / 2);
225
174
  var truncateStart = truncationPosition - characterRatio;
226
175
  var truncateEnd = truncationPosition + characterRatio;
227
176
 
228
177
  // If either of the approximate start/end truncation indices go beyond the
229
178
  // bounds of the actual text, we can simply use end or start truncation instead
230
179
  if (truncateStart < 0) {
231
- return _this2.truncateEnd();
180
+ return _this.truncateEnd();
232
181
  }
233
- if (truncateEnd >= _this2.fullText.length) {
234
- return _this2.truncateStart();
182
+ if (truncateEnd >= _this.fullText.length) {
183
+ return _this.truncateStart();
235
184
  }
236
- var truncatedText = _this2.fullText.substring(truncateStart, truncateEnd);
185
+ var truncatedText = _this.fullText.substring(truncateStart, truncateEnd);
237
186
  var combinedText = function combinedText() {
238
- return _this2.ellipsis + truncatedText + _this2.ellipsis;
187
+ return _this.ellipsis + truncatedText + _this.ellipsis;
239
188
  };
240
- _this2.setTextToCheck(combinedText());
189
+ _this.setTextToCheck(combinedText());
241
190
  var alternating;
242
- while (_this2.textWidth > _this2.availableWidth) {
191
+ while (_this.textWidth > _this.availableWidth) {
243
192
  truncatedText = alternating ? removeLastCharacter(truncatedText) : removeFirstCharacter(truncatedText);
244
193
  alternating = !alternating;
245
- _this2.setTextToCheck(combinedText());
194
+ _this.setTextToCheck(combinedText());
246
195
  }
247
196
  return combinedText();
248
197
  });
249
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "truncateStartEndAtMiddle", function () {
250
- var middlePosition = Math.floor(_this2.fullText.length / 2);
251
- return _this2.truncateStartEndAtPosition(middlePosition);
198
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "truncateStartEndAtMiddle", function () {
199
+ var middlePosition = Math.floor(_this.fullText.length / 2);
200
+ return _this.truncateStartEndAtPosition(middlePosition);
252
201
  });
253
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "truncateMiddle", function () {
254
- var middlePosition = Math.floor(_this2.fullText.length / 2);
255
- var _splitText$at7 = splitText(_this2.fullText).at(middlePosition),
202
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "truncateMiddle", function () {
203
+ var middlePosition = Math.floor(_this.fullText.length / 2);
204
+ var _splitText$at7 = splitText(_this.fullText).at(middlePosition),
256
205
  _splitText$at8 = (0, _slicedToArray2.default)(_splitText$at7, 2),
257
206
  firstHalf = _splitText$at8[0],
258
207
  secondHalf = _splitText$at8[1];
259
- _this2.setTextWidthRatio();
260
- firstHalf = _this2.getTextFromRatio(firstHalf, 'end');
261
- secondHalf = _this2.getTextFromRatio(secondHalf, 'start');
208
+ _this.setTextWidthRatio();
209
+ firstHalf = _this.getTextFromRatio(firstHalf, 'end');
210
+ secondHalf = _this.getTextFromRatio(secondHalf, 'start');
262
211
  var combinedText = function combinedText() {
263
- return firstHalf + _this2.ellipsis + secondHalf;
212
+ return firstHalf + _this.ellipsis + secondHalf;
264
213
  };
265
- _this2.setTextToCheck(combinedText());
214
+ _this.setTextToCheck(combinedText());
266
215
  var alternating;
267
- while (_this2.textWidth > _this2.availableWidth) {
216
+ while (_this.textWidth > _this.availableWidth) {
268
217
  alternating = !alternating;
269
218
  if (alternating) {
270
219
  firstHalf = removeLastCharacter(firstHalf);
271
220
  } else {
272
221
  secondHalf = removeFirstCharacter(secondHalf);
273
222
  }
274
- _this2.setTextToCheck(combinedText());
223
+ _this.setTextToCheck(combinedText());
275
224
  }
276
225
  return combinedText();
277
226
  });
278
- _this2.fullText = fullText;
279
- _this2.ellipsis = ellipsis;
280
- _this2.availableWidth = _availableWidth;
281
- return _this2;
227
+ _this.fullText = fullText;
228
+ _this.ellipsis = ellipsis;
229
+ _this.availableWidth = _availableWidth;
230
+ return _this;
282
231
  }
283
232
  (0, _createClass2.default)(TruncationUtils, [{
284
233
  key: "textWidth",
@@ -290,7 +239,7 @@ var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
290
239
  }
291
240
  }]);
292
241
  return TruncationUtils;
293
- }(CanvasTextUtils);
242
+ }(_canvas.CanvasTextUtils);
294
243
  /**
295
244
  * DRY character/substring utils
296
245
  */
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CanvasTextUtils = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ /*
12
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
13
+ * or more contributor license agreements. Licensed under the Elastic License
14
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
15
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
16
+ * Side Public License, v 1.
17
+ */
18
+ /**
19
+ * Creates a temporary Canvas element for manipulating text & determining text width.
20
+ *
21
+ * To accurately measure text, canvas rendering requires either a container to
22
+ * compute/derive font styles from, or a static font string (useful for usage
23
+ * outside the DOM). Particular care should be applied when fallback fonts are
24
+ * used, as more fallback fonts can lead to less precision.
25
+ *
26
+ * Please note that while canvas is more significantly more performant than DOM
27
+ * measurement, there are subpixel to single digit pixel differences between
28
+ * DOM and canvas measurement due to the different rendering engines used.
29
+ */
30
+ var CanvasTextUtils = /*#__PURE__*/function () {
31
+ function CanvasTextUtils(_ref) {
32
+ var _this = this;
33
+ var font = _ref.font,
34
+ container = _ref.container;
35
+ (0, _classCallCheck2.default)(this, CanvasTextUtils);
36
+ (0, _defineProperty2.default)(this, "context", void 0);
37
+ (0, _defineProperty2.default)(this, "currentText", '');
38
+ (0, _defineProperty2.default)(this, "computeFontFromElement", function (element) {
39
+ var computedStyles = window.getComputedStyle(element);
40
+ // TODO: font-stretch is not included even though it potentially should be
41
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/font#constituent_properties
42
+ // It appears to be unsupported and/or breaks font computation in canvas
43
+ return ['font-style', 'font-variant', 'font-weight', 'font-size', 'font-family'].map(function (prop) {
44
+ return computedStyles.getPropertyValue(prop);
45
+ }).join(' ').trim();
46
+ });
47
+ (0, _defineProperty2.default)(this, "setTextToCheck", function (text) {
48
+ _this.currentText = text;
49
+ });
50
+ this.context = document.createElement('canvas').getContext('2d');
51
+
52
+ // Set the canvas font to ensure text width calculations are correct
53
+ if (font) {
54
+ this.context.font = font;
55
+ } else if (container) {
56
+ this.context.font = this.computeFontFromElement(container);
57
+ }
58
+ }
59
+ (0, _createClass2.default)(CanvasTextUtils, [{
60
+ key: "textWidth",
61
+ get: function get() {
62
+ return this.context.measureText(this.currentText).width;
63
+ }
64
+ }]);
65
+ return CanvasTextUtils;
66
+ }();
67
+ exports.CanvasTextUtils = CanvasTextUtils;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CanvasTextUtils", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _canvas_text_utils.CanvasTextUtils;
10
+ }
11
+ });
12
+ var _canvas_text_utils = require("./canvas_text_utils");
@@ -20,6 +20,7 @@ var _exportNames = {
20
20
  useIsWithinBreakpoints: true,
21
21
  useIsWithinMaxBreakpoint: true,
22
22
  useIsWithinMinBreakpoint: true,
23
+ CanvasTextUtils: true,
23
24
  brighten: true,
24
25
  calculateContrast: true,
25
26
  calculateLuminance: true,
@@ -97,6 +98,12 @@ Object.defineProperty(exports, "CENTER_ALIGNMENT", {
97
98
  return _alignment.CENTER_ALIGNMENT;
98
99
  }
99
100
  });
101
+ Object.defineProperty(exports, "CanvasTextUtils", {
102
+ enumerable: true,
103
+ get: function get() {
104
+ return _canvas.CanvasTextUtils;
105
+ }
106
+ });
100
107
  Object.defineProperty(exports, "Comparators", {
101
108
  enumerable: true,
102
109
  get: function get() {
@@ -601,6 +608,7 @@ exports.keys = keys;
601
608
  var _accessibility = require("./accessibility");
602
609
  var _alignment = require("./alignment");
603
610
  var _breakpoint = require("./breakpoint");
611
+ var _canvas = require("./canvas");
604
612
  var _color = require("./color");
605
613
  var _color_picker = require("./color_picker");
606
614
  var _console = require("./console");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elastic/eui",
3
3
  "description": "Elastic UI Component Library",
4
- "version": "88.5.0",
4
+ "version": "88.5.2",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "lib",
7
7
  "module": "es",
@@ -66,11 +66,9 @@
66
66
  "@hello-pangea/dnd": "^16.3.0",
67
67
  "@types/lodash": "^4.14.198",
68
68
  "@types/numeral": "^2.0.2",
69
- "@types/react-input-autosize": "^2.2.1",
70
69
  "@types/react-window": "^1.8.5",
71
70
  "@types/refractor": "^3.0.2",
72
71
  "@types/resize-observer-browser": "^0.1.7",
73
- "@types/vfile-message": "^2.0.0",
74
72
  "chroma-js": "^2.4.2",
75
73
  "classnames": "^2.3.2",
76
74
  "lodash": "^4.17.21",
@@ -78,9 +76,8 @@
78
76
  "numeral": "^2.0.6",
79
77
  "prop-types": "^15.6.0",
80
78
  "react-dropzone": "^11.7.1",
81
- "react-element-to-jsx-string": "^14.3.4",
79
+ "react-element-to-jsx-string": "^15.0.0",
82
80
  "react-focus-on": "^3.9.1",
83
- "react-input-autosize": "^3.0.0",
84
81
  "react-is": "^17.0.2",
85
82
  "react-remove-scroll-bar": "^2.3.4",
86
83
  "react-virtualized-auto-sizer": "^1.0.20",
@@ -55,27 +55,20 @@
55
55
  /**
56
56
  * 1. Force field height to match other field heights.
57
57
  * 2. Force input height to expand to fill this element.
58
- * 3. Reset appearance on Safari.
59
- * 4. Fix react-input-autosize appearance.
60
- * 5. Prevent a lot of input from causing the react-input-autosize to overflow the container.
58
+ * 3. Reset input appearance to mimic text
61
59
  */
62
60
  .euiComboBox__input {
63
- // stylelint-disable-next-line declaration-no-important
64
- display: inline-flex !important; /* 1 */
65
- height: $euiSizeXL; /* 2 */
66
- overflow: hidden; /* 5 */
67
-
68
- > input {
69
- @include euiFont;
70
- appearance: none; /* 3 */
71
- padding: 0;
72
- border: none;
73
- background: transparent;
74
- font-size: $euiFontSizeS;
75
- color: $euiTextColor;
76
- margin: $euiSizeXS;
77
- line-height: $euiLineHeight; /* 4 */
78
- }
61
+ block-size: $euiSizeL; /* 2 */
62
+ min-inline-size: 2px;
63
+ max-inline-size: 100%;
64
+ margin: $euiSizeXS;
65
+
66
+ /* 3 */
67
+ appearance: none;
68
+ outline: none;
69
+ border: none;
70
+ background: transparent;
71
+ color: $euiTextColor;
79
72
  }
80
73
 
81
74
  &.euiComboBox-isOpen {
@@ -21,6 +21,9 @@ var _header = require("../header/header.styles");
21
21
  var _context = require("./context");
22
22
  var _collapsible_nav_button = require("./collapsible_nav_button");
23
23
  var _collapsible_nav_beta = require("./collapsible_nav_beta.styles");
24
+ var _collapsible_nav_body_footer = require("./collapsible_nav_body_footer");
25
+ var _collapsible_nav_group = require("./collapsible_nav_group");
26
+ var _collapsible_nav_item = require("./collapsible_nav_item");
24
27
  var _react2 = require("@emotion/react");
25
28
  var _excluded = ["id", "children", "className", "initialIsCollapsed", "onCollapseToggle", "width", "side", "focusTrapProps"];
26
29
  /*
@@ -34,7 +37,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
34
37
  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; }
35
38
  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; }
36
39
  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) { (0, _defineProperty2.default)(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; }
37
- var EuiCollapsibleNavBeta = function EuiCollapsibleNavBeta(_ref) {
40
+ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
38
41
  var id = _ref.id,
39
42
  children = _ref.children,
40
43
  className = _ref.className,
@@ -155,8 +158,11 @@ var EuiCollapsibleNavBeta = function EuiCollapsibleNavBeta(_ref) {
155
158
  "aria-controls": flyoutID
156
159
  }), !hideFlyout && flyout);
157
160
  };
158
- exports.EuiCollapsibleNavBeta = EuiCollapsibleNavBeta;
159
- EuiCollapsibleNavBeta.propTypes = {
161
+
162
+ /**
163
+ * Combined export with subcomponents
164
+ */
165
+ _EuiCollapsibleNavBeta.propTypes = {
160
166
  className: _propTypes.default.string,
161
167
  /**
162
168
  * Overlay flyouts are considered dialogs, and dialogs must have a label.
@@ -171,8 +177,9 @@ EuiCollapsibleNavBeta.propTypes = {
171
177
  "data-test-subj": _propTypes.default.string,
172
178
  css: _propTypes.default.any,
173
179
  /**
174
- * ReactNode(s) to render as navigation flyout content, typically `EuiCollapsibleNavItem`s.
175
- * You may also want to use `EuiFlyoutBody` and `EuiFlyoutFooter` for organization.
180
+ * ReactNode(s) to render as navigation flyout content, typically `EuiCollapsibleNavBeta.Item`s.
181
+ * You will likely want to use `EuiCollapsibleNavBeta.Body` and `EuiCollapsibleNavBeta.Footer`
182
+ * for organization.
176
183
  */
177
184
  children: _propTypes.default.node,
178
185
  /**
@@ -199,4 +206,11 @@ EuiCollapsibleNavBeta.propTypes = {
199
206
  * take up the full width of the page.
200
207
  */
201
208
  width: _propTypes.default.number
202
- };
209
+ };
210
+ var EuiCollapsibleNavBeta = Object.assign(_EuiCollapsibleNavBeta, {
211
+ Body: _collapsible_nav_body_footer.EuiCollapsibleNavBody,
212
+ Footer: _collapsible_nav_body_footer.EuiCollapsibleNavFooter,
213
+ Group: _collapsible_nav_group.EuiCollapsibleNavGroup,
214
+ Item: _collapsible_nav_item.EuiCollapsibleNavItem
215
+ });
216
+ exports.EuiCollapsibleNavBeta = EuiCollapsibleNavBeta;