@elastic/eui 77.1.3 → 77.1.5
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 +14 -13
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +14 -13
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/code/code_block_annotations.js +13 -4
- package/es/components/code/code_block_copy.js +14 -2
- package/es/components/code/code_block_line.styles.js +1 -1
- package/es/components/code/utils.js +29 -17
- package/es/components/datagrid/body/data_grid_cell.js +7 -2
- package/eui.d.ts +19 -3
- package/i18ntokens.json +12 -12
- package/lib/components/code/code_block_annotations.js +13 -4
- package/lib/components/code/code_block_copy.js +14 -2
- package/lib/components/code/code_block_line.styles.js +1 -1
- package/lib/components/code/utils.js +32 -18
- package/lib/components/datagrid/body/data_grid_cell.js +7 -2
- package/optimize/es/components/code/code_block_annotations.js +8 -4
- package/optimize/es/components/code/code_block_copy.js +14 -2
- package/optimize/es/components/code/code_block_line.styles.js +1 -1
- package/optimize/es/components/code/utils.js +29 -17
- package/optimize/es/components/datagrid/body/data_grid_cell.js +6 -2
- package/optimize/lib/components/code/code_block_annotations.js +8 -12
- package/optimize/lib/components/code/code_block_copy.js +14 -2
- package/optimize/lib/components/code/code_block_line.styles.js +1 -1
- package/optimize/lib/components/code/utils.js +32 -18
- package/optimize/lib/components/datagrid/body/data_grid_cell.js +6 -2
- package/package.json +1 -1
- package/src/components/table/_table.scss +7 -9
- package/test-env/components/code/code_block_annotations.js +12 -12
- package/test-env/components/code/code_block_copy.js +14 -2
- package/test-env/components/code/code_block_line.styles.js +1 -1
- package/test-env/components/code/utils.js +32 -18
- package/test-env/components/datagrid/body/data_grid_cell.js +7 -2
|
@@ -12,6 +12,7 @@ import { useInnerText } from '../inner_text';
|
|
|
12
12
|
import { EuiCopy } from '../copy';
|
|
13
13
|
import { useEuiI18n } from '../i18n';
|
|
14
14
|
import { EuiButtonIcon } from '../button';
|
|
15
|
+
import { NEW_LINE_REGEX_GLOBAL } from './utils';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Hook that returns copy-related state/logic/utils
|
|
@@ -26,7 +27,17 @@ export var useCopy = function useCopy(_ref) {
|
|
|
26
27
|
innerTextRef = _useInnerText2[0],
|
|
27
28
|
_innerText = _useInnerText2[1];
|
|
28
29
|
var innerText = useMemo(function () {
|
|
29
|
-
return (_innerText
|
|
30
|
+
return (_innerText
|
|
31
|
+
// Normalize line terminations to match native JS format
|
|
32
|
+
=== null || _innerText
|
|
33
|
+
// Normalize line terminations to match native JS format
|
|
34
|
+
=== void 0 ? void 0 : _innerText
|
|
35
|
+
// Normalize line terminations to match native JS format
|
|
36
|
+
.replace(NEW_LINE_REGEX_GLOBAL, '\n')
|
|
37
|
+
// Reduce two or more consecutive new line characters to a single one
|
|
38
|
+
// This is needed primarily because of how syntax highlighting
|
|
39
|
+
// generated DOM elements affect `innerText` output.
|
|
40
|
+
.replace(/\n{2,}/g, '\n')) || '';
|
|
30
41
|
}, [_innerText]);
|
|
31
42
|
var textToCopy = isVirtualized ? "".concat(children) : innerText; // Virtualized code blocks do not have inner text
|
|
32
43
|
|
|
@@ -42,7 +53,8 @@ export var useCopy = function useCopy(_ref) {
|
|
|
42
53
|
onClick: copy,
|
|
43
54
|
iconType: "copyClipboard",
|
|
44
55
|
color: "text",
|
|
45
|
-
"aria-label": copyAriaLabel
|
|
56
|
+
"aria-label": copyAriaLabel,
|
|
57
|
+
"data-test-subj": "euiCodeBlockCopy"
|
|
46
58
|
});
|
|
47
59
|
})) : null;
|
|
48
60
|
}, [showCopyButton, textToCopy, copyAriaLabel]);
|
|
@@ -44,7 +44,7 @@ export var euiCodeBlockLineStyles = function euiCodeBlockLineStyles(euiThemeCont
|
|
|
44
44
|
},
|
|
45
45
|
lineNumber: {
|
|
46
46
|
euiCodeBlock__lineNumberWrapper: /*#__PURE__*/css("position:relative;flex-grow:0;flex-shrink:0;user-select:none;padding-inline-end:", euiTheme.size.m, ";box-sizing:content-box;;label:euiCodeBlock__lineNumberWrapper;"),
|
|
47
|
-
euiCodeBlock__lineNumber: /*#__PURE__*/css("color:", euiTheme.colors.subduedText, ";text-align:end;display:block
|
|
47
|
+
euiCodeBlock__lineNumber: /*#__PURE__*/css("color:", euiTheme.colors.subduedText, ";text-align:end;display:block;&::before{content:attr(data-line-number);};label:euiCodeBlock__lineNumber;")
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
};
|
|
@@ -21,6 +21,22 @@ import { euiCodeBlockLineStyles } from './code_block_line.styles';
|
|
|
21
21
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
22
22
|
export var SUPPORTED_LANGUAGES = listLanguages();
|
|
23
23
|
export var DEFAULT_LANGUAGE = 'text';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Platform-agnostic new line regex that safely matches all standard
|
|
27
|
+
* line termination conventions:
|
|
28
|
+
* - LF: Unix-based platforms and JS-native sources like text areas
|
|
29
|
+
* - CRLF: Windows
|
|
30
|
+
* - CR: Mac Classic; to support files saved a long time ago
|
|
31
|
+
*/
|
|
32
|
+
export var NEW_LINE_REGEX = /\r\n|\r|\n/;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Platform-agnostic global new line regex that safely matches all standard
|
|
36
|
+
* line termination conventions.
|
|
37
|
+
* See [NEW_LINE_REGEX]{@link NEW_LINE_REGEX} for more details.
|
|
38
|
+
*/
|
|
39
|
+
export var NEW_LINE_REGEX_GLOBAL = new RegExp(NEW_LINE_REGEX, 'g');
|
|
24
40
|
export var checkSupportedLanguage = function checkSupportedLanguage(language) {
|
|
25
41
|
return SUPPORTED_LANGUAGES.includes(language) ? language : DEFAULT_LANGUAGE;
|
|
26
42
|
};
|
|
@@ -46,14 +62,12 @@ export var nodeToHtml = function nodeToHtml(node, idx, nodes) {
|
|
|
46
62
|
}), children && children.map(function (el, i) {
|
|
47
63
|
return (
|
|
48
64
|
// @ts-ignore - using a custom type here to handle JSX annotations
|
|
49
|
-
el.type === 'annotation' ?
|
|
50
|
-
|
|
51
|
-
___EmotionJSX(EuiCodeBlockAnnotation, {
|
|
65
|
+
el.type === 'annotation' ? ___EmotionJSX(EuiCodeBlockAnnotation, {
|
|
66
|
+
className: "euiCodeBlock__lineAnnotation",
|
|
52
67
|
lineNumber: el.lineNumber,
|
|
53
68
|
children: el.annotation,
|
|
54
69
|
key: i
|
|
55
|
-
})
|
|
56
|
-
: nodeToHtml(el, i, nodes, depth + 1)
|
|
70
|
+
}) : nodeToHtml(el, i, nodes, depth + 1)
|
|
57
71
|
);
|
|
58
72
|
}));
|
|
59
73
|
}
|
|
@@ -90,12 +104,12 @@ var addLineData = function addLineData(nodes, data) {
|
|
|
90
104
|
return nodes.reduce(function (result, node) {
|
|
91
105
|
var lineStart = data.lineNumber;
|
|
92
106
|
if (node.type === 'text') {
|
|
93
|
-
if (!node.value.match(
|
|
107
|
+
if (!node.value.match(NEW_LINE_REGEX)) {
|
|
94
108
|
node.lineStart = lineStart;
|
|
95
109
|
node.lineEnd = lineStart;
|
|
96
110
|
result.push(node);
|
|
97
111
|
} else {
|
|
98
|
-
var lines = node.value.split(
|
|
112
|
+
var lines = node.value.split(NEW_LINE_REGEX);
|
|
99
113
|
lines.forEach(function (line, i) {
|
|
100
114
|
var num = i === 0 ? data.lineNumber : ++data.lineNumber;
|
|
101
115
|
result.push({
|
|
@@ -169,11 +183,12 @@ function wrapLines(nodes, options, euiTheme) {
|
|
|
169
183
|
var lineNumberWrapperElement = {
|
|
170
184
|
type: 'element',
|
|
171
185
|
tagName: 'span',
|
|
172
|
-
properties:
|
|
186
|
+
properties: {
|
|
173
187
|
style: {
|
|
174
188
|
inlineSize: width
|
|
175
|
-
}
|
|
176
|
-
|
|
189
|
+
},
|
|
190
|
+
className: ['euiCodeBlock__lineNumberWrapper', lineNumberWrapperStyles]
|
|
191
|
+
},
|
|
177
192
|
children: []
|
|
178
193
|
};
|
|
179
194
|
|
|
@@ -182,13 +197,10 @@ function wrapLines(nodes, options, euiTheme) {
|
|
|
182
197
|
var lineNumberElement = {
|
|
183
198
|
type: 'element',
|
|
184
199
|
tagName: 'span',
|
|
185
|
-
properties:
|
|
186
|
-
className: [lineNumberStyles]
|
|
187
|
-
}, 'aria-hidden', true),
|
|
188
|
-
children: [
|
|
189
|
-
type: 'text',
|
|
190
|
-
value: String(lineNumber)
|
|
191
|
-
}]
|
|
200
|
+
properties: (_properties = {
|
|
201
|
+
className: ['euiCodeBlock__lineNumber', lineNumberStyles]
|
|
202
|
+
}, _defineProperty(_properties, 'data-line-number', lineNumber), _defineProperty(_properties, 'aria-hidden', true), _properties),
|
|
203
|
+
children: []
|
|
192
204
|
};
|
|
193
205
|
lineNumberWrapperElement.children.push(lineNumberElement);
|
|
194
206
|
|
|
@@ -7,7 +7,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
import _extends from "@babel/runtime/helpers/extends";
|
|
9
9
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
10
|
-
var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight"],
|
|
10
|
+
var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight", "isFocused"],
|
|
11
11
|
_excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
|
|
12
12
|
_excluded3 = ["isExpandable", "style", "className", "data-test-subj"];
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -46,6 +46,7 @@ var EuiDataGridCellContent = /*#__PURE__*/memo(function (_ref) {
|
|
|
46
46
|
ariaRowIndex = _ref.ariaRowIndex,
|
|
47
47
|
rowHeightUtils = _ref.rowHeightUtils,
|
|
48
48
|
isDefinedHeight = _ref.isDefinedHeight,
|
|
49
|
+
isFocused = _ref.isFocused,
|
|
49
50
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
50
51
|
// React is more permissible than the TS types indicate
|
|
51
52
|
var CellElement = renderCellValue;
|
|
@@ -60,7 +61,9 @@ var EuiDataGridCellContent = /*#__PURE__*/memo(function (_ref) {
|
|
|
60
61
|
rowIndex: rowIndex,
|
|
61
62
|
colIndex: colIndex,
|
|
62
63
|
schema: (column === null || column === void 0 ? void 0 : column.schema) || rest.columnType
|
|
63
|
-
}, rest))), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p",
|
|
64
|
+
}, rest))), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
|
|
65
|
+
hidden: !isFocused
|
|
66
|
+
}, '- ', ___EmotionJSX(EuiI18n, {
|
|
64
67
|
token: "euiDataGridCell.position",
|
|
65
68
|
default: "{columnId}, column {col}, row {row}",
|
|
66
69
|
values: {
|
|
@@ -526,6 +529,7 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
526
529
|
isExpandable: isExpandable,
|
|
527
530
|
isExpanded: popoverIsOpen,
|
|
528
531
|
isDetails: false,
|
|
532
|
+
isFocused: this.state.isFocused,
|
|
529
533
|
setCellContentsRef: this.setCellContentsRef,
|
|
530
534
|
rowHeightsOptions: rowHeightsOptions,
|
|
531
535
|
rowHeightUtils: rowHeightUtils,
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.EuiCodeBlockAnnotation = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
13
|
var _services = require("../../services");
|
|
13
14
|
var _i18n = require("../i18n");
|
|
@@ -16,19 +17,13 @@ var _icon = require("../icon");
|
|
|
16
17
|
var _button = require("../../themes/amsterdam/global_styling/mixins/button");
|
|
17
18
|
var _code_block_annotations = require("./code_block_annotations.style");
|
|
18
19
|
var _react2 = require("@emotion/react");
|
|
20
|
+
var _excluded = ["lineNumber", "children"];
|
|
19
21
|
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); }
|
|
20
22
|
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; }
|
|
21
|
-
/*
|
|
22
|
-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
23
|
-
* or more contributor license agreements. Licensed under the Elastic License
|
|
24
|
-
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
25
|
-
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
26
|
-
* Side Public License, v 1.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
23
|
var EuiCodeBlockAnnotation = function EuiCodeBlockAnnotation(_ref) {
|
|
30
24
|
var lineNumber = _ref.lineNumber,
|
|
31
|
-
children = _ref.children
|
|
25
|
+
children = _ref.children,
|
|
26
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
32
27
|
var _useState = (0, _react.useState)(false),
|
|
33
28
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
34
29
|
isOpen = _useState2[0],
|
|
@@ -43,7 +38,9 @@ var EuiCodeBlockAnnotation = function EuiCodeBlockAnnotation(_ref) {
|
|
|
43
38
|
var buttonIconFocusStyle = (0, _button.useEuiButtonFocusCSS)();
|
|
44
39
|
var cssButtonIconStyles = [styles.euiCodeBlockAnnotation__buttonIcon, buttonIconFocusStyle];
|
|
45
40
|
var isDarkMode = colorMode === 'DARK';
|
|
46
|
-
return (0, _react2.jsx)(_popover.EuiPopover, {
|
|
41
|
+
return (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({
|
|
42
|
+
css: styles.euiCodeBlockAnnotation
|
|
43
|
+
}, rest, {
|
|
47
44
|
isOpen: isOpen,
|
|
48
45
|
closePopover: function closePopover() {
|
|
49
46
|
return setIsOpen(false);
|
|
@@ -60,14 +57,13 @@ var EuiCodeBlockAnnotation = function EuiCodeBlockAnnotation(_ref) {
|
|
|
60
57
|
size: "s",
|
|
61
58
|
color: isDarkMode ? euiTheme.colors.ink : 'ghost'
|
|
62
59
|
})),
|
|
63
|
-
css: styles.euiCodeBlockAnnotation,
|
|
64
60
|
zIndex: Number(euiTheme.levels.mask) + 1 // Ensure fullscreen annotation popovers sit above the mask
|
|
65
61
|
,
|
|
66
62
|
anchorPosition: "downLeft",
|
|
67
63
|
panelProps: {
|
|
68
64
|
'data-test-subj': 'euiCodeBlockAnnotationPopover'
|
|
69
65
|
}
|
|
70
|
-
}, children);
|
|
66
|
+
}), children);
|
|
71
67
|
};
|
|
72
68
|
exports.EuiCodeBlockAnnotation = EuiCodeBlockAnnotation;
|
|
73
69
|
var AnnotationInfoIcon = function AnnotationInfoIcon(props) {
|
|
@@ -12,6 +12,7 @@ var _inner_text = require("../inner_text");
|
|
|
12
12
|
var _copy = require("../copy");
|
|
13
13
|
var _i18n = require("../i18n");
|
|
14
14
|
var _button = require("../button");
|
|
15
|
+
var _utils = require("./utils");
|
|
15
16
|
var _react2 = require("@emotion/react");
|
|
16
17
|
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); }
|
|
17
18
|
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; }
|
|
@@ -35,7 +36,17 @@ var useCopy = function useCopy(_ref) {
|
|
|
35
36
|
innerTextRef = _useInnerText2[0],
|
|
36
37
|
_innerText = _useInnerText2[1];
|
|
37
38
|
var innerText = (0, _react.useMemo)(function () {
|
|
38
|
-
return (_innerText
|
|
39
|
+
return (_innerText
|
|
40
|
+
// Normalize line terminations to match native JS format
|
|
41
|
+
=== null || _innerText
|
|
42
|
+
// Normalize line terminations to match native JS format
|
|
43
|
+
=== void 0 ? void 0 : _innerText
|
|
44
|
+
// Normalize line terminations to match native JS format
|
|
45
|
+
.replace(_utils.NEW_LINE_REGEX_GLOBAL, '\n')
|
|
46
|
+
// Reduce two or more consecutive new line characters to a single one
|
|
47
|
+
// This is needed primarily because of how syntax highlighting
|
|
48
|
+
// generated DOM elements affect `innerText` output.
|
|
49
|
+
.replace(/\n{2,}/g, '\n')) || '';
|
|
39
50
|
}, [_innerText]);
|
|
40
51
|
var textToCopy = isVirtualized ? "".concat(children) : innerText; // Virtualized code blocks do not have inner text
|
|
41
52
|
|
|
@@ -51,7 +62,8 @@ var useCopy = function useCopy(_ref) {
|
|
|
51
62
|
onClick: copy,
|
|
52
63
|
iconType: "copyClipboard",
|
|
53
64
|
color: "text",
|
|
54
|
-
"aria-label": copyAriaLabel
|
|
65
|
+
"aria-label": copyAriaLabel,
|
|
66
|
+
"data-test-subj": "euiCodeBlockCopy"
|
|
55
67
|
});
|
|
56
68
|
})) : null;
|
|
57
69
|
}, [showCopyButton, textToCopy, copyAriaLabel]);
|
|
@@ -35,7 +35,7 @@ var euiCodeBlockLineStyles = function euiCodeBlockLineStyles(euiThemeContext) {
|
|
|
35
35
|
},
|
|
36
36
|
lineNumber: {
|
|
37
37
|
euiCodeBlock__lineNumberWrapper: /*#__PURE__*/(0, _css.css)("position:relative;flex-grow:0;flex-shrink:0;user-select:none;padding-inline-end:", euiTheme.size.m, ";box-sizing:content-box;;label:euiCodeBlock__lineNumberWrapper;"),
|
|
38
|
-
euiCodeBlock__lineNumber: /*#__PURE__*/(0, _css.css)("color:", euiTheme.colors.subduedText, ";text-align:end;display:block
|
|
38
|
+
euiCodeBlock__lineNumber: /*#__PURE__*/(0, _css.css)("color:", euiTheme.colors.subduedText, ";text-align:end;display:block;&::before{content:attr(data-line-number);};label:euiCodeBlock__lineNumber;")
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
};
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.parseLineRanges = exports.nodeToHtml = exports.isAstElement = exports.highlightByLine = exports.getHtmlContent = exports.checkSupportedLanguage = exports.SUPPORTED_LANGUAGES = exports.DEFAULT_LANGUAGE = void 0;
|
|
8
|
+
exports.parseLineRanges = exports.nodeToHtml = exports.isAstElement = exports.highlightByLine = exports.getHtmlContent = exports.checkSupportedLanguage = exports.SUPPORTED_LANGUAGES = exports.NEW_LINE_REGEX_GLOBAL = exports.NEW_LINE_REGEX = exports.DEFAULT_LANGUAGE = void 0;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _refractor = require("refractor");
|
|
@@ -20,7 +20,25 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
20
20
|
var SUPPORTED_LANGUAGES = (0, _refractor.listLanguages)();
|
|
21
21
|
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
22
22
|
var DEFAULT_LANGUAGE = 'text';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Platform-agnostic new line regex that safely matches all standard
|
|
26
|
+
* line termination conventions:
|
|
27
|
+
* - LF: Unix-based platforms and JS-native sources like text areas
|
|
28
|
+
* - CRLF: Windows
|
|
29
|
+
* - CR: Mac Classic; to support files saved a long time ago
|
|
30
|
+
*/
|
|
23
31
|
exports.DEFAULT_LANGUAGE = DEFAULT_LANGUAGE;
|
|
32
|
+
var NEW_LINE_REGEX = /\r\n|\r|\n/;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Platform-agnostic global new line regex that safely matches all standard
|
|
36
|
+
* line termination conventions.
|
|
37
|
+
* See [NEW_LINE_REGEX]{@link NEW_LINE_REGEX} for more details.
|
|
38
|
+
*/
|
|
39
|
+
exports.NEW_LINE_REGEX = NEW_LINE_REGEX;
|
|
40
|
+
var NEW_LINE_REGEX_GLOBAL = new RegExp(NEW_LINE_REGEX, 'g');
|
|
41
|
+
exports.NEW_LINE_REGEX_GLOBAL = NEW_LINE_REGEX_GLOBAL;
|
|
24
42
|
var checkSupportedLanguage = function checkSupportedLanguage(language) {
|
|
25
43
|
return SUPPORTED_LANGUAGES.includes(language) ? language : DEFAULT_LANGUAGE;
|
|
26
44
|
};
|
|
@@ -49,14 +67,12 @@ var nodeToHtml = function nodeToHtml(node, idx, nodes) {
|
|
|
49
67
|
}), children && children.map(function (el, i) {
|
|
50
68
|
return (
|
|
51
69
|
// @ts-ignore - using a custom type here to handle JSX annotations
|
|
52
|
-
el.type === 'annotation' ?
|
|
53
|
-
|
|
54
|
-
(0, _react2.jsx)(_code_block_annotations.EuiCodeBlockAnnotation, {
|
|
70
|
+
el.type === 'annotation' ? (0, _react2.jsx)(_code_block_annotations.EuiCodeBlockAnnotation, {
|
|
71
|
+
className: "euiCodeBlock__lineAnnotation",
|
|
55
72
|
lineNumber: el.lineNumber,
|
|
56
73
|
children: el.annotation,
|
|
57
74
|
key: i
|
|
58
|
-
})
|
|
59
|
-
: nodeToHtml(el, i, nodes, depth + 1)
|
|
75
|
+
}) : nodeToHtml(el, i, nodes, depth + 1)
|
|
60
76
|
);
|
|
61
77
|
}));
|
|
62
78
|
}
|
|
@@ -94,12 +110,12 @@ var addLineData = function addLineData(nodes, data) {
|
|
|
94
110
|
return nodes.reduce(function (result, node) {
|
|
95
111
|
var lineStart = data.lineNumber;
|
|
96
112
|
if (node.type === 'text') {
|
|
97
|
-
if (!node.value.match(
|
|
113
|
+
if (!node.value.match(NEW_LINE_REGEX)) {
|
|
98
114
|
node.lineStart = lineStart;
|
|
99
115
|
node.lineEnd = lineStart;
|
|
100
116
|
result.push(node);
|
|
101
117
|
} else {
|
|
102
|
-
var lines = node.value.split(
|
|
118
|
+
var lines = node.value.split(NEW_LINE_REGEX);
|
|
103
119
|
lines.forEach(function (line, i) {
|
|
104
120
|
var num = i === 0 ? data.lineNumber : ++data.lineNumber;
|
|
105
121
|
result.push({
|
|
@@ -173,11 +189,12 @@ function wrapLines(nodes, options, euiTheme) {
|
|
|
173
189
|
var lineNumberWrapperElement = {
|
|
174
190
|
type: 'element',
|
|
175
191
|
tagName: 'span',
|
|
176
|
-
properties:
|
|
192
|
+
properties: {
|
|
177
193
|
style: {
|
|
178
194
|
inlineSize: width
|
|
179
|
-
}
|
|
180
|
-
|
|
195
|
+
},
|
|
196
|
+
className: ['euiCodeBlock__lineNumberWrapper', lineNumberWrapperStyles]
|
|
197
|
+
},
|
|
181
198
|
children: []
|
|
182
199
|
};
|
|
183
200
|
|
|
@@ -186,13 +203,10 @@ function wrapLines(nodes, options, euiTheme) {
|
|
|
186
203
|
var lineNumberElement = {
|
|
187
204
|
type: 'element',
|
|
188
205
|
tagName: 'span',
|
|
189
|
-
properties: (
|
|
190
|
-
className: [lineNumberStyles]
|
|
191
|
-
}, 'aria-hidden', true),
|
|
192
|
-
children: [
|
|
193
|
-
type: 'text',
|
|
194
|
-
value: String(lineNumber)
|
|
195
|
-
}]
|
|
206
|
+
properties: (_properties = {
|
|
207
|
+
className: ['euiCodeBlock__lineNumber', lineNumberStyles]
|
|
208
|
+
}, (0, _defineProperty2.default)(_properties, 'data-line-number', lineNumber), (0, _defineProperty2.default)(_properties, 'aria-hidden', true), _properties),
|
|
209
|
+
children: []
|
|
196
210
|
};
|
|
197
211
|
lineNumberWrapperElement.children.push(lineNumberElement);
|
|
198
212
|
|
|
@@ -29,7 +29,7 @@ var _data_grid_cell_actions = require("./data_grid_cell_actions");
|
|
|
29
29
|
var _data_grid_cell_popover = require("./data_grid_cell_popover");
|
|
30
30
|
var _utils = require("../../../utils");
|
|
31
31
|
var _react2 = require("@emotion/react");
|
|
32
|
-
var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight"],
|
|
32
|
+
var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight", "isFocused"],
|
|
33
33
|
_excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
|
|
34
34
|
_excluded3 = ["isExpandable", "style", "className", "data-test-subj"];
|
|
35
35
|
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); }
|
|
@@ -48,6 +48,7 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
48
48
|
ariaRowIndex = _ref.ariaRowIndex,
|
|
49
49
|
rowHeightUtils = _ref.rowHeightUtils,
|
|
50
50
|
isDefinedHeight = _ref.isDefinedHeight,
|
|
51
|
+
isFocused = _ref.isFocused,
|
|
51
52
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
52
53
|
// React is more permissible than the TS types indicate
|
|
53
54
|
var CellElement = renderCellValue;
|
|
@@ -62,7 +63,9 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
62
63
|
rowIndex: rowIndex,
|
|
63
64
|
colIndex: colIndex,
|
|
64
65
|
schema: (column === null || column === void 0 ? void 0 : column.schema) || rest.columnType
|
|
65
|
-
}, rest))), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p",
|
|
66
|
+
}, rest))), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
|
|
67
|
+
hidden: !isFocused
|
|
68
|
+
}, '- ', (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
66
69
|
token: "euiDataGridCell.position",
|
|
67
70
|
default: "{columnId}, column {col}, row {row}",
|
|
68
71
|
values: {
|
|
@@ -528,6 +531,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
528
531
|
isExpandable: isExpandable,
|
|
529
532
|
isExpanded: popoverIsOpen,
|
|
530
533
|
isDetails: false,
|
|
534
|
+
isFocused: this.state.isFocused,
|
|
531
535
|
setCellContentsRef: this.setCellContentsRef,
|
|
532
536
|
rowHeightsOptions: rowHeightsOptions,
|
|
533
537
|
rowHeightUtils: rowHeightUtils,
|
package/package.json
CHANGED
|
@@ -227,22 +227,20 @@
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// Animate expanded row must be on the contents div inside
|
|
230
|
-
|
|
230
|
+
// This adds a quick pop in animation, but does not attempt to animate to height auto
|
|
231
|
+
// - down that road dragons lie. @see https://github.com/elastic/eui/issues/6770
|
|
231
232
|
.euiTableRow-isExpandedRow .euiTableCellContent {
|
|
232
|
-
|
|
233
|
-
animation: $euiAnimSpeedNormal $euiAnimSlightResistance 1 normal forwards growExpandedRow;
|
|
233
|
+
animation: $euiAnimSpeedFast $euiAnimSlightResistance 1 normal none growExpandedRow;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
@keyframes growExpandedRow {
|
|
237
237
|
0% {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
99% {
|
|
242
|
-
max-height: 100vh;
|
|
238
|
+
opacity: 0;
|
|
239
|
+
transform: translateY(-$euiSizeM);
|
|
243
240
|
}
|
|
244
241
|
|
|
245
242
|
100% {
|
|
246
|
-
|
|
243
|
+
opacity: 1;
|
|
244
|
+
transform: translateY(0);
|
|
247
245
|
}
|
|
248
246
|
}
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.EuiCodeBlockAnnotation = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
14
|
var _services = require("../../services");
|
|
@@ -17,19 +18,13 @@ var _icon = require("../icon");
|
|
|
17
18
|
var _button = require("../../themes/amsterdam/global_styling/mixins/button");
|
|
18
19
|
var _code_block_annotations = require("./code_block_annotations.style");
|
|
19
20
|
var _react2 = require("@emotion/react");
|
|
21
|
+
var _excluded = ["lineNumber", "children"];
|
|
20
22
|
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); }
|
|
21
23
|
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; }
|
|
22
|
-
/*
|
|
23
|
-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
24
|
-
* or more contributor license agreements. Licensed under the Elastic License
|
|
25
|
-
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
26
|
-
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
27
|
-
* Side Public License, v 1.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
24
|
var EuiCodeBlockAnnotation = function EuiCodeBlockAnnotation(_ref) {
|
|
31
25
|
var lineNumber = _ref.lineNumber,
|
|
32
|
-
children = _ref.children
|
|
26
|
+
children = _ref.children,
|
|
27
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
33
28
|
var _useState = (0, _react.useState)(false),
|
|
34
29
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
35
30
|
isOpen = _useState2[0],
|
|
@@ -44,7 +39,9 @@ var EuiCodeBlockAnnotation = function EuiCodeBlockAnnotation(_ref) {
|
|
|
44
39
|
var buttonIconFocusStyle = (0, _button.useEuiButtonFocusCSS)();
|
|
45
40
|
var cssButtonIconStyles = [styles.euiCodeBlockAnnotation__buttonIcon, buttonIconFocusStyle];
|
|
46
41
|
var isDarkMode = colorMode === 'DARK';
|
|
47
|
-
return (0, _react2.jsx)(_popover.EuiPopover, {
|
|
42
|
+
return (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({
|
|
43
|
+
css: styles.euiCodeBlockAnnotation
|
|
44
|
+
}, rest, {
|
|
48
45
|
isOpen: isOpen,
|
|
49
46
|
closePopover: function closePopover() {
|
|
50
47
|
return setIsOpen(false);
|
|
@@ -61,17 +58,20 @@ var EuiCodeBlockAnnotation = function EuiCodeBlockAnnotation(_ref) {
|
|
|
61
58
|
size: "s",
|
|
62
59
|
color: isDarkMode ? euiTheme.colors.ink : 'ghost'
|
|
63
60
|
})),
|
|
64
|
-
css: styles.euiCodeBlockAnnotation,
|
|
65
61
|
zIndex: Number(euiTheme.levels.mask) + 1 // Ensure fullscreen annotation popovers sit above the mask
|
|
66
62
|
,
|
|
67
63
|
anchorPosition: "downLeft",
|
|
68
64
|
panelProps: {
|
|
69
65
|
'data-test-subj': 'euiCodeBlockAnnotationPopover'
|
|
70
66
|
}
|
|
71
|
-
}, children);
|
|
67
|
+
}), children);
|
|
72
68
|
};
|
|
73
69
|
exports.EuiCodeBlockAnnotation = EuiCodeBlockAnnotation;
|
|
74
70
|
EuiCodeBlockAnnotation.propTypes = {
|
|
71
|
+
className: _propTypes.default.string,
|
|
72
|
+
"aria-label": _propTypes.default.string,
|
|
73
|
+
"data-test-subj": _propTypes.default.string,
|
|
74
|
+
css: _propTypes.default.any,
|
|
75
75
|
lineNumber: _propTypes.default.number.isRequired
|
|
76
76
|
};
|
|
77
77
|
var AnnotationInfoIcon = function AnnotationInfoIcon(props) {
|
|
@@ -12,6 +12,7 @@ var _inner_text = require("../inner_text");
|
|
|
12
12
|
var _copy = require("../copy");
|
|
13
13
|
var _i18n = require("../i18n");
|
|
14
14
|
var _button = require("../button");
|
|
15
|
+
var _utils = require("./utils");
|
|
15
16
|
var _react2 = require("@emotion/react");
|
|
16
17
|
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); }
|
|
17
18
|
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; }
|
|
@@ -35,7 +36,17 @@ var useCopy = function useCopy(_ref) {
|
|
|
35
36
|
innerTextRef = _useInnerText2[0],
|
|
36
37
|
_innerText = _useInnerText2[1];
|
|
37
38
|
var innerText = (0, _react.useMemo)(function () {
|
|
38
|
-
return (_innerText
|
|
39
|
+
return (_innerText
|
|
40
|
+
// Normalize line terminations to match native JS format
|
|
41
|
+
=== null || _innerText
|
|
42
|
+
// Normalize line terminations to match native JS format
|
|
43
|
+
=== void 0 ? void 0 : _innerText
|
|
44
|
+
// Normalize line terminations to match native JS format
|
|
45
|
+
.replace(_utils.NEW_LINE_REGEX_GLOBAL, '\n')
|
|
46
|
+
// Reduce two or more consecutive new line characters to a single one
|
|
47
|
+
// This is needed primarily because of how syntax highlighting
|
|
48
|
+
// generated DOM elements affect `innerText` output.
|
|
49
|
+
.replace(/\n{2,}/g, '\n')) || '';
|
|
39
50
|
}, [_innerText]);
|
|
40
51
|
var textToCopy = isVirtualized ? "".concat(children) : innerText; // Virtualized code blocks do not have inner text
|
|
41
52
|
|
|
@@ -51,7 +62,8 @@ var useCopy = function useCopy(_ref) {
|
|
|
51
62
|
onClick: copy,
|
|
52
63
|
iconType: "copyClipboard",
|
|
53
64
|
color: "text",
|
|
54
|
-
"aria-label": copyAriaLabel
|
|
65
|
+
"aria-label": copyAriaLabel,
|
|
66
|
+
"data-test-subj": "euiCodeBlockCopy"
|
|
55
67
|
});
|
|
56
68
|
})) : null;
|
|
57
69
|
}, [showCopyButton, textToCopy, copyAriaLabel]);
|
|
@@ -35,7 +35,7 @@ var euiCodeBlockLineStyles = function euiCodeBlockLineStyles(euiThemeContext) {
|
|
|
35
35
|
},
|
|
36
36
|
lineNumber: {
|
|
37
37
|
euiCodeBlock__lineNumberWrapper: /*#__PURE__*/(0, _css.css)("position:relative;flex-grow:0;flex-shrink:0;user-select:none;padding-inline-end:", euiTheme.size.m, ";box-sizing:content-box;;label:euiCodeBlock__lineNumberWrapper;"),
|
|
38
|
-
euiCodeBlock__lineNumber: /*#__PURE__*/(0, _css.css)("color:", euiTheme.colors.subduedText, ";text-align:end;display:block
|
|
38
|
+
euiCodeBlock__lineNumber: /*#__PURE__*/(0, _css.css)("color:", euiTheme.colors.subduedText, ";text-align:end;display:block;&::before{content:attr(data-line-number);};label:euiCodeBlock__lineNumber;")
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
};
|