@elastic/eui 94.3.0 → 94.4.1

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 (145) hide show
  1. package/README.md +3 -0
  2. package/dist/eui_charts_theme.js +1519 -1519
  3. package/dist/eui_charts_theme.js.map +1 -1
  4. package/dist/eui_theme_dark.css +41 -497
  5. package/dist/eui_theme_dark.min.css +1 -1
  6. package/dist/eui_theme_light.css +41 -497
  7. package/dist/eui_theme_light.min.css +1 -1
  8. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  9. package/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  10. package/es/components/form/form.styles.js +26 -3
  11. package/es/components/markdown_editor/markdown_editor.js +12 -8
  12. package/es/components/markdown_editor/markdown_editor.styles.js +29 -0
  13. package/es/components/markdown_editor/markdown_editor_drop_zone.js +22 -9
  14. package/es/components/markdown_editor/markdown_editor_drop_zone.styles.js +33 -0
  15. package/es/components/markdown_editor/markdown_editor_footer.js +11 -2
  16. package/es/components/markdown_editor/markdown_editor_footer.styles.js +26 -0
  17. package/es/components/markdown_editor/markdown_editor_text_area.js +6 -1
  18. package/es/components/markdown_editor/markdown_editor_text_area.styles.js +22 -0
  19. package/es/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  20. package/es/components/markdown_editor/markdown_editor_toolbar.styles.js +21 -0
  21. package/es/components/markdown_editor/markdown_format.js +9 -6
  22. package/es/components/markdown_editor/markdown_format.styles.js +25 -10
  23. package/es/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -3
  24. package/es/components/markdown_editor/plugins/markdown_tooltip/renderer.js +13 -2
  25. package/es/components/selectable/selectable.js +10 -2
  26. package/es/components/selectable/selectable_list/selectable_list.js +95 -42
  27. package/es/components/selectable/selectable_list/selectable_list_item.js +234 -204
  28. package/es/components/selectable/selectable_option.js +9 -1
  29. package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +10 -2
  30. package/es/components/text/text_color.js +4 -1
  31. package/es/components/toast/global_toast_list_item.js +5 -5
  32. package/eui.d.ts +332 -234
  33. package/i18ntokens.json +124 -106
  34. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  35. package/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  36. package/lib/components/form/form.styles.js +30 -4
  37. package/lib/components/markdown_editor/markdown_editor.js +12 -8
  38. package/lib/components/markdown_editor/markdown_editor.styles.js +37 -0
  39. package/lib/components/markdown_editor/markdown_editor_drop_zone.js +20 -8
  40. package/lib/components/markdown_editor/markdown_editor_drop_zone.styles.js +38 -0
  41. package/lib/components/markdown_editor/markdown_editor_footer.js +10 -1
  42. package/lib/components/markdown_editor/markdown_editor_footer.styles.js +33 -0
  43. package/lib/components/markdown_editor/markdown_editor_text_area.js +6 -1
  44. package/lib/components/markdown_editor/markdown_editor_text_area.styles.js +29 -0
  45. package/lib/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  46. package/lib/components/markdown_editor/markdown_editor_toolbar.styles.js +28 -0
  47. package/lib/components/markdown_editor/markdown_format.js +8 -5
  48. package/lib/components/markdown_editor/markdown_format.styles.js +25 -10
  49. package/lib/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -4
  50. package/lib/components/markdown_editor/plugins/markdown_tooltip/renderer.js +19 -10
  51. package/lib/components/selectable/selectable.js +10 -2
  52. package/lib/components/selectable/selectable_list/selectable_list.js +95 -42
  53. package/lib/components/selectable/selectable_list/selectable_list_item.js +241 -210
  54. package/lib/components/selectable/selectable_option.js +12 -1
  55. package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +10 -2
  56. package/lib/components/text/text_color.js +6 -2
  57. package/lib/components/toast/global_toast_list_item.js +5 -5
  58. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  59. package/optimize/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  60. package/optimize/es/components/form/form.styles.js +26 -3
  61. package/optimize/es/components/markdown_editor/markdown_editor.js +12 -8
  62. package/optimize/es/components/markdown_editor/markdown_editor.styles.js +29 -0
  63. package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.js +19 -9
  64. package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.styles.js +33 -0
  65. package/optimize/es/components/markdown_editor/markdown_editor_footer.js +11 -2
  66. package/optimize/es/components/markdown_editor/markdown_editor_footer.styles.js +26 -0
  67. package/optimize/es/components/markdown_editor/markdown_editor_text_area.js +6 -1
  68. package/optimize/es/components/markdown_editor/markdown_editor_text_area.styles.js +22 -0
  69. package/optimize/es/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  70. package/optimize/es/components/markdown_editor/markdown_editor_toolbar.styles.js +21 -0
  71. package/optimize/es/components/markdown_editor/markdown_format.js +9 -6
  72. package/optimize/es/components/markdown_editor/markdown_format.styles.js +25 -10
  73. package/optimize/es/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -3
  74. package/optimize/es/components/markdown_editor/plugins/markdown_tooltip/renderer.js +13 -2
  75. package/optimize/es/components/selectable/selectable_list/selectable_list.js +81 -38
  76. package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +217 -198
  77. package/optimize/es/components/selectable/selectable_option.js +9 -1
  78. package/optimize/es/components/text/text_color.js +4 -1
  79. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  80. package/optimize/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  81. package/optimize/lib/components/form/form.styles.js +30 -4
  82. package/optimize/lib/components/markdown_editor/markdown_editor.js +12 -8
  83. package/optimize/lib/components/markdown_editor/markdown_editor.styles.js +37 -0
  84. package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.js +24 -16
  85. package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.styles.js +38 -0
  86. package/optimize/lib/components/markdown_editor/markdown_editor_footer.js +10 -1
  87. package/optimize/lib/components/markdown_editor/markdown_editor_footer.styles.js +33 -0
  88. package/optimize/lib/components/markdown_editor/markdown_editor_text_area.js +6 -1
  89. package/optimize/lib/components/markdown_editor/markdown_editor_text_area.styles.js +29 -0
  90. package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  91. package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.styles.js +28 -0
  92. package/optimize/lib/components/markdown_editor/markdown_format.js +8 -5
  93. package/optimize/lib/components/markdown_editor/markdown_format.styles.js +25 -10
  94. package/optimize/lib/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -4
  95. package/optimize/lib/components/markdown_editor/plugins/markdown_tooltip/renderer.js +19 -10
  96. package/optimize/lib/components/selectable/selectable_list/selectable_list.js +81 -38
  97. package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +224 -204
  98. package/optimize/lib/components/selectable/selectable_option.js +12 -1
  99. package/optimize/lib/components/text/text_color.js +6 -2
  100. package/package.json +5 -12
  101. package/src/components/date_picker/react-datepicker/LICENSE +21 -0
  102. package/src/components/date_picker/react-datepicker/README.md +168 -0
  103. package/src/components/date_picker/super_date_picker/date_popover/_absolute_tab.scss +13 -18
  104. package/src/components/form/checkbox/_checkbox.scss +23 -6
  105. package/src/components/index.scss +0 -1
  106. package/src/components/selectable/selectable_list/_selectable_list_item.scss +4 -0
  107. package/src/components/selectable/selectable_templates/_selectable_template_sitewide_option.scss +5 -1
  108. package/src/services/theme/README.md +153 -0
  109. package/src/test/README.md +44 -0
  110. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  111. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  112. package/test-env/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  113. package/test-env/components/form/form.styles.js +30 -4
  114. package/test-env/components/markdown_editor/markdown_editor.js +12 -8
  115. package/test-env/components/markdown_editor/markdown_editor.styles.js +37 -0
  116. package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +24 -16
  117. package/test-env/components/markdown_editor/markdown_editor_drop_zone.styles.js +38 -0
  118. package/test-env/components/markdown_editor/markdown_editor_footer.js +10 -1
  119. package/test-env/components/markdown_editor/markdown_editor_footer.styles.js +33 -0
  120. package/test-env/components/markdown_editor/markdown_editor_text_area.js +6 -1
  121. package/test-env/components/markdown_editor/markdown_editor_text_area.styles.js +29 -0
  122. package/test-env/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  123. package/test-env/components/markdown_editor/markdown_editor_toolbar.styles.js +28 -0
  124. package/test-env/components/markdown_editor/markdown_format.js +8 -5
  125. package/test-env/components/markdown_editor/markdown_format.styles.js +25 -10
  126. package/test-env/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -4
  127. package/test-env/components/markdown_editor/plugins/markdown_tooltip/renderer.js +19 -10
  128. package/test-env/components/selectable/selectable.js +10 -2
  129. package/test-env/components/selectable/selectable_list/selectable_list.js +95 -42
  130. package/test-env/components/selectable/selectable_list/selectable_list_item.js +233 -205
  131. package/test-env/components/selectable/selectable_option.js +12 -1
  132. package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +10 -2
  133. package/test-env/components/text/text_color.js +6 -2
  134. package/test-env/components/toast/global_toast_list_item.js +5 -5
  135. package/src/components/markdown_editor/_index.scss +0 -9
  136. package/src/components/markdown_editor/_markdown_editor.scss +0 -22
  137. package/src/components/markdown_editor/_markdown_editor_drop_zone.scss +0 -58
  138. package/src/components/markdown_editor/_markdown_editor_footer.scss +0 -42
  139. package/src/components/markdown_editor/_markdown_editor_preview.scss +0 -20
  140. package/src/components/markdown_editor/_markdown_editor_text_area.scss +0 -43
  141. package/src/components/markdown_editor/_markdown_editor_toolbar.scss +0 -29
  142. package/src/components/markdown_editor/_markdown_format.scss +0 -78
  143. package/src/components/markdown_editor/_variables.scss +0 -1
  144. package/src/components/markdown_editor/plugins/markdown_tooltip.scss +0 -4
  145. package/src/themes/amsterdam/overrides/_markdown_editor.scss +0 -18
@@ -1,22 +1,18 @@
1
- var _excluded = ["children", "className", "disabled", "checked", "isFocused", "showIcons", "prepend", "append", "allowExclusions", "onFocusBadge", "paddingSize", "role", "searchable", "textWrap"],
2
- _excluded2 = ["children", "className"];
3
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", "disabled", "checked", "isFocused", "showIcons", "prepend", "append", "allowExclusions", "onFocusBadge", "paddingSize", "role", "searchable", "textWrap", "toolTipContent", "toolTipProps", "aria-describedby"],
3
+ _excluded2 = ["children", "className"];
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; }
4
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); }
5
- 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; }
6
- 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; }
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
- 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; } }
16
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
11
  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; }
18
12
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
13
  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); }
14
+ 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; }
15
+ 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; }
20
16
  /*
21
17
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
22
18
  * or more contributor license agreements. Licensed under the Elastic License
@@ -27,12 +23,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
27
23
 
28
24
  import classNames from 'classnames';
29
25
  import PropTypes from "prop-types";
30
- import React, { Component } from 'react';
26
+ import React, { useState, useEffect, useMemo } from 'react';
31
27
  import { keysOf } from '../../common';
32
28
  import { EuiI18n } from '../../i18n';
33
29
  import { EuiIcon } from '../../icon';
34
30
  import { EuiScreenReaderOnly } from '../../accessibility';
35
31
  import { EuiBadge } from '../../badge';
32
+ import { EuiToolTip } from '../../tool_tip';
36
33
  import { jsx as ___EmotionJSX } from "@emotion/react";
37
34
  function resolveIconAndColor(checked) {
38
35
  switch (checked) {
@@ -63,197 +60,222 @@ var paddingSizeToClassNameMap = {
63
60
  s: 'euiSelectableListItem--paddingSmall'
64
61
  };
65
62
  export var PADDING_SIZES = keysOf(paddingSizeToClassNameMap);
66
- export var EuiSelectableListItem = /*#__PURE__*/function (_Component) {
67
- _inherits(EuiSelectableListItem, _Component);
68
- var _super = _createSuper(EuiSelectableListItem);
69
- function EuiSelectableListItem(props) {
70
- var _this;
71
- _classCallCheck(this, EuiSelectableListItem);
72
- _this = _super.call(this, props);
73
- // aria-checked is intended to be used with role="checkbox" but
74
- // the MDN documentation lists it as a possibility for role="option".
75
- // See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked
76
- // and https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/option_role
77
- _defineProperty(_assertThisInitialized(_this), "isChecked", function (role, checked) {
78
- var rolesThatCanBeMixed = ['option', 'checkbox', 'menuitemcheckbox'];
79
- var rolesThatCanBeChecked = [].concat(rolesThatCanBeMixed, ['radio', 'menuitemradio', 'switch']);
80
- if (!rolesThatCanBeChecked.includes(role)) return undefined;
81
- switch (checked) {
82
- case 'on':
83
- case 'off':
84
- return true;
85
- case 'mixed':
86
- if (rolesThatCanBeMixed.includes(role)) {
87
- return 'mixed';
88
- } else {
89
- return false;
90
- }
91
- default:
92
- return false;
93
- }
94
- });
95
- return _this;
96
- }
97
- _createClass(EuiSelectableListItem, [{
98
- key: "render",
99
- value: function render() {
100
- var _this$props = this.props,
101
- children = _this$props.children,
102
- className = _this$props.className,
103
- disabled = _this$props.disabled,
104
- checked = _this$props.checked,
105
- isFocused = _this$props.isFocused,
106
- showIcons = _this$props.showIcons,
107
- prepend = _this$props.prepend,
108
- append = _this$props.append,
109
- allowExclusions = _this$props.allowExclusions,
110
- onFocusBadge = _this$props.onFocusBadge,
111
- _this$props$paddingSi = _this$props.paddingSize,
112
- paddingSize = _this$props$paddingSi === void 0 ? 's' : _this$props$paddingSi,
113
- _this$props$role = _this$props.role,
114
- role = _this$props$role === void 0 ? 'option' : _this$props$role,
115
- searchable = _this$props.searchable,
116
- textWrap = _this$props.textWrap,
117
- rest = _objectWithoutProperties(_this$props, _excluded);
118
- var classes = classNames('euiSelectableListItem', {
119
- 'euiSelectableListItem-isFocused': isFocused
120
- }, paddingSizeToClassNameMap[paddingSize], className);
121
- var textClasses = classNames('euiSelectableListItem__text', _defineProperty({}, "euiSelectableListItem__text--".concat(textWrap), textWrap));
122
- var optionIcon;
123
- if (showIcons) {
124
- var _resolveIconAndColor = resolveIconAndColor(checked),
125
- icon = _resolveIconAndColor.icon,
126
- color = _resolveIconAndColor.color;
127
- optionIcon = ___EmotionJSX(EuiIcon, {
128
- className: "euiSelectableListItem__icon",
129
- color: color,
130
- type: icon
131
- });
132
- }
133
- var state;
134
- var instructions;
135
- var screenReaderStrings = {
136
- checked: {
137
- state: ___EmotionJSX(EuiI18n, {
138
- token: "euiSelectableListItem.checkedOption",
139
- default: "Checked option."
140
- }),
141
- instructions: ___EmotionJSX(EuiI18n, {
142
- token: "euiSelectableListItem.checkOptionInstructions",
143
- default: "To check this option, press Enter."
144
- })
145
- },
146
- unchecked: {
147
- instructions: ___EmotionJSX(EuiI18n, {
148
- token: "euiSelectableListItem.uncheckOptionInstructions",
149
- default: "To uncheck this option, press Enter."
150
- })
151
- },
152
- excluded: {
153
- state: ___EmotionJSX(EuiI18n, {
154
- token: "euiSelectableListItem.excludedOption",
155
- default: "Excluded option."
156
- }),
157
- instructions: ___EmotionJSX(EuiI18n, {
158
- token: "euiSelectableListItem.excludeOptionInstructions",
159
- default: "To exclude this option, press Enter."
160
- })
161
- },
162
- mixed: {
163
- state: ___EmotionJSX(EuiI18n, {
164
- token: "euiSelectableListItem.mixedOption",
165
- default: "Mixed (indeterminate) option."
166
- }),
167
- instructions: ___EmotionJSX(EuiI18n, {
168
- token: "euiSelectableListItem.mixedOptionInstructions",
169
- default: "To check this option for all, press Enter once."
170
- }),
171
- uncheckInstructions: ___EmotionJSX(EuiI18n, {
172
- token: "euiSelectableListItem.mixedOptionUncheckInstructions",
173
- default: "To uncheck this option for all, press Enter twice."
174
- }),
175
- excludeInstructions: ___EmotionJSX(EuiI18n, {
176
- token: "euiSelectableListItem.mixedOptionExcludeInstructions",
177
- default: "To exclude this option for all, press Enter twice."
178
- })
179
- }
180
- };
181
- switch (checked) {
182
- case 'on':
183
- state = screenReaderStrings.checked.state;
184
- instructions = allowExclusions ? screenReaderStrings.excluded.instructions : searchable ? screenReaderStrings.unchecked.instructions : undefined;
185
- break;
186
- case 'off':
187
- state = screenReaderStrings.excluded.state;
188
- instructions = screenReaderStrings.unchecked.instructions;
189
- break;
190
- case 'mixed':
191
- state = screenReaderStrings.mixed.state;
192
- instructions = ___EmotionJSX(React.Fragment, null, screenReaderStrings.mixed.instructions, ' ', allowExclusions ? screenReaderStrings.mixed.excludeInstructions : screenReaderStrings.mixed.uncheckInstructions);
193
- break;
194
- case undefined:
195
- default:
196
- instructions = allowExclusions || searchable ? screenReaderStrings.checked.instructions : undefined;
197
- break;
198
- }
199
- var prependNode;
200
- if (prepend) {
201
- prependNode = ___EmotionJSX("span", {
202
- className: "euiSelectableListItem__prepend"
203
- }, prepend);
63
+ export var EuiSelectableListItem = function EuiSelectableListItem(_ref) {
64
+ var children = _ref.children,
65
+ className = _ref.className,
66
+ disabled = _ref.disabled,
67
+ checked = _ref.checked,
68
+ isFocused = _ref.isFocused,
69
+ _ref$showIcons = _ref.showIcons,
70
+ showIcons = _ref$showIcons === void 0 ? true : _ref$showIcons,
71
+ prepend = _ref.prepend,
72
+ append = _ref.append,
73
+ allowExclusions = _ref.allowExclusions,
74
+ _ref$onFocusBadge = _ref.onFocusBadge,
75
+ onFocusBadge = _ref$onFocusBadge === void 0 ? true : _ref$onFocusBadge,
76
+ _ref$paddingSize = _ref.paddingSize,
77
+ paddingSize = _ref$paddingSize === void 0 ? 's' : _ref$paddingSize,
78
+ _ref$role = _ref.role,
79
+ role = _ref$role === void 0 ? 'option' : _ref$role,
80
+ searchable = _ref.searchable,
81
+ _ref$textWrap = _ref.textWrap,
82
+ textWrap = _ref$textWrap === void 0 ? 'truncate' : _ref$textWrap,
83
+ toolTipContent = _ref.toolTipContent,
84
+ toolTipProps = _ref.toolTipProps,
85
+ _ariaDescribedBy = _ref['aria-describedby'],
86
+ rest = _objectWithoutProperties(_ref, _excluded);
87
+ var classes = classNames('euiSelectableListItem', {
88
+ 'euiSelectableListItem-isFocused': isFocused
89
+ }, paddingSizeToClassNameMap[paddingSize], className);
90
+ var textClasses = classNames('euiSelectableListItem__text', _defineProperty({}, "euiSelectableListItem__text--".concat(textWrap), textWrap));
91
+ var optionIcon = useMemo(function () {
92
+ if (showIcons) {
93
+ var _resolveIconAndColor = resolveIconAndColor(checked),
94
+ icon = _resolveIconAndColor.icon,
95
+ color = _resolveIconAndColor.color;
96
+ return ___EmotionJSX(EuiIcon, {
97
+ className: "euiSelectableListItem__icon",
98
+ color: color,
99
+ type: icon
100
+ });
101
+ }
102
+ }, [showIcons, checked]);
103
+ var prependNode = useMemo(function () {
104
+ if (prepend) {
105
+ return ___EmotionJSX("span", {
106
+ className: "euiSelectableListItem__prepend"
107
+ }, prepend);
108
+ }
109
+ }, [prepend]);
110
+ var onFocusBadgeNode = useMemo(function () {
111
+ var defaultOnFocusBadgeProps = {
112
+ 'aria-hidden': true,
113
+ iconType: 'returnKey',
114
+ iconSide: 'left',
115
+ color: 'hollow'
116
+ };
117
+ if (onFocusBadge === true) {
118
+ return ___EmotionJSX(EuiBadge, _extends({
119
+ className: "euiSelectableListItem__onFocusBadge"
120
+ }, defaultOnFocusBadgeProps));
121
+ } else if (typeof onFocusBadge !== 'boolean' && !!onFocusBadge) {
122
+ var _children = onFocusBadge.children,
123
+ _className = onFocusBadge.className,
124
+ restBadgeProps = _objectWithoutProperties(onFocusBadge, _excluded2);
125
+ return ___EmotionJSX(EuiBadge, _extends({
126
+ className: classNames('euiSelectableListItem__onFocusBadge', _className)
127
+ }, defaultOnFocusBadgeProps, restBadgeProps), _children);
128
+ }
129
+ }, [onFocusBadge]);
130
+ var showOnFocusBadge = !!(isFocused && !disabled && onFocusBadgeNode);
131
+ var appendNode = useMemo(function () {
132
+ if (append || showOnFocusBadge) {
133
+ return ___EmotionJSX("span", {
134
+ className: "euiSelectableListItem__append"
135
+ }, append, " ", showOnFocusBadge ? onFocusBadgeNode : null);
136
+ }
137
+ }, [append, showOnFocusBadge, onFocusBadgeNode]);
138
+ var screenReaderText = useMemo(function () {
139
+ var state;
140
+ var instructions;
141
+ var screenReaderStrings = {
142
+ checked: {
143
+ state: ___EmotionJSX(EuiI18n, {
144
+ token: "euiSelectableListItem.checkedOption",
145
+ default: "Checked option."
146
+ }),
147
+ instructions: ___EmotionJSX(EuiI18n, {
148
+ token: "euiSelectableListItem.checkOptionInstructions",
149
+ default: "To check this option, press Enter."
150
+ })
151
+ },
152
+ unchecked: {
153
+ instructions: ___EmotionJSX(EuiI18n, {
154
+ token: "euiSelectableListItem.uncheckOptionInstructions",
155
+ default: "To uncheck this option, press Enter."
156
+ })
157
+ },
158
+ excluded: {
159
+ state: ___EmotionJSX(EuiI18n, {
160
+ token: "euiSelectableListItem.excludedOption",
161
+ default: "Excluded option."
162
+ }),
163
+ instructions: ___EmotionJSX(EuiI18n, {
164
+ token: "euiSelectableListItem.excludeOptionInstructions",
165
+ default: "To exclude this option, press Enter."
166
+ })
167
+ },
168
+ mixed: {
169
+ state: ___EmotionJSX(EuiI18n, {
170
+ token: "euiSelectableListItem.mixedOption",
171
+ default: "Mixed (indeterminate) option."
172
+ }),
173
+ instructions: ___EmotionJSX(EuiI18n, {
174
+ token: "euiSelectableListItem.mixedOptionInstructions",
175
+ default: "To check this option for all, press Enter once."
176
+ }),
177
+ uncheckInstructions: ___EmotionJSX(EuiI18n, {
178
+ token: "euiSelectableListItem.mixedOptionUncheckInstructions",
179
+ default: "To uncheck this option for all, press Enter twice."
180
+ }),
181
+ excludeInstructions: ___EmotionJSX(EuiI18n, {
182
+ token: "euiSelectableListItem.mixedOptionExcludeInstructions",
183
+ default: "To exclude this option for all, press Enter twice."
184
+ })
204
185
  }
205
- var appendNode;
206
- if (append || !!onFocusBadge) {
207
- var onFocusBadgeNode;
208
- var defaultOnFocusBadgeProps = {
209
- 'aria-hidden': true,
210
- iconType: 'returnKey',
211
- iconSide: 'left',
212
- color: 'hollow'
213
- };
214
- if (onFocusBadge === true) {
215
- onFocusBadgeNode = ___EmotionJSX(EuiBadge, _extends({
216
- className: "euiSelectableListItem__onFocusBadge"
217
- }, defaultOnFocusBadgeProps));
218
- } else if (typeof onFocusBadge !== 'boolean' && !!onFocusBadge) {
219
- var _children = onFocusBadge.children,
220
- _className = onFocusBadge.className,
221
- restBadgeProps = _objectWithoutProperties(onFocusBadge, _excluded2);
222
- onFocusBadgeNode = ___EmotionJSX(EuiBadge, _extends({
223
- className: classNames('euiSelectableListItem__onFocusBadge', _className)
224
- }, defaultOnFocusBadgeProps, restBadgeProps), _children);
225
- }
186
+ };
187
+ switch (checked) {
188
+ case 'on':
189
+ state = screenReaderStrings.checked.state;
190
+ instructions = allowExclusions ? screenReaderStrings.excluded.instructions : searchable ? screenReaderStrings.unchecked.instructions : undefined;
191
+ break;
192
+ case 'off':
193
+ state = screenReaderStrings.excluded.state;
194
+ instructions = screenReaderStrings.unchecked.instructions;
195
+ break;
196
+ case 'mixed':
197
+ state = screenReaderStrings.mixed.state;
198
+ instructions = ___EmotionJSX(React.Fragment, null, screenReaderStrings.mixed.instructions, ' ', allowExclusions ? screenReaderStrings.mixed.excludeInstructions : screenReaderStrings.mixed.uncheckInstructions);
199
+ break;
200
+ case undefined:
201
+ default:
202
+ instructions = allowExclusions || searchable ? screenReaderStrings.checked.instructions : undefined;
203
+ break;
204
+ }
205
+ return state || instructions ? ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("div", null, state || instructions ? '. ' : null, state, state && instructions ? ' ' : null, instructions)) : null;
206
+ }, [checked, searchable, allowExclusions]);
226
207
 
227
- // Only display the append wrapper if append exists or isFocused
228
- if (append || isFocused && !disabled) {
229
- appendNode = ___EmotionJSX("span", {
230
- className: "euiSelectableListItem__append"
231
- }, append, " ", isFocused && !disabled ? onFocusBadgeNode : null);
208
+ // aria-checked is intended to be used with role="checkbox" but
209
+ // the MDN documentation lists it as a possibility for role="option".
210
+ // See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked
211
+ // and https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/option_role
212
+ var ariaChecked = useMemo(function () {
213
+ var rolesThatCanBeMixed = ['option', 'checkbox', 'menuitemcheckbox'];
214
+ var rolesThatCanBeChecked = [].concat(rolesThatCanBeMixed, ['radio', 'menuitemradio', 'switch']);
215
+ if (!rolesThatCanBeChecked.includes(role)) return undefined;
216
+ switch (checked) {
217
+ case 'on':
218
+ case 'off':
219
+ return true;
220
+ case 'mixed':
221
+ if (rolesThatCanBeMixed.includes(role)) {
222
+ return 'mixed';
223
+ } else {
224
+ return false;
232
225
  }
233
- }
234
- var screenReaderText = (state || instructions) && ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("div", null, state || instructions ? '. ' : null, state, state && instructions ? ' ' : null, instructions));
235
- return ___EmotionJSX("li", _extends({
236
- role: role,
237
- "aria-disabled": disabled,
238
- "aria-checked": this.isChecked(role, checked) // Whether the item is "checked"
239
- ,
240
- "aria-selected": !disabled && isFocused // Whether the item has keyboard focus per W3 spec
241
- ,
242
- className: classes
243
- }, rest), ___EmotionJSX("span", {
244
- className: "euiSelectableListItem__content"
245
- }, optionIcon, prependNode, ___EmotionJSX("span", {
246
- className: textClasses
247
- }, children, screenReaderText), appendNode));
226
+ default:
227
+ return false;
228
+ }
229
+ }, [role, checked]);
230
+ var hasToolTip = !!toolTipContent && !disabled;
231
+ var _useState = useState(null),
232
+ _useState2 = _slicedToArray(_useState, 2),
233
+ tooltipRef = _useState2[0],
234
+ setTooltipRef = _useState2[1]; // Needs to be state and not a ref to trigger useEffect
235
+ var _useState3 = useState(_ariaDescribedBy),
236
+ _useState4 = _slicedToArray(_useState3, 2),
237
+ ariaDescribedBy = _useState4[0],
238
+ setAriaDescribedBy = _useState4[1];
239
+
240
+ // Manually trigger the tooltip on keyboard focus
241
+ useEffect(function () {
242
+ if (!tooltipRef) return;
243
+ if (isFocused) {
244
+ tooltipRef.showToolTip();
245
+ } else {
246
+ tooltipRef.hideToolTip();
248
247
  }
249
- }]);
250
- return EuiSelectableListItem;
251
- }(Component);
252
- _defineProperty(EuiSelectableListItem, "defaultProps", {
253
- showIcons: true,
254
- onFocusBadge: true,
255
- textWrap: 'truncate'
256
- });
248
+ }, [isFocused, tooltipRef]);
249
+
250
+ // Manually set the `aria-describedby` id on the <li> wrapper
251
+ useEffect(function () {
252
+ if (tooltipRef) {
253
+ var tooltipId = tooltipRef.state.id;
254
+ setAriaDescribedBy(classNames(tooltipId, _ariaDescribedBy));
255
+ }
256
+ }, [tooltipRef, _ariaDescribedBy]);
257
+ var content = ___EmotionJSX("span", {
258
+ className: "euiSelectableListItem__content"
259
+ }, optionIcon, prependNode, ___EmotionJSX("span", {
260
+ className: textClasses
261
+ }, children, screenReaderText), appendNode);
262
+ return ___EmotionJSX("li", _extends({
263
+ role: role,
264
+ "aria-disabled": disabled,
265
+ "aria-checked": ariaChecked // Whether the item is "checked"
266
+ ,
267
+ "aria-selected": !disabled && isFocused // Whether the item has keyboard focus per W3 spec
268
+ ,
269
+ className: classes
270
+ }, rest, {
271
+ "aria-describedby": ariaDescribedBy
272
+ }), hasToolTip ? ___EmotionJSX(EuiToolTip, _extends({
273
+ ref: setTooltipRef,
274
+ content: toolTipContent,
275
+ anchorClassName: "euiSelectableListItem__tooltipAnchor",
276
+ position: "left"
277
+ }, toolTipProps), content) : content);
278
+ };
257
279
  EuiSelectableListItem.propTypes = {
258
280
  className: PropTypes.string,
259
281
  "aria-label": PropTypes.string,
@@ -263,7 +285,7 @@ EuiSelectableListItem.propTypes = {
263
285
  /**
264
286
  * Applies an icon and visual styling to activated items
265
287
  */
266
- checked: PropTypes.oneOf(["on", "off", "mixed", undefined]),
288
+ checked: PropTypes.any,
267
289
  /**
268
290
  * Shows icons based on `checked` type
269
291
  */
@@ -346,5 +368,13 @@ EuiSelectableListItem.propTypes = {
346
368
  * How to handle long text within the item.
347
369
  * Wrapping only works if virtualization is off.
348
370
  */
349
- textWrap: PropTypes.oneOf(["truncate", "wrap"])
371
+ textWrap: PropTypes.oneOf(["truncate", "wrap"]),
372
+ /**
373
+ * Optional custom tooltip content for the button
374
+ */
375
+ toolTipContent: PropTypes.node,
376
+ /**
377
+ * Optional props to pass to the underlying **[EuiToolTip](/#/display/tooltip)**
378
+ */
379
+ toolTipProps: PropTypes.any
350
380
  };
@@ -1 +1,9 @@
1
- export {};
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 var OPTION_CHECKED_STATES = ['on', 'off', 'mixed', undefined];
@@ -375,7 +375,7 @@ EuiSelectableTemplateSitewide.propTypes = {
375
375
  * 'on' to indicate inclusion, 'off' to indicate exclusion,
376
376
  * or 'mixed' to indicate inclusion for some.
377
377
  */
378
- checked: PropTypes.oneOf(["on", "off", "mixed", undefined]),
378
+ checked: PropTypes.any,
379
379
  disabled: PropTypes.bool,
380
380
  /**
381
381
  * Node to add between the selection icon and the label
@@ -405,7 +405,15 @@ EuiSelectableTemplateSitewide.propTypes = {
405
405
  * Note: when searching, custom truncation props are ignored. The highlighted search
406
406
  * text will always take precedence.
407
407
  */
408
- truncationProps: PropTypes.any
408
+ truncationProps: PropTypes.any,
409
+ /**
410
+ * Optional custom tooltip content for the button
411
+ */
412
+ toolTipContent: PropTypes.node,
413
+ /**
414
+ * Optional props to pass to the underlying **[EuiToolTip](/#/display/tooltip)**
415
+ */
416
+ toolTipProps: PropTypes.any
409
417
  }).isRequired).isRequired,
410
418
  /**
411
419
  * Override some of the EuiPopover props housing the list.
@@ -21,6 +21,9 @@ import { useEuiMemoizedStyles, cloneElementWithCss } from '../../services';
21
21
  import { euiTextColorStyles } from './text_color.styles';
22
22
  import { jsx as ___EmotionJSX } from "@emotion/react";
23
23
  export var COLORS = ['default', 'subdued', 'success', 'accent', 'danger', 'warning', 'ghost', 'inherit'];
24
+ export var _isNamedColor = function _isNamedColor(color) {
25
+ return COLORS.includes(color);
26
+ };
24
27
  export var EuiTextColor = function EuiTextColor(_ref) {
25
28
  var children = _ref.children,
26
29
  _ref$color = _ref.color,
@@ -31,7 +34,7 @@ export var EuiTextColor = function EuiTextColor(_ref) {
31
34
  cloneElement = _ref$cloneElement === void 0 ? false : _ref$cloneElement,
32
35
  style = _ref.style,
33
36
  rest = _objectWithoutProperties(_ref, _excluded);
34
- var isNamedColor = COLORS.includes(color);
37
+ var isNamedColor = _isNamedColor(color);
35
38
  var styles = useEuiMemoizedStyles(euiTextColorStyles);
36
39
  var cssStyles = [styles.euiTextColor, isNamedColor ? styles[color] : styles.customColor];
37
40
 
@@ -33,13 +33,13 @@ export var EuiGlobalToastListItem = function EuiGlobalToastListItem(_ref) {
33
33
  }));
34
34
  };
35
35
  EuiGlobalToastListItem.propTypes = {
36
- className: PropTypes.string,
37
- "aria-label": PropTypes.string,
38
- "data-test-subj": PropTypes.string,
39
- css: PropTypes.any,
40
36
  isDismissed: PropTypes.bool,
41
37
  /**
42
38
  * ReactElement to render as this component's content
43
39
  */
44
- children: PropTypes.element
40
+ children: PropTypes.element,
41
+ className: PropTypes.string,
42
+ "aria-label": PropTypes.string,
43
+ "data-test-subj": PropTypes.string,
44
+ css: PropTypes.any
45
45
  };