@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.
- package/dist/eui_theme_dark.css +0 -375
- package/dist/eui_theme_dark.json +0 -27
- package/dist/eui_theme_dark.json.d.ts +0 -27
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +0 -375
- package/dist/eui_theme_light.json +0 -27
- package/dist/eui_theme_light.json.d.ts +0 -27
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/basic_table/in_memory_table.js +8 -2
- package/es/components/code/code.js +7 -3
- package/es/components/code/code.styles.js +32 -0
- package/es/components/code/code_block.js +72 -315
- package/es/components/code/code_block.styles.js +153 -0
- package/es/components/code/code_block_controls.js +29 -0
- package/es/components/code/code_block_controls.styles.js +43 -0
- package/es/components/code/code_block_copy.js +65 -0
- package/es/components/code/code_block_full_screen.js +90 -0
- package/es/components/code/code_block_line.styles.js +49 -0
- package/es/components/code/code_block_overflow.js +78 -0
- package/es/components/code/code_block_virtualized.js +59 -0
- package/es/components/code/code_syntax.styles.js +43 -0
- package/es/components/code/utils.js +43 -37
- package/es/components/collapsible_nav/collapsible_nav.js +0 -5
- package/es/components/overlay_mask/overlay_mask.js +8 -14
- package/es/components/overlay_mask/overlay_mask.styles.js +4 -14
- package/es/components/overlay_mask/overlay_mask_body.styles.js +18 -0
- package/es/components/provider/provider.js +1 -5
- package/es/components/resizable_container/helpers.js +2 -2
- package/es/components/resizable_container/resizable_container.js +6 -9
- package/es/components/resizable_container/resizable_container.styles.js +28 -0
- package/es/components/resizable_container/resizable_panel.js +25 -48
- package/es/components/resizable_container/resizable_panel.styles.js +69 -0
- package/es/components/search_bar/query/ast.js +14 -3
- package/es/components/tool_tip/tool_tip.js +3 -2
- package/es/components/tool_tip/tool_tip.styles.js +17 -22
- package/es/components/tool_tip/tool_tip_arrow.js +17 -3
- package/es/components/tool_tip/tool_tip_popover.js +7 -7
- package/es/components/tour/tour.styles.js +4 -3
- package/es/components/tour/tour_step.js +7 -5
- package/es/global_styling/functions/logicals.js +5 -3
- package/es/global_styling/functions/math.js +37 -19
- package/es/global_styling/mixins/_padding.js +13 -9
- package/eui.d.ts +291 -37
- package/i18ntokens.json +22 -22
- package/lib/components/basic_table/in_memory_table.js +8 -2
- package/lib/components/code/code.js +9 -3
- package/lib/components/code/code.styles.js +35 -0
- package/lib/components/code/code_block.js +72 -320
- package/lib/components/code/code_block.styles.js +154 -0
- package/lib/components/code/code_block_controls.js +48 -0
- package/lib/components/code/code_block_controls.styles.js +39 -0
- package/lib/components/code/code_block_copy.js +78 -0
- package/lib/components/code/code_block_full_screen.js +108 -0
- package/lib/components/code/code_block_line.styles.js +45 -0
- package/lib/components/code/code_block_overflow.js +82 -0
- package/lib/components/code/code_block_virtualized.js +72 -0
- package/lib/components/code/code_syntax.styles.js +57 -0
- package/lib/components/code/utils.js +40 -39
- package/lib/components/collapsible_nav/collapsible_nav.js +0 -5
- package/lib/components/overlay_mask/overlay_mask.js +9 -14
- package/lib/components/overlay_mask/overlay_mask.styles.js +13 -17
- package/lib/components/overlay_mask/overlay_mask_body.styles.js +20 -0
- package/lib/components/provider/provider.js +7 -12
- package/lib/components/resizable_container/helpers.js +2 -2
- package/lib/components/resizable_container/resizable_container.js +7 -9
- package/lib/components/resizable_container/resizable_container.styles.js +31 -0
- package/lib/components/resizable_container/resizable_panel.js +28 -49
- package/lib/components/resizable_container/resizable_panel.styles.js +74 -0
- package/lib/components/search_bar/query/ast.js +14 -3
- package/lib/components/tool_tip/tool_tip.js +3 -2
- package/lib/components/tool_tip/tool_tip.styles.js +18 -26
- package/lib/components/tool_tip/tool_tip_arrow.js +19 -4
- package/lib/components/tool_tip/tool_tip_popover.js +6 -6
- package/lib/components/tour/tour.styles.js +3 -2
- package/lib/components/tour/tour_step.js +7 -5
- package/lib/global_styling/functions/logicals.js +5 -3
- package/lib/global_styling/functions/math.js +37 -19
- package/lib/global_styling/mixins/_padding.js +17 -10
- package/optimize/es/components/basic_table/in_memory_table.js +1 -1
- package/optimize/es/components/code/code.js +7 -3
- package/optimize/es/components/code/code.styles.js +32 -0
- package/optimize/es/components/code/code_block.js +70 -299
- package/optimize/es/components/code/code_block.styles.js +153 -0
- package/optimize/es/components/code/code_block_controls.js +29 -0
- package/optimize/es/components/code/code_block_controls.styles.js +43 -0
- package/optimize/es/components/code/code_block_copy.js +55 -0
- package/optimize/es/components/code/code_block_full_screen.js +80 -0
- package/optimize/es/components/code/code_block_line.styles.js +49 -0
- package/optimize/es/components/code/code_block_overflow.js +67 -0
- package/optimize/es/components/code/code_block_virtualized.js +59 -0
- package/optimize/es/components/code/code_syntax.styles.js +43 -0
- package/optimize/es/components/code/utils.js +43 -37
- package/optimize/es/components/overlay_mask/overlay_mask.js +8 -9
- package/optimize/es/components/overlay_mask/overlay_mask.styles.js +4 -14
- package/optimize/es/components/overlay_mask/overlay_mask_body.styles.js +18 -0
- package/optimize/es/components/provider/provider.js +1 -5
- package/optimize/es/components/resizable_container/helpers.js +2 -2
- package/optimize/es/components/resizable_container/resizable_container.js +6 -9
- package/optimize/es/components/resizable_container/resizable_container.styles.js +28 -0
- package/optimize/es/components/resizable_container/resizable_panel.js +25 -48
- package/optimize/es/components/resizable_container/resizable_panel.styles.js +69 -0
- package/optimize/es/components/search_bar/query/ast.js +14 -3
- package/optimize/es/components/tool_tip/tool_tip.js +3 -2
- package/optimize/es/components/tool_tip/tool_tip.styles.js +17 -22
- package/optimize/es/components/tool_tip/tool_tip_arrow.js +9 -3
- package/optimize/es/components/tool_tip/tool_tip_popover.js +7 -7
- package/optimize/es/components/tour/tour.styles.js +4 -3
- package/optimize/es/components/tour/tour_step.js +7 -5
- package/optimize/es/global_styling/functions/logicals.js +5 -3
- package/optimize/es/global_styling/functions/math.js +35 -17
- package/optimize/es/global_styling/mixins/_padding.js +13 -9
- package/optimize/lib/components/basic_table/in_memory_table.js +1 -1
- package/optimize/lib/components/code/code.js +9 -3
- package/optimize/lib/components/code/code.styles.js +35 -0
- package/optimize/lib/components/code/code_block.js +71 -306
- package/optimize/lib/components/code/code_block.styles.js +156 -0
- package/optimize/lib/components/code/code_block_controls.js +48 -0
- package/optimize/lib/components/code/code_block_controls.styles.js +39 -0
- package/optimize/lib/components/code/code_block_copy.js +78 -0
- package/optimize/lib/components/code/code_block_full_screen.js +108 -0
- package/optimize/lib/components/code/code_block_line.styles.js +45 -0
- package/optimize/lib/components/code/code_block_overflow.js +82 -0
- package/optimize/lib/components/code/code_block_virtualized.js +81 -0
- package/optimize/lib/components/code/code_syntax.styles.js +57 -0
- package/optimize/lib/components/code/utils.js +40 -37
- package/optimize/lib/components/overlay_mask/overlay_mask.js +9 -9
- package/optimize/lib/components/overlay_mask/overlay_mask.styles.js +13 -17
- package/optimize/lib/components/overlay_mask/overlay_mask_body.styles.js +20 -0
- package/optimize/lib/components/provider/provider.js +7 -12
- package/optimize/lib/components/resizable_container/helpers.js +2 -2
- package/optimize/lib/components/resizable_container/resizable_container.js +7 -9
- package/optimize/lib/components/resizable_container/resizable_container.styles.js +31 -0
- package/optimize/lib/components/resizable_container/resizable_panel.js +28 -49
- package/optimize/lib/components/resizable_container/resizable_panel.styles.js +76 -0
- package/optimize/lib/components/search_bar/query/ast.js +14 -3
- package/optimize/lib/components/tool_tip/tool_tip.js +3 -2
- package/optimize/lib/components/tool_tip/tool_tip.styles.js +18 -26
- package/optimize/lib/components/tool_tip/tool_tip_arrow.js +10 -10
- package/optimize/lib/components/tool_tip/tool_tip_popover.js +6 -6
- package/optimize/lib/components/tour/tour.styles.js +3 -2
- package/optimize/lib/components/tour/tour_step.js +7 -5
- package/optimize/lib/global_styling/functions/logicals.js +4 -10
- package/optimize/lib/global_styling/functions/math.js +37 -19
- package/optimize/lib/global_styling/mixins/_padding.js +17 -10
- package/package.json +8 -7
- package/src/components/index.scss +0 -1
- package/src/components/resizable_container/_index.scss +0 -2
- package/src/global_styling/mixins/_header.scss +1 -1
- package/src/global_styling/variables/_index.scss +0 -1
- package/src/themes/amsterdam/overrides/_index.scss +0 -1
- package/test-env/components/basic_table/in_memory_table.js +8 -2
- package/test-env/components/code/code.styles.js +35 -0
- package/test-env/components/code/code_block.styles.js +156 -0
- package/test-env/components/code/code_block_controls.js +48 -0
- package/test-env/components/code/code_block_controls.styles.js +39 -0
- package/test-env/components/code/code_block_copy.js +78 -0
- package/test-env/components/code/code_block_full_screen.js +108 -0
- package/test-env/components/code/code_block_line.styles.js +45 -0
- package/test-env/components/code/code_block_overflow.js +82 -0
- package/test-env/components/code/code_block_virtualized.js +81 -0
- package/test-env/components/code/code_syntax.styles.js +57 -0
- package/test-env/components/code/utils.js +40 -37
- package/test-env/components/collapsible_nav/collapsible_nav.js +0 -5
- package/test-env/components/overlay_mask/overlay_mask.js +9 -14
- package/test-env/components/overlay_mask/overlay_mask.styles.js +13 -17
- package/test-env/components/overlay_mask/overlay_mask_body.styles.js +20 -0
- package/test-env/components/provider/provider.js +7 -12
- package/test-env/components/resizable_container/helpers.js +2 -2
- package/test-env/components/resizable_container/resizable_container.js +7 -9
- package/test-env/components/resizable_container/resizable_container.styles.js +31 -0
- package/test-env/components/resizable_container/resizable_panel.js +28 -49
- package/test-env/components/resizable_container/resizable_panel.styles.js +76 -0
- package/test-env/components/search_bar/query/ast.js +14 -3
- package/test-env/components/tool_tip/tool_tip.js +3 -2
- package/test-env/components/tool_tip/tool_tip.styles.js +18 -26
- package/test-env/components/tool_tip/tool_tip_arrow.js +16 -11
- package/test-env/components/tool_tip/tool_tip_popover.js +6 -6
- package/test-env/components/tour/tour.styles.js +3 -2
- package/test-env/components/tour/tour_step.js +7 -5
- package/test-env/global_styling/functions/logicals.js +4 -10
- package/test-env/global_styling/functions/math.js +37 -19
- package/test-env/global_styling/mixins/_padding.js +17 -10
- package/src/components/code/_code.scss +0 -15
- package/src/components/code/_code_block.scss +0 -177
- package/src/components/code/_index.scss +0 -4
- package/src/components/code/_mixins.scss +0 -127
- package/src/components/code/_variables.scss +0 -5
- package/src/components/resizable_container/_resizable_container.scss +0 -8
- package/src/components/resizable_container/_resizable_panel.scss +0 -51
- package/src/global_styling/variables/_colors_code.scss +0 -23
- package/src/themes/amsterdam/overrides/_code.scss +0 -9
|
@@ -16,21 +16,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
17
17
|
* Side Public License, v 1.
|
|
18
18
|
*/
|
|
19
|
-
import React, {
|
|
19
|
+
import React, { useMemo } from 'react';
|
|
20
20
|
import classNames from 'classnames';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import { useInnerText } from '../inner_text';
|
|
30
|
-
import { useMutationObserver } from '../observer/mutation_observer';
|
|
31
|
-
import { useResizeObserver } from '../observer/resize_observer';
|
|
32
|
-
import { EuiOverlayMask } from '../overlay_mask';
|
|
33
|
-
import { DEFAULT_LANGUAGE, checkSupportedLanguage, getHtmlContent, nodeToHtml, highlightByLine } from './utils'; // Based on observed line height for non-virtualized code blocks
|
|
21
|
+
import { useCombinedRefs, useEuiTheme } from '../../services';
|
|
22
|
+
import { DEFAULT_LANGUAGE, checkSupportedLanguage, getHtmlContent, highlightByLine } from './utils';
|
|
23
|
+
import { useOverflow } from './code_block_overflow';
|
|
24
|
+
import { useCopy } from './code_block_copy';
|
|
25
|
+
import { useFullScreen, EuiCodeBlockFullScreenWrapper } from './code_block_full_screen';
|
|
26
|
+
import { EuiCodeBlockControls } from './code_block_controls';
|
|
27
|
+
import { EuiCodeBlockVirtualized } from './code_block_virtualized';
|
|
28
|
+
import { euiCodeBlockStyles, euiCodeBlockPreStyles, euiCodeBlockCodeStyles } from './code_block.styles'; // Based on observed line height for non-virtualized code blocks
|
|
34
29
|
|
|
35
30
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
36
31
|
var fontSizeToRowHeightMap = {
|
|
@@ -38,20 +33,8 @@ var fontSizeToRowHeightMap = {
|
|
|
38
33
|
m: 21,
|
|
39
34
|
l: 24
|
|
40
35
|
};
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
m: 'euiCodeBlock--fontMedium',
|
|
44
|
-
l: 'euiCodeBlock--fontLarge'
|
|
45
|
-
};
|
|
46
|
-
export var FONT_SIZES = keysOf(fontSizeToClassNameMap);
|
|
47
|
-
var paddingSizeToClassNameMap = {
|
|
48
|
-
none: '',
|
|
49
|
-
s: 'euiCodeBlock--paddingSmall',
|
|
50
|
-
m: 'euiCodeBlock--paddingMedium',
|
|
51
|
-
l: 'euiCodeBlock--paddingLarge'
|
|
52
|
-
};
|
|
53
|
-
export var PADDING_SIZES = keysOf(paddingSizeToClassNameMap); // This exclusive union enforces specific props based on isVirtualized
|
|
54
|
-
|
|
36
|
+
export var FONT_SIZES = ['s', 'm', 'l'];
|
|
37
|
+
export var PADDING_SIZES = ['none', 's', 'm', 'l'];
|
|
55
38
|
export var EuiCodeBlock = function EuiCodeBlock(_ref) {
|
|
56
39
|
var _ref$language = _ref.language,
|
|
57
40
|
_language = _ref$language === void 0 ? DEFAULT_LANGUAGE : _ref$language,
|
|
@@ -73,6 +56,7 @@ export var EuiCodeBlock = function EuiCodeBlock(_ref) {
|
|
|
73
56
|
lineNumbers = _ref$lineNumbers === void 0 ? false : _ref$lineNumbers,
|
|
74
57
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
75
58
|
|
|
59
|
+
var euiTheme = useEuiTheme();
|
|
76
60
|
var language = useMemo(function () {
|
|
77
61
|
return checkSupportedLanguage(_language);
|
|
78
62
|
}, [_language]);
|
|
@@ -92,8 +76,8 @@ export var EuiCodeBlock = function EuiCodeBlock(_ref) {
|
|
|
92
76
|
return [];
|
|
93
77
|
}
|
|
94
78
|
|
|
95
|
-
return highlightByLine(children, language, lineNumbersConfig);
|
|
96
|
-
}, [children, language, lineNumbersConfig]); // Used by `pre` when `isVirtualized=false` or `children` is not parsable
|
|
79
|
+
return highlightByLine(children, language, lineNumbersConfig, euiTheme);
|
|
80
|
+
}, [children, language, lineNumbersConfig, euiTheme]); // Used by `pre` when `isVirtualized=false` or `children` is not parsable
|
|
97
81
|
|
|
98
82
|
var content = useMemo(function () {
|
|
99
83
|
return getHtmlContent(data, children);
|
|
@@ -108,296 +92,83 @@ export var EuiCodeBlock = function EuiCodeBlock(_ref) {
|
|
|
108
92
|
children: children
|
|
109
93
|
}),
|
|
110
94
|
innerTextRef = _useCopy.innerTextRef,
|
|
111
|
-
|
|
112
|
-
textToCopy = _useCopy.textToCopy;
|
|
95
|
+
copyButton = _useCopy.copyButton;
|
|
113
96
|
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
97
|
+
var _useOverflow = useOverflow({
|
|
98
|
+
overflowHeight: overflowHeight
|
|
99
|
+
}),
|
|
100
|
+
setWrapperRef = _useOverflow.setWrapperRef,
|
|
101
|
+
tabIndex = _useOverflow.tabIndex,
|
|
102
|
+
overflowHeightStyles = _useOverflow.overflowHeightStyles;
|
|
117
103
|
|
|
118
104
|
var combinedRef = useCombinedRefs([innerTextRef, setWrapperRef]);
|
|
119
105
|
|
|
120
106
|
var _useFullScreen = useFullScreen({
|
|
121
107
|
overflowHeight: overflowHeight
|
|
122
108
|
}),
|
|
123
|
-
|
|
124
|
-
onKeyDown = _useFullScreen.onKeyDown,
|
|
109
|
+
fullScreenButton = _useFullScreen.fullScreenButton,
|
|
125
110
|
isFullScreen = _useFullScreen.isFullScreen,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
111
|
+
onKeyDown = _useFullScreen.onKeyDown;
|
|
112
|
+
|
|
113
|
+
var hasControls = !!(copyButton || fullScreenButton);
|
|
114
|
+
var hasBothControls = !!(copyButton && fullScreenButton);
|
|
115
|
+
var styles = euiCodeBlockStyles(euiTheme);
|
|
116
|
+
var cssStyles = [styles.euiCodeBlock, styles[fontSize], transparentBackground && styles.transparentBackground, hasControls && (hasBothControls ? styles.hasBothControls[paddingSize] : styles.hasControls[paddingSize])];
|
|
117
|
+
|
|
118
|
+
var _useMemo = useMemo(function () {
|
|
119
|
+
var isWhiteSpacePre = whiteSpace === 'pre' || isVirtualized;
|
|
120
|
+
var styles = euiCodeBlockPreStyles(euiTheme);
|
|
121
|
+
var cssStyles = [styles.euiCodeBlock__pre, isWhiteSpacePre ? styles.whiteSpace.pre.pre : styles.whiteSpace.preWrap.preWrap];
|
|
122
|
+
var preProps = {
|
|
123
|
+
className: 'euiCodeBlock__pre',
|
|
124
|
+
css: [].concat(cssStyles, [styles.padding[paddingSize], hasControls && (isWhiteSpacePre ? styles.whiteSpace.pre.controlsOffset[paddingSize] : styles.whiteSpace.preWrap.controlsOffset[paddingSize])]),
|
|
125
|
+
tabIndex: isVirtualized ? 0 : tabIndex
|
|
126
|
+
};
|
|
127
|
+
var preFullscreenProps = {
|
|
128
|
+
className: 'euiCodeBlock__pre',
|
|
129
|
+
css: [].concat(cssStyles, [// Force fullscreen to use xl padding
|
|
130
|
+
styles.padding.xl, hasControls && (isWhiteSpacePre ? styles.whiteSpace.pre.controlsOffset.xl : styles.whiteSpace.preWrap.controlsOffset.xl)]),
|
|
131
|
+
tabIndex: 0,
|
|
132
|
+
onKeyDown: onKeyDown
|
|
133
|
+
};
|
|
134
|
+
return [preProps, preFullscreenProps];
|
|
135
|
+
}, [euiTheme, whiteSpace, isVirtualized, hasControls, paddingSize, onKeyDown, tabIndex]),
|
|
136
|
+
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
137
|
+
preProps = _useMemo2[0],
|
|
138
|
+
preFullscreenProps = _useMemo2[1];
|
|
134
139
|
|
|
135
|
-
var classes = classNames(wrapperClasses, fontSizeToClassNameMap[fontSize], paddingSizeToClassNameMap[paddingSize], {
|
|
136
|
-
'euiCodeBlock--transparentBackground': transparentBackground
|
|
137
|
-
});
|
|
138
140
|
var codeProps = useMemo(function () {
|
|
141
|
+
var styles = euiCodeBlockCodeStyles(euiTheme);
|
|
142
|
+
var cssStyles = [styles.euiCodeBlock__code, isVirtualized && styles.isVirtualized];
|
|
139
143
|
return _objectSpread({
|
|
140
144
|
className: 'euiCodeBlock__code',
|
|
145
|
+
css: cssStyles,
|
|
141
146
|
'data-code-language': language
|
|
142
147
|
}, rest);
|
|
143
|
-
}, [language, rest]);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
var preFullscreenProps = useMemo(function () {
|
|
150
|
-
return {
|
|
151
|
-
className: preClasses,
|
|
152
|
-
tabIndex: 0,
|
|
153
|
-
onKeyDown: onKeyDown
|
|
154
|
-
};
|
|
155
|
-
}, [preClasses, onKeyDown]);
|
|
156
|
-
var overflowHeightStyles = useMemo(function () {
|
|
157
|
-
if (overflowHeight) {
|
|
158
|
-
var property = typeof overflowHeight === 'string' ? 'height' : 'maxHeight';
|
|
159
|
-
return _defineProperty({}, property, overflowHeight);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return {};
|
|
163
|
-
}, [overflowHeight]);
|
|
164
|
-
var wrapperProps = useMemo(function () {
|
|
165
|
-
return {
|
|
166
|
-
className: classes,
|
|
167
|
-
style: overflowHeightStyles
|
|
168
|
-
};
|
|
169
|
-
}, [classes, overflowHeightStyles]);
|
|
170
|
-
var codeBlockControls = useMemo(function () {
|
|
171
|
-
if (showCopyButton || showFullScreenButton) {
|
|
172
|
-
return ___EmotionJSX("div", {
|
|
173
|
-
className: "euiCodeBlock__controls"
|
|
174
|
-
}, showFullScreenButton && ___EmotionJSX(FullScreenButton, {
|
|
175
|
-
isFullScreen: isFullScreen,
|
|
176
|
-
toggleFullScreen: toggleFullScreen
|
|
177
|
-
}), showCopyButton && ___EmotionJSX(CopyButton, {
|
|
178
|
-
textToCopy: textToCopy
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
}, [isFullScreen, toggleFullScreen, showCopyButton, showFullScreenButton, textToCopy]);
|
|
182
|
-
return ___EmotionJSX("div", wrapperProps, isVirtualized ? ___EmotionJSX(VirtualizedCodeBlock, {
|
|
148
|
+
}, [language, euiTheme, isVirtualized, rest]);
|
|
149
|
+
return ___EmotionJSX("div", {
|
|
150
|
+
css: cssStyles,
|
|
151
|
+
className: classNames('euiCodeBlock', className),
|
|
152
|
+
style: overflowHeightStyles
|
|
153
|
+
}, isVirtualized ? ___EmotionJSX(EuiCodeBlockVirtualized, {
|
|
183
154
|
data: data,
|
|
184
155
|
rowHeight: fontSizeToRowHeightMap[fontSize],
|
|
185
156
|
overflowHeight: overflowHeight,
|
|
186
|
-
preProps:
|
|
187
|
-
,
|
|
157
|
+
preProps: preProps,
|
|
188
158
|
codeProps: codeProps
|
|
189
|
-
}) : ___EmotionJSX("pre", {
|
|
159
|
+
}) : ___EmotionJSX("pre", _extends({}, preProps, {
|
|
190
160
|
ref: combinedRef,
|
|
191
|
-
style: overflowHeightStyles
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}, isVirtualized ? ___EmotionJSX(VirtualizedCodeBlock, {
|
|
161
|
+
style: overflowHeightStyles
|
|
162
|
+
}), ___EmotionJSX("code", codeProps, content)), ___EmotionJSX(EuiCodeBlockControls, {
|
|
163
|
+
controls: [fullScreenButton, copyButton],
|
|
164
|
+
paddingSize: paddingSize
|
|
165
|
+
}), isFullScreen && ___EmotionJSX(EuiCodeBlockFullScreenWrapper, null, isVirtualized ? ___EmotionJSX(EuiCodeBlockVirtualized, {
|
|
197
166
|
data: data,
|
|
198
167
|
rowHeight: fontSizeToRowHeightMap.l,
|
|
199
168
|
preProps: preFullscreenProps,
|
|
200
169
|
codeProps: codeProps
|
|
201
|
-
}) : ___EmotionJSX("pre", preFullscreenProps, ___EmotionJSX("code", codeProps, content)),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
* Detects whether the code block overflows and returns a tabIndex of 0 if so,
|
|
207
|
-
* which allows keyboard users to use the up/down arrow keys to scroll through
|
|
208
|
-
* the container.
|
|
209
|
-
*/
|
|
210
|
-
|
|
211
|
-
var useOverflowDetection = function useOverflowDetection() {
|
|
212
|
-
var _useState = useState(null),
|
|
213
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
214
|
-
wrapperRef = _useState2[0],
|
|
215
|
-
setWrapperRef = _useState2[1];
|
|
216
|
-
|
|
217
|
-
var _useState3 = useState(-1),
|
|
218
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
219
|
-
tabIndex = _useState4[0],
|
|
220
|
-
setTabIndex = _useState4[1];
|
|
221
|
-
|
|
222
|
-
var _useResizeObserver = useResizeObserver(wrapperRef),
|
|
223
|
-
width = _useResizeObserver.width,
|
|
224
|
-
height = _useResizeObserver.height;
|
|
225
|
-
|
|
226
|
-
var doesOverflow = function doesOverflow() {
|
|
227
|
-
if (!wrapperRef) return;
|
|
228
|
-
var clientWidth = wrapperRef.clientWidth,
|
|
229
|
-
clientHeight = wrapperRef.clientHeight,
|
|
230
|
-
scrollWidth = wrapperRef.scrollWidth,
|
|
231
|
-
scrollHeight = wrapperRef.scrollHeight;
|
|
232
|
-
var doesOverflow = scrollHeight > clientHeight || scrollWidth > clientWidth;
|
|
233
|
-
setTabIndex(doesOverflow ? 0 : -1);
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
useMutationObserver(wrapperRef, doesOverflow, {
|
|
237
|
-
subtree: true,
|
|
238
|
-
childList: true
|
|
239
|
-
});
|
|
240
|
-
useEffect(doesOverflow, [width, height, wrapperRef]);
|
|
241
|
-
return {
|
|
242
|
-
setWrapperRef: setWrapperRef,
|
|
243
|
-
tabIndex: tabIndex
|
|
244
|
-
};
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Copy logic
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var CopyButton = function CopyButton(_ref3) {
|
|
252
|
-
var textToCopy = _ref3.textToCopy;
|
|
253
|
-
var copyButton = useEuiI18n('euiCodeBlock.copyButton', 'Copy');
|
|
254
|
-
return ___EmotionJSX("div", {
|
|
255
|
-
className: "euiCodeBlock__copyButton"
|
|
256
|
-
}, ___EmotionJSX(EuiCopy, {
|
|
257
|
-
textToCopy: textToCopy
|
|
258
|
-
}, function (copy) {
|
|
259
|
-
return ___EmotionJSX(EuiButtonIcon, {
|
|
260
|
-
onClick: copy,
|
|
261
|
-
iconType: "copyClipboard",
|
|
262
|
-
color: "text",
|
|
263
|
-
"aria-label": copyButton
|
|
264
|
-
});
|
|
265
|
-
}));
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
var useCopy = function useCopy(_ref4) {
|
|
269
|
-
var isCopyable = _ref4.isCopyable,
|
|
270
|
-
isVirtualized = _ref4.isVirtualized,
|
|
271
|
-
children = _ref4.children;
|
|
272
|
-
|
|
273
|
-
var _useInnerText = useInnerText(''),
|
|
274
|
-
_useInnerText2 = _slicedToArray(_useInnerText, 2),
|
|
275
|
-
innerTextRef = _useInnerText2[0],
|
|
276
|
-
_innerText = _useInnerText2[1];
|
|
277
|
-
|
|
278
|
-
var innerText = useMemo(function () {
|
|
279
|
-
return (_innerText === null || _innerText === void 0 ? void 0 : _innerText.replace(/[\r\n?]{2}|\n\n/g, '\n')) || '';
|
|
280
|
-
}, [_innerText]);
|
|
281
|
-
var textToCopy = isVirtualized ? "".concat(children) : innerText; // Virtualized code blocks do not have inner text
|
|
282
|
-
|
|
283
|
-
var showCopyButton = isCopyable && textToCopy;
|
|
284
|
-
return {
|
|
285
|
-
innerTextRef: innerTextRef,
|
|
286
|
-
showCopyButton: showCopyButton,
|
|
287
|
-
textToCopy: textToCopy
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* Fullscreen logic
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var FullScreenButton = function FullScreenButton(_ref5) {
|
|
296
|
-
var isFullScreen = _ref5.isFullScreen,
|
|
297
|
-
toggleFullScreen = _ref5.toggleFullScreen;
|
|
298
|
-
|
|
299
|
-
var _useEuiI18n = useEuiI18n(['euiCodeBlock.fullscreenCollapse', 'euiCodeBlock.fullscreenExpand'], ['Collapse', 'Expand']),
|
|
300
|
-
_useEuiI18n2 = _slicedToArray(_useEuiI18n, 2),
|
|
301
|
-
fullscreenCollapse = _useEuiI18n2[0],
|
|
302
|
-
fullscreenExpand = _useEuiI18n2[1];
|
|
303
|
-
|
|
304
|
-
return ___EmotionJSX(EuiButtonIcon, {
|
|
305
|
-
className: "euiCodeBlock__fullScreenButton",
|
|
306
|
-
onClick: toggleFullScreen,
|
|
307
|
-
iconType: isFullScreen ? 'fullScreenExit' : 'fullScreen',
|
|
308
|
-
color: "text",
|
|
309
|
-
"aria-label": isFullScreen ? fullscreenCollapse : fullscreenExpand
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
var FullScreenDisplay = function FullScreenDisplay(_ref6) {
|
|
314
|
-
var children = _ref6.children,
|
|
315
|
-
className = _ref6.className;
|
|
316
|
-
// Force fullscreen to use large font and padding.
|
|
317
|
-
var fullScreenClasses = classNames(className, 'euiCodeBlock--fontLarge', 'euiCodeBlock--paddingLarge', 'euiCodeBlock-isFullScreen'); // Attaches to the body because of EuiOverlayMask's React portal usage.
|
|
318
|
-
|
|
319
|
-
return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, {
|
|
320
|
-
clickOutsideDisables: true
|
|
321
|
-
}, ___EmotionJSX("div", {
|
|
322
|
-
className: fullScreenClasses
|
|
323
|
-
}, children)));
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
var useFullScreen = function useFullScreen(_ref7) {
|
|
327
|
-
var overflowHeight = _ref7.overflowHeight;
|
|
328
|
-
|
|
329
|
-
var _useState5 = useState(false),
|
|
330
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
331
|
-
isFullScreen = _useState6[0],
|
|
332
|
-
setIsFullScreen = _useState6[1];
|
|
333
|
-
|
|
334
|
-
var toggleFullScreen = useCallback(function () {
|
|
335
|
-
setIsFullScreen(function (isFullScreen) {
|
|
336
|
-
return !isFullScreen;
|
|
337
|
-
});
|
|
338
|
-
}, []);
|
|
339
|
-
var onKeyDown = useCallback(function (event) {
|
|
340
|
-
if (event.key === keys.ESCAPE) {
|
|
341
|
-
event.preventDefault();
|
|
342
|
-
event.stopPropagation();
|
|
343
|
-
setIsFullScreen(false);
|
|
344
|
-
}
|
|
345
|
-
}, []);
|
|
346
|
-
var showFullScreenButton = !!overflowHeight;
|
|
347
|
-
return {
|
|
348
|
-
showFullScreenButton: showFullScreenButton,
|
|
349
|
-
isFullScreen: isFullScreen,
|
|
350
|
-
toggleFullScreen: toggleFullScreen,
|
|
351
|
-
onKeyDown: onKeyDown
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
/**
|
|
355
|
-
* Virtualization logic
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
var ListRow = function ListRow(_ref8) {
|
|
360
|
-
var data = _ref8.data,
|
|
361
|
-
index = _ref8.index,
|
|
362
|
-
style = _ref8.style;
|
|
363
|
-
var row = data[index];
|
|
364
|
-
row.properties.style = style;
|
|
365
|
-
return nodeToHtml(row, index, data, 0);
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
var VirtualizedCodeBlock = function VirtualizedCodeBlock(_ref9) {
|
|
369
|
-
var data = _ref9.data,
|
|
370
|
-
rowHeight = _ref9.rowHeight,
|
|
371
|
-
overflowHeight = _ref9.overflowHeight,
|
|
372
|
-
preProps = _ref9.preProps,
|
|
373
|
-
codeProps = _ref9.codeProps;
|
|
374
|
-
var VirtualizedOuterElement = useMemo(function () {
|
|
375
|
-
return /*#__PURE__*/forwardRef(function (props, ref) {
|
|
376
|
-
return ___EmotionJSX("pre", _extends({}, props, {
|
|
377
|
-
ref: ref
|
|
378
|
-
}, preProps));
|
|
379
|
-
});
|
|
380
|
-
}, [preProps]);
|
|
381
|
-
var VirtualizedInnerElement = useMemo(function () {
|
|
382
|
-
return /*#__PURE__*/forwardRef(function (props, ref) {
|
|
383
|
-
return ___EmotionJSX("code", _extends({}, props, {
|
|
384
|
-
ref: ref
|
|
385
|
-
}, codeProps));
|
|
386
|
-
});
|
|
387
|
-
}, [codeProps]);
|
|
388
|
-
return ___EmotionJSX(EuiAutoSizer, {
|
|
389
|
-
disableHeight: typeof overflowHeight === 'number'
|
|
390
|
-
}, function (_ref10) {
|
|
391
|
-
var height = _ref10.height,
|
|
392
|
-
width = _ref10.width;
|
|
393
|
-
return ___EmotionJSX(FixedSizeList, {
|
|
394
|
-
height: height !== null && height !== void 0 ? height : overflowHeight,
|
|
395
|
-
width: width,
|
|
396
|
-
itemData: data,
|
|
397
|
-
itemSize: rowHeight,
|
|
398
|
-
itemCount: data.length,
|
|
399
|
-
outerElementType: VirtualizedOuterElement,
|
|
400
|
-
innerElementType: VirtualizedInnerElement
|
|
401
|
-
}, ListRow);
|
|
402
|
-
});
|
|
170
|
+
}) : ___EmotionJSX("pre", preFullscreenProps, ___EmotionJSX("code", codeProps, content)), ___EmotionJSX(EuiCodeBlockControls, {
|
|
171
|
+
controls: [fullScreenButton, copyButton],
|
|
172
|
+
paddingSize: "l"
|
|
173
|
+
})));
|
|
403
174
|
};
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
19
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
20
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
21
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
22
|
+
* Side Public License, v 1.
|
|
23
|
+
*/
|
|
24
|
+
import { css } from '@emotion/react';
|
|
25
|
+
import { euiPaddingSize, euiFontSize, euiScrollBarStyles, mathWithUnits } from '../../global_styling';
|
|
26
|
+
import { euiCodeSyntaxColors, euiCodeSyntaxTokens } from './code_syntax.styles';
|
|
27
|
+
|
|
28
|
+
var _ref4 = process.env.NODE_ENV === "production" ? {
|
|
29
|
+
name: "i92zwx-isFullScreen",
|
|
30
|
+
styles: "position:fixed;inset:0;label:isFullScreen;"
|
|
31
|
+
} : {
|
|
32
|
+
name: "i92zwx-isFullScreen",
|
|
33
|
+
styles: "position:fixed;inset:0;label:isFullScreen;",
|
|
34
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var _ref5 = process.env.NODE_ENV === "production" ? {
|
|
38
|
+
name: "gfiv3z-transparentBackground",
|
|
39
|
+
styles: "background:transparent;label:transparentBackground;"
|
|
40
|
+
} : {
|
|
41
|
+
name: "gfiv3z-transparentBackground",
|
|
42
|
+
styles: "background:transparent;label:transparentBackground;",
|
|
43
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export var euiCodeBlockStyles = function euiCodeBlockStyles(euiThemeContext) {
|
|
47
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
48
|
+
var euiCodeSyntax = euiCodeSyntaxColors(euiThemeContext);
|
|
49
|
+
return {
|
|
50
|
+
euiCodeBlock: /*#__PURE__*/css("max-inline-size:100%;display:block;position:relative;background:", euiCodeSyntax.backgroundColor, ";", euiCodeSyntaxTokens(euiThemeContext), ";;label:euiCodeBlock;"),
|
|
51
|
+
// Font size
|
|
52
|
+
s: /*#__PURE__*/css(euiFontSize(euiThemeContext, 'xs'), ";;label:s;"),
|
|
53
|
+
m: /*#__PURE__*/css(euiFontSize(euiThemeContext, 's'), ";;label:m;"),
|
|
54
|
+
l: /*#__PURE__*/css(euiFontSize(euiThemeContext, 'm'), ";;label:l;"),
|
|
55
|
+
// Variants
|
|
56
|
+
transparentBackground: _ref5,
|
|
57
|
+
isFullScreen: _ref4,
|
|
58
|
+
// Account for control heights
|
|
59
|
+
hasControls: generatePaddingCss(euiThemeContext, function (paddingSize) {
|
|
60
|
+
return /*#__PURE__*/css("min-block-size:", mathWithUnits([euiTheme.size.l, paddingSize], function (iconSize, paddingSize) {
|
|
61
|
+
return iconSize + paddingSize * 2;
|
|
62
|
+
}), ";;label:hasControls;");
|
|
63
|
+
}),
|
|
64
|
+
hasBothControls: generatePaddingCss(euiThemeContext, function (paddingSize) {
|
|
65
|
+
return /*#__PURE__*/css("min-block-size:", mathWithUnits([euiTheme.size.l, euiTheme.size.xs, paddingSize], function (iconSize, gap, paddingSize) {
|
|
66
|
+
return iconSize * 2 + gap + paddingSize * 2;
|
|
67
|
+
}), ";;label:hasBothControls;");
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var _ref2 = process.env.NODE_ENV === "production" ? {
|
|
73
|
+
name: "eav5br-preWrap",
|
|
74
|
+
styles: "white-space:pre-wrap;label:preWrap;"
|
|
75
|
+
} : {
|
|
76
|
+
name: "eav5br-preWrap",
|
|
77
|
+
styles: "white-space:pre-wrap;label:preWrap;",
|
|
78
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var _ref3 = process.env.NODE_ENV === "production" ? {
|
|
82
|
+
name: "4dmmkq-pre",
|
|
83
|
+
styles: "white-space:pre;label:pre;"
|
|
84
|
+
} : {
|
|
85
|
+
name: "4dmmkq-pre",
|
|
86
|
+
styles: "white-space:pre;label:pre;",
|
|
87
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export var euiCodeBlockPreStyles = function euiCodeBlockPreStyles(euiThemeContext) {
|
|
91
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
92
|
+
return {
|
|
93
|
+
euiCodeBlock__pre: /*#__PURE__*/css("block-size:100%;overflow:auto;display:block;", euiScrollBarStyles(euiThemeContext), ";;label:euiCodeBlock__pre;"),
|
|
94
|
+
padding: _objectSpread({}, generatePaddingCss(euiThemeContext, function (paddingSize) {
|
|
95
|
+
return /*#__PURE__*/css("padding:", paddingSize, ";;label:padding;");
|
|
96
|
+
})),
|
|
97
|
+
whiteSpace: {
|
|
98
|
+
pre: {
|
|
99
|
+
pre: _ref3,
|
|
100
|
+
controlsOffset: generatePaddingCss(euiThemeContext, function (paddingSize) {
|
|
101
|
+
return /*#__PURE__*/css("margin-inline-end:", mathWithUnits([paddingSize, euiTheme.size.l, euiTheme.size.xs], function (paddingSize, iconSize, gap) {
|
|
102
|
+
return paddingSize + gap + iconSize;
|
|
103
|
+
}), ";;label:controlsOffset;");
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
preWrap: {
|
|
107
|
+
preWrap: _ref2,
|
|
108
|
+
controlsOffset: generatePaddingCss(euiThemeContext, function (paddingSize) {
|
|
109
|
+
return /*#__PURE__*/css("padding-inline-end:", mathWithUnits([paddingSize, euiTheme.size.l, euiTheme.size.xs], function (paddingSize, iconSize, gap) {
|
|
110
|
+
return paddingSize + gap + iconSize;
|
|
111
|
+
}), ";;label:controlsOffset;");
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
119
|
+
name: "9y8iu3-isVirtualized",
|
|
120
|
+
styles: "position:relative;label:isVirtualized;"
|
|
121
|
+
} : {
|
|
122
|
+
name: "9y8iu3-isVirtualized",
|
|
123
|
+
styles: "position:relative;label:isVirtualized;",
|
|
124
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export var euiCodeBlockCodeStyles = function euiCodeBlockCodeStyles(euiThemeContext) {
|
|
128
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
129
|
+
var euiCodeSyntax = euiCodeSyntaxColors(euiThemeContext);
|
|
130
|
+
return {
|
|
131
|
+
euiCodeBlock__code: /*#__PURE__*/css("font-family:", euiTheme.font.familyCode, ";font-size:inherit;color:", euiCodeSyntax.color, ";display:block;;label:euiCodeBlock__code;"),
|
|
132
|
+
isVirtualized: _ref
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Helper for generating keys for each code block padding size
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
var generatePaddingCss = function generatePaddingCss(euiThemeContext, callback) {
|
|
140
|
+
var cssKeys = {
|
|
141
|
+
none: /*#__PURE__*/css(";label:none;"),
|
|
142
|
+
s: /*#__PURE__*/css(";label:s;"),
|
|
143
|
+
m: /*#__PURE__*/css(";label:m;"),
|
|
144
|
+
l: /*#__PURE__*/css(";label:l;"),
|
|
145
|
+
xl: /*#__PURE__*/css(";label:xl;")
|
|
146
|
+
}; // xl padding used by fullscreen mode
|
|
147
|
+
|
|
148
|
+
['none', 's', 'm', 'l', 'xl'].forEach(function (size) {
|
|
149
|
+
var paddingSize = euiPaddingSize(euiThemeContext, size) || 0;
|
|
150
|
+
cssKeys[size] = callback(paddingSize);
|
|
151
|
+
});
|
|
152
|
+
return cssKeys;
|
|
153
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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, { Fragment } from 'react';
|
|
9
|
+
import { useEuiTheme } from '../../services';
|
|
10
|
+
import { euiCodeBlockControlsStyles } from './code_block_controls.styles';
|
|
11
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
12
|
+
export var EuiCodeBlockControls = function EuiCodeBlockControls(_ref) {
|
|
13
|
+
var paddingSize = _ref.paddingSize,
|
|
14
|
+
controls = _ref.controls;
|
|
15
|
+
var euiTheme = useEuiTheme();
|
|
16
|
+
var styles = euiCodeBlockControlsStyles(euiTheme);
|
|
17
|
+
var cssStyles = [styles.euiCodeBlock__controls, styles.offset[paddingSize]];
|
|
18
|
+
var hasControls = controls.some(function (control) {
|
|
19
|
+
return !!control;
|
|
20
|
+
});
|
|
21
|
+
return hasControls ? ___EmotionJSX("div", {
|
|
22
|
+
className: "euiCodeBlock__controls",
|
|
23
|
+
css: cssStyles
|
|
24
|
+
}, controls.map(function (control, i) {
|
|
25
|
+
return ___EmotionJSX(Fragment, {
|
|
26
|
+
key: i
|
|
27
|
+
}, control);
|
|
28
|
+
})) : null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
13
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
14
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
15
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
16
|
+
* Side Public License, v 1.
|
|
17
|
+
*/
|
|
18
|
+
import { css } from '@emotion/react';
|
|
19
|
+
import { euiPaddingSize } from '../../global_styling';
|
|
20
|
+
import { euiCodeSyntaxColors } from './code_syntax.styles';
|
|
21
|
+
|
|
22
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
23
|
+
name: "to86kv-none",
|
|
24
|
+
styles: "inset-block-start:0;inset-inline-end:0;label:none;"
|
|
25
|
+
} : {
|
|
26
|
+
name: "to86kv-none",
|
|
27
|
+
styles: "inset-block-start:0;inset-inline-end:0;label:none;",
|
|
28
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export var euiCodeBlockControlsStyles = function euiCodeBlockControlsStyles(euiThemeContext) {
|
|
32
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
33
|
+
var euiCodeSyntax = euiCodeSyntaxColors(euiThemeContext);
|
|
34
|
+
return {
|
|
35
|
+
euiCodeBlock__controls: /*#__PURE__*/css("position:absolute;display:flex;flex-direction:column;gap:", euiTheme.size.xs, ";background:", euiCodeSyntax.backgroundColor, ";;label:euiCodeBlock__controls;"),
|
|
36
|
+
offset: {
|
|
37
|
+
none: _ref,
|
|
38
|
+
s: /*#__PURE__*/css("inset-block-start:", euiPaddingSize(euiThemeContext, 's'), ";inset-inline-end:", euiPaddingSize(euiThemeContext, 's'), ";;label:s;"),
|
|
39
|
+
m: /*#__PURE__*/css("inset-block-start:", euiPaddingSize(euiThemeContext, 'm'), ";inset-inline-end:", euiPaddingSize(euiThemeContext, 'm'), ";;label:m;"),
|
|
40
|
+
l: /*#__PURE__*/css("inset-block-start:", euiPaddingSize(euiThemeContext, 'l'), ";inset-inline-end:", euiPaddingSize(euiThemeContext, 'l'), ";;label:l;")
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|