@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.
Files changed (33) hide show
  1. package/dist/eui_theme_dark.css +14 -13
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +14 -13
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/code/code_block_annotations.js +13 -4
  6. package/es/components/code/code_block_copy.js +14 -2
  7. package/es/components/code/code_block_line.styles.js +1 -1
  8. package/es/components/code/utils.js +29 -17
  9. package/es/components/datagrid/body/data_grid_cell.js +7 -2
  10. package/eui.d.ts +19 -3
  11. package/i18ntokens.json +12 -12
  12. package/lib/components/code/code_block_annotations.js +13 -4
  13. package/lib/components/code/code_block_copy.js +14 -2
  14. package/lib/components/code/code_block_line.styles.js +1 -1
  15. package/lib/components/code/utils.js +32 -18
  16. package/lib/components/datagrid/body/data_grid_cell.js +7 -2
  17. package/optimize/es/components/code/code_block_annotations.js +8 -4
  18. package/optimize/es/components/code/code_block_copy.js +14 -2
  19. package/optimize/es/components/code/code_block_line.styles.js +1 -1
  20. package/optimize/es/components/code/utils.js +29 -17
  21. package/optimize/es/components/datagrid/body/data_grid_cell.js +6 -2
  22. package/optimize/lib/components/code/code_block_annotations.js +8 -12
  23. package/optimize/lib/components/code/code_block_copy.js +14 -2
  24. package/optimize/lib/components/code/code_block_line.styles.js +1 -1
  25. package/optimize/lib/components/code/utils.js +32 -18
  26. package/optimize/lib/components/datagrid/body/data_grid_cell.js +6 -2
  27. package/package.json +1 -1
  28. package/src/components/table/_table.scss +7 -9
  29. package/test-env/components/code/code_block_annotations.js +12 -12
  30. package/test-env/components/code/code_block_copy.js +14 -2
  31. package/test-env/components/code/code_block_line.styles.js +1 -1
  32. package/test-env/components/code/utils.js +32 -18
  33. package/test-env/components/datagrid/body/data_grid_cell.js +7 -2
@@ -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
- // @ts-ignore - custom keys are passed by annotationElement below
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
- }) // prettier-ignore
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(/\r\n?|\n/)) {
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(/\r\n?|\n/);
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: (_properties = {
192
+ properties: {
177
193
  style: {
178
194
  inlineSize: width
179
- }
180
- }, (0, _defineProperty2.default)(_properties, 'data-line-number', lineNumber), (0, _defineProperty2.default)(_properties, "className", ['euiCodeBlock__lineNumber', lineNumberWrapperStyles]), _properties),
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: (0, _defineProperty2.default)({
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
 
@@ -30,7 +30,7 @@ var _data_grid_cell_actions = require("./data_grid_cell_actions");
30
30
  var _data_grid_cell_popover = require("./data_grid_cell_popover");
31
31
  var _utils = require("../../../utils");
32
32
  var _react2 = require("@emotion/react");
33
- var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight"],
33
+ var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight", "isFocused"],
34
34
  _excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
35
35
  _excluded3 = ["isExpandable", "style", "className", "data-test-subj"];
36
36
  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); }
@@ -49,6 +49,7 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
49
49
  ariaRowIndex = _ref.ariaRowIndex,
50
50
  rowHeightUtils = _ref.rowHeightUtils,
51
51
  isDefinedHeight = _ref.isDefinedHeight,
52
+ isFocused = _ref.isFocused,
52
53
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
53
54
  // React is more permissible than the TS types indicate
54
55
  var CellElement = renderCellValue;
@@ -63,7 +64,9 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
63
64
  rowIndex: rowIndex,
64
65
  colIndex: colIndex,
65
66
  schema: (column === null || column === void 0 ? void 0 : column.schema) || rest.columnType
66
- }, rest))), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", null, '- ', (0, _react2.jsx)(_i18n.EuiI18n, {
67
+ }, rest))), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
68
+ hidden: !isFocused
69
+ }, '- ', (0, _react2.jsx)(_i18n.EuiI18n, {
67
70
  token: "euiDataGridCell.position",
68
71
  default: "{columnId}, column {col}, row {row}",
69
72
  values: {
@@ -552,6 +555,7 @@ EuiDataGridCellContent.propTypes = {
552
555
  setCellContentsRef: _propTypes.default.any.isRequired,
553
556
  isExpanded: _propTypes.default.bool.isRequired,
554
557
  isDefinedHeight: _propTypes.default.bool.isRequired,
558
+ isFocused: _propTypes.default.bool.isRequired,
555
559
  ariaRowIndex: _propTypes.default.number.isRequired
556
560
  };
557
561
  var EuiDataGridCell = /*#__PURE__*/function (_Component) {
@@ -1010,6 +1014,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
1010
1014
  isExpandable: isExpandable,
1011
1015
  isExpanded: popoverIsOpen,
1012
1016
  isDetails: false,
1017
+ isFocused: this.state.isFocused,
1013
1018
  setCellContentsRef: this.setCellContentsRef,
1014
1019
  rowHeightsOptions: rowHeightsOptions,
1015
1020
  rowHeightUtils: rowHeightUtils,