@elastic/eui 113.2.1 → 114.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/es/components/basic_table/collapsed_item_actions.js +2 -0
  2. package/es/components/button/split_button/split_button.js +13 -0
  3. package/es/components/button/split_button/split_button_actions.js +15 -0
  4. package/es/components/collapsible_nav/collapsible_nav.js +5 -0
  5. package/es/components/color_picker/color_picker.js +31 -8
  6. package/es/components/context_menu/context_menu_item.js +9 -3
  7. package/es/components/context_menu/context_menu_item.styles.js +6 -2
  8. package/es/components/datagrid/utils/scrolling.js +39 -10
  9. package/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  10. package/es/components/flyout/_flyout_overlay.js +34 -4
  11. package/es/components/flyout/const.js +10 -0
  12. package/es/components/flyout/flyout.component.js +49 -57
  13. package/es/components/flyout/flyout.js +10 -2
  14. package/es/components/flyout/flyout.styles.js +2 -2
  15. package/es/components/flyout/flyout_menu.js +19 -5
  16. package/es/components/flyout/flyout_resizable.js +5 -0
  17. package/es/components/flyout/manager/actions.js +12 -5
  18. package/es/components/flyout/manager/flyout_child.js +9 -2
  19. package/es/components/flyout/manager/flyout_managed.js +27 -14
  20. package/es/components/flyout/manager/reducer.js +251 -54
  21. package/es/components/flyout/manager/store.js +74 -12
  22. package/es/components/flyout/use_flyout_menu.js +70 -0
  23. package/es/components/form/file_picker/file_picker.js +46 -18
  24. package/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  25. package/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
  26. package/es/components/overlay_mask/overlay_mask.js +10 -3
  27. package/es/components/tree_view/tree_view_item.styles.js +1 -1
  28. package/es/services/hooks/index.js +8 -8
  29. package/es/services/hooks/useIsPointerDown.js +6 -15
  30. package/es/services/index.js +1 -1
  31. package/eui.d.ts +477 -63
  32. package/i18ntokens.json +661 -643
  33. package/lib/components/basic_table/collapsed_item_actions.js +2 -0
  34. package/lib/components/button/split_button/split_button.js +13 -0
  35. package/lib/components/button/split_button/split_button_actions.js +15 -0
  36. package/lib/components/collapsible_nav/collapsible_nav.js +5 -0
  37. package/lib/components/color_picker/color_picker.js +30 -7
  38. package/lib/components/context_menu/context_menu_item.js +9 -3
  39. package/lib/components/context_menu/context_menu_item.styles.js +5 -1
  40. package/lib/components/datagrid/utils/scrolling.js +37 -8
  41. package/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  42. package/lib/components/flyout/_flyout_overlay.js +33 -3
  43. package/lib/components/flyout/const.js +11 -1
  44. package/lib/components/flyout/flyout.component.js +48 -56
  45. package/lib/components/flyout/flyout.js +15 -1
  46. package/lib/components/flyout/flyout.styles.js +2 -2
  47. package/lib/components/flyout/flyout_menu.js +19 -5
  48. package/lib/components/flyout/flyout_resizable.js +5 -0
  49. package/lib/components/flyout/manager/actions.js +12 -5
  50. package/lib/components/flyout/manager/flyout_child.js +9 -2
  51. package/lib/components/flyout/manager/flyout_managed.js +19 -12
  52. package/lib/components/flyout/manager/reducer.js +250 -53
  53. package/lib/components/flyout/manager/store.js +74 -14
  54. package/lib/components/flyout/use_flyout_menu.js +75 -0
  55. package/lib/components/form/file_picker/file_picker.js +46 -18
  56. package/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  57. package/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
  58. package/lib/components/overlay_mask/overlay_mask.js +10 -3
  59. package/lib/components/tree_view/tree_view_item.styles.js +1 -1
  60. package/lib/services/hooks/index.js +60 -91
  61. package/lib/services/hooks/useIsPointerDown.js +7 -14
  62. package/lib/services/index.js +70 -11
  63. package/optimize/es/components/basic_table/collapsed_item_actions.js +2 -0
  64. package/optimize/es/components/color_picker/color_picker.js +31 -8
  65. package/optimize/es/components/context_menu/context_menu_item.js +3 -2
  66. package/optimize/es/components/context_menu/context_menu_item.styles.js +6 -2
  67. package/optimize/es/components/datagrid/utils/scrolling.js +39 -10
  68. package/optimize/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  69. package/optimize/es/components/flyout/_flyout_overlay.js +34 -4
  70. package/optimize/es/components/flyout/const.js +10 -0
  71. package/optimize/es/components/flyout/flyout.component.js +49 -57
  72. package/optimize/es/components/flyout/flyout.js +5 -2
  73. package/optimize/es/components/flyout/flyout.styles.js +2 -2
  74. package/optimize/es/components/flyout/flyout_menu.js +7 -3
  75. package/optimize/es/components/flyout/manager/actions.js +12 -5
  76. package/optimize/es/components/flyout/manager/flyout_managed.js +18 -12
  77. package/optimize/es/components/flyout/manager/reducer.js +251 -54
  78. package/optimize/es/components/flyout/manager/store.js +69 -12
  79. package/optimize/es/components/flyout/use_flyout_menu.js +69 -0
  80. package/optimize/es/components/form/file_picker/file_picker.js +35 -18
  81. package/optimize/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  82. package/optimize/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
  83. package/optimize/es/components/overlay_mask/overlay_mask.js +4 -2
  84. package/optimize/es/components/tree_view/tree_view_item.styles.js +1 -1
  85. package/optimize/es/services/hooks/index.js +8 -8
  86. package/optimize/es/services/hooks/useIsPointerDown.js +6 -10
  87. package/optimize/es/services/index.js +1 -1
  88. package/optimize/lib/components/basic_table/collapsed_item_actions.js +2 -0
  89. package/optimize/lib/components/color_picker/color_picker.js +30 -7
  90. package/optimize/lib/components/context_menu/context_menu_item.js +3 -2
  91. package/optimize/lib/components/context_menu/context_menu_item.styles.js +5 -1
  92. package/optimize/lib/components/datagrid/utils/scrolling.js +37 -8
  93. package/optimize/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  94. package/optimize/lib/components/flyout/_flyout_overlay.js +33 -3
  95. package/optimize/lib/components/flyout/const.js +11 -1
  96. package/optimize/lib/components/flyout/flyout.component.js +48 -56
  97. package/optimize/lib/components/flyout/flyout.js +10 -1
  98. package/optimize/lib/components/flyout/flyout.styles.js +2 -2
  99. package/optimize/lib/components/flyout/flyout_menu.js +7 -3
  100. package/optimize/lib/components/flyout/manager/actions.js +12 -5
  101. package/optimize/lib/components/flyout/manager/flyout_managed.js +18 -12
  102. package/optimize/lib/components/flyout/manager/reducer.js +250 -53
  103. package/optimize/lib/components/flyout/manager/store.js +70 -12
  104. package/optimize/lib/components/flyout/use_flyout_menu.js +74 -0
  105. package/optimize/lib/components/form/file_picker/file_picker.js +35 -18
  106. package/optimize/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  107. package/optimize/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
  108. package/optimize/lib/components/overlay_mask/overlay_mask.js +4 -2
  109. package/optimize/lib/components/tree_view/tree_view_item.styles.js +1 -1
  110. package/optimize/lib/services/hooks/index.js +60 -91
  111. package/optimize/lib/services/hooks/useIsPointerDown.js +5 -10
  112. package/optimize/lib/services/index.js +70 -11
  113. package/package.json +4 -4
  114. package/test-env/components/basic_table/collapsed_item_actions.js +2 -0
  115. package/test-env/components/button/split_button/split_button.js +13 -0
  116. package/test-env/components/button/split_button/split_button_actions.js +15 -0
  117. package/test-env/components/collapsible_nav/collapsible_nav.js +5 -0
  118. package/test-env/components/color_picker/color_picker.js +30 -7
  119. package/test-env/components/context_menu/context_menu_item.js +9 -3
  120. package/test-env/components/context_menu/context_menu_item.styles.js +5 -1
  121. package/test-env/components/datagrid/utils/scrolling.js +37 -8
  122. package/test-env/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  123. package/test-env/components/flyout/_flyout_overlay.js +33 -3
  124. package/test-env/components/flyout/const.js +11 -1
  125. package/test-env/components/flyout/flyout.component.js +48 -56
  126. package/test-env/components/flyout/flyout.styles.js +2 -2
  127. package/test-env/components/flyout/flyout_menu.js +19 -5
  128. package/test-env/components/flyout/flyout_resizable.js +5 -0
  129. package/test-env/components/flyout/manager/actions.js +12 -5
  130. package/test-env/components/flyout/manager/flyout_child.js +9 -2
  131. package/test-env/components/flyout/manager/flyout_managed.js +19 -12
  132. package/test-env/components/flyout/manager/reducer.js +250 -53
  133. package/test-env/components/flyout/manager/store.js +70 -12
  134. package/test-env/components/flyout/use_flyout_menu.js +74 -0
  135. package/test-env/components/form/file_picker/file_picker.js +46 -18
  136. package/test-env/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  137. package/test-env/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
  138. package/test-env/components/overlay_mask/overlay_mask.js +10 -3
  139. package/test-env/components/tree_view/tree_view_item.styles.js +1 -1
  140. package/test-env/services/hooks/index.js +60 -91
  141. package/test-env/services/hooks/useIsPointerDown.js +5 -10
  142. package/test-env/services/index.js +70 -11
@@ -7,7 +7,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _inherits from "@babel/runtime/helpers/inherits";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
- var _excluded = ["stylesMemoizer", "id", "name", "initialPromptText", "className", "disabled", "compressed", "onChange", "isInvalid", "fullWidth", "isLoading", "display"];
10
+ var _excluded = ["stylesMemoizer", "id", "name", "initialPromptText", "className", "disabled", "compressed", "onChange", "isInvalid", "fullWidth", "isLoading", "display", "files"];
11
11
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  /*
@@ -39,36 +39,41 @@ export var EuiFilePickerClass = /*#__PURE__*/function (_Component) {
39
39
  args[_key] = arguments[_key];
40
40
  }
41
41
  _this = _callSuper(this, EuiFilePickerClass, [].concat(args));
42
+ _defineProperty(_this, "fileInput", null);
43
+ _defineProperty(_this, "generatedId", htmlIdGenerator()());
44
+ _defineProperty(_this, "getPromptTextFromFileList", function (files) {
45
+ if (!files || files.length === 0) {
46
+ return null;
47
+ }
48
+ if (files.length > 1) {
49
+ return ___EmotionJSX(EuiI18n, {
50
+ token: "euiFilePicker.filesSelected",
51
+ default: "{fileCount} files selected",
52
+ values: {
53
+ fileCount: files.length
54
+ }
55
+ });
56
+ }
57
+ return files[0].name;
58
+ });
42
59
  _defineProperty(_this, "state", {
43
- promptText: null,
60
+ promptText: _this.props.files ? _this.getPromptTextFromFileList(_this.props.files) : null,
44
61
  isHoveringDrop: false
45
62
  });
46
- _defineProperty(_this, "fileInput", null);
47
- _defineProperty(_this, "generatedId", htmlIdGenerator()());
48
63
  _defineProperty(_this, "handleChange", function () {
49
64
  if (!_this.fileInput) return;
50
- if (_this.fileInput.files && _this.fileInput.files.length > 1) {
51
- _this.setState({
52
- promptText: ___EmotionJSX(EuiI18n, {
53
- token: "euiFilePicker.filesSelected",
54
- default: "{fileCount} files selected",
55
- values: {
56
- fileCount: _this.fileInput.files.length
57
- }
58
- })
59
- });
60
- } else if (_this.fileInput.files && _this.fileInput.files.length === 0) {
65
+ if (_this.fileInput.files && _this.fileInput.files.length === 1) {
61
66
  _this.setState({
62
- promptText: null
67
+ promptText: _this.fileInput.value.split('\\').pop()
63
68
  });
64
69
  } else {
65
70
  _this.setState({
66
- promptText: _this.fileInput.value.split('\\').pop()
71
+ promptText: _this.getPromptTextFromFileList(_this.fileInput.files ? Array.from(_this.fileInput.files) : null)
67
72
  });
68
73
  }
69
74
  var onChange = _this.props.onChange;
70
75
  if (onChange) {
71
- onChange(_this.fileInput.files);
76
+ onChange(_this.fileInput.files && _this.fileInput.files.length > 0 ? _this.fileInput.files : null);
72
77
  }
73
78
  });
74
79
  _defineProperty(_this, "removeFiles", function (e) {
@@ -96,6 +101,17 @@ export var EuiFilePickerClass = /*#__PURE__*/function (_Component) {
96
101
  }
97
102
  _inherits(EuiFilePickerClass, _Component);
98
103
  return _createClass(EuiFilePickerClass, [{
104
+ key: "componentDidUpdate",
105
+ value: function componentDidUpdate(prevProps) {
106
+ // Update prompt text when files prop changes
107
+ if (this.props.files !== prevProps.files) {
108
+ var _this$props$files;
109
+ this.setState({
110
+ promptText: this.getPromptTextFromFileList((_this$props$files = this.props.files) !== null && _this$props$files !== void 0 ? _this$props$files : null)
111
+ });
112
+ }
113
+ }
114
+ }, {
99
115
  key: "render",
100
116
  value: function render() {
101
117
  var _this2 = this;
@@ -119,6 +135,7 @@ export var EuiFilePickerClass = /*#__PURE__*/function (_Component) {
119
135
  fullWidth = _this2$props$fullWidt === void 0 ? defaultFullWidth : _this2$props$fullWidt,
120
136
  isLoading = _this2$props.isLoading,
121
137
  display = _this2$props.display,
138
+ files = _this2$props.files,
122
139
  rest = _objectWithoutProperties(_this2$props, _excluded);
123
140
  var promptId = "".concat(id || _this2.generatedId, "-filePicker__prompt");
124
141
  var isOverridingInitialPrompt = _this2.state.promptText != null;
@@ -18,6 +18,7 @@ import markdown from 'remark-parse-no-trim';
18
18
  import emoji from 'remark-emoji';
19
19
  import breaks from 'remark-breaks';
20
20
  import highlight from '../remark/remark_prismjs';
21
+ import intrawordUnderscore from '../remark/remark_intraword_underscore';
21
22
  import * as MarkdownTooltip from '../markdown_tooltip';
22
23
  import * as MarkdownCheckbox from '../markdown_checkbox';
23
24
  import { euiMarkdownLinkValidator, DEFAULT_OPTIONS as LINK_VALIDATOR_DEFAULTS } from '../markdown_link_validator';
@@ -34,7 +35,7 @@ export var getDefaultEuiMarkdownParsingPlugins = function getDefaultEuiMarkdownP
34
35
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
36
  var exclude = _ref.exclude,
36
37
  parsingConfig = _objectWithoutProperties(_ref, _excluded);
37
- var parsingPlugins = [[markdown, {}], [highlight, {}]];
38
+ var parsingPlugins = [[markdown, {}], [highlight, {}], [intrawordUnderscore, {}]];
38
39
  Object.entries(DEFAULT_PARSING_PLUGINS).forEach(function (_ref2) {
39
40
  var _ref3 = _slicedToArray(_ref2, 2),
40
41
  pluginName = _ref3[0],
@@ -0,0 +1,172 @@
1
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
+ /*
5
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
+ * or more contributor license agreements. Licensed under the Elastic License
7
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
8
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
9
+ * Side Public License, v 1.
10
+ */
11
+
12
+ // Temporary workaround for https://github.com/elastic/eui/issues/9404
13
+ // remark-parse v8 doesn't implement the CommonMark rule that underscore
14
+ // emphasis delimiters flanked by alphanumerics on both sides (intraword)
15
+ // cannot open or close emphasis. This causes identifiers like
16
+ // `ABCD__PineappleCherry__e` to render with bold formatting.
17
+ // This plugin walks the parsed AST and reverses incorrectly applied
18
+ // emphasis/strong nodes when both sides are alphanumeric characters.
19
+
20
+ // eslint-disable-next-line import/no-unresolved
21
+
22
+ var isTextNode = function isTextNode(node) {
23
+ return node.type === 'text';
24
+ };
25
+ var isEmphasisOrStrong = function isEmphasisOrStrong(node) {
26
+ return node.type === 'emphasis' || node.type === 'strong';
27
+ };
28
+ var isAlphanumeric = function isAlphanumeric(ch) {
29
+ return /[a-zA-Z0-9]/.test(ch);
30
+ };
31
+
32
+ /**
33
+ * Recursively converts an emphasis/strong node back into plain text
34
+ * with underscore delimiters restored.
35
+ */
36
+ function flattenToText(node) {
37
+ var delimiter = node.type === 'emphasis' ? '_' : '__';
38
+ var inner = '';
39
+ var _iterator = _createForOfIteratorHelper(node.children),
40
+ _step;
41
+ try {
42
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
43
+ var child = _step.value;
44
+ if (isTextNode(child)) {
45
+ inner += child.value;
46
+ } else if (isEmphasisOrStrong(child)) {
47
+ inner += flattenToText(child);
48
+ } else {
49
+ // Contains non-text children (links, images, etc.) — leave emphasis intact
50
+ return delimiter + collectText(node) + delimiter;
51
+ }
52
+ }
53
+ } catch (err) {
54
+ _iterator.e(err);
55
+ } finally {
56
+ _iterator.f();
57
+ }
58
+ return delimiter + inner + delimiter;
59
+ }
60
+ function collectText(node) {
61
+ if (isTextNode(node)) return node.value;
62
+ if ('children' in node) {
63
+ return node.children.map(collectText).join('');
64
+ }
65
+ return '';
66
+ }
67
+ function processParent(parent, source) {
68
+ var modified = false;
69
+ var i = 0;
70
+ while (i < parent.children.length) {
71
+ var child = parent.children[i];
72
+ if (isEmphasisOrStrong(child) && isIntraword(parent, i, source)) {
73
+ var textValue = flattenToText(child);
74
+ var replacement = {
75
+ type: 'text',
76
+ value: textValue
77
+ };
78
+ parent.children.splice(i, 1, replacement);
79
+ modified = true;
80
+ // Don't advance — the replaced node may need to merge with neighbors
81
+ } else {
82
+ if ('children' in child) {
83
+ processParent(child, source);
84
+ }
85
+ i++;
86
+ }
87
+ if (modified) {
88
+ mergeAdjacentText(parent);
89
+ modified = false;
90
+ // After merging, restart scan since indices shifted
91
+ i = 0;
92
+ }
93
+ }
94
+ }
95
+ function getInnerText(node) {
96
+ if (isTextNode(node)) return node.value;
97
+ if ('children' in node) {
98
+ var children = node.children;
99
+ if (children.length > 0) return getInnerText(children[0]);
100
+ }
101
+ return '';
102
+ }
103
+ function getInnerTextEnd(node) {
104
+ if (isTextNode(node)) return node.value;
105
+ if ('children' in node) {
106
+ var children = node.children;
107
+ if (children.length > 0) return getInnerTextEnd(children[children.length - 1]);
108
+ }
109
+ return '';
110
+ }
111
+
112
+ /**
113
+ * Checks whether the emphasis/strong node at `index` within `parent`
114
+ * is an intraword usage of underscore delimiters.
115
+ *
116
+ * A node is intraword when at least one side has an alphanumeric text
117
+ * neighbor AND the inner content on the corresponding delimiter side
118
+ * also touches word characters — proving the underscores are embedded
119
+ * in a word rather than used as formatting.
120
+ */
121
+ function isIntraword(parent, index, source) {
122
+ var _node$position;
123
+ var node = parent.children[index];
124
+
125
+ // Verify the delimiter is `_` (not `*`) by inspecting the source
126
+ if (((_node$position = node.position) === null || _node$position === void 0 || (_node$position = _node$position.start) === null || _node$position === void 0 ? void 0 : _node$position.offset) != null) {
127
+ var ch = source[node.position.start.offset];
128
+ if (ch !== '_') return false;
129
+ }
130
+ var prev = index > 0 ? parent.children[index - 1] : null;
131
+ var next = index < parent.children.length - 1 ? parent.children[index + 1] : null;
132
+ var prevChar = prev != null && isTextNode(prev) && prev.value.length > 0 ? prev.value[prev.value.length - 1] : null;
133
+ var nextChar = next != null && isTextNode(next) && next.value.length > 0 ? next.value[0] : null;
134
+ var prevIsAlpha = prevChar != null && isAlphanumeric(prevChar);
135
+ var nextIsAlpha = nextChar != null && isAlphanumeric(nextChar);
136
+
137
+ // Both sides flanked by alphanumeric — classic intraword (e.g. `foo__bar__baz`)
138
+ if (prevIsAlpha && nextIsAlpha) return true;
139
+
140
+ // One-sided: prev is alpha or underscore, no alpha next — check inner text
141
+ // starts with alpha (e.g. `Lorem__ipsum__` or `Lorem__ipsum_`)
142
+ if (prevIsAlpha || prevChar === '_') {
143
+ var inner = getInnerText(node);
144
+ if (inner.length > 0 && isAlphanumeric(inner[0])) return true;
145
+ }
146
+
147
+ // One-sided: next is alpha or underscore, no alpha prev — check inner text
148
+ // ends with alpha (e.g. `__Lorem__ipsum` or `_Lorem__ipsum`)
149
+ if (nextIsAlpha || nextChar === '_') {
150
+ var _inner = getInnerTextEnd(node);
151
+ if (_inner.length > 0 && isAlphanumeric(_inner[_inner.length - 1])) return true;
152
+ }
153
+ return false;
154
+ }
155
+ function mergeAdjacentText(parent) {
156
+ var i = 0;
157
+ while (i < parent.children.length - 1) {
158
+ if (isTextNode(parent.children[i]) && isTextNode(parent.children[i + 1])) {
159
+ parent.children[i].value += parent.children[i + 1].value;
160
+ parent.children.splice(i + 1, 1);
161
+ } else {
162
+ i++;
163
+ }
164
+ }
165
+ }
166
+ var attacher = function remarkIntrawordUnderscore() {
167
+ return function (tree, file) {
168
+ var source = String(file);
169
+ processParent(tree, source);
170
+ };
171
+ };
172
+ export default attacher;
@@ -1,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["className", "children", "headerZindexLocation", "maskRef"];
4
+ var _excluded = ["className", "children", "headerZindexLocation", "maskRef", "hasAnimation"];
5
5
  /*
6
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
7
  * or more contributor license agreements. Licensed under the Elastic License
@@ -25,6 +25,8 @@ export var EuiOverlayMask = function EuiOverlayMask(_ref) {
25
25
  _ref$headerZindexLoca = _ref.headerZindexLocation,
26
26
  headerZindexLocation = _ref$headerZindexLoca === void 0 ? 'above' : _ref$headerZindexLoca,
27
27
  maskRef = _ref.maskRef,
28
+ _ref$hasAnimation = _ref.hasAnimation,
29
+ hasAnimation = _ref$hasAnimation === void 0 ? true : _ref$hasAnimation,
28
30
  rest = _objectWithoutProperties(_ref, _excluded);
29
31
  var hasRendered = useRef(false);
30
32
  var _useState = useState(null),
@@ -36,7 +38,7 @@ export var EuiOverlayMask = function EuiOverlayMask(_ref) {
36
38
  hasRendered.current = true;
37
39
  }, []);
38
40
  var styles = useEuiMemoizedStyles(euiOverlayMaskStyles);
39
- var cssStyles = cx([styles.euiOverlayMask, styles["".concat(headerZindexLocation, "Header")], hasRendered.current && styles.noAnimation]);
41
+ var cssStyles = cx([styles.euiOverlayMask, styles["".concat(headerZindexLocation, "Header")], (hasRendered.current || !hasAnimation) && styles.noAnimation]);
40
42
  useEffect(function () {
41
43
  if (!overlayMaskNode) return;
42
44
  keysOf(rest).forEach(function (key) {
@@ -26,7 +26,7 @@ export var euiTreeViewItemStyles = function euiTreeViewItemStyles(euiThemeContex
26
26
  euiTreeView__node: _ref,
27
27
  default: /*#__PURE__*/css(logicalCSS('max-height', defaultSize), " line-height:", defaultSize, ";;label:default;"),
28
28
  compressed: /*#__PURE__*/css(logicalCSS('max-height', compressedSize), " line-height:", compressedSize, ";;label:compressed;"),
29
- expanded: /*#__PURE__*/css(logicalCSS('max-height', '100vh'), ";;label:expanded;")
29
+ expanded: /*#__PURE__*/css(logicalCSS('max-height', 'none'), ";;label:expanded;")
30
30
  },
31
31
  button: {
32
32
  euiTreeView__nodeInner: /*#__PURE__*/css(logicalCSS('width', '100%'), " ", logicalCSS('padding-left', euiTheme.size.s), " ", logicalCSS('padding-right', euiTheme.size.xxs), " display:flex;align-items:center;&:focus{", euiFocusRing(euiThemeContext, 'inset'), ";}&:hover,&:active,&:focus{background-color:", euiTheme.components.treeViewItemBackgroundHover, ";};label:euiTreeView__nodeInner;"),
@@ -6,12 +6,12 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
 
9
- export * from './useDependentState';
10
- export * from './useCombinedRefs';
11
- export * from './useForceRender';
12
- export * from './useLatest';
13
- export * from './useDeepEqual';
14
- export * from './useMouseMove';
15
- export * from './useIsPointerDown';
16
- export * from './useUpdateEffect';
9
+ export { useDependentState } from './useDependentState';
10
+ export { useCombinedRefs, setMultipleRefs } from './useCombinedRefs';
11
+ export { useForceRender } from './useForceRender';
12
+ export { useLatest } from './useLatest';
13
+ export { useDeepEqual } from './useDeepEqual';
14
+ export { isMouseEvent, useMouseMove } from './useMouseMove';
15
+ export { useIsPointerDown } from './useIsPointerDown';
16
+ export { useUpdateEffect } from './useUpdateEffect';
17
17
  export { useEuiDisabledElement } from './useEuiDisabledElement';
@@ -1,4 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  /*
3
2
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
3
  * or more contributor license agreements. Licensed under the Elastic License
@@ -7,30 +6,27 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
7
6
  * Side Public License, v 1.
8
7
  */
9
8
 
10
- import { useState, useEffect } from 'react';
9
+ import { useRef, useEffect } from 'react';
11
10
 
12
11
  /**
13
12
  * A hook that tracks whether the pointer is currently down/pressed.
14
13
  * Useful for detecting text selection in progress.
15
14
  */
16
15
  export function useIsPointerDown(container) {
17
- var _useState = useState(false),
18
- _useState2 = _slicedToArray(_useState, 2),
19
- isPointerDown = _useState2[0],
20
- setIsPointerDown = _useState2[1];
16
+ var isPointerDownRef = useRef(false);
21
17
  useEffect(function () {
22
18
  var handlePointerDown = function handlePointerDown(event) {
23
19
  if (container !== null && container !== void 0 && container.current && !container.current.contains(event.target)) {
24
20
  return;
25
21
  }
26
- setIsPointerDown(true);
22
+ isPointerDownRef.current = true;
27
23
  };
28
24
  var handlePointerUpOrCancel = function handlePointerUpOrCancel() {
29
- setIsPointerDown(false);
25
+ isPointerDownRef.current = false;
30
26
  };
31
27
  var handleVisibilityChange = function handleVisibilityChange() {
32
28
  if (document.visibilityState === 'hidden') {
33
- setIsPointerDown(false);
29
+ isPointerDownRef.current = false;
34
30
  }
35
31
  };
36
32
  var controller = new AbortController();
@@ -48,5 +44,5 @@ export function useIsPointerDown(container) {
48
44
  controller.abort();
49
45
  };
50
46
  }, [container]);
51
- return isPointerDown;
47
+ return isPointerDownRef;
52
48
  }
@@ -22,7 +22,7 @@ export * from './emotion';
22
22
  export * from './findElement';
23
23
  export { focusTrapPubSub } from './focus_trap';
24
24
  export { dateFormatAliases, formatAuto, formatBoolean, formatDate, formatNumber, formatText } from './format';
25
- export * from './hooks';
25
+ export { useDependentState, useCombinedRefs, setMultipleRefs, useForceRender, useLatest, useDeepEqual, isMouseEvent, useMouseMove, useUpdateEffect, useEuiDisabledElement } from './hooks';
26
26
  export { isEvenlyDivisibleBy, isWithinRange } from './number';
27
27
  export { Pager } from './paging';
28
28
  export { calculatePopoverPosition, findPopoverPosition } from './popover';
@@ -69,6 +69,7 @@ var CollapsedItemActions = exports.CollapsedItemActions = function CollapsedItem
69
69
  var toolTipContent = (0, _action_types.callWithItemIfFunction)(item)(action.description);
70
70
  var href = (0, _action_types.callWithItemIfFunction)(item)(action.href);
71
71
  var dataTestSubj = (0, _action_types.callWithItemIfFunction)(item)(action['data-test-subj']);
72
+ var color = action.color ? (0, _action_types.callWithItemIfFunction)(item)(action.color) : undefined;
72
73
  var _onClick = action.onClick,
73
74
  target = action.target;
74
75
  controls.push((0, _react2.jsx)(_context_menu.EuiContextMenuItem, {
@@ -78,6 +79,7 @@ var CollapsedItemActions = exports.CollapsedItemActions = function CollapsedItem
78
79
  href: href,
79
80
  target: target,
80
81
  icon: icon,
82
+ color: color,
81
83
  "data-test-subj": dataTestSubj,
82
84
  onClick: function onClick(event) {
83
85
  event.persist();
@@ -95,9 +95,12 @@ var EuiColorPicker = exports.EuiColorPicker = function EuiColorPicker(_ref) {
95
95
  _ref$isClearable = _ref.isClearable,
96
96
  isClearable = _ref$isClearable === void 0 ? false : _ref$isClearable,
97
97
  placeholder = _ref.placeholder,
98
- dataTestSubj = _ref['data-test-subj'];
99
- var _useEuiI18n = (0, _i18n.useEuiI18n)(['euiColorPicker.popoverLabel', 'euiColorPicker.colorLabel', 'euiColorPicker.selectedColorLabel', 'euiColorPicker.colorErrorMessage', 'euiColorPicker.transparent', 'euiColorPicker.alphaLabel', 'euiColorPicker.openLabel', 'euiColorPicker.closeLabel'], ['Color selection dialog', 'Color value', 'Selected color', 'Invalid color value', 'Transparent', 'Alpha channel (opacity) value', 'Press the escape key to close the popover', 'Press the down key to open a popover containing color options']),
100
- _useEuiI18n2 = (0, _slicedToArray2.default)(_useEuiI18n, 8),
98
+ dataTestSubj = _ref['data-test-subj'],
99
+ _ariaLabel = _ref['aria-label'],
100
+ ariaLabelledby = _ref['aria-labelledby'],
101
+ ariaDescribedby = _ref['aria-describedby'];
102
+ var _useEuiI18n = (0, _i18n.useEuiI18n)(['euiColorPicker.popoverLabel', 'euiColorPicker.colorLabel', 'euiColorPicker.selectedColorLabel', 'euiColorPicker.colorErrorMessage', 'euiColorPicker.transparent', 'euiColorPicker.alphaLabel', 'euiColorPicker.openLabel', 'euiColorPicker.closeLabel', 'euiColorPicker.ariaLabel'], ['Color selection dialog', 'Color value', 'Selected color', 'Invalid color value', 'Transparent', 'Alpha channel (opacity) value', 'Press the escape key to close the popover', 'Press the down key to open a popover containing color options', 'Select a color']),
103
+ _useEuiI18n2 = (0, _slicedToArray2.default)(_useEuiI18n, 9),
101
104
  popoverLabel = _useEuiI18n2[0],
102
105
  colorLabel = _useEuiI18n2[1],
103
106
  selectedColorLabel = _useEuiI18n2[2],
@@ -105,7 +108,16 @@ var EuiColorPicker = exports.EuiColorPicker = function EuiColorPicker(_ref) {
105
108
  transparent = _useEuiI18n2[4],
106
109
  alphaLabel = _useEuiI18n2[5],
107
110
  openLabel = _useEuiI18n2[6],
108
- closeLabel = _useEuiI18n2[7];
111
+ closeLabel = _useEuiI18n2[7],
112
+ ariaLabel = _useEuiI18n2[8];
113
+ var openLabelId = (0, _services.useGeneratedHtmlId)({
114
+ prefix: 'colorPicker',
115
+ suffix: 'openLabel'
116
+ });
117
+ var closeLabelId = (0, _services.useGeneratedHtmlId)({
118
+ prefix: 'colorPicker',
119
+ suffix: 'closeLabel'
120
+ });
109
121
  var defaultSwatches = (0, _services.useEuiPaletteColorBlind)();
110
122
  var swatches = _swatches !== null && _swatches !== void 0 ? _swatches : defaultSwatches;
111
123
  var preferredFormat = (0, _react.useMemo)(function () {
@@ -434,10 +446,21 @@ var EuiColorPicker = exports.EuiColorPicker = function EuiColorPicker(_ref) {
434
446
  readOnly: readOnly,
435
447
  fullWidth: fullWidth,
436
448
  autoComplete: "off",
437
- "data-test-subj": testSubjAnchor,
438
- "aria-label": isColorSelectorShown ? openLabel : closeLabel,
449
+ "data-test-subj": testSubjAnchor
450
+ // if an id is provided it might be used in combination with `htmlFor` on a label,
451
+ // so we don't want to override it with a fallback `aria-label`
452
+ ,
453
+ "aria-label": _ariaLabel ? _ariaLabel : id || ariaLabelledby ? undefined : ariaLabel,
454
+ "aria-labelledby": ariaLabelledby,
455
+ "aria-describedby": (0, _classnames.default)(isColorSelectorShown ? openLabelId : closeLabelId, ariaDescribedby),
439
456
  controlOnly: true // Don't need two EuiFormControlwrappers
440
- }));
457
+ }), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("span", null, (0, _react2.jsx)("span", {
458
+ id: openLabelId,
459
+ "aria-hidden": !isColorSelectorShown
460
+ }, openLabel), (0, _react2.jsx)("span", {
461
+ id: closeLabelId,
462
+ "aria-hidden": isColorSelectorShown
463
+ }, closeLabel))));
441
464
  }
442
465
  return display === 'inline' ? (0, _react2.jsx)("div", {
443
466
  css: styles.euiColorPicker,
@@ -16,7 +16,7 @@ var _icon = require("../icon");
16
16
  var _tool_tip = require("../tool_tip");
17
17
  var _context_menu_item = require("./context_menu_item.styles");
18
18
  var _react2 = require("@emotion/react");
19
- var _excluded = ["children", "className", "hasPanel", "icon", "buttonRef", "disabled", "layoutAlign", "toolTipContent", "toolTipProps", "href", "target", "rel", "size"];
19
+ var _excluded = ["children", "className", "hasPanel", "icon", "buttonRef", "disabled", "layoutAlign", "toolTipContent", "toolTipProps", "href", "target", "rel", "size", "color"];
20
20
  /*
21
21
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
22
22
  * or more contributor license agreements. Licensed under the Elastic License
@@ -47,12 +47,13 @@ var EuiContextMenuItem = exports.EuiContextMenuItem = function EuiContextMenuIte
47
47
  rel = _ref.rel,
48
48
  _ref$size = _ref.size,
49
49
  size = _ref$size === void 0 ? 'm' : _ref$size,
50
+ color = _ref.color,
50
51
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
51
52
  var isHrefValid = !href || (0, _href_validator.validateHref)(href);
52
53
  var disabled = _disabled || !isHrefValid;
53
54
  var classes = (0, _classnames.default)('euiContextMenuItem', className);
54
55
  var styles = (0, _services.useEuiMemoizedStyles)(_context_menu_item.euiContextMenuItemStyles);
55
- var cssStyles = [styles.euiContextMenuItem, styles.sizes[size], styles.layoutAlign[layoutAlign], disabled && styles.disabled];
56
+ var cssStyles = [styles.euiContextMenuItem, styles.sizes[size], styles.layoutAlign[layoutAlign], disabled && styles.disabled, !disabled && color && styles.colors[color]];
56
57
  var iconInstance = icon && (typeof icon === 'string' ? (0, _react2.jsx)(_icon.EuiIcon, {
57
58
  type: icon,
58
59
  size: "m",
@@ -81,6 +81,10 @@ var euiContextMenuItemStyles = exports.euiContextMenuItemStyles = function euiCo
81
81
  euiContextMenuItem__text: _ref2,
82
82
  s: /*#__PURE__*/(0, _react.css)((0, _global_styling.euiFontSize)(euiThemeContext, 's'), ";;label:s;")
83
83
  },
84
- euiContextMenuItem__arrow: _ref
84
+ euiContextMenuItem__arrow: _ref,
85
+ // Colors - maps button color names to text color overrides
86
+ colors: Object.fromEntries(_global_styling.EXTENDED_BUTTON_COLORS.map(function (color) {
87
+ return [color, /*#__PURE__*/(0, _react.css)("color:", (0, _global_styling.euiButtonEmptyColor)(euiThemeContext, color).color, ";;label:colors;")];
88
+ }))
85
89
  };
86
90
  };
@@ -10,6 +10,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _services = require("../../../services");
13
+ var _hooks = require("../../../services/hooks");
13
14
  var _global_styling = require("../../../global_styling");
14
15
  var _cell = require("../body/cell");
15
16
  var _focus = require("./focus");
@@ -37,20 +38,48 @@ var useScroll = exports.useScroll = function useScroll(args) {
37
38
  scrollCellIntoView = _useScrollCellIntoVie.scrollCellIntoView;
38
39
  var _useContext = (0, _react.useContext)(_focus.DataGridFocusContext),
39
40
  focusedCell = _useContext.focusedCell;
40
- var isPointerDown = (0, _services.useIsPointerDown)(args.outerGridRef);
41
+ var isPointerDownRef = (0, _hooks.useIsPointerDown)(args.outerGridRef);
42
+
43
+ /**
44
+ * Set when `focusedCell` changes while the pointer is held down (e.g. clicking a cell).
45
+ * Allows the `pointerup` listener below to scroll on release without
46
+ * causing snap-back when the user scrolls the grid without changing focus.
47
+ */
48
+ var pendingScrollRef = (0, _react.useRef)(false);
49
+ (0, _react.useEffect)(function () {
50
+ if (!focusedCell) return;
51
+ if (isPointerDownRef.current) {
52
+ // Pointer is down - defer scroll decision to the pointerup listener
53
+ pendingScrollRef.current = true;
54
+ return;
55
+ }
56
+ scrollCellIntoView({
57
+ rowIndex: focusedCell[1],
58
+ colIndex: focusedCell[0]
59
+ });
60
+ }, [focusedCell, scrollCellIntoView, isPointerDownRef]);
41
61
  (0, _react.useEffect)(function () {
42
- if (focusedCell) {
62
+ var handlePointerUp = function handlePointerUp() {
43
63
  var _window;
44
- // do not scroll if text is being selected
45
- if (isPointerDown || ((_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 ? void 0 : _window.type) === 'Range') {
46
- return;
47
- }
64
+ if (!pendingScrollRef.current || !focusedCell) return;
65
+ pendingScrollRef.current = false;
66
+
67
+ // Skip if the interaction resulted in text being selected
68
+ if (((_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 ? void 0 : _window.type) === 'Range') return;
48
69
  scrollCellIntoView({
49
70
  rowIndex: focusedCell[1],
50
71
  colIndex: focusedCell[0]
51
72
  });
52
- }
53
- }, [focusedCell, isPointerDown, scrollCellIntoView]);
73
+ };
74
+ document.addEventListener('pointerup', handlePointerUp, {
75
+ capture: true
76
+ });
77
+ return function () {
78
+ return document.removeEventListener('pointerup', handlePointerUp, {
79
+ capture: true
80
+ });
81
+ };
82
+ }, [focusedCell, scrollCellIntoView]);
54
83
  var _useContext2 = (0, _react.useContext)(_cell.DataGridCellPopoverContext),
55
84
  popoverIsOpen = _useContext2.popoverIsOpen,
56
85
  cellLocation = _useContext2.cellLocation;
@@ -160,11 +160,20 @@ var EuiTimeWindowButtons = exports.EuiTimeWindowButtons = function EuiTimeWindow
160
160
  function useEuiTimeWindow(start, end, apply, options) {
161
161
  var _options$zoomFactor;
162
162
  var min = _datemath.default.parse(start);
163
+
164
+ /* `roundUp: true` will result in an "inclusive" time (e.g. 23:59:59.999 for 'now/d').
165
+ It only changes the value for relative expressions (e.g. 'now/d') but not absolute ISO strings. */
163
166
  var max = _datemath.default.parse(end, {
164
167
  roundUp: true
165
168
  });
166
169
  var isInvalid = !min || !min.isValid() || !max || !max.isValid();
167
- var windowDuration = isInvalid ? -1 : max.diff(min);
170
+ /* An end at .999ms is always considered an inclusive boundary (either as result of `roundUp: true`
171
+ or entered manually).
172
+ To avoid a 1ms drift on every time window or zoom step, windowDuration has to be increased by 1ms.
173
+ This ensures the window is always at a clean boundary (e.g. 00:00:00.000 - 23:59:59.999). */
174
+ var isInclusiveBoundary = !isInvalid && max.milliseconds() === 999;
175
+ var endBoundary = !isInvalid ? isInclusiveBoundary ? (0, _moment.default)(max).add(1, 'ms') : (0, _moment.default)(max) : null;
176
+ var windowDuration = isInvalid || !endBoundary ? -1 : endBoundary.diff(min);
168
177
  var isWindowDurationZero = windowDuration === 0;
169
178
  var zoomFactor = getPercentageMultiplier((_options$zoomFactor = options === null || options === void 0 ? void 0 : options.zoomFactor) !== null && _options$zoomFactor !== void 0 ? _options$zoomFactor : ZOOM_FACTOR_DEFAULT);
170
179
  var zoomDelta = windowDuration * (zoomFactor / 2); // Gets added to each end, that's why it's split in half
@@ -185,7 +194,10 @@ function useEuiTimeWindow(start, end, apply, options) {
185
194
  function stepForward() {
186
195
  if (isInvalid || isWindowDurationZero) return;
187
196
  apply({
188
- start: (0, _moment.default)(max).toISOString(),
197
+ /* Prevent 1ms drifts for inclusive boundaries by using the exclusive max (+ 1ms)
198
+ as the start of the next window (e.g. 00:00:00.000 instead of 23:59:59.999) */
199
+ start: (isInclusiveBoundary ? endBoundary // `!` is safe here because we early return on `isInvalid`
200
+ : (0, _moment.default)(max)).toISOString(),
189
201
  end: (0, _moment.default)(max).add(windowDuration, 'ms').toISOString()
190
202
  });
191
203
  }
@@ -193,7 +205,9 @@ function useEuiTimeWindow(start, end, apply, options) {
193
205
  if (isInvalid || isWindowDurationZero) return;
194
206
  apply({
195
207
  start: (0, _moment.default)(min).subtract(windowDuration, 'ms').toISOString(),
196
- end: (0, _moment.default)(min).toISOString()
208
+ /* Prevent 1ms drifts for inclusive boundaries by using the exclusive min (- 1ms)
209
+ as the end of the previous window (e.g. 23:59:59.999 instead of 00:00:00.000) */
210
+ end: (isInclusiveBoundary ? (0, _moment.default)(min).subtract(1, 'ms') : (0, _moment.default)(min)).toISOString()
197
211
  });
198
212
  }
199
213
  function expandWindow() {