@elastic/eui 67.0.0 → 67.1.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 (141) hide show
  1. package/dist/eui_theme_dark.css +0 -98
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +0 -98
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/badge/badge.js +84 -78
  6. package/es/components/badge/badge.styles.js +56 -0
  7. package/es/components/basic_table/in_memory_table.js +8 -0
  8. package/es/components/button/button.js +0 -1
  9. package/es/components/button/button_display/_button_display.js +10 -5
  10. package/es/components/button/button_display/_button_display.styles.js +2 -2
  11. package/es/components/button/button_display/_button_display_content.js +5 -3
  12. package/es/components/button/button_display/_button_display_content.styles.js +4 -1
  13. package/es/components/card/card.js +2 -2
  14. package/es/components/card/card.styles.js +5 -2
  15. package/es/components/notification/notification_event.js +1 -1
  16. package/es/components/notification/notification_event_meta.js +1 -1
  17. package/es/components/popover/popover_title.js +2 -2
  18. package/es/components/popover/popover_title.styles.js +18 -6
  19. package/es/components/search_bar/filters/custom_component_filter.js +16 -0
  20. package/es/components/search_bar/filters/filters.js +6 -0
  21. package/es/components/search_bar/query/ast.js +12 -0
  22. package/es/components/search_bar/query/ast_to_es_query_dsl.js +15 -10
  23. package/es/components/search_bar/query/query.js +17 -0
  24. package/es/components/search_bar/search_bar.js +4 -0
  25. package/es/components/search_bar/search_filters.js +4 -0
  26. package/es/components/selectable/selectable_list/selectable_list.js +2 -2
  27. package/es/components/selectable/selectable_list/selectable_list_item.js +2 -2
  28. package/es/services/color/contrast.js +2 -0
  29. package/es/services/index.js +1 -1
  30. package/es/services/theme/context.js +2 -1
  31. package/es/services/theme/hooks.js +27 -1
  32. package/es/services/theme/index.js +1 -1
  33. package/es/services/theme/provider.js +15 -1
  34. package/eui.d.ts +104 -28
  35. package/lib/components/badge/badge.js +92 -80
  36. package/lib/components/badge/badge.styles.js +61 -0
  37. package/lib/components/basic_table/in_memory_table.js +8 -0
  38. package/lib/components/button/button.js +0 -1
  39. package/lib/components/button/button_display/_button_display.js +10 -5
  40. package/lib/components/button/button_display/_button_display.styles.js +2 -2
  41. package/lib/components/button/button_display/_button_display_content.js +9 -4
  42. package/lib/components/button/button_display/_button_display_content.styles.js +4 -1
  43. package/lib/components/card/card.js +2 -2
  44. package/lib/components/card/card.styles.js +5 -2
  45. package/lib/components/notification/notification_event.js +1 -1
  46. package/lib/components/notification/notification_event_meta.js +1 -1
  47. package/lib/components/popover/popover_title.js +2 -2
  48. package/lib/components/popover/popover_title.styles.js +19 -7
  49. package/lib/components/search_bar/filters/custom_component_filter.js +29 -0
  50. package/lib/components/search_bar/filters/filters.js +7 -0
  51. package/lib/components/search_bar/query/ast.js +12 -0
  52. package/lib/components/search_bar/query/ast_to_es_query_dsl.js +16 -11
  53. package/lib/components/search_bar/query/query.js +17 -0
  54. package/lib/components/search_bar/search_bar.js +4 -0
  55. package/lib/components/search_bar/search_filters.js +4 -0
  56. package/lib/components/selectable/selectable_list/selectable_list.js +2 -2
  57. package/lib/components/selectable/selectable_list/selectable_list_item.js +2 -2
  58. package/lib/services/color/contrast.js +6 -1
  59. package/lib/services/index.js +7 -0
  60. package/lib/services/theme/context.js +4 -2
  61. package/lib/services/theme/hooks.js +28 -0
  62. package/lib/services/theme/index.js +12 -0
  63. package/lib/services/theme/provider.js +23 -2
  64. package/optimize/es/components/badge/badge.js +82 -76
  65. package/optimize/es/components/badge/badge.styles.js +56 -0
  66. package/optimize/es/components/basic_table/in_memory_table.js +4 -0
  67. package/optimize/es/components/button/button.js +0 -1
  68. package/optimize/es/components/button/button_display/_button_display.js +8 -3
  69. package/optimize/es/components/button/button_display/_button_display.styles.js +2 -2
  70. package/optimize/es/components/button/button_display/_button_display_content.js +3 -1
  71. package/optimize/es/components/button/button_display/_button_display_content.styles.js +4 -1
  72. package/optimize/es/components/card/card.js +2 -2
  73. package/optimize/es/components/card/card.styles.js +5 -2
  74. package/optimize/es/components/popover/popover_title.js +2 -2
  75. package/optimize/es/components/popover/popover_title.styles.js +18 -6
  76. package/optimize/es/components/search_bar/filters/custom_component_filter.js +16 -0
  77. package/optimize/es/components/search_bar/filters/filters.js +6 -0
  78. package/optimize/es/components/search_bar/query/ast.js +12 -0
  79. package/optimize/es/components/search_bar/query/ast_to_es_query_dsl.js +14 -9
  80. package/optimize/es/components/search_bar/query/query.js +17 -0
  81. package/optimize/es/services/color/contrast.js +2 -0
  82. package/optimize/es/services/index.js +1 -1
  83. package/optimize/es/services/theme/context.js +2 -1
  84. package/optimize/es/services/theme/hooks.js +27 -1
  85. package/optimize/es/services/theme/index.js +1 -1
  86. package/optimize/es/services/theme/provider.js +14 -1
  87. package/optimize/lib/components/badge/badge.js +90 -78
  88. package/optimize/lib/components/badge/badge.styles.js +61 -0
  89. package/optimize/lib/components/basic_table/in_memory_table.js +4 -0
  90. package/optimize/lib/components/button/button.js +0 -1
  91. package/optimize/lib/components/button/button_display/_button_display.js +8 -3
  92. package/optimize/lib/components/button/button_display/_button_display.styles.js +2 -2
  93. package/optimize/lib/components/button/button_display/_button_display_content.js +6 -2
  94. package/optimize/lib/components/button/button_display/_button_display_content.styles.js +4 -1
  95. package/optimize/lib/components/card/card.js +2 -2
  96. package/optimize/lib/components/card/card.styles.js +5 -2
  97. package/optimize/lib/components/popover/popover_title.js +2 -2
  98. package/optimize/lib/components/popover/popover_title.styles.js +19 -7
  99. package/optimize/lib/components/search_bar/filters/custom_component_filter.js +29 -0
  100. package/optimize/lib/components/search_bar/filters/filters.js +7 -0
  101. package/optimize/lib/components/search_bar/query/ast.js +12 -0
  102. package/optimize/lib/components/search_bar/query/ast_to_es_query_dsl.js +16 -11
  103. package/optimize/lib/components/search_bar/query/query.js +17 -0
  104. package/optimize/lib/services/color/contrast.js +5 -1
  105. package/optimize/lib/services/index.js +7 -0
  106. package/optimize/lib/services/theme/context.js +4 -2
  107. package/optimize/lib/services/theme/hooks.js +28 -0
  108. package/optimize/lib/services/theme/index.js +12 -0
  109. package/optimize/lib/services/theme/provider.js +23 -9
  110. package/package.json +5 -5
  111. package/src/components/badge/_index.scss +0 -1
  112. package/test-env/components/badge/badge.js +92 -80
  113. package/test-env/components/badge/badge.styles.js +61 -0
  114. package/test-env/components/basic_table/in_memory_table.js +8 -0
  115. package/test-env/components/button/button.js +0 -1
  116. package/test-env/components/button/button_display/_button_display.js +10 -5
  117. package/test-env/components/button/button_display/_button_display.styles.js +2 -2
  118. package/test-env/components/button/button_display/_button_display_content.js +8 -4
  119. package/test-env/components/button/button_display/_button_display_content.styles.js +4 -1
  120. package/test-env/components/card/card.js +2 -2
  121. package/test-env/components/card/card.styles.js +5 -2
  122. package/test-env/components/notification/notification_event.js +1 -1
  123. package/test-env/components/notification/notification_event_meta.js +1 -1
  124. package/test-env/components/popover/popover_title.js +2 -2
  125. package/test-env/components/popover/popover_title.styles.js +19 -7
  126. package/test-env/components/search_bar/filters/custom_component_filter.js +29 -0
  127. package/test-env/components/search_bar/filters/filters.js +7 -0
  128. package/test-env/components/search_bar/query/ast.js +12 -0
  129. package/test-env/components/search_bar/query/ast_to_es_query_dsl.js +16 -11
  130. package/test-env/components/search_bar/query/query.js +17 -0
  131. package/test-env/components/search_bar/search_bar.js +4 -0
  132. package/test-env/components/search_bar/search_filters.js +4 -0
  133. package/test-env/components/selectable/selectable_list/selectable_list.js +2 -2
  134. package/test-env/components/selectable/selectable_list/selectable_list_item.js +2 -2
  135. package/test-env/services/color/contrast.js +5 -1
  136. package/test-env/services/index.js +7 -0
  137. package/test-env/services/theme/context.js +4 -2
  138. package/test-env/services/theme/hooks.js +28 -0
  139. package/test-env/services/theme/index.js +12 -0
  140. package/test-env/services/theme/provider.js +23 -9
  141. package/src/components/badge/_badge.scss +0 -133
@@ -15,38 +15,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
15
  * in compliance with, at your election, the Elastic License 2.0 or the Server
16
16
  * Side Public License, v 1.
17
17
  */
18
- import React from 'react';
18
+ import React, { useMemo } from 'react';
19
19
  import classNames from 'classnames';
20
20
  import chroma from 'chroma-js';
21
- import { keysOf } from '../common';
22
- import { euiPaletteColorBlindBehindText, getSecureRelForTarget, isColorDark } from '../../services';
21
+ import { useEuiTheme, euiPaletteColorBlindBehindText, getSecureRelForTarget, isColorDark, wcagContrastMin } from '../../services';
23
22
  import { EuiInnerText } from '../inner_text';
24
23
  import { EuiIcon } from '../icon';
25
24
  import { chromaValid, parseColor } from '../color_picker/utils';
26
25
  import { validateHref } from '../../services/security/href_validator';
26
+ import { euiBadgeStyles } from './badge.styles';
27
27
  import { jsx as ___EmotionJSX } from "@emotion/react";
28
- // TODO - replace with variables once https://github.com/elastic/eui/issues/2731 is closed
29
- var colorInk = '#000';
30
- var colorGhost = '#fff'; // The color blind palette has some stricter accessibility needs with regards to
28
+ export var ICON_SIDES = ['left', 'right'];
29
+ export var COLORS = ['default', 'hollow', 'primary', 'success', 'accent', 'warning', 'danger'];
30
+ // The color blind palette has some stricter accessibility needs with regards to
31
31
  // charts and contrast. We use the euiPaletteColorBlindBehindText variant here since our
32
32
  // accessibility concerns pertain to foreground (text) and background contrast
33
-
34
33
  var visColors = euiPaletteColorBlindBehindText();
35
- var colorToHexMap = {
36
- // TODO - replace with variable once https://github.com/elastic/eui/issues/2731 is closed
37
- default: '#d3dae6',
38
- primary: visColors[1],
39
- success: visColors[0],
40
- accent: visColors[2],
41
- warning: visColors[5],
42
- danger: visColors[9]
43
- };
44
- export var COLORS = keysOf(colorToHexMap);
45
- var iconSideToClassNameMap = {
46
- left: 'euiBadge--iconLeft',
47
- right: 'euiBadge--iconRight'
48
- };
49
- export var ICON_SIDES = keysOf(iconSideToClassNameMap);
50
34
  export var EuiBadge = function EuiBadge(_ref) {
51
35
  var children = _ref.children,
52
36
  _ref$color = _ref.color,
@@ -67,53 +51,63 @@ export var EuiBadge = function EuiBadge(_ref) {
67
51
  style = _ref.style,
68
52
  rest = _objectWithoutProperties(_ref, _excluded);
69
53
 
54
+ var euiTheme = useEuiTheme();
70
55
  var isHrefValid = !href || validateHref(href);
71
56
  var isDisabled = _isDisabled || !isHrefValid;
72
- var optionalCustomStyles = style;
73
- var textColor = null; // TODO - replace with variable once https://github.com/elastic/eui/issues/2731 is closed
74
-
75
- var wcagContrastBase = 4.5; // WCAG AA contrast level
76
-
77
- var wcagContrast = null;
78
- var colorHex = null; // Check if a valid color name was provided
79
-
80
- try {
81
- if (COLORS.indexOf(color) > -1) {
82
- // Get the hex equivalent for the provided color name
83
- colorHex = colorToHexMap[color]; // Set dark or light text color based upon best contrast
84
-
85
- textColor = setTextColor(colorHex);
86
- optionalCustomStyles = _objectSpread({
87
- backgroundColor: colorHex,
88
- color: textColor
89
- }, optionalCustomStyles);
90
- } else if (color !== 'hollow') {
91
- // This is a custom color that is neither from the base palette nor hollow
92
- // Let's do our best to ensure that it provides sufficient contrast
93
- // Set dark or light text color based upon best contrast
94
- textColor = setTextColor(color); // Check the contrast
95
-
96
- wcagContrast = getColorContrast(textColor, color);
97
-
98
- if (wcagContrast < wcagContrastBase) {
99
- // It's low contrast, so lets show a warning in the console
100
- console.warn('Warning: ', color, ' badge has low contrast of ', wcagContrast.toFixed(2), '. Should be above ', wcagContrastBase, '.');
57
+ var optionalCustomStyles = useMemo(function () {
58
+ var colorToHexMap = {
59
+ default: euiTheme.euiTheme.colors.lightShade,
60
+ hollow: '',
61
+ primary: visColors[1],
62
+ success: visColors[0],
63
+ accent: visColors[2],
64
+ warning: visColors[5],
65
+ danger: visColors[9]
66
+ };
67
+ var textColor = null;
68
+ var contrastRatio = null;
69
+ var colorHex = null;
70
+
71
+ try {
72
+ // Check if a valid color name was provided
73
+ if (COLORS.includes(color)) {
74
+ if (color === 'hollow') return style; // hollow uses its own CSS class
75
+ // Get the hex equivalent for the provided color name
76
+
77
+ colorHex = colorToHexMap[color]; // Set dark or light text color based upon best contrast
78
+
79
+ textColor = setTextColor(euiTheme, colorHex);
80
+ return _objectSpread({
81
+ backgroundColor: colorHex,
82
+ color: textColor
83
+ }, style);
84
+ } else {
85
+ // This is a custom color- let's do our best to ensure that it provides sufficient contrast
86
+ // Set dark or light text color based upon best contrast
87
+ textColor = setTextColor(euiTheme, color); // Check the contrast
88
+
89
+ contrastRatio = getColorContrast(textColor, color);
90
+
91
+ if (contrastRatio < wcagContrastMin) {
92
+ // It's low contrast, so lets show a warning in the console
93
+ console.warn('Warning: ', color, ' badge has low contrast of ', contrastRatio.toFixed(2), '. Should be above ', wcagContrastMin, '.');
94
+ }
95
+
96
+ return _objectSpread({
97
+ backgroundColor: color,
98
+ color: textColor
99
+ }, style);
101
100
  }
102
-
103
- optionalCustomStyles = _objectSpread({
104
- backgroundColor: color,
105
- color: textColor
106
- }, optionalCustomStyles);
101
+ } catch (err) {
102
+ handleInvalidColor(color);
107
103
  }
108
- } catch (err) {
109
- handleInvalidColor(color);
110
- }
111
-
112
- var classes = classNames('euiBadge', {
113
- 'euiBadge-isClickable': (onClick || href) && !iconOnClick,
114
- 'euiBadge-isDisabled': isDisabled,
115
- 'euiBadge--hollow': color === 'hollow'
116
- }, iconSideToClassNameMap[iconSide], className);
104
+ }, [color, style, euiTheme]);
105
+ var styles = euiBadgeStyles(euiTheme);
106
+ var cssStyles = [styles.euiBadge, (onClick || href) && !iconOnClick && styles.clickable, isDisabled && styles.disabled, color === 'hollow' && styles.hollow];
107
+ var textCssStyles = [styles.text.euiBadge__text, (onClick || href) && !isDisabled && styles.text.clickable];
108
+ var iconCssStyles = [styles.icon.euiBadge__icon, styles.icon[iconSide]];
109
+ var iconButtonCssStyles = [styles.iconButton.euiBadge__iconButton, styles.iconButton[iconSide]];
110
+ var classes = classNames('euiBadge', className);
117
111
  var closeClassNames = classNames('euiBadge__icon', closeButtonProps && closeButtonProps.className);
118
112
  var Element = href && !isDisabled ? 'a' : 'button';
119
113
  var relObj = {};
@@ -143,6 +137,7 @@ export var EuiBadge = function EuiBadge(_ref) {
143
137
  optionalIcon = ___EmotionJSX("button", {
144
138
  type: "button",
145
139
  className: "euiBadge__iconButton",
140
+ css: iconButtonCssStyles,
146
141
  "aria-label": iconOnClickAriaLabel,
147
142
  disabled: isDisabled,
148
143
  title: iconOnClickAriaLabel,
@@ -151,7 +146,8 @@ export var EuiBadge = function EuiBadge(_ref) {
151
146
  type: iconType,
152
147
  size: "s",
153
148
  color: "inherit" // forces the icon to inherit its parent color
154
-
149
+ ,
150
+ css: iconCssStyles
155
151
  }, closeButtonProps, {
156
152
  className: closeClassNames
157
153
  })));
@@ -160,6 +156,7 @@ export var EuiBadge = function EuiBadge(_ref) {
160
156
  type: iconType,
161
157
  size: children ? 's' : 'm',
162
158
  className: "euiBadge__icon",
159
+ css: iconCssStyles,
163
160
  color: "inherit" // forces the icon to inherit its parent color
164
161
 
165
162
  });
@@ -171,28 +168,34 @@ export var EuiBadge = function EuiBadge(_ref) {
171
168
  }
172
169
 
173
170
  var content = ___EmotionJSX("span", {
174
- className: "euiBadge__content"
175
- }, children && ___EmotionJSX("span", {
176
- className: "euiBadge__text"
177
- }, children), optionalIcon);
171
+ className: "euiBadge__content",
172
+ css: styles.euiBadge__content
173
+ }, iconSide === 'left' && optionalIcon, children && ___EmotionJSX("span", {
174
+ className: "euiBadge__text",
175
+ css: textCssStyles
176
+ }, children), iconSide === 'right' && optionalIcon);
178
177
 
179
178
  if (iconOnClick) {
180
179
  return onClick || href ? ___EmotionJSX("span", {
181
180
  className: classes,
181
+ css: cssStyles,
182
182
  style: optionalCustomStyles
183
183
  }, ___EmotionJSX("span", {
184
- className: "euiBadge__content"
185
- }, ___EmotionJSX(EuiInnerText, null, function (ref, innerText) {
184
+ className: "euiBadge__content",
185
+ css: styles.euiBadge__content
186
+ }, iconSide === 'left' && optionalIcon, ___EmotionJSX(EuiInnerText, null, function (ref, innerText) {
186
187
  return ___EmotionJSX(Element, _extends({
187
188
  className: "euiBadge__childButton",
189
+ css: styles.euiBadge__childButton,
188
190
  disabled: isDisabled,
189
191
  "aria-label": onClickAriaLabel,
190
192
  ref: ref,
191
193
  title: innerText
192
194
  }, relObj, rest), children);
193
- }), optionalIcon)) : ___EmotionJSX(EuiInnerText, null, function (ref, innerText) {
195
+ }), iconSide === 'right' && optionalIcon)) : ___EmotionJSX(EuiInnerText, null, function (ref, innerText) {
194
196
  return ___EmotionJSX("span", _extends({
195
197
  className: classes,
198
+ css: cssStyles,
196
199
  style: optionalCustomStyles,
197
200
  ref: ref,
198
201
  title: innerText
@@ -204,6 +207,7 @@ export var EuiBadge = function EuiBadge(_ref) {
204
207
  disabled: isDisabled,
205
208
  "aria-label": onClickAriaLabel,
206
209
  className: classes,
210
+ css: cssStyles,
207
211
  style: optionalCustomStyles,
208
212
  ref: ref,
209
213
  title: innerText
@@ -213,6 +217,7 @@ export var EuiBadge = function EuiBadge(_ref) {
213
217
  return ___EmotionJSX(EuiInnerText, null, function (ref, innerText) {
214
218
  return ___EmotionJSX("span", _extends({
215
219
  className: classes,
220
+ css: cssStyles,
216
221
  style: optionalCustomStyles,
217
222
  ref: ref,
218
223
  title: innerText
@@ -226,13 +231,14 @@ function getColorContrast(textColor, color) {
226
231
  return contrastValue;
227
232
  }
228
233
 
229
- function setTextColor(bgColor) {
230
- var textColor = isColorDark.apply(void 0, _toConsumableArray(chroma(bgColor).rgb())) ? colorGhost : colorInk;
234
+ function setTextColor(_ref2, bgColor) {
235
+ var euiTheme = _ref2.euiTheme;
236
+ var textColor = isColorDark.apply(void 0, _toConsumableArray(chroma(bgColor).rgb())) ? euiTheme.colors.ghost : euiTheme.colors.ink;
231
237
  return textColor;
232
238
  }
233
239
 
234
240
  function handleInvalidColor(color) {
235
- var isNamedColor = color && COLORS.includes(color) || color === 'hollow';
241
+ var isNamedColor = COLORS.includes(color);
236
242
  var isValidColorString = color && chromaValid(parseColor(color) || '');
237
243
 
238
244
  if (!isNamedColor && !isValidColorString) {
@@ -0,0 +1,56 @@
1
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
2
+
3
+ /*
4
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
5
+ * or more contributor license agreements. Licensed under the Elastic License
6
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
7
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
8
+ * Side Public License, v 1.
9
+ */
10
+ import { css } from '@emotion/react';
11
+ import { euiFontSize, euiFocusRing, euiTextTruncate, logicalCSS, logicalTextAlignCSS } from '../../global_styling';
12
+ import { euiButtonColor } from '../../themes/amsterdam/global_styling/mixins';
13
+ import { tint, transparentize } from '../../services';
14
+
15
+ var _ref = process.env.NODE_ENV === "production" ? {
16
+ name: "1hw5vc4-clickable",
17
+ styles: "cursor:pointer;label:clickable;"
18
+ } : {
19
+ name: "1hw5vc4-clickable",
20
+ styles: "cursor:pointer;label:clickable;",
21
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
22
+ };
23
+
24
+ export var euiBadgeStyles = function euiBadgeStyles(euiThemeContext) {
25
+ var euiTheme = euiThemeContext.euiTheme,
26
+ colorMode = euiThemeContext.colorMode;
27
+ return {
28
+ euiBadge: /*#__PURE__*/css("display:inline-block;vertical-align:middle;padding:0 ", euiTheme.size.s, ";", logicalCSS('max-width', '100%'), " font-size:", euiFontSize(euiThemeContext, 'xs').fontSize, ";line-height:", euiTheme.base + 2, "px;font-weight:", euiTheme.font.weight.medium, ";white-space:nowrap;text-decoration:none;cursor:default;background-color:transparent;border:", euiTheme.border.width.thin, " solid transparent;border-radius:", parseFloat(String(euiTheme.border.radius.medium)) / 2, "px;", logicalTextAlignCSS('left'), " &:focus-within{", euiFocusRing(euiThemeContext), ";}&+.euiBadge{", logicalCSS('margin-left', euiTheme.size.xs), ";};label:euiBadge;"),
29
+ clickable: /*#__PURE__*/css("&:not(:disabled){&:hover,&:focus{text-decoration:underline;}}&:focus{", euiFocusRing(euiThemeContext), ";}&:disabled{cursor:not-allowed;};label:clickable;"),
30
+ disabled: /*#__PURE__*/css("color:", euiButtonColor(euiThemeContext, 'disabled').color, "!important;background-color:", euiButtonColor(euiThemeContext, 'disabled').backgroundColor, "!important;;label:disabled;"),
31
+ // Hollow has a border and is mostly used for autocompleters.
32
+ hollow: /*#__PURE__*/css("background-color:", euiTheme.colors.emptyShade, ";border-color:", colorMode === 'DARK' ? tint(euiTheme.border.color, 0.15) : euiTheme.border.color, ";color:", euiTheme.colors.text, ";;label:hollow;"),
33
+ // Content wrapper
34
+ euiBadge__content: /*#__PURE__*/css(logicalCSS( // Ensure proper height in case of just displaying an icon
35
+ 'min-height', "".concat(euiTheme.base + parseFloat(String(euiTheme.border.width.thin)) * 2, "px")), " display:flex;align-items:center;overflow:hidden;;label:euiBadge__content;"),
36
+ // Text
37
+ text: {
38
+ euiBadge__text: /*#__PURE__*/css(euiTextTruncate(), " cursor:inherit;;label:euiBadge__text;"),
39
+ clickable: _ref
40
+ },
41
+ // Icon
42
+ icon: {
43
+ euiBadge__icon: /*#__PURE__*/css(";label:euiBadge__icon;"),
44
+ right: /*#__PURE__*/css("&:not(:only-child){", logicalCSS('margin-left', euiTheme.size.xs), ";};label:right;"),
45
+ left: /*#__PURE__*/css("&:not(:only-child){", logicalCSS('margin-right', euiTheme.size.xs), ";};label:left;")
46
+ },
47
+ // Clickable icons (iconOnClick)
48
+ iconButton: {
49
+ euiBadge__iconButton: /*#__PURE__*/css("font-size:0;&:focus{background-color:", transparentize(euiTheme.colors.ghost, 0.8), ";color:", euiTheme.colors.ink, ";border-radius:", parseFloat(String(euiTheme.border.radius.small)) / 2, "px;}&:disabled{cursor:not-allowed;}.euiBadge__icon{margin:0!important;};label:euiBadge__iconButton;"),
50
+ right: /*#__PURE__*/css(logicalCSS('margin-left', euiTheme.size.xs), ";;label:right;"),
51
+ left: /*#__PURE__*/css(logicalCSS('margin-right', euiTheme.size.xs), ";;label:left;")
52
+ },
53
+ // Used in badges with both onClick & iconOnClick
54
+ euiBadge__childButton: /*#__PURE__*/css(euiTextTruncate(), " text-align:inherit;font-weight:inherit;line-height:inherit;color:inherit;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover,&:focus{text-decoration:underline;}};label:euiBadge__childButton;")
55
+ };
56
+ };
@@ -523,6 +523,10 @@ export var EuiInMemoryTable = /*#__PURE__*/function (_Component) {
523
523
 
524
524
  if (sortName !== prevState.prevProps.sortName || sortDirection !== prevState.prevProps.sortDirection) {
525
525
  updatedPrevState = _objectSpread(_objectSpread({}, updatedPrevState), {}, {
526
+ prevProps: _objectSpread(_objectSpread({}, updatedPrevState.prevProps), {}, {
527
+ sortName: sortName,
528
+ sortDirection: sortDirection
529
+ }),
526
530
  sortName: sortName,
527
531
  sortDirection: sortDirection
528
532
  });
@@ -68,7 +68,6 @@ export var EuiButton = function EuiButton(props) {
68
68
  EuiButton.displayName = 'EuiButton'; // Use defaultProps for simple pass-through props
69
69
 
70
70
  EuiButton.defaultProps = {
71
- minWidth: 112,
72
71
  size: 'm',
73
72
  color: 'primary'
74
73
  };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "iconType", "iconSide", "size", "isDisabled", "disabled", "isLoading", "isSelected", "fullWidth", "minWidth", "contentProps", "textProps", "href", "target", "rel", "type"];
4
+ var _excluded = ["children", "iconType", "iconSide", "iconSize", "size", "isDisabled", "disabled", "isLoading", "isSelected", "fullWidth", "minWidth", "contentProps", "textProps", "href", "target", "rel", "type", "style"];
5
5
 
6
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
7
 
@@ -40,6 +40,7 @@ export var EuiButtonDisplay = /*#__PURE__*/forwardRef(function (_ref2, ref) {
40
40
  var children = _ref2.children,
41
41
  iconType = _ref2.iconType,
42
42
  iconSide = _ref2.iconSide,
43
+ iconSize = _ref2.iconSize,
43
44
  _ref2$size = _ref2.size,
44
45
  size = _ref2$size === void 0 ? 'm' : _ref2$size,
45
46
  isDisabled = _ref2.isDisabled,
@@ -55,6 +56,7 @@ export var EuiButtonDisplay = /*#__PURE__*/forwardRef(function (_ref2, ref) {
55
56
  rel = _ref2.rel,
56
57
  _ref2$type = _ref2.type,
57
58
  type = _ref2$type === void 0 ? 'button' : _ref2$type,
59
+ style = _ref2.style,
58
60
  rest = _objectWithoutProperties(_ref2, _excluded);
59
61
 
60
62
  var buttonIsDisabled = isButtonDisabled({
@@ -62,9 +64,8 @@ export var EuiButtonDisplay = /*#__PURE__*/forwardRef(function (_ref2, ref) {
62
64
  isDisabled: isDisabled || disabled,
63
65
  isLoading: isLoading
64
66
  });
65
- var minWidthPx = typeof minWidth === 'number' ? "".concat(minWidth, "px") : minWidth;
66
67
  var theme = useEuiTheme();
67
- var styles = euiButtonDisplayStyles(theme, minWidthPx);
68
+ var styles = euiButtonDisplayStyles(theme);
68
69
  var buttonRadiusStyle = useEuiButtonRadiusCSS()[size];
69
70
  var cssStyles = [styles.euiButtonDisplay, styles[size], fullWidth && styles.fullWidth, buttonIsDisabled && styles.isDisabled, buttonRadiusStyle];
70
71
 
@@ -73,6 +74,7 @@ export var EuiButtonDisplay = /*#__PURE__*/forwardRef(function (_ref2, ref) {
73
74
  isDisabled: buttonIsDisabled,
74
75
  iconType: iconType,
75
76
  iconSide: iconSide,
77
+ iconSize: iconSize,
76
78
  textProps: _objectSpread({}, textProps)
77
79
  }, contentProps), children);
78
80
 
@@ -102,6 +104,9 @@ export var EuiButtonDisplay = /*#__PURE__*/forwardRef(function (_ref2, ref) {
102
104
 
103
105
  return createElement(element, _objectSpread(_objectSpread(_objectSpread({
104
106
  css: cssStyles,
107
+ style: minWidth ? _objectSpread(_objectSpread({}, style), {}, {
108
+ minWidth: minWidth
109
+ }) : style,
105
110
  ref: ref
106
111
  }, elementProps), relObj), rest), innerNode);
107
112
  });
@@ -28,11 +28,11 @@ var _ref = process.env.NODE_ENV === "production" ? {
28
28
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
29
29
  };
30
30
 
31
- export var euiButtonDisplayStyles = function euiButtonDisplayStyles(euiThemeContext, minWidth) {
31
+ export var euiButtonDisplayStyles = function euiButtonDisplayStyles(euiThemeContext) {
32
32
  var euiTheme = euiThemeContext.euiTheme;
33
33
  return {
34
34
  // Base
35
- euiButtonDisplay: /*#__PURE__*/css(euiButtonBaseCSS(), ";", minWidth && logicalCSS('min-width', minWidth), ";font-weight:", euiTheme.font.weight.medium, ";padding:0 ", euiTheme.size.m, ";&:hover:not(:disabled),&:focus{text-decoration:underline;};label:euiButtonDisplay;"),
35
+ euiButtonDisplay: /*#__PURE__*/css(euiButtonBaseCSS(), ";", logicalCSS('min-width', "".concat(euiTheme.base * 7, "px")), " font-weight:", euiTheme.font.weight.medium, ";padding:0 ", euiTheme.size.m, ";&:hover:not(:disabled),&:focus{text-decoration:underline;};label:euiButtonDisplay;"),
36
36
  // States
37
37
  isDisabled: _ref,
38
38
  fullWidth: /*#__PURE__*/css("display:block;", logicalCSS('width', '100%'), ";;label:fullWidth;"),
@@ -16,6 +16,8 @@ import { EuiIcon } from '../../icon';
16
16
  import { euiButtonDisplayContentStyles } from './_button_display_content.styles';
17
17
  import classNames from 'classnames';
18
18
  import { jsx as ___EmotionJSX } from "@emotion/react";
19
+ export var ICON_SIZES = ['s', 'm'];
20
+ export var ICON_SIDES = ['left', 'right'];
19
21
  export var EuiButtonDisplayContent = function EuiButtonDisplayContent(_ref) {
20
22
  var children = _ref.children,
21
23
  textProps = _ref.textProps,
@@ -33,7 +35,7 @@ export var EuiButtonDisplayContent = function EuiButtonDisplayContent(_ref) {
33
35
  var styles = euiButtonDisplayContentStyles(theme);
34
36
  var cssStyles = [styles.euiButtonDisplayContent, iconSide && styles[iconSide]];
35
37
  var cssSpinnerStyles = [styles.euiButtonDisplayContent__spinner];
36
- var cssIconStyles = [styles.euiButtonDisplayContent__icon]; // Add an icon to the button if one exists.
38
+ var cssIconStyles = [styles.euiButtonDisplayContent__icon, iconSize && styles[iconSize]]; // Add an icon to the button if one exists.
37
39
 
38
40
  var icon; // When the button is disabled the text gets gray
39
41
  // and in some buttons the background gets a light gray
@@ -46,6 +46,9 @@ export var euiButtonDisplayContentStyles = function euiButtonDisplayContentStyle
46
46
  left: /*#__PURE__*/css(";label:left;"),
47
47
  right: _ref3,
48
48
  euiButtonDisplayContent__spinner: _ref2,
49
- euiButtonDisplayContent__icon: _ref
49
+ euiButtonDisplayContent__icon: _ref,
50
+ // Icon size
51
+ s: /*#__PURE__*/css(";label:s;"),
52
+ m: /*#__PURE__*/css(";label:m;")
50
53
  };
51
54
  };
@@ -76,7 +76,7 @@ export var EuiCard = function EuiCard(_ref) {
76
76
  var isDisabled = _isDisabled || !isHrefValid;
77
77
  var isClickable = !isDisabled && (onClick || href || selectable && !selectable.isDisabled);
78
78
  var euiThemeContext = useEuiTheme();
79
- var styles = euiCardStyles(euiThemeContext, paddingSize, display);
79
+ var styles = euiCardStyles(euiThemeContext, paddingSize);
80
80
  var cardStyles = [styles.card.euiCard, // Text alignment should always be left when horizontal
81
81
  styles.card.aligned[layout === 'horizontal' ? 'left' : textAlign], styles.card.layout[layout], isDisabled && styles.card.disabled];
82
82
  var contentStyles = [styles.content.euiCard__content, styles.content.layout[layout]];
@@ -122,7 +122,7 @@ export var EuiCard = function EuiCard(_ref) {
122
122
 
123
123
  if (image && layout === 'vertical') {
124
124
  if ( /*#__PURE__*/isValidElement(image) || typeof image === 'string') {
125
- var imageStyles = [styles.euiCard__image];
125
+ var imageStyles = [styles.image.euiCard__image, display === 'transparent' && styles.image.transparent];
126
126
  imageNode = ___EmotionJSX("div", {
127
127
  className: "euiCard__image",
128
128
  css: imageStyles
@@ -54,7 +54,7 @@ var _ref5 = process.env.NODE_ENV === "production" ? {
54
54
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
55
55
  };
56
56
 
57
- export var euiCardStyles = function euiCardStyles(euiThemeContext, paddingSize, color) {
57
+ export var euiCardStyles = function euiCardStyles(euiThemeContext, paddingSize) {
58
58
  var euiTheme = euiThemeContext.euiTheme;
59
59
  var paddingAmount = euiPaddingSize(euiThemeContext, paddingSize);
60
60
  var spacing = euiPaddingSize(euiThemeContext, paddingKey);
@@ -91,7 +91,10 @@ export var euiCardStyles = function euiCardStyles(euiThemeContext, paddingSize,
91
91
  },
92
92
  disabled: _ref2
93
93
  },
94
- euiCard__image: /*#__PURE__*/css("position:relative;overflow:hidden;", logicalCSS('width', "calc(100% + (".concat(paddingAmount, " * 2))")), ";", logicalCSS('left', "-".concat(paddingAmount)), ";", logicalCSS('top', "-".concat(paddingAmount)), ";", logicalCSS('margin-bottom', "-".concat(paddingAmount)), ";", logicalCSS('border-top-left-radius', "calc(".concat(euiTheme.border.radius.medium, " - ").concat(euiTheme.border.width.thin, ")")), " ", logicals['border-top-right-radius'], ":calc(", euiTheme.border.radius.medium, " - ", euiTheme.border.width.thin, ");", color === 'transparent' ? "border-radius: ".concat(euiTheme.border.radius.medium, ";") : undefined, " img{", logicalCSS('width', '100%'), ";};label:euiCard__image;"),
94
+ image: {
95
+ euiCard__image: /*#__PURE__*/css("position:relative;overflow:hidden;", logicalCSS('width', "calc(100% + (".concat(paddingAmount, " * 2))")), ";", logicalCSS('left', "-".concat(paddingAmount)), ";", logicalCSS('top', "-".concat(paddingAmount)), ";", logicalCSS('margin-bottom', "-".concat(paddingAmount)), ";", logicalCSS('border-top-left-radius', "calc(".concat(euiTheme.border.radius.medium, " - ").concat(euiTheme.border.width.thin, ")")), " ", logicals['border-top-right-radius'], ":calc(", euiTheme.border.radius.medium, " - ", euiTheme.border.width.thin, ");img{", logicalCSS('width', '100%'), ";};label:euiCard__image;"),
96
+ transparent: /*#__PURE__*/css("border-radius:", euiTheme.border.radius.medium, ";;label:transparent;")
97
+ },
95
98
  icon: {
96
99
  euiCard__icon: /*#__PURE__*/css(";label:euiCard__icon;"),
97
100
  withImage: /*#__PURE__*/css("position:absolute;", logicalCSS('top', '50%'), ";", logicalCSS('left', '50%'), ";transform:translate(-50%, calc(-50% + -", paddingAmount, "))!important;;label:withImage;"),
@@ -26,9 +26,9 @@ export var EuiPopoverTitle = function EuiPopoverTitle(_ref) {
26
26
  panelPadding = _useContext.paddingSize;
27
27
 
28
28
  var euiTheme = useEuiTheme();
29
- var styles = euiPopoverTitleStyles(euiTheme, panelPadding);
29
+ var styles = euiPopoverTitleStyles(euiTheme);
30
30
  var paddingStyles = useEuiPaddingCSS();
31
- var cssStyles = [styles.euiPopoverTitle, // If a paddingSize is not directly provided, inherit from the EuiPopoverPanel
31
+ var cssStyles = [styles.euiPopoverTitle, styles.panelPaddingSizes[panelPadding], // If a paddingSize is not directly provided, inherit from the EuiPopoverPanel
32
32
  paddingStyles[paddingSize || panelPadding]];
33
33
  var classes = classNames('euiPopoverTitle', className);
34
34
  return ___EmotionJSX("div", _extends({
@@ -8,13 +8,25 @@
8
8
  import { css } from '@emotion/react';
9
9
  import { euiPaddingSize, logicalCSS } from '../../global_styling';
10
10
  import { euiTitle } from '../title/title.styles';
11
- export var euiPopoverTitleStyles = function euiPopoverTitleStyles(euiThemeContext, panelPadding) {
12
- var euiTheme = euiThemeContext.euiTheme; // If the popover's containing panel has padding applied,
13
- // ensure the title expands to cover that padding and
14
-
15
- var panelPaddingSize = euiPaddingSize(euiThemeContext, panelPadding);
11
+ export var euiPopoverTitleStyles = function euiPopoverTitleStyles(euiThemeContext) {
12
+ var euiTheme = euiThemeContext.euiTheme;
16
13
  return {
17
14
  // Base
18
- euiPopoverTitle: /*#__PURE__*/css(euiTitle(euiThemeContext, 'xxs'), ";", logicalCSS('border-bottom', euiTheme.border.thin), ";margin:-", panelPaddingSize, " -", panelPaddingSize, " ", panelPaddingSize, ";;label:euiPopoverTitle;")
15
+ euiPopoverTitle: /*#__PURE__*/css(euiTitle(euiThemeContext, 'xxs'), ";", logicalCSS('border-bottom', euiTheme.border.thin), ";;label:euiPopoverTitle;"),
16
+ // If the popover's containing panel has padding applied,
17
+ // ensure the title expands to cover that padding via negative margins
18
+ panelPaddingSizes: {
19
+ none: /*#__PURE__*/css(";label:none;"),
20
+ xs: /*#__PURE__*/css(getPaddingOffset(euiThemeContext, 'xs'), ";;label:xs;"),
21
+ s: /*#__PURE__*/css(getPaddingOffset(euiThemeContext, 's'), ";;label:s;"),
22
+ m: /*#__PURE__*/css(getPaddingOffset(euiThemeContext, 'm'), ";;label:m;"),
23
+ l: /*#__PURE__*/css(getPaddingOffset(euiThemeContext, 'l'), ";;label:l;"),
24
+ xl: /*#__PURE__*/css(getPaddingOffset(euiThemeContext, 'xl'), ";;label:xl;")
25
+ }
19
26
  };
27
+ };
28
+
29
+ var getPaddingOffset = function getPaddingOffset(euiThemeContext, size) {
30
+ var panelPaddingSize = euiPaddingSize(euiThemeContext, size);
31
+ return "margin: -".concat(panelPaddingSize, " -").concat(panelPaddingSize, " ").concat(panelPaddingSize, ";");
20
32
  };
@@ -0,0 +1,16 @@
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
+ import React from 'react';
9
+ import { jsx as ___EmotionJSX } from "@emotion/react";
10
+ export var CustomComponentFilter = function CustomComponentFilter(props) {
11
+ var CustomComponent = props.config.component;
12
+ return ___EmotionJSX(CustomComponent, {
13
+ query: props.query,
14
+ onChange: props.onChange
15
+ });
16
+ };
@@ -12,6 +12,7 @@ import { IsFilter } from './is_filter';
12
12
  import { FieldValueSelectionFilter } from './field_value_selection_filter';
13
13
  import { FieldValueToggleFilter } from './field_value_toggle_filter';
14
14
  import { FieldValueToggleGroupFilter } from './field_value_toggle_group_filter';
15
+ import { CustomComponentFilter } from './custom_component_filter';
15
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
16
17
  export var createFilter = function createFilter(index, config, query, onChange) {
17
18
  var props = {
@@ -45,6 +46,11 @@ export var createFilter = function createFilter(index, config, query, onChange)
45
46
  config: config
46
47
  }));
47
48
 
49
+ case 'custom_component':
50
+ return ___EmotionJSX(CustomComponentFilter, _extends({}, props, {
51
+ config: config
52
+ }));
53
+
48
54
  default:
49
55
  // @ts-ignore TS knows that we've checked `config.type` exhaustively
50
56
  throw new Error("Unknown search filter type [".concat(config.type, "]"));
@@ -528,6 +528,18 @@ export var _AST = /*#__PURE__*/function () {
528
528
  return !Is.isInstance(clause) || clause.flag !== flag;
529
529
  }));
530
530
  }
531
+ }, {
532
+ key: "removeIsClauses",
533
+ value: function removeIsClauses() {
534
+ return new _AST(this._clauses.filter(function (clause) {
535
+ return !Is.isInstance(clause);
536
+ }));
537
+ }
538
+ }, {
539
+ key: "removeAllClauses",
540
+ value: function removeAllClauses() {
541
+ return new _AST();
542
+ }
531
543
  }, {
532
544
  key: "getGroupClauses",
533
545
  value: function getGroupClauses() {
@@ -1,5 +1,5 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
 
4
4
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
5
 
@@ -14,11 +14,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
14
14
  * in compliance with, at your election, the Elastic License 2.0 or the Server
15
15
  * Side Public License, v 1.
16
16
  */
17
- import { printIso8601 } from './date_format';
18
- import { isDateValue, dateValue } from './date_value';
19
- import { AST } from './ast';
20
17
  import { isArray, isDateLike, isString } from '../../../services/predicate';
21
18
  import { keysOf } from '../../common';
19
+ import { AST } from './ast';
20
+ import { printIso8601 } from './date_format';
21
+ import { dateValue, isDateValue } from './date_value';
22
22
 
23
23
  var processDateOperation = function processDateOperation(value, operator) {
24
24
  var granularity = value.granularity,
@@ -108,12 +108,17 @@ export var _fieldValuesToQuery = function _fieldValuesToQuery(field, operations,
108
108
  }
109
109
  });
110
110
 
111
- if (_terms.length > 0) {
111
+ if (_terms.length > 1) {
112
+ queries.push({
113
+ bool: _defineProperty({}, andOr === 'and' ? 'must' : 'should', _toConsumableArray(_terms.map(function (value) {
114
+ return {
115
+ match: _defineProperty({}, field, value)
116
+ };
117
+ })))
118
+ });
119
+ } else if (_terms.length === 1) {
112
120
  queries.push({
113
- match: _defineProperty({}, field, {
114
- query: _terms.join(' '),
115
- operator: andOr
116
- })
121
+ match: _defineProperty({}, field, _terms[0])
117
122
  });
118
123
  }
119
124