@elastic/eui 69.0.0 → 70.0.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 (191) hide show
  1. package/dist/eui_theme_dark.css +0 -375
  2. package/dist/eui_theme_dark.json +0 -27
  3. package/dist/eui_theme_dark.json.d.ts +0 -27
  4. package/dist/eui_theme_dark.min.css +1 -1
  5. package/dist/eui_theme_light.css +0 -375
  6. package/dist/eui_theme_light.json +0 -27
  7. package/dist/eui_theme_light.json.d.ts +0 -27
  8. package/dist/eui_theme_light.min.css +1 -1
  9. package/es/components/basic_table/in_memory_table.js +8 -2
  10. package/es/components/code/code.js +7 -3
  11. package/es/components/code/code.styles.js +32 -0
  12. package/es/components/code/code_block.js +72 -315
  13. package/es/components/code/code_block.styles.js +153 -0
  14. package/es/components/code/code_block_controls.js +29 -0
  15. package/es/components/code/code_block_controls.styles.js +43 -0
  16. package/es/components/code/code_block_copy.js +65 -0
  17. package/es/components/code/code_block_full_screen.js +90 -0
  18. package/es/components/code/code_block_line.styles.js +49 -0
  19. package/es/components/code/code_block_overflow.js +78 -0
  20. package/es/components/code/code_block_virtualized.js +59 -0
  21. package/es/components/code/code_syntax.styles.js +43 -0
  22. package/es/components/code/utils.js +43 -37
  23. package/es/components/collapsible_nav/collapsible_nav.js +0 -5
  24. package/es/components/overlay_mask/overlay_mask.js +8 -14
  25. package/es/components/overlay_mask/overlay_mask.styles.js +4 -14
  26. package/es/components/overlay_mask/overlay_mask_body.styles.js +18 -0
  27. package/es/components/provider/provider.js +1 -5
  28. package/es/components/resizable_container/helpers.js +2 -2
  29. package/es/components/resizable_container/resizable_container.js +6 -9
  30. package/es/components/resizable_container/resizable_container.styles.js +28 -0
  31. package/es/components/resizable_container/resizable_panel.js +25 -48
  32. package/es/components/resizable_container/resizable_panel.styles.js +69 -0
  33. package/es/components/search_bar/query/ast.js +14 -3
  34. package/es/components/tool_tip/tool_tip.js +3 -2
  35. package/es/components/tool_tip/tool_tip.styles.js +17 -22
  36. package/es/components/tool_tip/tool_tip_arrow.js +17 -3
  37. package/es/components/tool_tip/tool_tip_popover.js +7 -7
  38. package/es/components/tour/tour.styles.js +4 -3
  39. package/es/components/tour/tour_step.js +7 -5
  40. package/es/global_styling/functions/logicals.js +5 -3
  41. package/es/global_styling/functions/math.js +37 -19
  42. package/es/global_styling/mixins/_padding.js +13 -9
  43. package/eui.d.ts +291 -37
  44. package/i18ntokens.json +22 -22
  45. package/lib/components/basic_table/in_memory_table.js +8 -2
  46. package/lib/components/code/code.js +9 -3
  47. package/lib/components/code/code.styles.js +35 -0
  48. package/lib/components/code/code_block.js +72 -320
  49. package/lib/components/code/code_block.styles.js +154 -0
  50. package/lib/components/code/code_block_controls.js +48 -0
  51. package/lib/components/code/code_block_controls.styles.js +39 -0
  52. package/lib/components/code/code_block_copy.js +78 -0
  53. package/lib/components/code/code_block_full_screen.js +108 -0
  54. package/lib/components/code/code_block_line.styles.js +45 -0
  55. package/lib/components/code/code_block_overflow.js +82 -0
  56. package/lib/components/code/code_block_virtualized.js +72 -0
  57. package/lib/components/code/code_syntax.styles.js +57 -0
  58. package/lib/components/code/utils.js +40 -39
  59. package/lib/components/collapsible_nav/collapsible_nav.js +0 -5
  60. package/lib/components/overlay_mask/overlay_mask.js +9 -14
  61. package/lib/components/overlay_mask/overlay_mask.styles.js +13 -17
  62. package/lib/components/overlay_mask/overlay_mask_body.styles.js +20 -0
  63. package/lib/components/provider/provider.js +7 -12
  64. package/lib/components/resizable_container/helpers.js +2 -2
  65. package/lib/components/resizable_container/resizable_container.js +7 -9
  66. package/lib/components/resizable_container/resizable_container.styles.js +31 -0
  67. package/lib/components/resizable_container/resizable_panel.js +28 -49
  68. package/lib/components/resizable_container/resizable_panel.styles.js +74 -0
  69. package/lib/components/search_bar/query/ast.js +14 -3
  70. package/lib/components/tool_tip/tool_tip.js +3 -2
  71. package/lib/components/tool_tip/tool_tip.styles.js +18 -26
  72. package/lib/components/tool_tip/tool_tip_arrow.js +19 -4
  73. package/lib/components/tool_tip/tool_tip_popover.js +6 -6
  74. package/lib/components/tour/tour.styles.js +3 -2
  75. package/lib/components/tour/tour_step.js +7 -5
  76. package/lib/global_styling/functions/logicals.js +5 -3
  77. package/lib/global_styling/functions/math.js +37 -19
  78. package/lib/global_styling/mixins/_padding.js +17 -10
  79. package/optimize/es/components/basic_table/in_memory_table.js +1 -1
  80. package/optimize/es/components/code/code.js +7 -3
  81. package/optimize/es/components/code/code.styles.js +32 -0
  82. package/optimize/es/components/code/code_block.js +70 -299
  83. package/optimize/es/components/code/code_block.styles.js +153 -0
  84. package/optimize/es/components/code/code_block_controls.js +29 -0
  85. package/optimize/es/components/code/code_block_controls.styles.js +43 -0
  86. package/optimize/es/components/code/code_block_copy.js +55 -0
  87. package/optimize/es/components/code/code_block_full_screen.js +80 -0
  88. package/optimize/es/components/code/code_block_line.styles.js +49 -0
  89. package/optimize/es/components/code/code_block_overflow.js +67 -0
  90. package/optimize/es/components/code/code_block_virtualized.js +59 -0
  91. package/optimize/es/components/code/code_syntax.styles.js +43 -0
  92. package/optimize/es/components/code/utils.js +43 -37
  93. package/optimize/es/components/overlay_mask/overlay_mask.js +8 -9
  94. package/optimize/es/components/overlay_mask/overlay_mask.styles.js +4 -14
  95. package/optimize/es/components/overlay_mask/overlay_mask_body.styles.js +18 -0
  96. package/optimize/es/components/provider/provider.js +1 -5
  97. package/optimize/es/components/resizable_container/helpers.js +2 -2
  98. package/optimize/es/components/resizable_container/resizable_container.js +6 -9
  99. package/optimize/es/components/resizable_container/resizable_container.styles.js +28 -0
  100. package/optimize/es/components/resizable_container/resizable_panel.js +25 -48
  101. package/optimize/es/components/resizable_container/resizable_panel.styles.js +69 -0
  102. package/optimize/es/components/search_bar/query/ast.js +14 -3
  103. package/optimize/es/components/tool_tip/tool_tip.js +3 -2
  104. package/optimize/es/components/tool_tip/tool_tip.styles.js +17 -22
  105. package/optimize/es/components/tool_tip/tool_tip_arrow.js +9 -3
  106. package/optimize/es/components/tool_tip/tool_tip_popover.js +7 -7
  107. package/optimize/es/components/tour/tour.styles.js +4 -3
  108. package/optimize/es/components/tour/tour_step.js +7 -5
  109. package/optimize/es/global_styling/functions/logicals.js +5 -3
  110. package/optimize/es/global_styling/functions/math.js +35 -17
  111. package/optimize/es/global_styling/mixins/_padding.js +13 -9
  112. package/optimize/lib/components/basic_table/in_memory_table.js +1 -1
  113. package/optimize/lib/components/code/code.js +9 -3
  114. package/optimize/lib/components/code/code.styles.js +35 -0
  115. package/optimize/lib/components/code/code_block.js +71 -306
  116. package/optimize/lib/components/code/code_block.styles.js +156 -0
  117. package/optimize/lib/components/code/code_block_controls.js +48 -0
  118. package/optimize/lib/components/code/code_block_controls.styles.js +39 -0
  119. package/optimize/lib/components/code/code_block_copy.js +78 -0
  120. package/optimize/lib/components/code/code_block_full_screen.js +108 -0
  121. package/optimize/lib/components/code/code_block_line.styles.js +45 -0
  122. package/optimize/lib/components/code/code_block_overflow.js +82 -0
  123. package/optimize/lib/components/code/code_block_virtualized.js +81 -0
  124. package/optimize/lib/components/code/code_syntax.styles.js +57 -0
  125. package/optimize/lib/components/code/utils.js +40 -37
  126. package/optimize/lib/components/overlay_mask/overlay_mask.js +9 -9
  127. package/optimize/lib/components/overlay_mask/overlay_mask.styles.js +13 -17
  128. package/optimize/lib/components/overlay_mask/overlay_mask_body.styles.js +20 -0
  129. package/optimize/lib/components/provider/provider.js +7 -12
  130. package/optimize/lib/components/resizable_container/helpers.js +2 -2
  131. package/optimize/lib/components/resizable_container/resizable_container.js +7 -9
  132. package/optimize/lib/components/resizable_container/resizable_container.styles.js +31 -0
  133. package/optimize/lib/components/resizable_container/resizable_panel.js +28 -49
  134. package/optimize/lib/components/resizable_container/resizable_panel.styles.js +76 -0
  135. package/optimize/lib/components/search_bar/query/ast.js +14 -3
  136. package/optimize/lib/components/tool_tip/tool_tip.js +3 -2
  137. package/optimize/lib/components/tool_tip/tool_tip.styles.js +18 -26
  138. package/optimize/lib/components/tool_tip/tool_tip_arrow.js +10 -10
  139. package/optimize/lib/components/tool_tip/tool_tip_popover.js +6 -6
  140. package/optimize/lib/components/tour/tour.styles.js +3 -2
  141. package/optimize/lib/components/tour/tour_step.js +7 -5
  142. package/optimize/lib/global_styling/functions/logicals.js +4 -10
  143. package/optimize/lib/global_styling/functions/math.js +37 -19
  144. package/optimize/lib/global_styling/mixins/_padding.js +17 -10
  145. package/package.json +8 -7
  146. package/src/components/index.scss +0 -1
  147. package/src/components/resizable_container/_index.scss +0 -2
  148. package/src/global_styling/mixins/_header.scss +1 -1
  149. package/src/global_styling/variables/_index.scss +0 -1
  150. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  151. package/test-env/components/basic_table/in_memory_table.js +8 -2
  152. package/test-env/components/code/code.styles.js +35 -0
  153. package/test-env/components/code/code_block.styles.js +156 -0
  154. package/test-env/components/code/code_block_controls.js +48 -0
  155. package/test-env/components/code/code_block_controls.styles.js +39 -0
  156. package/test-env/components/code/code_block_copy.js +78 -0
  157. package/test-env/components/code/code_block_full_screen.js +108 -0
  158. package/test-env/components/code/code_block_line.styles.js +45 -0
  159. package/test-env/components/code/code_block_overflow.js +82 -0
  160. package/test-env/components/code/code_block_virtualized.js +81 -0
  161. package/test-env/components/code/code_syntax.styles.js +57 -0
  162. package/test-env/components/code/utils.js +40 -37
  163. package/test-env/components/collapsible_nav/collapsible_nav.js +0 -5
  164. package/test-env/components/overlay_mask/overlay_mask.js +9 -14
  165. package/test-env/components/overlay_mask/overlay_mask.styles.js +13 -17
  166. package/test-env/components/overlay_mask/overlay_mask_body.styles.js +20 -0
  167. package/test-env/components/provider/provider.js +7 -12
  168. package/test-env/components/resizable_container/helpers.js +2 -2
  169. package/test-env/components/resizable_container/resizable_container.js +7 -9
  170. package/test-env/components/resizable_container/resizable_container.styles.js +31 -0
  171. package/test-env/components/resizable_container/resizable_panel.js +28 -49
  172. package/test-env/components/resizable_container/resizable_panel.styles.js +76 -0
  173. package/test-env/components/search_bar/query/ast.js +14 -3
  174. package/test-env/components/tool_tip/tool_tip.js +3 -2
  175. package/test-env/components/tool_tip/tool_tip.styles.js +18 -26
  176. package/test-env/components/tool_tip/tool_tip_arrow.js +16 -11
  177. package/test-env/components/tool_tip/tool_tip_popover.js +6 -6
  178. package/test-env/components/tour/tour.styles.js +3 -2
  179. package/test-env/components/tour/tour_step.js +7 -5
  180. package/test-env/global_styling/functions/logicals.js +4 -10
  181. package/test-env/global_styling/functions/math.js +37 -19
  182. package/test-env/global_styling/mixins/_padding.js +17 -10
  183. package/src/components/code/_code.scss +0 -15
  184. package/src/components/code/_code_block.scss +0 -177
  185. package/src/components/code/_index.scss +0 -4
  186. package/src/components/code/_mixins.scss +0 -127
  187. package/src/components/code/_variables.scss +0 -5
  188. package/src/components/resizable_container/_resizable_container.scss +0 -8
  189. package/src/components/resizable_container/_resizable_panel.scss +0 -51
  190. package/src/global_styling/variables/_colors_code.scss +0 -23
  191. package/src/themes/amsterdam/overrides/_code.scss +0 -9
@@ -23,11 +23,8 @@ import { EuiResizableContainerContextProvider } from './context';
23
23
  import { euiResizableButtonWithControls } from './resizable_button';
24
24
  import { euiResizablePanelWithControls, getModeType } from './resizable_panel';
25
25
  import { useContainerCallbacks, getPosition } from './helpers';
26
+ import { euiResizableContainerStyles } from './resizable_container.styles';
26
27
  import { jsx as ___EmotionJSX } from "@emotion/react";
27
- var containerDirections = {
28
- vertical: 'vertical',
29
- horizontal: 'horizontal'
30
- };
31
28
  var initialState = {
32
29
  isDragging: false,
33
30
  currentResizerPos: -1,
@@ -49,11 +46,10 @@ export var EuiResizableContainer = function EuiResizableContainer(_ref) {
49
46
  rest = _objectWithoutProperties(_ref, _excluded);
50
47
 
51
48
  var containerRef = useRef(null);
52
- var isHorizontal = direction === containerDirections.horizontal;
53
- var classes = classNames('euiResizableContainer', {
54
- 'euiResizableContainer--vertical': !isHorizontal,
55
- 'euiResizableContainer--horizontal': isHorizontal
56
- }, className);
49
+ var isHorizontal = direction === 'horizontal';
50
+ var classes = classNames('euiResizableContainer', className);
51
+ var styles = euiResizableContainerStyles();
52
+ var cssStyles = [styles.euiResizableContainer, styles[direction]];
57
53
 
58
54
  var _useContainerCallback = useContainerCallbacks({
59
55
  initialState: _objectSpread(_objectSpread({}, initialState), {}, {
@@ -226,6 +222,7 @@ export var EuiResizableContainer = function EuiResizableContainer(_ref) {
226
222
  resizers: reducerState.resizers
227
223
  }
228
224
  }, ___EmotionJSX("div", _extends({
225
+ css: cssStyles,
229
226
  className: classes,
230
227
  ref: containerRef,
231
228
  onMouseMove: reducerState.isDragging ? onMouseMove : undefined,
@@ -0,0 +1,28 @@
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 { logicalCSS } from '../../global_styling';
12
+
13
+ var _ref = process.env.NODE_ENV === "production" ? {
14
+ name: "omnk2l-vertical",
15
+ styles: "flex-direction:column;label:vertical;"
16
+ } : {
17
+ name: "omnk2l-vertical",
18
+ styles: "flex-direction:column;label:vertical;",
19
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
20
+ };
21
+
22
+ export var euiResizableContainerStyles = function euiResizableContainerStyles() {
23
+ return {
24
+ euiResizableContainer: /*#__PURE__*/css("display:flex;", logicalCSS('width', '100%'), ";;label:euiResizableContainer;"),
25
+ horizontal: /*#__PURE__*/css(";label:horizontal;"),
26
+ vertical: _ref
27
+ };
28
+ };
@@ -17,20 +17,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
17
  */
18
18
  import React, { useEffect, useMemo, useRef } from 'react';
19
19
  import classNames from 'classnames';
20
+ import { useGeneratedHtmlId, useEuiTheme } from '../../services';
21
+ import { logicalSizeStyle, euiPaddingSize } from '../../global_styling';
20
22
  import { useEuiResizableContainerContext } from './context';
21
- import { useGeneratedHtmlId } from '../../services';
22
23
  import { EuiPanel } from '../panel';
23
24
  import { useEuiI18n } from '../i18n';
24
25
  import { EuiResizableCollapseButton } from './resizable_collapse_button';
26
+ import { euiResizablePanelStyles, euiResizablePanelContentStyles } from './resizable_panel.styles';
25
27
  import { jsx as ___EmotionJSX } from "@emotion/react";
26
- var panelPaddingValues = {
27
- none: 0,
28
- xs: 4,
29
- s: 8,
30
- m: 16,
31
- l: 24,
32
- xl: 32
33
- };
34
28
  var defaultToggleOptions = {
35
29
  className: null,
36
30
  'data-test-subj': undefined,
@@ -42,12 +36,6 @@ export var getModeType = function getModeType(mode) {
42
36
  export var getToggleOptions = function getToggleOptions(mode) {
43
37
  return _typeof(mode) === 'object' ? _objectSpread(_objectSpread({}, defaultToggleOptions), mode[1]) : defaultToggleOptions;
44
38
  };
45
- var paddingSizeToClassNameMap = {
46
- none: null,
47
- s: 'euiResizablePanel--paddingSmall',
48
- m: 'euiResizablePanel--paddingMedium',
49
- l: 'euiResizablePanel--paddingLarge'
50
- };
51
39
 
52
40
  var getPosition = function getPosition(ref) {
53
41
  var position = 'middle';
@@ -154,34 +142,18 @@ export var EuiResizablePanel = function EuiResizablePanel(_ref) {
154
142
 
155
143
  return direction;
156
144
  }, [isCollapsed, isCollapsible, position, panels, panelId]);
157
- var padding = useMemo(function () {
158
- return "".concat(panelPaddingValues[paddingSize] * 2, "px");
159
- }, [paddingSize]);
160
- var classes = classNames('euiResizablePanel', // @ts-expect-error EuiPanel increased its available sizes
161
- // When we convert this component to Emotion, we should also increase sizes to match EuiPanel and remove this comment.
162
- paddingSizeToClassNameMap[wrapperPadding], {
163
- 'euiResizablePanel--collapsible': isCollapsible,
164
- 'euiResizablePanel-isCollapsed': isCollapsed
165
- }, "euiResizablePanel--".concat(position), wrapperProps && wrapperProps.className);
166
- var panelClasses = classNames('euiResizablePanel__content', {
167
- 'euiResizablePanel__content--scrollable': scrollable
168
- }, className);
169
- var dimensions;
170
-
171
- if (size) {
172
- dimensions = {
173
- width: isHorizontal ? "".concat(size, "%") : '100%',
174
- height: isHorizontal ? 'auto' : "".concat(size, "%")
175
- };
176
- } else {
177
- dimensions = {
178
- width: isHorizontal ? "".concat(innerSize, "%") : '100%',
179
- height: isHorizontal ? 'auto' : "".concat(innerSize, "%")
180
- };
181
- }
182
-
183
- var styles = _objectSpread(_objectSpread({}, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style), dimensions);
184
-
145
+ var axis = isHorizontal ? 'horizontal' : 'vertical';
146
+ var euiTheme = useEuiTheme();
147
+ var styles = euiResizablePanelStyles(euiTheme);
148
+ var cssStyles = [styles.euiResizablePanel, isCollapsed && styles.collapsed, styles.paddingSizes[wrapperPadding]];
149
+ var contentStyles = euiResizablePanelContentStyles(euiTheme);
150
+ var contentCssStyles = [contentStyles.euiResizablePanel__content, scrollable && contentStyles.scrollable, isCollapsed && contentStyles.collapsedChildren, isCollapsed && !isCollapsible && contentStyles[axis].collapsed, isCollapsible && contentStyles[axis].hasCollapsibleButton];
151
+ var classes = classNames('euiResizablePanel', wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.className);
152
+ var panelClasses = classNames('euiResizablePanel__content', className);
153
+
154
+ var inlineStyles = _objectSpread(_objectSpread({}, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style), isHorizontal ? logicalSizeStyle("".concat(size || innerSize, "%"), 'auto') : logicalSizeStyle('100%', "".concat(size || innerSize, "%")));
155
+
156
+ var padding = euiPaddingSize(euiTheme, paddingSize) || '0px';
185
157
  useEffect(function () {
186
158
  if (!registration) return;
187
159
  var initSize = size !== null && size !== void 0 ? size : initialSize || 0;
@@ -233,7 +205,7 @@ export var EuiResizablePanel = function EuiResizablePanel(_ref) {
233
205
  theResizer = resizers[resizerIds.current[0]];
234
206
  theToggle = ___EmotionJSX(EuiResizableCollapseButton, {
235
207
  externalPosition: "before",
236
- direction: isHorizontal ? 'horizontal' : 'vertical',
208
+ direction: axis,
237
209
  isVisible: theResizer && (theResizer.isFocused || theResizer.isDisabled),
238
210
  isCollapsed: theResizer && theResizer.isDisabled,
239
211
  internalPosition: toggleOpts.position,
@@ -245,7 +217,7 @@ export var EuiResizablePanel = function EuiResizablePanel(_ref) {
245
217
  theResizer = resizers[resizerIds.current[1]];
246
218
  theToggle = ___EmotionJSX(EuiResizableCollapseButton, {
247
219
  externalPosition: "after",
248
- direction: isHorizontal ? 'horizontal' : 'vertical',
220
+ direction: axis,
249
221
  isVisible: theResizer && (theResizer.isFocused || theResizer.isDisabled),
250
222
  isCollapsed: theResizer && theResizer.isDisabled,
251
223
  internalPosition: toggleOpts.position,
@@ -255,12 +227,17 @@ export var EuiResizablePanel = function EuiResizablePanel(_ref) {
255
227
  });
256
228
  }
257
229
 
258
- return ___EmotionJSX("div", _extends({}, wrapperProps, {
230
+ return ___EmotionJSX("div", _extends({
231
+ css: cssStyles
232
+ }, wrapperProps, {
259
233
  id: panelId,
260
234
  ref: divRef,
261
- style: styles,
262
- className: classes
235
+ style: inlineStyles,
236
+ className: classes,
237
+ "data-collapsed": isCollapsed || undefined,
238
+ "data-position": position
263
239
  }), hasVisibleToggle && hasLeftToggle && theToggle, ___EmotionJSX(EuiPanel, _extends({
240
+ css: contentCssStyles,
264
241
  className: panelClasses,
265
242
  hasShadow: hasShadow,
266
243
  borderRadius: borderRadius,
@@ -0,0 +1,69 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ 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; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ 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)."; }
8
+
9
+ /*
10
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
11
+ * or more contributor license agreements. Licensed under the Elastic License
12
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
13
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
14
+ * Side Public License, v 1.
15
+ */
16
+ import { css } from '@emotion/react';
17
+ import { logicalCSS, logicalCSSWithFallback, euiScrollBarStyles, euiPaddingSizeCSS } from '../../global_styling';
18
+
19
+ var _ref2 = process.env.NODE_ENV === "production" ? {
20
+ name: "11qmbh3-collapsed",
21
+ styles: "overflow:hidden;label:collapsed;"
22
+ } : {
23
+ name: "11qmbh3-collapsed",
24
+ styles: "overflow:hidden;label:collapsed;",
25
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
26
+ };
27
+
28
+ var _ref3 = process.env.NODE_ENV === "production" ? {
29
+ name: "15ifdgc-euiResizablePanel",
30
+ styles: "position:relative;label:euiResizablePanel;"
31
+ } : {
32
+ name: "15ifdgc-euiResizablePanel",
33
+ styles: "position:relative;label:euiResizablePanel;",
34
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
35
+ };
36
+
37
+ export var euiResizablePanelStyles = function euiResizablePanelStyles(euiThemeContext) {
38
+ return {
39
+ euiResizablePanel: _ref3,
40
+ collapsed: _ref2,
41
+ paddingSizes: _objectSpread({}, euiPaddingSizeCSS(euiThemeContext))
42
+ };
43
+ };
44
+
45
+ var _ref = process.env.NODE_ENV === "production" ? {
46
+ name: "597kt8-collapsedChildren",
47
+ styles: "*{display:none;};label:collapsedChildren;"
48
+ } : {
49
+ name: "597kt8-collapsedChildren",
50
+ styles: "*{display:none;};label:collapsedChildren;",
51
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
52
+ };
53
+
54
+ export var euiResizablePanelContentStyles = function euiResizablePanelContentStyles(euiThemeContext) {
55
+ var euiTheme = euiThemeContext.euiTheme;
56
+ return {
57
+ euiResizablePanel__content: /*#__PURE__*/css(logicalCSS('height', '100%'), ";;label:euiResizablePanel__content;"),
58
+ scrollable: /*#__PURE__*/css(euiScrollBarStyles(euiThemeContext), " ", logicalCSSWithFallback('overflow-y', 'auto'), ";;label:scrollable;"),
59
+ collapsedChildren: _ref,
60
+ horizontal: {
61
+ collapsed: /*#__PURE__*/css(logicalCSS('min-width', '0 !important'), ";;label:collapsed;"),
62
+ hasCollapsibleButton: /*#__PURE__*/css(logicalCSS('min-width', "".concat(euiTheme.size.l, " !important")), ";;label:hasCollapsibleButton;")
63
+ },
64
+ vertical: {
65
+ collapsed: /*#__PURE__*/css(logicalCSS('min-height', '0 !important'), ";;label:collapsed;"),
66
+ hasCollapsibleButton: /*#__PURE__*/css(logicalCSS('min-height', "".concat(euiTheme.size.l, " !important")), ";;label:hasCollapsibleButton;")
67
+ }
68
+ };
69
+ };
@@ -268,6 +268,10 @@ var arrayIncludesValue = function arrayIncludesValue(array, value) {
268
268
  return valuesEqual(item, value);
269
269
  });
270
270
  };
271
+
272
+ var mustToMatch = function mustToMatch(must) {
273
+ return must === true ? Match.MUST : Match.MUST_NOT;
274
+ };
271
275
  /**
272
276
  * The AST structure is an array of clauses. There are 3 types of clauses that are supported:
273
277
  *
@@ -392,9 +396,16 @@ export var _AST = /*#__PURE__*/function () {
392
396
  }
393
397
  }, {
394
398
  key: "getOrFieldClause",
395
- value: function getOrFieldClause(field, value) {
399
+ value: function getOrFieldClause(field, value, must, operator) {
396
400
  return this.getFieldClause(field, function (clause) {
397
- return isArray(clause.value) && (isNil(value) || arrayIncludesValue(clause.value, value));
401
+ if (!isArray(clause.value)) {
402
+ return false;
403
+ }
404
+
405
+ var matchValue = isNil(value) || arrayIncludesValue(clause.value, value);
406
+ var matchMust = isNil(must) || mustToMatch(must) === clause.match;
407
+ var matchOperator = isNil(operator) || operator === clause.operator;
408
+ return matchValue && matchMust && matchOperator;
398
409
  });
399
410
  }
400
411
  }, {
@@ -402,7 +413,7 @@ export var _AST = /*#__PURE__*/function () {
402
413
  value: function addOrFieldValue(field, value) {
403
414
  var must = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
404
415
  var operator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Operator.EQ;
405
- var existingClause = this.getOrFieldClause(field);
416
+ var existingClause = this.getOrFieldClause(field, undefined, must, operator);
406
417
 
407
418
  if (!existingClause) {
408
419
  var newClause = must ? Field.must[operator](field, [value]) : Field.mustNot[operator](field, [value]);
@@ -262,7 +262,7 @@ export var EuiToolTip = /*#__PURE__*/function (_Component) {
262
262
  toolTipStyles = _this$state.toolTipStyles,
263
263
  visible = _this$state.visible,
264
264
  calculatedPosition = _this$state.calculatedPosition;
265
- var classes = classNames('euiToolTip', positionsToClassNameMap[this.state.calculatedPosition], className);
265
+ var classes = classNames('euiToolTip', className);
266
266
  var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
267
267
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
268
268
  ref: this.setAnchorRef,
@@ -285,7 +285,8 @@ export var EuiToolTip = /*#__PURE__*/function (_Component) {
285
285
  calculatedPosition: calculatedPosition
286
286
  }, rest), ___EmotionJSX(EuiToolTipArrow, {
287
287
  style: arrowStyles,
288
- className: "euiToolTip__arrow"
288
+ className: "euiToolTip__arrow",
289
+ position: calculatedPosition
289
290
  }), ___EmotionJSX(EuiResizeObserver, {
290
291
  onResize: this.positionToolTip
291
292
  }, function (resizeRef) {
@@ -12,7 +12,7 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
12
12
  * Side Public License, v 1.
13
13
  */
14
14
  import { css, keyframes } from '@emotion/react';
15
- import { logicalCSS, logicalSizeCSS, euiFontSize, mathWithUnits } from '../../global_styling';
15
+ import { logicalCSS, logicalSizeCSS, euiFontSize, euiCanAnimate, mathWithUnits } from '../../global_styling';
16
16
  import { COLOR_MODES_STANDARD, tint, shade } from '../../services';
17
17
  import { euiShadow } from '../../themes/amsterdam';
18
18
  export var euiToolTipBackgroundColor = function euiToolTipBackgroundColor(euiTheme, colorMode) {
@@ -33,39 +33,34 @@ var euiToolTipAnimationHorizontal = function euiToolTipAnimationHorizontal(size)
33
33
  export var euiToolTipStyles = function euiToolTipStyles(euiThemeContext) {
34
34
  var euiTheme = euiThemeContext.euiTheme,
35
35
  colorMode = euiThemeContext.colorMode;
36
- var animationTiming = "".concat(euiTheme.animation.slow, " ease-out 0s forwards");
37
- /*
38
- * 1. Shift arrow 1px more than half its size to account for border radius
39
- */
36
+ var animationTiming = "".concat(euiTheme.animation.slow, " ease-out 0s forwards"); // Shift arrow 1px more than half its size to account for border radius
40
37
 
41
38
  var arrowSize = euiTheme.size.m;
42
39
  var arrowPlusSize = mathWithUnits(arrowSize, function (x) {
43
40
  return (x / 2 + 1) * -1;
44
- }); // 1.
45
-
41
+ });
46
42
  var arrowMinusSize = mathWithUnits(arrowSize, function (x) {
47
43
  return (x / 2 - 1) * -1;
48
- }); // 1.
49
-
44
+ });
50
45
  return {
51
46
  // Base
52
47
  euiToolTip: /*#__PURE__*/css(euiShadow(euiThemeContext), ";border-radius:", euiTheme.border.radius.medium, ";background-color:", euiToolTipBackgroundColor(euiTheme, colorMode), ";color:", euiTheme.colors.ghost, ";z-index:", euiTheme.levels.toast, ";", logicalCSS('max-width', '256px'), " overflow-wrap:break-word;padding:", euiTheme.size.s, ";", euiFontSize(euiThemeContext, 's'), ";position:absolute;[class*='euiHorizontalRule']{background-color:", euiToolTipBorderColor(euiTheme, colorMode), ";};label:euiToolTip;"),
53
48
  // Sizes
54
49
  s: /*#__PURE__*/css(euiFontSize(euiThemeContext, 'xs'), ";;label:s;"),
55
50
  // Positions
56
- top: /*#__PURE__*/css("animation:", euiToolTipAnimationVertical("-".concat(euiTheme.size.base)), " ", animationTiming, ";;label:top;"),
57
- bottom: /*#__PURE__*/css("animation:", euiToolTipAnimationVertical(euiTheme.size.base), " ", animationTiming, ";[class*='euiToolTip__arrow']{transform:translateY(", arrowMinusSize, ") rotateZ(45deg);};label:bottom;"),
58
- left: /*#__PURE__*/css("animation:", euiToolTipAnimationHorizontal("-".concat(euiTheme.size.base)), " ", animationTiming, ";[class*='euiToolTip__arrow']{transform:translateX(", arrowPlusSize, ") rotateZ(45deg);};label:left;"),
59
- right: /*#__PURE__*/css("animation:", euiToolTipAnimationHorizontal(euiTheme.size.base), " ", animationTiming, ";[class*='euiToolTip__arrow']{transform:translateX(", arrowMinusSize, ") rotateZ(45deg);};label:right;"),
60
- // Elements
61
- euiToolTip__arrow: /*#__PURE__*/css("content:'';position:absolute;transform-origin:center;border-radius:2px;background-color:", euiToolTipBackgroundColor(euiTheme, colorMode), ";", logicalSizeCSS(arrowSize, arrowSize), ";transform:translateY(", arrowPlusSize, ") rotateZ(45deg);;label:euiToolTip__arrow;")
62
- };
63
- };
64
- export var euiToolTipPopoverStyles = function euiToolTipPopoverStyles(_ref4) {
65
- var euiTheme = _ref4.euiTheme,
66
- colorMode = _ref4.colorMode;
67
- return {
68
- // Elements
51
+ top: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationVertical("-".concat(euiTheme.size.base)), " ", animationTiming, ";};label:top;"),
52
+ bottom: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationVertical(euiTheme.size.base), " ", animationTiming, ";};label:bottom;"),
53
+ left: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationHorizontal("-".concat(euiTheme.size.base)), " ", animationTiming, ";};label:left;"),
54
+ right: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationHorizontal(euiTheme.size.base), " ", animationTiming, ";};label:right;"),
55
+ // Arrow
56
+ euiToolTip__arrow: /*#__PURE__*/css("content:'';position:absolute;transform-origin:center;border-radius:2px;background-color:", euiToolTipBackgroundColor(euiTheme, colorMode), ";", logicalSizeCSS(arrowSize, arrowSize), ";;label:euiToolTip__arrow;"),
57
+ arrowPositions: {
58
+ top: /*#__PURE__*/css("transform:translateY(", arrowPlusSize, ") rotateZ(45deg);;label:top;"),
59
+ bottom: /*#__PURE__*/css("transform:translateY(", arrowMinusSize, ") rotateZ(45deg);;label:bottom;"),
60
+ left: /*#__PURE__*/css("transform:translateX(", arrowPlusSize, ") rotateZ(45deg);;label:left;"),
61
+ right: /*#__PURE__*/css("transform:translateX(", arrowMinusSize, ") rotateZ(45deg);;label:right;")
62
+ },
63
+ // Title
69
64
  euiToolTip__title: /*#__PURE__*/css("font-weight:", euiTheme.font.weight.bold, ";", logicalCSS('border-bottom', "solid ".concat(euiTheme.border.width.thin, " ").concat(euiToolTipBorderColor(euiTheme, colorMode))), ";", logicalCSS('padding-bottom', euiTheme.size.xs), ";", logicalCSS('margin-bottom', euiTheme.size.xs), ";;label:euiToolTip__title;")
70
65
  };
71
66
  };
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["position"];
2
4
 
3
5
  /*
4
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -11,10 +13,14 @@ import React from 'react';
11
13
  import { useEuiTheme } from '../../services';
12
14
  import { euiToolTipStyles } from './tool_tip.styles';
13
15
  import { jsx as ___EmotionJSX } from "@emotion/react";
14
- export var EuiToolTipArrow = function EuiToolTipArrow(props) {
16
+ export var EuiToolTipArrow = function EuiToolTipArrow(_ref) {
17
+ var position = _ref.position,
18
+ props = _objectWithoutProperties(_ref, _excluded);
19
+
15
20
  var euiTheme = useEuiTheme();
16
- var toolTipCss = euiToolTipStyles(euiTheme);
21
+ var styles = euiToolTipStyles(euiTheme);
22
+ var cssStyles = [styles.euiToolTip__arrow, styles.arrowPositions[position]];
17
23
  return ___EmotionJSX("div", _extends({
18
- css: [toolTipCss.euiToolTip__arrow, ";label:EuiToolTipArrow;"]
24
+ css: cssStyles
19
25
  }, props));
20
26
  };
@@ -12,7 +12,7 @@ var _excluded = ["children", "title", "className", "positionToolTip", "popoverRe
12
12
  import React, { useEffect, useRef, useCallback } from 'react';
13
13
  import classNames from 'classnames';
14
14
  import { useEuiTheme } from '../../services';
15
- import { euiToolTipStyles, euiToolTipPopoverStyles } from './tool_tip.styles';
15
+ import { euiToolTipStyles } from './tool_tip.styles';
16
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
17
17
  export var EuiToolTipPopover = function EuiToolTipPopover(_ref) {
18
18
  var children = _ref.children,
@@ -25,9 +25,8 @@ export var EuiToolTipPopover = function EuiToolTipPopover(_ref) {
25
25
 
26
26
  var popover = useRef();
27
27
  var euiTheme = useEuiTheme();
28
- var toolTipCss = euiToolTipStyles(euiTheme);
29
- var popoverStyles = euiToolTipPopoverStyles(euiTheme);
30
- var titleCss = [popoverStyles.euiToolTip__title];
28
+ var styles = euiToolTipStyles(euiTheme);
29
+ var cssStyles = [styles.euiToolTip, calculatedPosition && styles[calculatedPosition]];
31
30
  var updateDimensions = useCallback(function () {
32
31
  requestAnimationFrame(function () {
33
32
  // Because of this delay, sometimes `positionToolTip` becomes unavailable.
@@ -53,11 +52,12 @@ export var EuiToolTipPopover = function EuiToolTipPopover(_ref) {
53
52
  }, [updateDimensions]);
54
53
  var classes = classNames('euiToolTipPopover', className);
55
54
  return ___EmotionJSX("div", _extends({
56
- css: [toolTipCss.euiToolTip, calculatedPosition && toolTipCss[calculatedPosition], ";label:EuiToolTipPopover;"],
55
+ css: cssStyles,
57
56
  className: classes,
58
- ref: setPopoverRef
57
+ ref: setPopoverRef,
58
+ "data-position": calculatedPosition
59
59
  }, rest), title && ___EmotionJSX("div", {
60
- css: titleCss,
60
+ css: styles.euiToolTip__title,
61
61
  className: "euiToolTip__title"
62
62
  }, title), children);
63
63
  };
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { css } from '@emotion/react';
9
9
  import { shade, tint, COLOR_MODES_STANDARD } from '../../services';
10
- import { logicalCSS, mathWithUnits } from '../../global_styling';
10
+ import { logicalCSS, mathWithUnits, euiCanAnimate } from '../../global_styling';
11
11
  import { openAnimationTiming } from '../popover/popover_panel/_popover_panel.styles';
12
12
  import { popoverArrowSize } from '../popover/popover_arrow/_popover_arrow.styles';
13
13
 
@@ -20,7 +20,7 @@ export var euiTourStyles = function euiTourStyles(_ref) {
20
20
  colorMode = _ref.colorMode;
21
21
  return {
22
22
  // Targets EuiPopoverPanel
23
- euiTour: /*#__PURE__*/css("&[data-popover-open='true']{[class*='euiTourBeacon']{opacity:1;}}[data-popover-arrow='top']{&:before{", logicalCSS('border-top-color', backgroundColor(euiTheme.colors.lightestShade, colorMode)), ";}};label:euiTour;")
23
+ euiTour: /*#__PURE__*/css("[data-popover-arrow='top']::before{", logicalCSS('border-top-color', backgroundColor(euiTheme.colors.lightestShade, colorMode)), ";};label:euiTour;")
24
24
  };
25
25
  };
26
26
  export var euiTourBeaconStyles = function euiTourBeaconStyles(_ref2) {
@@ -34,7 +34,8 @@ export var euiTourBeaconStyles = function euiTourBeaconStyles(_ref2) {
34
34
  });
35
35
  return {
36
36
  // Base
37
- euiTourBeacon: /*#__PURE__*/css("pointer-events:none;position:absolute;opacity:0;transition:opacity 0s ", euiTheme.animation[openAnimationTiming], ";;label:euiTourBeacon;"),
37
+ euiTourBeacon: /*#__PURE__*/css("pointer-events:none;position:absolute;", euiCanAnimate, "{opacity:0;transition:opacity 0s ", euiTheme.animation[openAnimationTiming], ";};label:euiTourBeacon;"),
38
+ isOpen: /*#__PURE__*/css(euiCanAnimate, "{opacity:1;};label:isOpen;"),
38
39
  // Positions
39
40
  right: /*#__PURE__*/css(logicalCSS('top', arrowHalfSize), ";", logicalCSS('left', arrowOffset), ";;label:right;"),
40
41
  left: /*#__PURE__*/css(logicalCSS('top', arrowHalfSize), ";", logicalCSS('left', arrowSize), ";;label:left;"),
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
6
- var _excluded = ["anchorPosition", "anchor", "children", "className", "closePopover", "content", "isStepOpen", "minWidth", "maxWidth", "onFinish", "step", "stepsTotal", "style", "subtitle", "title", "decoration", "footerAction"];
6
+ var _excluded = ["anchorPosition", "anchor", "children", "className", "css", "closePopover", "content", "isStepOpen", "minWidth", "maxWidth", "onFinish", "step", "stepsTotal", "style", "subtitle", "title", "decoration", "footerAction", "panelProps"];
7
7
 
8
8
  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; }
9
9
 
@@ -34,6 +34,7 @@ export var EuiTourStep = function EuiTourStep(_ref) {
34
34
  anchor = _ref.anchor,
35
35
  children = _ref.children,
36
36
  className = _ref.className,
37
+ css = _ref.css,
37
38
  _ref$closePopover = _ref.closePopover,
38
39
  closePopover = _ref$closePopover === void 0 ? function () {} : _ref$closePopover,
39
40
  content = _ref.content,
@@ -53,6 +54,7 @@ export var EuiTourStep = function EuiTourStep(_ref) {
53
54
  _ref$decoration = _ref.decoration,
54
55
  decoration = _ref$decoration === void 0 ? 'beacon' : _ref$decoration,
55
56
  footerAction = _ref.footerAction,
57
+ panelProps = _ref.panelProps,
56
58
  rest = _objectWithoutProperties(_ref, _excluded);
57
59
 
58
60
  var titleId = useGeneratedHtmlId();
@@ -96,7 +98,7 @@ export var EuiTourStep = function EuiTourStep(_ref) {
96
98
  var headerStyles = euiTourHeaderStyles(euiTheme);
97
99
  var footerStyles = euiTourFooterStyles(euiTheme);
98
100
  var beaconStyles = euiTourBeaconStyles(euiTheme);
99
- var beaconCss = [beaconStyles.euiTourBeacon, popoverPosition && beaconStyles[popoverPosition]];
101
+ var beaconCss = [beaconStyles.euiTourBeacon, isStepOpen && beaconStyles.isOpen, popoverPosition && beaconStyles[popoverPosition]];
100
102
  var finishButtonProps = {
101
103
  color: 'text',
102
104
  flush: 'right',
@@ -157,9 +159,9 @@ export var EuiTourStep = function EuiTourStep(_ref) {
157
159
  ownFocus: false,
158
160
  panelClassName: classes,
159
161
  panelStyle: style,
160
- panelProps: {
161
- css: tourStyles.euiTour
162
- },
162
+ panelProps: _objectSpread(_objectSpread({}, panelProps), {}, {
163
+ css: [tourStyles.euiTour, css, panelProps === null || panelProps === void 0 ? void 0 : panelProps.css]
164
+ }),
163
165
  offset: hasBeacon ? 10 : 0,
164
166
  'aria-labelledby': titleId,
165
167
  arrowChildren: hasBeacon && ___EmotionJSX(EuiBeacon, {
@@ -1,5 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
+ 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; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
3
7
  /*
4
8
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
5
9
  * or more contributor license agreements. Licensed under the Elastic License
@@ -83,9 +87,7 @@ export var logicalSizeCSS = function logicalSizeCSS(width, height) {
83
87
  */
84
88
 
85
89
  export var logicalSizeStyle = function logicalSizeStyle(width, height) {
86
- var _ref2;
87
-
88
- return _ref2 = {}, _defineProperty(_ref2, logicals.width, width), _defineProperty(_ref2, logicals.height, height), _ref2;
90
+ return _objectSpread(_objectSpread({}, logicalStyle('width', width)), logicalStyle('height', height));
89
91
  }; // Text alignment is separate because its the value that changes not the property
90
92
 
91
93
  export var logicalText = {
@@ -19,26 +19,44 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return
19
19
  * Example usage:
20
20
  * mathWithUnits('4px', (x) => x / 2) = '2px';
21
21
  * mathWithUnits(euiTheme.size.xs, (x) => x + 2) = '6px';
22
+ * mathWithUnits([euiTheme.size.l, euiTheme.size.s], (x, y) => x - y) = '16px';
22
23
  */
23
- export var mathWithUnits = function mathWithUnits(value, callback) {
24
+ // Unfortunately, this is the CSSProperties[] type used for several euiTheme vars
25
+ export var mathWithUnits = function mathWithUnits(values, callback) {
24
26
  var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
27
+ if (!Array.isArray(values)) values = [values];
28
+ var foundNumericValues = [];
29
+ var foundUnit = '';
30
+ values.forEach(function (value) {
31
+ if (typeof value === 'string') {
32
+ var _matches$groups, _matches$groups2;
25
33
 
26
- if (typeof value === 'string') {
27
- var _matches$groups;
34
+ var regex = /*#__PURE__*/_wrapRegExp(/(\x2D?[\.0-9]+)(%|[A-Za-z]*)/, {
35
+ value: 1,
36
+ unit: 2
37
+ });
28
38
 
29
- var regex = /*#__PURE__*/_wrapRegExp(/(\x2D?[\.0-9]+)(%|[A-Za-z]*)/, {
30
- value: 1,
31
- unit: 2
32
- });
39
+ var matches = regex.exec(value);
40
+ var numericValue = Number(matches === null || matches === void 0 ? void 0 : (_matches$groups = matches.groups) === null || _matches$groups === void 0 ? void 0 : _matches$groups.value);
33
41
 
34
- var matches = regex.exec(value);
35
- if (!(matches !== null && matches !== void 0 && (_matches$groups = matches.groups) !== null && _matches$groups !== void 0 && _matches$groups.value)) return value;
36
- var numericValue = Number(matches.groups.value);
37
- var passedUnit = matches.groups.unit || unit;
38
- return "".concat(callback(numericValue)).concat(passedUnit);
39
- } else if (typeof value === 'number') {
40
- return "".concat(callback(value)).concat(unit);
41
- } else {
42
- return value;
43
- }
42
+ if (!isNaN(numericValue)) {
43
+ foundNumericValues.push(numericValue);
44
+ } else {
45
+ throw new Error('No valid numeric value found');
46
+ }
47
+
48
+ if (!unit && matches !== null && matches !== void 0 && (_matches$groups2 = matches.groups) !== null && _matches$groups2 !== void 0 && _matches$groups2.unit) {
49
+ if (!foundUnit) {
50
+ foundUnit = matches.groups.unit;
51
+ } else if (foundUnit !== matches.groups.unit) {
52
+ throw new Error('Multiple units found. Use `calc()` to mix and math multiple unit types (e.g. `%` & `px`) instead');
53
+ }
54
+ }
55
+ } else if (typeof value === 'number') {
56
+ foundNumericValues.push(value);
57
+ } else {
58
+ throw new Error('Invalid value type - pass a string or number');
59
+ }
60
+ });
61
+ return "".concat(callback.apply(void 0, foundNumericValues)).concat(unit || foundUnit);
44
62
  };