@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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
15
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
16
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
17
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
18
|
+
* Side Public License, v 1.
|
|
19
|
+
*/
|
|
20
|
+
import React, { useMemo } from 'react';
|
|
21
|
+
import { useInnerText } from '../inner_text';
|
|
22
|
+
import { EuiCopy } from '../copy';
|
|
23
|
+
import { useEuiI18n } from '../i18n';
|
|
24
|
+
import { EuiButtonIcon } from '../button';
|
|
25
|
+
/**
|
|
26
|
+
* Hook that returns copy-related state/logic/utils
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
|
+
export var useCopy = function useCopy(_ref) {
|
|
31
|
+
var isCopyable = _ref.isCopyable,
|
|
32
|
+
isVirtualized = _ref.isVirtualized,
|
|
33
|
+
children = _ref.children;
|
|
34
|
+
|
|
35
|
+
var _useInnerText = useInnerText(''),
|
|
36
|
+
_useInnerText2 = _slicedToArray(_useInnerText, 2),
|
|
37
|
+
innerTextRef = _useInnerText2[0],
|
|
38
|
+
_innerText = _useInnerText2[1];
|
|
39
|
+
|
|
40
|
+
var innerText = useMemo(function () {
|
|
41
|
+
return (_innerText === null || _innerText === void 0 ? void 0 : _innerText.replace(/[\r\n?]{2}|\n\n/g, '\n')) || '';
|
|
42
|
+
}, [_innerText]);
|
|
43
|
+
var textToCopy = isVirtualized ? "".concat(children) : innerText; // Virtualized code blocks do not have inner text
|
|
44
|
+
|
|
45
|
+
var showCopyButton = isCopyable && textToCopy;
|
|
46
|
+
var copyAriaLabel = useEuiI18n('euiCodeBlockCopy.copy', 'Copy');
|
|
47
|
+
var copyButton = useMemo(function () {
|
|
48
|
+
return showCopyButton ? ___EmotionJSX("div", {
|
|
49
|
+
className: "euiCodeBlock__copyButton"
|
|
50
|
+
}, ___EmotionJSX(EuiCopy, {
|
|
51
|
+
textToCopy: textToCopy
|
|
52
|
+
}, function (copy) {
|
|
53
|
+
return ___EmotionJSX(EuiButtonIcon, {
|
|
54
|
+
onClick: copy,
|
|
55
|
+
iconType: "copyClipboard",
|
|
56
|
+
color: "text",
|
|
57
|
+
"aria-label": copyAriaLabel
|
|
58
|
+
});
|
|
59
|
+
})) : null;
|
|
60
|
+
}, [showCopyButton, textToCopy, copyAriaLabel]);
|
|
61
|
+
return {
|
|
62
|
+
innerTextRef: innerTextRef,
|
|
63
|
+
copyButton: copyButton
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
15
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
16
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
17
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
18
|
+
* Side Public License, v 1.
|
|
19
|
+
*/
|
|
20
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
21
|
+
import { keys, useEuiTheme } from '../../services';
|
|
22
|
+
import { useEuiI18n } from '../i18n';
|
|
23
|
+
import { EuiButtonIcon } from '../button';
|
|
24
|
+
import { EuiFocusTrap } from '../focus_trap';
|
|
25
|
+
import { EuiOverlayMask } from '../overlay_mask';
|
|
26
|
+
import { euiCodeBlockStyles } from './code_block.styles';
|
|
27
|
+
/**
|
|
28
|
+
* Hook that returns fullscreen-related state/logic/utils
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
32
|
+
export var useFullScreen = function useFullScreen(_ref) {
|
|
33
|
+
var overflowHeight = _ref.overflowHeight;
|
|
34
|
+
var showFullScreenButton = !!overflowHeight;
|
|
35
|
+
|
|
36
|
+
var _useState = useState(false),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
isFullScreen = _useState2[0],
|
|
39
|
+
setIsFullScreen = _useState2[1];
|
|
40
|
+
|
|
41
|
+
var toggleFullScreen = useCallback(function () {
|
|
42
|
+
setIsFullScreen(function (isFullScreen) {
|
|
43
|
+
return !isFullScreen;
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
46
|
+
var onKeyDown = useCallback(function (event) {
|
|
47
|
+
if (event.key === keys.ESCAPE) {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
setIsFullScreen(false);
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
var _useEuiI18n = useEuiI18n(['euiCodeBlockFullScreen.fullscreenCollapse', 'euiCodeBlockFullScreen.fullscreenExpand'], ['Collapse', 'Expand']),
|
|
55
|
+
_useEuiI18n2 = _slicedToArray(_useEuiI18n, 2),
|
|
56
|
+
fullscreenCollapse = _useEuiI18n2[0],
|
|
57
|
+
fullscreenExpand = _useEuiI18n2[1];
|
|
58
|
+
|
|
59
|
+
var fullScreenButton = useMemo(function () {
|
|
60
|
+
return showFullScreenButton ? ___EmotionJSX(EuiButtonIcon, {
|
|
61
|
+
className: "euiCodeBlock__fullScreenButton",
|
|
62
|
+
onClick: toggleFullScreen,
|
|
63
|
+
iconType: isFullScreen ? 'fullScreenExit' : 'fullScreen',
|
|
64
|
+
color: "text",
|
|
65
|
+
"aria-label": isFullScreen ? fullscreenCollapse : fullscreenExpand
|
|
66
|
+
}) : null;
|
|
67
|
+
}, [showFullScreenButton, toggleFullScreen, isFullScreen, fullscreenCollapse, fullscreenExpand]);
|
|
68
|
+
return {
|
|
69
|
+
fullScreenButton: fullScreenButton,
|
|
70
|
+
isFullScreen: isFullScreen,
|
|
71
|
+
onKeyDown: onKeyDown
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Portalled full screen wrapper
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
export var EuiCodeBlockFullScreenWrapper = function EuiCodeBlockFullScreenWrapper(_ref2) {
|
|
79
|
+
var children = _ref2.children;
|
|
80
|
+
var euiThemeContext = useEuiTheme();
|
|
81
|
+
var styles = euiCodeBlockStyles(euiThemeContext);
|
|
82
|
+
var cssStyles = [styles.euiCodeBlock, styles.l, // Force fullscreen to use large font
|
|
83
|
+
styles.isFullScreen];
|
|
84
|
+
return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, {
|
|
85
|
+
clickOutsideDisables: true
|
|
86
|
+
}, ___EmotionJSX("div", {
|
|
87
|
+
className: "euiCodeBlockFullScreen",
|
|
88
|
+
css: cssStyles
|
|
89
|
+
}, children)));
|
|
90
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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/css';
|
|
19
|
+
import { euiBackgroundColor } from '../../global_styling';
|
|
20
|
+
// Note: These styles must be in a separate file due to using `css` from `@emotion/css`
|
|
21
|
+
// (i.e., applying styles in vanilla JS / directly to DOM nodes instead of React)
|
|
22
|
+
export var euiCodeBlockLineStyles = function euiCodeBlockLineStyles(euiThemeContext) {
|
|
23
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
24
|
+
return {
|
|
25
|
+
euiCodeBlock__line: /*#__PURE__*/css(process.env.NODE_ENV === "production" ? {
|
|
26
|
+
name: "yn676d-euiCodeBlock__line",
|
|
27
|
+
styles: "display:block;label:euiCodeBlock__line;"
|
|
28
|
+
} : {
|
|
29
|
+
name: "yn676d-euiCodeBlock__line",
|
|
30
|
+
styles: "display:block;label:euiCodeBlock__line;",
|
|
31
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
32
|
+
}),
|
|
33
|
+
hasLineNumbers: /*#__PURE__*/css(process.env.NODE_ENV === "production" ? {
|
|
34
|
+
name: "156gjef-hasLineNumbers",
|
|
35
|
+
styles: "display:flex;user-select:none;label:hasLineNumbers;"
|
|
36
|
+
} : {
|
|
37
|
+
name: "156gjef-hasLineNumbers",
|
|
38
|
+
styles: "display:flex;user-select:none;label:hasLineNumbers;",
|
|
39
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
40
|
+
}),
|
|
41
|
+
lineText: {
|
|
42
|
+
euiCodeBlock__lineText: /*#__PURE__*/css("flex-grow:1;display:inline-block;padding-inline-start:", euiTheme.size.s, ";border-inline-start:", euiTheme.border.thin, ";user-select:text;;label:euiCodeBlock__lineText;"),
|
|
43
|
+
isHighlighted: /*#__PURE__*/css("background:", euiBackgroundColor(euiThemeContext, 'primary'), ";border-inline-start:", euiTheme.border.width.thick, " solid ", euiTheme.colors.primary, ";;label:isHighlighted;")
|
|
44
|
+
},
|
|
45
|
+
lineNumber: {
|
|
46
|
+
euiCodeBlock__lineNumber: /*#__PURE__*/css("flex-grow:0;flex-shrink:0;user-select:none;padding-inline-end:", euiTheme.size.s, ";box-sizing:content-box;&:before{content:attr(data-line-number);color:", euiTheme.colors.subduedText, ";text-align:end;display:block;};label:euiCodeBlock__lineNumber;")
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
+
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
+
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
17
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
18
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
19
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
20
|
+
* Side Public License, v 1.
|
|
21
|
+
*/
|
|
22
|
+
import { useEffect, useState, useMemo } from 'react';
|
|
23
|
+
import { useMutationObserver } from '../observer/mutation_observer';
|
|
24
|
+
import { useResizeObserver } from '../observer/resize_observer';
|
|
25
|
+
/**
|
|
26
|
+
* Overflow logic - returns overflow-related state/logic/utils
|
|
27
|
+
*
|
|
28
|
+
* Detects whether the code block overflows and returns a tabIndex of 0 if so,
|
|
29
|
+
* which allows keyboard users to use the up/down arrow keys to scroll through
|
|
30
|
+
* the container.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export var useOverflow = function useOverflow(_ref) {
|
|
34
|
+
var overflowHeight = _ref.overflowHeight;
|
|
35
|
+
|
|
36
|
+
var _useState = useState(null),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
wrapperRef = _useState2[0],
|
|
39
|
+
setWrapperRef = _useState2[1];
|
|
40
|
+
|
|
41
|
+
var _useState3 = useState(-1),
|
|
42
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
+
tabIndex = _useState4[0],
|
|
44
|
+
setTabIndex = _useState4[1];
|
|
45
|
+
|
|
46
|
+
var _useResizeObserver = useResizeObserver(wrapperRef),
|
|
47
|
+
width = _useResizeObserver.width,
|
|
48
|
+
height = _useResizeObserver.height;
|
|
49
|
+
|
|
50
|
+
var doesOverflow = function doesOverflow() {
|
|
51
|
+
if (!wrapperRef) return;
|
|
52
|
+
var clientWidth = wrapperRef.clientWidth,
|
|
53
|
+
clientHeight = wrapperRef.clientHeight,
|
|
54
|
+
scrollWidth = wrapperRef.scrollWidth,
|
|
55
|
+
scrollHeight = wrapperRef.scrollHeight;
|
|
56
|
+
var doesOverflow = scrollHeight > clientHeight || scrollWidth > clientWidth;
|
|
57
|
+
setTabIndex(doesOverflow ? 0 : -1);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
useMutationObserver(wrapperRef, doesOverflow, {
|
|
61
|
+
subtree: true,
|
|
62
|
+
childList: true
|
|
63
|
+
});
|
|
64
|
+
useEffect(doesOverflow, [width, height, wrapperRef]);
|
|
65
|
+
var overflowHeightStyles = useMemo(function () {
|
|
66
|
+
if (overflowHeight) {
|
|
67
|
+
var property = typeof overflowHeight === 'string' ? 'blockSize' : 'maxBlockSize';
|
|
68
|
+
return _defineProperty({}, property, overflowHeight);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {};
|
|
72
|
+
}, [overflowHeight]);
|
|
73
|
+
return {
|
|
74
|
+
setWrapperRef: setWrapperRef,
|
|
75
|
+
tabIndex: tabIndex,
|
|
76
|
+
overflowHeightStyles: overflowHeightStyles
|
|
77
|
+
};
|
|
78
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
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 React, { forwardRef, useMemo } from 'react';
|
|
11
|
+
import { FixedSizeList } from 'react-window';
|
|
12
|
+
import { EuiAutoSizer } from '../auto_sizer';
|
|
13
|
+
import { nodeToHtml } from './utils';
|
|
14
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
15
|
+
export var EuiCodeBlockVirtualized = function EuiCodeBlockVirtualized(_ref) {
|
|
16
|
+
var data = _ref.data,
|
|
17
|
+
rowHeight = _ref.rowHeight,
|
|
18
|
+
overflowHeight = _ref.overflowHeight,
|
|
19
|
+
preProps = _ref.preProps,
|
|
20
|
+
codeProps = _ref.codeProps;
|
|
21
|
+
var VirtualizedOuterElement = useMemo(function () {
|
|
22
|
+
return /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
|
+
return ___EmotionJSX("pre", _extends({}, props, {
|
|
24
|
+
ref: ref
|
|
25
|
+
}, preProps));
|
|
26
|
+
});
|
|
27
|
+
}, [preProps]);
|
|
28
|
+
var VirtualizedInnerElement = useMemo(function () {
|
|
29
|
+
return /*#__PURE__*/forwardRef(function (props, ref) {
|
|
30
|
+
return ___EmotionJSX("code", _extends({}, props, {
|
|
31
|
+
ref: ref
|
|
32
|
+
}, codeProps));
|
|
33
|
+
});
|
|
34
|
+
}, [codeProps]);
|
|
35
|
+
return ___EmotionJSX(EuiAutoSizer, {
|
|
36
|
+
disableHeight: typeof overflowHeight === 'number'
|
|
37
|
+
}, function (_ref2) {
|
|
38
|
+
var height = _ref2.height,
|
|
39
|
+
width = _ref2.width;
|
|
40
|
+
return ___EmotionJSX(FixedSizeList, {
|
|
41
|
+
height: height !== null && height !== void 0 ? height : overflowHeight,
|
|
42
|
+
width: width,
|
|
43
|
+
itemData: data,
|
|
44
|
+
itemSize: rowHeight,
|
|
45
|
+
itemCount: data.length,
|
|
46
|
+
outerElementType: VirtualizedOuterElement,
|
|
47
|
+
innerElementType: VirtualizedInnerElement
|
|
48
|
+
}, ListRow);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var ListRow = function ListRow(_ref3) {
|
|
53
|
+
var data = _ref3.data,
|
|
54
|
+
index = _ref3.index,
|
|
55
|
+
style = _ref3.style;
|
|
56
|
+
var row = data[index];
|
|
57
|
+
row.properties.style = style;
|
|
58
|
+
return nodeToHtml(row, index, data, 0);
|
|
59
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { makeHighContrastColor, euiPaletteColorBlind } from '../../services';
|
|
9
|
+
var visColors = euiPaletteColorBlind();
|
|
10
|
+
export var euiCodeSyntaxColors = function euiCodeSyntaxColors(euiThemeContext) {
|
|
11
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
12
|
+
var backgroundColor = euiTheme.colors.lightestShade;
|
|
13
|
+
return {
|
|
14
|
+
backgroundColor: backgroundColor,
|
|
15
|
+
color: makeHighContrastColor(euiTheme.colors.text)(backgroundColor),
|
|
16
|
+
inlineCodeColor: makeHighContrastColor(visColors[3])(backgroundColor),
|
|
17
|
+
selectedBackgroundColor: 'inherit',
|
|
18
|
+
commentColor: makeHighContrastColor(euiTheme.colors.subduedText)(backgroundColor),
|
|
19
|
+
selectorTagColor: 'inherit',
|
|
20
|
+
stringColor: makeHighContrastColor(visColors[2])(backgroundColor),
|
|
21
|
+
tagColor: makeHighContrastColor(visColors[1])(backgroundColor),
|
|
22
|
+
nameColor: makeHighContrastColor(visColors[1])(backgroundColor),
|
|
23
|
+
numberColor: makeHighContrastColor(visColors[0])(backgroundColor),
|
|
24
|
+
keywordColor: makeHighContrastColor(visColors[3])(backgroundColor),
|
|
25
|
+
functionTitleColor: 'inherit',
|
|
26
|
+
typeColor: makeHighContrastColor(visColors[1])(backgroundColor),
|
|
27
|
+
attributeColor: 'inherit',
|
|
28
|
+
symbolColor: makeHighContrastColor(visColors[9])(backgroundColor),
|
|
29
|
+
paramsColor: 'inherit',
|
|
30
|
+
metaColor: makeHighContrastColor(euiTheme.colors.subduedText)(backgroundColor),
|
|
31
|
+
titleColor: makeHighContrastColor(visColors[7])(backgroundColor),
|
|
32
|
+
sectionColor: makeHighContrastColor(visColors[9])(backgroundColor),
|
|
33
|
+
additionColor: makeHighContrastColor(visColors[0])(backgroundColor),
|
|
34
|
+
deletionColor: makeHighContrastColor(euiTheme.colors.danger)(backgroundColor),
|
|
35
|
+
selectorClassColor: 'inherit',
|
|
36
|
+
selectorIdColor: 'inherit'
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export var euiCodeSyntaxTokens = function euiCodeSyntaxTokens(euiThemeContext) {
|
|
40
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
41
|
+
var euiCodeBlock = euiCodeSyntaxColors(euiThemeContext);
|
|
42
|
+
return "\n .token.punctuation:not(.interpolation-punctuation):not([class*='attr-']) {\n opacity: .7;\n }\n \n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata,\n .token.coord,\n .token.blockquote {\n color: ".concat(euiCodeBlock.commentColor, ";\n font-style: italic;\n }\n \n .token.selector {\n color: ").concat(euiCodeBlock.selectorTagColor, ";\n }\n \n .token.string,\n .token.interpolation,\n .token.interpolation-punctuation,\n .token.doc-comment .token.keyword,\n .token.attr-value,\n .token.url .token.content {\n color: ").concat(euiCodeBlock.stringColor, ";\n }\n \n .token.number,\n .token.boolean,\n .token.keyword.nil,\n .token.regex,\n .token.variable,\n .token.unit,\n .token.hexcode,\n .token.attr-name,\n .token.attr-equals {\n color: ").concat(euiCodeBlock.numberColor, ";\n }\n \n .token.atrule .token.rule,\n .token.keyword {\n color: ").concat(euiCodeBlock.keywordColor, ";\n }\n \n .token.function {\n color: ").concat(euiCodeBlock.functionTitleColor, ";\n }\n \n .token.tag {\n color: ").concat(euiCodeBlock.tagColor, ";\n }\n \n .token.class-name {\n color: ").concat(euiCodeBlock.typeColor, ";\n }\n \n .token.property {\n color: ").concat(euiCodeBlock.attributeColor, ";\n }\n \n .token.console,\n .token.list-punctuation,\n .token.url-reference,\n .token.url .token.url {\n color: ").concat(euiCodeBlock.symbolColor, ";\n }\n \n .token.paramater {\n color: ").concat(euiCodeBlock.paramsColor, ";\n }\n \n .token.meta,\n .token.important {\n color: ").concat(euiCodeBlock.metaColor, ";\n }\n \n .token.title {\n color: ").concat(euiCodeBlock.titleColor, ";\n }\n \n .token.section {\n color: ").concat(euiCodeBlock.sectionColor, ";\n }\n \n .token.prefix.inserted,\n .token.prefix.deleted {\n padding-inline-start: -").concat(euiTheme.size.xs, ";\n margin-inline-start: -").concat(euiTheme.size.xs, ";\n }\n \n .token.prefix.inserted {\n box-shadow: -").concat(euiTheme.size.xs, " 0 ").concat(euiCodeBlock.additionColor, ";\n color: ").concat(euiCodeBlock.additionColor, ";\n }\n \n .token.prefix.deleted {\n box-shadow: -").concat(euiTheme.size.xs, " 0 ").concat(euiCodeBlock.deletionColor, ";\n color: ").concat(euiCodeBlock.deletionColor, ";\n }\n \n .token.selector .token.class {\n color: ").concat(euiCodeBlock.selectorClassColor, ";\n }\n \n .token.selector .token.id {\n color: ").concat(euiCodeBlock.selectorIdColor, ";\n }\n \n .token.italic {\n font-style: italic;\n }\n \n .token.important,\n .token.bold {\n font-weight: $euiCodeFontWeightBold;\n }\n \n .token.url-reference,\n .token.url .token.url {\n text-decoration: underline;\n }\n \n .token.entity {\n cursor: help;\n }\n ");
|
|
43
|
+
};
|