@elastic/eui 69.0.0 → 70.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eui_theme_dark.css +0 -554
- 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 -554
- 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/badge/beta_badge/beta_badge.js +6 -6
- package/es/components/basic_table/in_memory_table.js +16 -2
- package/es/components/button/button_display/_button_display.js +7 -6
- package/es/components/button/button_display/_button_display.styles.js +4 -4
- package/es/components/button/button_display/_button_display_content.js +6 -9
- package/es/components/button/button_display/_button_display_content.styles.js +3 -41
- 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/datagrid/controls/column_selector.js +1 -1
- package/es/components/datagrid/controls/column_sorting.js +1 -1
- package/es/components/header/header_links/header_links.js +6 -0
- package/es/components/loading/loading_spinner.js +14 -3
- package/es/components/loading/loading_spinner.styles.js +11 -7
- package/es/components/modal/modal.js +17 -2
- 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/page_template/page_template.js +6 -9
- package/es/components/popover/popover.js +13 -3
- package/es/components/popover/popover_arrow/_popover_arrow.js +1 -0
- package/es/components/popover/popover_panel/_popover_panel.js +8 -2
- package/es/components/popover/popover_panel/_popover_panel.styles.js +15 -1
- 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/search_bar/search_bar.js +39 -5
- package/es/components/search_bar/search_box.js +37 -4
- package/es/components/tabs/tab.js +33 -13
- package/es/components/tabs/tab.styles.js +50 -0
- package/es/components/tabs/tabbed_content/tabbed_content.js +16 -0
- package/es/components/tabs/tabs.js +20 -14
- package/es/components/tabs/tabs.styles.js +23 -0
- 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 +13 -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 +401 -84
- package/i18ntokens.json +26 -26
- package/lib/components/badge/beta_badge/beta_badge.js +6 -10
- package/lib/components/basic_table/in_memory_table.js +16 -2
- package/lib/components/button/button_display/_button_display.js +7 -6
- package/lib/components/button/button_display/_button_display.styles.js +4 -4
- package/lib/components/button/button_display/_button_display_content.js +6 -9
- package/lib/components/button/button_display/_button_display_content.styles.js +10 -40
- 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/datagrid/controls/column_selector.js +1 -1
- package/lib/components/datagrid/controls/column_sorting.js +1 -1
- package/lib/components/header/header_links/header_links.js +6 -0
- package/lib/components/loading/loading_spinner.js +13 -2
- package/lib/components/loading/loading_spinner.styles.js +14 -6
- package/lib/components/modal/modal.js +23 -2
- 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/page_template/page_template.js +6 -9
- package/lib/components/popover/popover.js +13 -3
- package/lib/components/popover/popover_arrow/_popover_arrow.js +1 -0
- package/lib/components/popover/popover_panel/_popover_panel.js +8 -2
- package/lib/components/popover/popover_panel/_popover_panel.styles.js +16 -1
- 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/search_bar/search_bar.js +40 -5
- package/lib/components/search_bar/search_box.js +38 -4
- package/lib/components/tabs/tab.js +33 -12
- package/lib/components/tabs/tab.styles.js +56 -0
- package/lib/components/tabs/tabbed_content/tabbed_content.js +16 -0
- package/lib/components/tabs/tabs.js +24 -14
- package/lib/components/tabs/tabs.styles.js +34 -0
- 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/badge/beta_badge/beta_badge.js +6 -6
- package/optimize/es/components/basic_table/in_memory_table.js +1 -1
- package/optimize/es/components/button/button_display/_button_display.js +6 -5
- package/optimize/es/components/button/button_display/_button_display.styles.js +4 -4
- package/optimize/es/components/button/button_display/_button_display_content.js +6 -9
- package/optimize/es/components/button/button_display/_button_display_content.styles.js +3 -41
- 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/datagrid/controls/column_selector.js +1 -1
- package/optimize/es/components/datagrid/controls/column_sorting.js +1 -1
- package/optimize/es/components/loading/loading_spinner.js +13 -3
- package/optimize/es/components/loading/loading_spinner.styles.js +11 -7
- package/optimize/es/components/modal/modal.js +17 -2
- 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/page_template/page_template.js +6 -9
- package/optimize/es/components/popover/popover.js +7 -3
- package/optimize/es/components/popover/popover_arrow/_popover_arrow.js +1 -0
- package/optimize/es/components/popover/popover_panel/_popover_panel.js +6 -1
- package/optimize/es/components/popover/popover_panel/_popover_panel.styles.js +15 -1
- 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/search_bar/search_bar.js +31 -5
- package/optimize/es/components/search_bar/search_box.js +29 -3
- package/optimize/es/components/tabs/tab.js +21 -13
- package/optimize/es/components/tabs/tab.styles.js +50 -0
- package/optimize/es/components/tabs/tabs.js +20 -14
- package/optimize/es/components/tabs/tabs.styles.js +23 -0
- 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/badge/beta_badge/beta_badge.js +6 -13
- package/optimize/lib/components/basic_table/in_memory_table.js +1 -1
- package/optimize/lib/components/button/button_display/_button_display.js +7 -6
- package/optimize/lib/components/button/button_display/_button_display.styles.js +4 -4
- package/optimize/lib/components/button/button_display/_button_display_content.js +6 -9
- package/optimize/lib/components/button/button_display/_button_display_content.styles.js +10 -40
- 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/datagrid/controls/column_selector.js +1 -1
- package/optimize/lib/components/datagrid/controls/column_sorting.js +1 -1
- package/optimize/lib/components/loading/loading_spinner.js +14 -2
- package/optimize/lib/components/loading/loading_spinner.styles.js +14 -6
- package/optimize/lib/components/modal/modal.js +22 -2
- 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/page_template/page_template.js +6 -9
- package/optimize/lib/components/popover/popover.js +7 -3
- package/optimize/lib/components/popover/popover_arrow/_popover_arrow.js +1 -0
- package/optimize/lib/components/popover/popover_panel/_popover_panel.js +6 -1
- package/optimize/lib/components/popover/popover_panel/_popover_panel.styles.js +16 -1
- 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/search_bar/search_bar.js +31 -5
- package/optimize/lib/components/search_bar/search_box.js +30 -3
- package/optimize/lib/components/tabs/tab.js +21 -12
- package/optimize/lib/components/tabs/tab.styles.js +56 -0
- package/optimize/lib/components/tabs/tabs.js +24 -14
- package/optimize/lib/components/tabs/tabs.styles.js +34 -0
- 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 +10 -9
- package/src/components/datagrid/controls/_data_grid_toolbar.scss +0 -8
- package/src/components/index.scss +0 -2
- 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 -2
- package/test-env/components/badge/beta_badge/beta_badge.js +6 -13
- package/test-env/components/basic_table/in_memory_table.js +16 -2
- package/test-env/components/button/button_display/_button_display.js +7 -6
- package/test-env/components/button/button_display/_button_display.styles.js +4 -4
- package/test-env/components/button/button_display/_button_display_content.js +6 -9
- package/test-env/components/button/button_display/_button_display_content.styles.js +10 -40
- 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/datagrid/controls/column_selector.js +1 -1
- package/test-env/components/datagrid/controls/column_sorting.js +1 -1
- package/test-env/components/header/header_links/header_links.js +6 -0
- package/test-env/components/loading/loading_spinner.js +14 -2
- package/test-env/components/loading/loading_spinner.styles.js +14 -6
- package/test-env/components/modal/modal.js +22 -2
- 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/page_template/page_template.js +6 -9
- package/test-env/components/popover/popover.js +13 -3
- package/test-env/components/popover/popover_arrow/_popover_arrow.js +1 -0
- package/test-env/components/popover/popover_panel/_popover_panel.js +8 -2
- package/test-env/components/popover/popover_panel/_popover_panel.styles.js +16 -1
- 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/search_bar/search_bar.js +39 -5
- package/test-env/components/search_bar/search_box.js +38 -4
- package/test-env/components/tabs/tab.js +33 -12
- package/test-env/components/tabs/tab.styles.js +56 -0
- package/test-env/components/tabs/tabbed_content/tabbed_content.js +16 -0
- package/test-env/components/tabs/tabs.js +24 -14
- package/test-env/components/tabs/tabs.styles.js +34 -0
- 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/components/tabs/_index.scss +0 -1
- package/src/components/tabs/_tabs.scss +0 -110
- package/src/global_styling/variables/_colors_code.scss +0 -23
- package/src/themes/amsterdam/overrides/_code.scss +0 -9
- package/src/themes/amsterdam/overrides/_tabs.scss +0 -80
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.euiCodeBlockControlsStyles = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
|
+
|
|
10
|
+
var _global_styling = require("../../global_styling");
|
|
11
|
+
|
|
12
|
+
var _code_syntax = require("./code_syntax.styles");
|
|
13
|
+
|
|
14
|
+
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)."; }
|
|
15
|
+
|
|
16
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
17
|
+
name: "to86kv-none",
|
|
18
|
+
styles: "inset-block-start:0;inset-inline-end:0;label:none;"
|
|
19
|
+
} : {
|
|
20
|
+
name: "to86kv-none",
|
|
21
|
+
styles: "inset-block-start:0;inset-inline-end:0;label:none;",
|
|
22
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var euiCodeBlockControlsStyles = function euiCodeBlockControlsStyles(euiThemeContext) {
|
|
26
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
27
|
+
var euiCodeSyntax = (0, _code_syntax.euiCodeSyntaxColors)(euiThemeContext);
|
|
28
|
+
return {
|
|
29
|
+
euiCodeBlock__controls: /*#__PURE__*/(0, _react.css)("position:absolute;display:flex;flex-direction:column;gap:", euiTheme.size.xs, ";background:", euiCodeSyntax.backgroundColor, ";;label:euiCodeBlock__controls;"),
|
|
30
|
+
offset: {
|
|
31
|
+
none: _ref,
|
|
32
|
+
s: /*#__PURE__*/(0, _react.css)("inset-block-start:", (0, _global_styling.euiPaddingSize)(euiThemeContext, 's'), ";inset-inline-end:", (0, _global_styling.euiPaddingSize)(euiThemeContext, 's'), ";;label:s;"),
|
|
33
|
+
m: /*#__PURE__*/(0, _react.css)("inset-block-start:", (0, _global_styling.euiPaddingSize)(euiThemeContext, 'm'), ";inset-inline-end:", (0, _global_styling.euiPaddingSize)(euiThemeContext, 'm'), ";;label:m;"),
|
|
34
|
+
l: /*#__PURE__*/(0, _react.css)("inset-block-start:", (0, _global_styling.euiPaddingSize)(euiThemeContext, 'l'), ";inset-inline-end:", (0, _global_styling.euiPaddingSize)(euiThemeContext, 'l'), ";;label:l;")
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.euiCodeBlockControlsStyles = euiCodeBlockControlsStyles;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.useCopy = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _inner_text = require("../inner_text");
|
|
17
|
+
|
|
18
|
+
var _copy = require("../copy");
|
|
19
|
+
|
|
20
|
+
var _i18n = require("../i18n");
|
|
21
|
+
|
|
22
|
+
var _button = require("../button");
|
|
23
|
+
|
|
24
|
+
var _react2 = require("@emotion/react");
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
32
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
33
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
34
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
35
|
+
* Side Public License, v 1.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Hook that returns copy-related state/logic/utils
|
|
40
|
+
*/
|
|
41
|
+
var useCopy = function useCopy(_ref) {
|
|
42
|
+
var isCopyable = _ref.isCopyable,
|
|
43
|
+
isVirtualized = _ref.isVirtualized,
|
|
44
|
+
children = _ref.children;
|
|
45
|
+
|
|
46
|
+
var _useInnerText = (0, _inner_text.useInnerText)(''),
|
|
47
|
+
_useInnerText2 = (0, _slicedToArray2.default)(_useInnerText, 2),
|
|
48
|
+
innerTextRef = _useInnerText2[0],
|
|
49
|
+
_innerText = _useInnerText2[1];
|
|
50
|
+
|
|
51
|
+
var innerText = (0, _react.useMemo)(function () {
|
|
52
|
+
return (_innerText === null || _innerText === void 0 ? void 0 : _innerText.replace(/[\r\n?]{2}|\n\n/g, '\n')) || '';
|
|
53
|
+
}, [_innerText]);
|
|
54
|
+
var textToCopy = isVirtualized ? "".concat(children) : innerText; // Virtualized code blocks do not have inner text
|
|
55
|
+
|
|
56
|
+
var showCopyButton = isCopyable && textToCopy;
|
|
57
|
+
var copyAriaLabel = (0, _i18n.useEuiI18n)('euiCodeBlockCopy.copy', 'Copy');
|
|
58
|
+
var copyButton = (0, _react.useMemo)(function () {
|
|
59
|
+
return showCopyButton ? (0, _react2.jsx)("div", {
|
|
60
|
+
className: "euiCodeBlock__copyButton"
|
|
61
|
+
}, (0, _react2.jsx)(_copy.EuiCopy, {
|
|
62
|
+
textToCopy: textToCopy
|
|
63
|
+
}, function (copy) {
|
|
64
|
+
return (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
65
|
+
onClick: copy,
|
|
66
|
+
iconType: "copyClipboard",
|
|
67
|
+
color: "text",
|
|
68
|
+
"aria-label": copyAriaLabel
|
|
69
|
+
});
|
|
70
|
+
})) : null;
|
|
71
|
+
}, [showCopyButton, textToCopy, copyAriaLabel]);
|
|
72
|
+
return {
|
|
73
|
+
innerTextRef: innerTextRef,
|
|
74
|
+
copyButton: copyButton
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.useCopy = useCopy;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.useFullScreen = exports.EuiCodeBlockFullScreenWrapper = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _services = require("../../services");
|
|
17
|
+
|
|
18
|
+
var _i18n = require("../i18n");
|
|
19
|
+
|
|
20
|
+
var _button = require("../button");
|
|
21
|
+
|
|
22
|
+
var _focus_trap = require("../focus_trap");
|
|
23
|
+
|
|
24
|
+
var _overlay_mask = require("../overlay_mask");
|
|
25
|
+
|
|
26
|
+
var _code_block = require("./code_block.styles");
|
|
27
|
+
|
|
28
|
+
var _react2 = require("@emotion/react");
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
36
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
37
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
38
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
39
|
+
* Side Public License, v 1.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Hook that returns fullscreen-related state/logic/utils
|
|
44
|
+
*/
|
|
45
|
+
var useFullScreen = function useFullScreen(_ref) {
|
|
46
|
+
var overflowHeight = _ref.overflowHeight;
|
|
47
|
+
var showFullScreenButton = !!overflowHeight;
|
|
48
|
+
|
|
49
|
+
var _useState = (0, _react.useState)(false),
|
|
50
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
|
+
isFullScreen = _useState2[0],
|
|
52
|
+
setIsFullScreen = _useState2[1];
|
|
53
|
+
|
|
54
|
+
var toggleFullScreen = (0, _react.useCallback)(function () {
|
|
55
|
+
setIsFullScreen(function (isFullScreen) {
|
|
56
|
+
return !isFullScreen;
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
59
|
+
var onKeyDown = (0, _react.useCallback)(function (event) {
|
|
60
|
+
if (event.key === _services.keys.ESCAPE) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
setIsFullScreen(false);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
var _useEuiI18n = (0, _i18n.useEuiI18n)(['euiCodeBlockFullScreen.fullscreenCollapse', 'euiCodeBlockFullScreen.fullscreenExpand'], ['Collapse', 'Expand']),
|
|
68
|
+
_useEuiI18n2 = (0, _slicedToArray2.default)(_useEuiI18n, 2),
|
|
69
|
+
fullscreenCollapse = _useEuiI18n2[0],
|
|
70
|
+
fullscreenExpand = _useEuiI18n2[1];
|
|
71
|
+
|
|
72
|
+
var fullScreenButton = (0, _react.useMemo)(function () {
|
|
73
|
+
return showFullScreenButton ? (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
74
|
+
className: "euiCodeBlock__fullScreenButton",
|
|
75
|
+
onClick: toggleFullScreen,
|
|
76
|
+
iconType: isFullScreen ? 'fullScreenExit' : 'fullScreen',
|
|
77
|
+
color: "text",
|
|
78
|
+
"aria-label": isFullScreen ? fullscreenCollapse : fullscreenExpand
|
|
79
|
+
}) : null;
|
|
80
|
+
}, [showFullScreenButton, toggleFullScreen, isFullScreen, fullscreenCollapse, fullscreenExpand]);
|
|
81
|
+
return {
|
|
82
|
+
fullScreenButton: fullScreenButton,
|
|
83
|
+
isFullScreen: isFullScreen,
|
|
84
|
+
onKeyDown: onKeyDown
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Portalled full screen wrapper
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
exports.useFullScreen = useFullScreen;
|
|
93
|
+
|
|
94
|
+
var EuiCodeBlockFullScreenWrapper = function EuiCodeBlockFullScreenWrapper(_ref2) {
|
|
95
|
+
var children = _ref2.children;
|
|
96
|
+
var euiThemeContext = (0, _services.useEuiTheme)();
|
|
97
|
+
var styles = (0, _code_block.euiCodeBlockStyles)(euiThemeContext);
|
|
98
|
+
var cssStyles = [styles.euiCodeBlock, styles.l, // Force fullscreen to use large font
|
|
99
|
+
styles.isFullScreen];
|
|
100
|
+
return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
|
|
101
|
+
clickOutsideDisables: true
|
|
102
|
+
}, (0, _react2.jsx)("div", {
|
|
103
|
+
className: "euiCodeBlockFullScreen",
|
|
104
|
+
css: cssStyles
|
|
105
|
+
}, children)));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.EuiCodeBlockFullScreenWrapper = EuiCodeBlockFullScreenWrapper;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.euiCodeBlockLineStyles = void 0;
|
|
7
|
+
|
|
8
|
+
var _css = require("@emotion/css");
|
|
9
|
+
|
|
10
|
+
var _global_styling = require("../../global_styling");
|
|
11
|
+
|
|
12
|
+
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)."; }
|
|
13
|
+
|
|
14
|
+
// Note: These styles must be in a separate file due to using `css` from `@emotion/css`
|
|
15
|
+
// (i.e., applying styles in vanilla JS / directly to DOM nodes instead of React)
|
|
16
|
+
var euiCodeBlockLineStyles = function euiCodeBlockLineStyles(euiThemeContext) {
|
|
17
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
18
|
+
return {
|
|
19
|
+
euiCodeBlock__line: /*#__PURE__*/(0, _css.css)(process.env.NODE_ENV === "production" ? {
|
|
20
|
+
name: "yn676d-euiCodeBlock__line",
|
|
21
|
+
styles: "display:block;label:euiCodeBlock__line;"
|
|
22
|
+
} : {
|
|
23
|
+
name: "yn676d-euiCodeBlock__line",
|
|
24
|
+
styles: "display:block;label:euiCodeBlock__line;",
|
|
25
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
26
|
+
}),
|
|
27
|
+
hasLineNumbers: /*#__PURE__*/(0, _css.css)(process.env.NODE_ENV === "production" ? {
|
|
28
|
+
name: "156gjef-hasLineNumbers",
|
|
29
|
+
styles: "display:flex;user-select:none;label:hasLineNumbers;"
|
|
30
|
+
} : {
|
|
31
|
+
name: "156gjef-hasLineNumbers",
|
|
32
|
+
styles: "display:flex;user-select:none;label:hasLineNumbers;",
|
|
33
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
34
|
+
}),
|
|
35
|
+
lineText: {
|
|
36
|
+
euiCodeBlock__lineText: /*#__PURE__*/(0, _css.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;"),
|
|
37
|
+
isHighlighted: /*#__PURE__*/(0, _css.css)("background:", (0, _global_styling.euiBackgroundColor)(euiThemeContext, 'primary'), ";border-inline-start:", euiTheme.border.width.thick, " solid ", euiTheme.colors.primary, ";;label:isHighlighted;")
|
|
38
|
+
},
|
|
39
|
+
lineNumber: {
|
|
40
|
+
euiCodeBlock__lineNumber: /*#__PURE__*/(0, _css.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;")
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.euiCodeBlockLineStyles = euiCodeBlockLineStyles;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useOverflow = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = require("react");
|
|
15
|
+
|
|
16
|
+
var _mutation_observer = require("../observer/mutation_observer");
|
|
17
|
+
|
|
18
|
+
var _resize_observer = require("../observer/resize_observer");
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
23
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
24
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
25
|
+
* Side Public License, v 1.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Overflow logic - returns overflow-related state/logic/utils
|
|
30
|
+
*
|
|
31
|
+
* Detects whether the code block overflows and returns a tabIndex of 0 if so,
|
|
32
|
+
* which allows keyboard users to use the up/down arrow keys to scroll through
|
|
33
|
+
* the container.
|
|
34
|
+
*/
|
|
35
|
+
var useOverflow = function useOverflow(_ref) {
|
|
36
|
+
var overflowHeight = _ref.overflowHeight;
|
|
37
|
+
|
|
38
|
+
var _useState = (0, _react.useState)(null),
|
|
39
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
40
|
+
wrapperRef = _useState2[0],
|
|
41
|
+
setWrapperRef = _useState2[1];
|
|
42
|
+
|
|
43
|
+
var _useState3 = (0, _react.useState)(-1),
|
|
44
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
45
|
+
tabIndex = _useState4[0],
|
|
46
|
+
setTabIndex = _useState4[1];
|
|
47
|
+
|
|
48
|
+
var _useResizeObserver = (0, _resize_observer.useResizeObserver)(wrapperRef),
|
|
49
|
+
width = _useResizeObserver.width,
|
|
50
|
+
height = _useResizeObserver.height;
|
|
51
|
+
|
|
52
|
+
var doesOverflow = function doesOverflow() {
|
|
53
|
+
if (!wrapperRef) return;
|
|
54
|
+
var clientWidth = wrapperRef.clientWidth,
|
|
55
|
+
clientHeight = wrapperRef.clientHeight,
|
|
56
|
+
scrollWidth = wrapperRef.scrollWidth,
|
|
57
|
+
scrollHeight = wrapperRef.scrollHeight;
|
|
58
|
+
var doesOverflow = scrollHeight > clientHeight || scrollWidth > clientWidth;
|
|
59
|
+
setTabIndex(doesOverflow ? 0 : -1);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
(0, _mutation_observer.useMutationObserver)(wrapperRef, doesOverflow, {
|
|
63
|
+
subtree: true,
|
|
64
|
+
childList: true
|
|
65
|
+
});
|
|
66
|
+
(0, _react.useEffect)(doesOverflow, [width, height, wrapperRef]);
|
|
67
|
+
var overflowHeightStyles = (0, _react.useMemo)(function () {
|
|
68
|
+
if (overflowHeight) {
|
|
69
|
+
var property = typeof overflowHeight === 'string' ? 'blockSize' : 'maxBlockSize';
|
|
70
|
+
return (0, _defineProperty2.default)({}, property, overflowHeight);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {};
|
|
74
|
+
}, [overflowHeight]);
|
|
75
|
+
return {
|
|
76
|
+
setWrapperRef: setWrapperRef,
|
|
77
|
+
tabIndex: tabIndex,
|
|
78
|
+
overflowHeightStyles: overflowHeightStyles
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
exports.useOverflow = useOverflow;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.EuiCodeBlockVirtualized = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _reactWindow = require("react-window");
|
|
17
|
+
|
|
18
|
+
var _auto_sizer = require("../auto_sizer");
|
|
19
|
+
|
|
20
|
+
var _utils = require("./utils");
|
|
21
|
+
|
|
22
|
+
var _react2 = require("@emotion/react");
|
|
23
|
+
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
30
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
31
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
32
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
33
|
+
* Side Public License, v 1.
|
|
34
|
+
*/
|
|
35
|
+
var EuiCodeBlockVirtualized = function EuiCodeBlockVirtualized(_ref) {
|
|
36
|
+
var data = _ref.data,
|
|
37
|
+
rowHeight = _ref.rowHeight,
|
|
38
|
+
overflowHeight = _ref.overflowHeight,
|
|
39
|
+
preProps = _ref.preProps,
|
|
40
|
+
codeProps = _ref.codeProps;
|
|
41
|
+
var VirtualizedOuterElement = (0, _react.useMemo)(function () {
|
|
42
|
+
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
43
|
+
return (0, _react2.jsx)("pre", (0, _extends2.default)({}, props, {
|
|
44
|
+
ref: ref
|
|
45
|
+
}, preProps));
|
|
46
|
+
});
|
|
47
|
+
}, [preProps]);
|
|
48
|
+
var VirtualizedInnerElement = (0, _react.useMemo)(function () {
|
|
49
|
+
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
50
|
+
return (0, _react2.jsx)("code", (0, _extends2.default)({}, props, {
|
|
51
|
+
ref: ref
|
|
52
|
+
}, codeProps));
|
|
53
|
+
});
|
|
54
|
+
}, [codeProps]);
|
|
55
|
+
return (0, _react2.jsx)(_auto_sizer.EuiAutoSizer, {
|
|
56
|
+
disableHeight: typeof overflowHeight === 'number'
|
|
57
|
+
}, function (_ref2) {
|
|
58
|
+
var height = _ref2.height,
|
|
59
|
+
width = _ref2.width;
|
|
60
|
+
return (0, _react2.jsx)(_reactWindow.FixedSizeList, {
|
|
61
|
+
height: height !== null && height !== void 0 ? height : overflowHeight,
|
|
62
|
+
width: width,
|
|
63
|
+
itemData: data,
|
|
64
|
+
itemSize: rowHeight,
|
|
65
|
+
itemCount: data.length,
|
|
66
|
+
outerElementType: VirtualizedOuterElement,
|
|
67
|
+
innerElementType: VirtualizedInnerElement
|
|
68
|
+
}, ListRow);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.EuiCodeBlockVirtualized = EuiCodeBlockVirtualized;
|
|
73
|
+
|
|
74
|
+
var ListRow = function ListRow(_ref3) {
|
|
75
|
+
var data = _ref3.data,
|
|
76
|
+
index = _ref3.index,
|
|
77
|
+
style = _ref3.style;
|
|
78
|
+
var row = data[index];
|
|
79
|
+
row.properties.style = style;
|
|
80
|
+
return (0, _utils.nodeToHtml)(row, index, data, 0);
|
|
81
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.euiCodeSyntaxTokens = exports.euiCodeSyntaxColors = void 0;
|
|
7
|
+
|
|
8
|
+
var _services = require("../../services");
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
12
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
13
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
14
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
15
|
+
* Side Public License, v 1.
|
|
16
|
+
*/
|
|
17
|
+
var visColors = (0, _services.euiPaletteColorBlind)();
|
|
18
|
+
|
|
19
|
+
var euiCodeSyntaxColors = function euiCodeSyntaxColors(euiThemeContext) {
|
|
20
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
21
|
+
var backgroundColor = euiTheme.colors.lightestShade;
|
|
22
|
+
return {
|
|
23
|
+
backgroundColor: backgroundColor,
|
|
24
|
+
color: (0, _services.makeHighContrastColor)(euiTheme.colors.text)(backgroundColor),
|
|
25
|
+
inlineCodeColor: (0, _services.makeHighContrastColor)(visColors[3])(backgroundColor),
|
|
26
|
+
selectedBackgroundColor: 'inherit',
|
|
27
|
+
commentColor: (0, _services.makeHighContrastColor)(euiTheme.colors.subduedText)(backgroundColor),
|
|
28
|
+
selectorTagColor: 'inherit',
|
|
29
|
+
stringColor: (0, _services.makeHighContrastColor)(visColors[2])(backgroundColor),
|
|
30
|
+
tagColor: (0, _services.makeHighContrastColor)(visColors[1])(backgroundColor),
|
|
31
|
+
nameColor: (0, _services.makeHighContrastColor)(visColors[1])(backgroundColor),
|
|
32
|
+
numberColor: (0, _services.makeHighContrastColor)(visColors[0])(backgroundColor),
|
|
33
|
+
keywordColor: (0, _services.makeHighContrastColor)(visColors[3])(backgroundColor),
|
|
34
|
+
functionTitleColor: 'inherit',
|
|
35
|
+
typeColor: (0, _services.makeHighContrastColor)(visColors[1])(backgroundColor),
|
|
36
|
+
attributeColor: 'inherit',
|
|
37
|
+
symbolColor: (0, _services.makeHighContrastColor)(visColors[9])(backgroundColor),
|
|
38
|
+
paramsColor: 'inherit',
|
|
39
|
+
metaColor: (0, _services.makeHighContrastColor)(euiTheme.colors.subduedText)(backgroundColor),
|
|
40
|
+
titleColor: (0, _services.makeHighContrastColor)(visColors[7])(backgroundColor),
|
|
41
|
+
sectionColor: (0, _services.makeHighContrastColor)(visColors[9])(backgroundColor),
|
|
42
|
+
additionColor: (0, _services.makeHighContrastColor)(visColors[0])(backgroundColor),
|
|
43
|
+
deletionColor: (0, _services.makeHighContrastColor)(euiTheme.colors.danger)(backgroundColor),
|
|
44
|
+
selectorClassColor: 'inherit',
|
|
45
|
+
selectorIdColor: 'inherit'
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.euiCodeSyntaxColors = euiCodeSyntaxColors;
|
|
50
|
+
|
|
51
|
+
var euiCodeSyntaxTokens = function euiCodeSyntaxTokens(euiThemeContext) {
|
|
52
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
53
|
+
var euiCodeBlock = euiCodeSyntaxColors(euiThemeContext);
|
|
54
|
+
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 ");
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.euiCodeSyntaxTokens = euiCodeSyntaxTokens;
|
|
@@ -15,7 +15,9 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _refractor = require("refractor");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _css = require("@emotion/css");
|
|
19
|
+
|
|
20
|
+
var _code_block_line = require("./code_block_line.styles");
|
|
19
21
|
|
|
20
22
|
var _react2 = require("@emotion/react");
|
|
21
23
|
|
|
@@ -64,7 +66,7 @@ var nodeToHtml = function nodeToHtml(node, idx, nodes) {
|
|
|
64
66
|
children = node.children;
|
|
65
67
|
return /*#__PURE__*/(0, _react.createElement)(tagName, _objectSpread(_objectSpread({}, properties), {}, {
|
|
66
68
|
key: key,
|
|
67
|
-
className: (0,
|
|
69
|
+
className: (0, _css.cx)(properties.className)
|
|
68
70
|
}), children && children.map(function (el, i) {
|
|
69
71
|
return nodeToHtml(el, i, nodes, depth + 1);
|
|
70
72
|
}));
|
|
@@ -81,8 +83,7 @@ var nodeToHtml = function nodeToHtml(node, idx, nodes) {
|
|
|
81
83
|
|
|
82
84
|
exports.nodeToHtml = nodeToHtml;
|
|
83
85
|
// Approximate width of a single digit/character
|
|
84
|
-
var CHAR_SIZE = 8;
|
|
85
|
-
var $euiSizeS = 8; // Creates an array of numbers from comma-separeated
|
|
86
|
+
var CHAR_SIZE = 8; // Creates an array of numbers from comma-separeated
|
|
86
87
|
// string of numbers or number ranges using `-`
|
|
87
88
|
// (e.g., "1, 3-10, 15")
|
|
88
89
|
|
|
@@ -157,8 +158,7 @@ var addLineData = function addLineData(nodes, data) {
|
|
|
157
158
|
}, []);
|
|
158
159
|
};
|
|
159
160
|
|
|
160
|
-
function wrapLines(nodes, options) {
|
|
161
|
-
var highlights = options.highlight ? parseLineRanges(options.highlight) : [];
|
|
161
|
+
function wrapLines(nodes, options, euiTheme) {
|
|
162
162
|
var grouped = [];
|
|
163
163
|
nodes.forEach(function (node) {
|
|
164
164
|
var lineStart = node.lineStart - 1;
|
|
@@ -170,41 +170,44 @@ function wrapLines(nodes, options) {
|
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
var wrapped = [];
|
|
173
|
-
var digits = grouped.length.toString().length;
|
|
174
|
-
var width = digits * CHAR_SIZE;
|
|
175
173
|
grouped.forEach(function (node, i) {
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
var
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
174
|
+
var children = node;
|
|
175
|
+
var styles = (0, _code_block_line.euiCodeBlockLineStyles)(euiTheme);
|
|
176
|
+
var lineStyles = (0, _css.cx)([styles.euiCodeBlock__line, options.showLineNumbers && styles.hasLineNumbers]);
|
|
177
|
+
|
|
178
|
+
if (options.showLineNumbers) {
|
|
179
|
+
var _properties;
|
|
180
|
+
|
|
181
|
+
var lineNumber = i + 1;
|
|
182
|
+
var digits = grouped.length.toString().length;
|
|
183
|
+
var width = digits * CHAR_SIZE;
|
|
184
|
+
var highlights = options.highlight ? parseLineRanges(options.highlight) : [];
|
|
185
|
+
var lineTextStyles = (0, _css.cx)([styles.lineText.euiCodeBlock__lineText, highlights.includes(lineNumber) && styles.lineText.isHighlighted]);
|
|
186
|
+
var lineNumberStyles = (0, _css.cx)(styles.lineNumber.euiCodeBlock__lineNumber);
|
|
187
|
+
children = [{
|
|
188
|
+
type: 'element',
|
|
189
|
+
tagName: 'span',
|
|
190
|
+
properties: (_properties = {
|
|
191
|
+
style: {
|
|
192
|
+
inlineSize: width
|
|
193
|
+
}
|
|
194
|
+
}, (0, _defineProperty2.default)(_properties, 'data-line-number', lineNumber), (0, _defineProperty2.default)(_properties, 'aria-hidden', true), (0, _defineProperty2.default)(_properties, "className", ['euiCodeBlock__lineNumber', lineNumberStyles]), _properties),
|
|
195
|
+
children: []
|
|
196
|
+
}, {
|
|
197
|
+
type: 'element',
|
|
198
|
+
tagName: 'span',
|
|
199
|
+
properties: {
|
|
200
|
+
className: ['euiCodeBlock__lineText', lineTextStyles]
|
|
198
201
|
},
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
children: node
|
|
203
|
+
}];
|
|
204
|
+
}
|
|
205
|
+
|
|
203
206
|
wrapped.push({
|
|
204
207
|
type: 'element',
|
|
205
208
|
tagName: 'span',
|
|
206
209
|
properties: {
|
|
207
|
-
className: [
|
|
210
|
+
className: ['euiCodeBlock__line', lineStyles]
|
|
208
211
|
},
|
|
209
212
|
children: children
|
|
210
213
|
});
|
|
@@ -212,13 +215,13 @@ function wrapLines(nodes, options) {
|
|
|
212
215
|
return wrapped;
|
|
213
216
|
}
|
|
214
217
|
|
|
215
|
-
var highlightByLine = function highlightByLine(children, language, data) {
|
|
218
|
+
var highlightByLine = function highlightByLine(children, language, data, euiTheme) {
|
|
216
219
|
return wrapLines(addLineData((0, _refractor.highlight)(children, language), {
|
|
217
220
|
lineNumber: data.start
|
|
218
221
|
}), {
|
|
219
222
|
showLineNumbers: data.show,
|
|
220
223
|
highlight: data.highlight
|
|
221
|
-
});
|
|
224
|
+
}, euiTheme);
|
|
222
225
|
};
|
|
223
226
|
|
|
224
227
|
exports.highlightByLine = highlightByLine;
|
|
@@ -138,7 +138,7 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
|
|
|
138
138
|
},
|
|
139
139
|
anchorPosition: "downLeft",
|
|
140
140
|
panelPaddingSize: "s",
|
|
141
|
-
|
|
141
|
+
hasDragDrop: true,
|
|
142
142
|
button: (0, _react2.jsx)(_button.EuiButtonEmpty, {
|
|
143
143
|
size: "xs",
|
|
144
144
|
iconType: allowColumnHiding ? 'listAdd' : 'list',
|
|
@@ -150,7 +150,7 @@ var useDataGridColumnSorting = function useDataGridColumnSorting(columns, sortin
|
|
|
150
150
|
},
|
|
151
151
|
anchorPosition: "downLeft",
|
|
152
152
|
panelPaddingSize: "s",
|
|
153
|
-
|
|
153
|
+
hasDragDrop: true,
|
|
154
154
|
button: (0, _react2.jsx)(_button.EuiButtonEmpty, {
|
|
155
155
|
size: "xs",
|
|
156
156
|
iconType: "sortable",
|