@elastic/eui 72.2.0 → 74.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eui_theme_dark.css +15 -67
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +15 -67
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/basic_table/basic_table.js +56 -101
- package/es/components/basic_table/basic_table.styles.js +45 -0
- package/es/components/datagrid/controls/column_selector.js +23 -7
- package/es/components/datagrid/controls/column_sorting_draggable.js +17 -8
- package/es/components/datagrid/data_grid.a11y.js +3 -2
- package/es/components/modal/confirm_modal.js +5 -3
- package/es/components/modal/modal.a11y.js +1 -1
- package/es/components/modal/modal_header_title.js +12 -3
- package/es/components/notification/notification_event.a11y.js +113 -0
- package/es/components/page/page_header/page_header.a11y.js +32 -0
- package/es/components/portal/portal.a11y.js +70 -0
- package/es/components/resizable_container/resizable_panel.js +5 -0
- package/es/components/tool_tip/tool_tip.js +10 -5
- package/es/components/tool_tip/tool_tip_manager.js +42 -0
- package/es/services/security/get_secure_rel_for_target.js +2 -8
- package/es/services/theme/hooks.js +18 -0
- package/es/services/theme/index.js +1 -1
- package/eui.d.ts +57 -19
- package/i18ntokens.json +54 -38
- package/lib/components/basic_table/basic_table.js +56 -100
- package/lib/components/basic_table/basic_table.styles.js +54 -0
- package/lib/components/datagrid/controls/column_selector.js +21 -6
- package/lib/components/datagrid/controls/column_sorting_draggable.js +17 -8
- package/lib/components/datagrid/data_grid.a11y.js +3 -2
- package/lib/components/modal/confirm_modal.js +5 -3
- package/lib/components/modal/modal.a11y.js +1 -1
- package/lib/components/modal/modal_header_title.js +12 -3
- package/lib/components/notification/notification_event.a11y.js +117 -0
- package/lib/components/page/page_header/page_header.a11y.js +40 -0
- package/lib/components/portal/portal.a11y.js +73 -0
- package/lib/components/resizable_container/resizable_panel.js +5 -0
- package/lib/components/tool_tip/tool_tip.js +13 -7
- package/lib/components/tool_tip/tool_tip_manager.js +50 -0
- package/lib/services/security/get_secure_rel_for_target.js +2 -9
- package/lib/services/theme/hooks.js +22 -2
- package/lib/services/theme/index.js +6 -0
- package/optimize/es/components/basic_table/basic_table.js +56 -101
- package/optimize/es/components/basic_table/basic_table.styles.js +45 -0
- package/optimize/es/components/datagrid/controls/column_selector.js +22 -7
- package/optimize/es/components/datagrid/controls/column_sorting_draggable.js +17 -8
- package/optimize/es/components/datagrid/data_grid.a11y.js +3 -2
- package/optimize/es/components/modal/confirm_modal.js +4 -3
- package/optimize/es/components/modal/modal.a11y.js +1 -1
- package/optimize/es/components/modal/modal_header_title.js +4 -2
- package/optimize/es/components/notification/notification_event.a11y.js +103 -0
- package/optimize/es/components/page/page_header/page_header.a11y.js +32 -0
- package/optimize/es/components/portal/portal.a11y.js +60 -0
- package/optimize/es/components/tool_tip/tool_tip.js +10 -5
- package/optimize/es/components/tool_tip/tool_tip_manager.js +41 -0
- package/optimize/es/services/security/get_secure_rel_for_target.js +2 -8
- package/optimize/es/services/theme/hooks.js +18 -0
- package/optimize/es/services/theme/index.js +1 -1
- package/optimize/lib/components/basic_table/basic_table.js +56 -95
- package/optimize/lib/components/basic_table/basic_table.styles.js +56 -0
- package/optimize/lib/components/datagrid/controls/column_selector.js +21 -6
- package/optimize/lib/components/datagrid/controls/column_sorting_draggable.js +17 -8
- package/optimize/lib/components/datagrid/data_grid.a11y.js +3 -2
- package/optimize/lib/components/modal/confirm_modal.js +4 -3
- package/optimize/lib/components/modal/modal.a11y.js +1 -1
- package/optimize/lib/components/modal/modal_header_title.js +4 -2
- package/optimize/lib/components/notification/notification_event.a11y.js +117 -0
- package/optimize/lib/components/page/page_header/page_header.a11y.js +40 -0
- package/optimize/lib/components/portal/portal.a11y.js +73 -0
- package/optimize/lib/components/tool_tip/tool_tip.js +13 -7
- package/optimize/lib/components/tool_tip/tool_tip_manager.js +49 -0
- package/optimize/lib/services/security/get_secure_rel_for_target.js +2 -9
- package/optimize/lib/services/theme/hooks.js +22 -2
- package/optimize/lib/services/theme/index.js +6 -0
- package/package.json +1 -1
- package/src/components/datagrid/controls/_data_grid_column_sorting.scss +14 -13
- package/src/components/index.scss +0 -1
- package/test-env/components/basic_table/basic_table.js +56 -95
- package/test-env/components/basic_table/basic_table.styles.js +56 -0
- package/test-env/components/datagrid/controls/column_selector.js +21 -6
- package/test-env/components/datagrid/controls/column_sorting_draggable.js +17 -8
- package/test-env/components/datagrid/data_grid.a11y.js +3 -2
- package/test-env/components/modal/confirm_modal.js +5 -3
- package/test-env/components/modal/modal.a11y.js +1 -1
- package/test-env/components/modal/modal_header_title.js +12 -3
- package/test-env/components/notification/notification_event.a11y.js +117 -0
- package/test-env/components/page/page_header/page_header.a11y.js +40 -0
- package/test-env/components/portal/portal.a11y.js +73 -0
- package/test-env/components/resizable_container/resizable_panel.js +5 -0
- package/test-env/components/tool_tip/tool_tip.js +13 -7
- package/test-env/components/tool_tip/tool_tip_manager.js +49 -0
- package/test-env/services/security/get_secure_rel_for_target.js +2 -9
- package/test-env/services/theme/hooks.js +22 -2
- package/test-env/services/theme/index.js +6 -0
- package/es/services/url.js +0 -23
- package/lib/services/url.js +0 -32
- package/optimize/es/services/url.js +0 -23
- package/optimize/lib/services/url.js +0 -32
- package/src/components/basic_table/_basic_table.scss +0 -41
- package/src/components/basic_table/_index.scss +0 -1
- package/test-env/services/url.js +0 -32
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
5
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
6
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
7
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
8
|
+
* Side Public License, v 1.
|
|
9
|
+
*/
|
|
10
|
+
/// <reference types="../../../cypress/support"/>
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
|
+
import { EuiButton } from '../button';
|
|
13
|
+
import { EuiPortal } from './portal';
|
|
14
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
15
|
+
|
|
16
|
+
var Portal = function Portal() {
|
|
17
|
+
var _useState = useState(false),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
isPortalVisible = _useState2[0],
|
|
20
|
+
setIsPortalVisible = _useState2[1];
|
|
21
|
+
|
|
22
|
+
var togglePortal = function togglePortal() {
|
|
23
|
+
setIsPortalVisible(!isPortalVisible);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var closePortal = function closePortal() {
|
|
27
|
+
setIsPortalVisible(false);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var customPortal;
|
|
31
|
+
|
|
32
|
+
if (isPortalVisible) {
|
|
33
|
+
customPortal = ___EmotionJSX(EuiPortal, null, ___EmotionJSX("div", null, "This is the portal. Click anywhere to close."), ___EmotionJSX(EuiButton, {
|
|
34
|
+
onClick: closePortal
|
|
35
|
+
}, "Close portal"));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return ___EmotionJSX("div", null, ___EmotionJSX(EuiButton, {
|
|
39
|
+
onClick: togglePortal
|
|
40
|
+
}, "View guide"), customPortal);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('EuiPortal', function () {
|
|
44
|
+
beforeEach(function () {
|
|
45
|
+
cy.viewport(1024, 768); // medium breakpoint
|
|
46
|
+
|
|
47
|
+
cy.realMount(___EmotionJSX(Portal, null));
|
|
48
|
+
cy.get('div[data-relative-to-header="above"]').should('not.exist');
|
|
49
|
+
});
|
|
50
|
+
describe('Automated accessibility check', function () {
|
|
51
|
+
it('has zero violations on first render', function () {
|
|
52
|
+
cy.checkAxe();
|
|
53
|
+
});
|
|
54
|
+
it('has zero violations after the portal is activated', function () {
|
|
55
|
+
cy.get('button[type="button"]').contains('View guide').realClick();
|
|
56
|
+
cy.get('div[data-euiportal="true"]').should('exist');
|
|
57
|
+
cy.checkAxe();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -23,13 +23,14 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
23
23
|
import React, { Component } from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
25
|
import { keysOf } from '../common';
|
|
26
|
+
import { findPopoverPosition, htmlIdGenerator } from '../../services';
|
|
27
|
+
import { enqueueStateChange } from '../../services/react';
|
|
28
|
+
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
26
29
|
import { EuiPortal } from '../portal';
|
|
30
|
+
import { EuiToolTipPopover } from './tool_tip_popover';
|
|
27
31
|
import { EuiToolTipAnchor } from './tool_tip_anchor';
|
|
28
32
|
import { EuiToolTipArrow } from './tool_tip_arrow';
|
|
29
|
-
import {
|
|
30
|
-
import { enqueueStateChange } from '../../services/react';
|
|
31
|
-
import { findPopoverPosition, htmlIdGenerator } from '../../services';
|
|
32
|
-
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
33
|
+
import { toolTipManager } from './tool_tip_manager';
|
|
33
34
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
34
35
|
var positionsToClassNameMap = {
|
|
35
36
|
top: 'euiToolTip--top',
|
|
@@ -124,9 +125,11 @@ export var EuiToolTip = /*#__PURE__*/function (_Component) {
|
|
|
124
125
|
if (!_this.timeoutId) {
|
|
125
126
|
_this.timeoutId = setTimeout(function () {
|
|
126
127
|
enqueueStateChange(function () {
|
|
127
|
-
|
|
128
|
+
_this.setState({
|
|
128
129
|
visible: true
|
|
129
130
|
});
|
|
131
|
+
|
|
132
|
+
toolTipManager.registerTooltip(_this.hideToolTip);
|
|
130
133
|
});
|
|
131
134
|
}, delayToMsMap[_this.props.delay]);
|
|
132
135
|
}
|
|
@@ -187,6 +190,8 @@ export var EuiToolTip = /*#__PURE__*/function (_Component) {
|
|
|
187
190
|
toolTipStyles: DEFAULT_TOOLTIP_STYLES,
|
|
188
191
|
arrowStyles: undefined
|
|
189
192
|
});
|
|
193
|
+
|
|
194
|
+
toolTipManager.deregisterToolTip(_this.hideToolTip);
|
|
190
195
|
}
|
|
191
196
|
});
|
|
192
197
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
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
|
+
/**
|
|
13
|
+
* Manager utility that ensures only one tooltip is visible at a time
|
|
14
|
+
*
|
|
15
|
+
* UX rationale (primarily for mouse-only users):
|
|
16
|
+
* @see https://github.com/elastic/kibana/issues/144482
|
|
17
|
+
* @see https://github.com/elastic/eui/issues/5883
|
|
18
|
+
*/
|
|
19
|
+
var ToolTipManager = function ToolTipManager() {
|
|
20
|
+
var _this = this;
|
|
21
|
+
|
|
22
|
+
_classCallCheck(this, ToolTipManager);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "toolTipsToHide", new Set());
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "registerTooltip", function (hideCallback) {
|
|
27
|
+
_this.toolTipsToHide.forEach(function (hide) {
|
|
28
|
+
return hide();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
_this.toolTipsToHide.clear();
|
|
32
|
+
|
|
33
|
+
_this.toolTipsToHide.add(hideCallback);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
_defineProperty(this, "deregisterToolTip", function (hideCallback) {
|
|
37
|
+
_this.toolTipsToHide.delete(hideCallback);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export var toolTipManager = new ToolTipManager();
|
|
@@ -10,20 +10,14 @@
|
|
|
10
10
|
* Secures outbound links. For more info:
|
|
11
11
|
* https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
|
|
12
12
|
*/
|
|
13
|
-
import { isDomainSecure } from '../url';
|
|
14
13
|
export var getSecureRelForTarget = function getSecureRelForTarget(_ref) {
|
|
15
|
-
var
|
|
16
|
-
_ref$target = _ref.target,
|
|
14
|
+
var _ref$target = _ref.target,
|
|
17
15
|
target = _ref$target === void 0 ? '' : _ref$target,
|
|
18
16
|
rel = _ref.rel;
|
|
19
|
-
var isElasticHref = !!href && isDomainSecure(href);
|
|
20
17
|
var relParts = !!rel ? rel.split(' ').filter(function (part) {
|
|
21
18
|
return !!part.length && part !== 'noreferrer';
|
|
22
19
|
}) : [];
|
|
23
|
-
|
|
24
|
-
if (!isElasticHref) {
|
|
25
|
-
relParts.push('noreferrer');
|
|
26
|
-
}
|
|
20
|
+
relParts.push('noreferrer');
|
|
27
21
|
|
|
28
22
|
if (target.includes('_blank') && relParts.indexOf('noopener') === -1) {
|
|
29
23
|
relParts.push('noopener');
|
|
@@ -12,6 +12,10 @@ import { EuiThemeContext, EuiModificationsContext, EuiColorModeContext, defaultC
|
|
|
12
12
|
import { getEuiDevProviderWarning } from './provider';
|
|
13
13
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
14
14
|
var providerMessage = "`EuiProvider` is missing which can result in negative effects.\nWrap your component in `EuiProvider`: https://ela.st/euiprovider.";
|
|
15
|
+
/**
|
|
16
|
+
* Hook for function components
|
|
17
|
+
*/
|
|
18
|
+
|
|
15
19
|
export var useEuiTheme = function useEuiTheme() {
|
|
16
20
|
var theme = useContext(EuiThemeContext);
|
|
17
21
|
var colorMode = useContext(EuiColorModeContext);
|
|
@@ -46,6 +50,10 @@ export var useEuiTheme = function useEuiTheme() {
|
|
|
46
50
|
}, [theme, colorMode, modifications]);
|
|
47
51
|
return assembledTheme;
|
|
48
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* HOC for class components
|
|
55
|
+
*/
|
|
56
|
+
|
|
49
57
|
// Provide the component props interface as the generic to allow the docs props table to populate.
|
|
50
58
|
// e.g., `const EuiComponent = withEuiTheme<EuiComponentProps>(_EuiComponent)`
|
|
51
59
|
export var withEuiTheme = function withEuiTheme(Component) {
|
|
@@ -62,4 +70,14 @@ export var withEuiTheme = function withEuiTheme(Component) {
|
|
|
62
70
|
var WithEuiTheme = /*#__PURE__*/forwardRef(Render);
|
|
63
71
|
WithEuiTheme.displayName = componentName;
|
|
64
72
|
return WithEuiTheme;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Render prop alternative for complex class components
|
|
76
|
+
* Most useful for scenarios where a HOC may interfere with typing
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
export var RenderWithEuiTheme = function RenderWithEuiTheme(_ref) {
|
|
80
|
+
var children = _ref.children;
|
|
81
|
+
var theme = useEuiTheme();
|
|
82
|
+
return children(theme);
|
|
65
83
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Side Public License, v 1.
|
|
7
7
|
*/
|
|
8
8
|
export { EuiSystemContext, EuiThemeContext, EuiModificationsContext, EuiColorModeContext } from './context';
|
|
9
|
-
export { useEuiTheme, withEuiTheme } from './hooks';
|
|
9
|
+
export { useEuiTheme, withEuiTheme, RenderWithEuiTheme } from './hooks';
|
|
10
10
|
export { EuiThemeProvider, getEuiDevProviderWarning, setEuiDevProviderWarning } from './provider';
|
|
11
11
|
export { buildTheme, computed, isInverseColorMode, getColorMode, getComputed, getOn, mergeDeep, setOn, Computed } from './utils';
|
|
12
12
|
export { COLOR_MODES_STANDARD } from './types';
|
|
@@ -62,6 +62,8 @@ var _delay_render = require("../delay_render");
|
|
|
62
62
|
|
|
63
63
|
var _accessibility2 = require("../../services/accessibility");
|
|
64
64
|
|
|
65
|
+
var _basic_table = require("./basic_table.styles");
|
|
66
|
+
|
|
65
67
|
var _react2 = require("@emotion/react");
|
|
66
68
|
|
|
67
69
|
var _excluded = ["className", "loading", "items", "itemId", "columns", "pagination", "sorting", "selection", "onChange", "error", "noItemsMessage", "compressed", "itemIdToExpandedRowMap", "responsive", "isSelectable", "isExpandable", "hasActions", "rowProps", "cellProps", "tableCaption", "rowHeader", "tableLayout"],
|
|
@@ -182,40 +184,6 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
182
184
|
|
|
183
185
|
(0, _classCallCheck2.default)(this, EuiBasicTable);
|
|
184
186
|
_this = _super.call(this, props);
|
|
185
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cleanups", []);
|
|
186
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tbody", null);
|
|
187
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setTbody", function (tbody) {
|
|
188
|
-
// remove listeners from an existing element
|
|
189
|
-
_this.removeLoadingListeners(); // update the ref
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
_this.tbody = tbody; // if loading, add listeners
|
|
193
|
-
|
|
194
|
-
if (_this.props.loading === true && tbody) {
|
|
195
|
-
_this.addLoadingListeners(tbody);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "addLoadingListeners", function (tbody) {
|
|
199
|
-
var listener = function listener(event) {
|
|
200
|
-
event.stopPropagation();
|
|
201
|
-
event.preventDefault();
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
['mousedown', 'mouseup', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'click', 'dblclick', 'keydown', 'keyup', 'keypress'].forEach(function (event) {
|
|
205
|
-
tbody.addEventListener(event, listener, true);
|
|
206
|
-
|
|
207
|
-
_this.cleanups.push(function () {
|
|
208
|
-
tbody.removeEventListener(event, listener, true);
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "removeLoadingListeners", function () {
|
|
213
|
-
_this.cleanups.forEach(function (cleanup) {
|
|
214
|
-
return cleanup();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
_this.cleanups.length = 0;
|
|
218
|
-
});
|
|
219
187
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tableId", (0, _accessibility2.htmlIdGenerator)('__table')());
|
|
220
188
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectAllIdGenerator", (0, _accessibility2.htmlIdGenerator)('_selection_column-checkbox'));
|
|
221
189
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderSelectAll", function (isMobile) {
|
|
@@ -302,27 +270,13 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
302
270
|
(0, _createClass2.default)(EuiBasicTable, [{
|
|
303
271
|
key: "componentDidMount",
|
|
304
272
|
value: function componentDidMount() {
|
|
305
|
-
if (this.props.loading && this.tbody) this.addLoadingListeners(this.tbody);
|
|
306
273
|
this.getInitialSelection();
|
|
307
274
|
}
|
|
308
275
|
}, {
|
|
309
276
|
key: "componentDidUpdate",
|
|
310
|
-
value: function componentDidUpdate(
|
|
311
|
-
if (prevProps.loading !== this.props.loading) {
|
|
312
|
-
if (this.props.loading && this.tbody) {
|
|
313
|
-
this.addLoadingListeners(this.tbody);
|
|
314
|
-
} else {
|
|
315
|
-
this.removeLoadingListeners();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
277
|
+
value: function componentDidUpdate() {
|
|
319
278
|
this.getInitialSelection();
|
|
320
279
|
}
|
|
321
|
-
}, {
|
|
322
|
-
key: "componentWillUnmount",
|
|
323
|
-
value: function componentWillUnmount() {
|
|
324
|
-
this.removeLoadingListeners();
|
|
325
|
-
}
|
|
326
280
|
}, {
|
|
327
281
|
key: "getInitialSelection",
|
|
328
282
|
value: function getInitialSelection() {
|
|
@@ -482,7 +436,8 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
482
436
|
var _this$props3 = this.props,
|
|
483
437
|
compressed = _this$props3.compressed,
|
|
484
438
|
responsive = _this$props3.responsive,
|
|
485
|
-
tableLayout = _this$props3.tableLayout
|
|
439
|
+
tableLayout = _this$props3.tableLayout,
|
|
440
|
+
loading = _this$props3.loading;
|
|
486
441
|
var mobileHeader = responsive ? (0, _react2.jsx)(_table.EuiTableHeaderMobile, null, (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
487
442
|
responsive: false,
|
|
488
443
|
justifyContent: "spaceBetween",
|
|
@@ -500,7 +455,8 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
500
455
|
id: this.tableId,
|
|
501
456
|
tableLayout: tableLayout,
|
|
502
457
|
responsive: responsive,
|
|
503
|
-
compressed: compressed
|
|
458
|
+
compressed: compressed,
|
|
459
|
+
css: loading && _basic_table.safariLoadingWorkaround
|
|
504
460
|
}, caption, head, body, footer));
|
|
505
461
|
}
|
|
506
462
|
}, {
|
|
@@ -763,30 +719,35 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
763
719
|
value: function renderTableBody() {
|
|
764
720
|
var _this4 = this;
|
|
765
721
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
var
|
|
771
|
-
|
|
772
|
-
if (
|
|
773
|
-
|
|
722
|
+
var _this$props8 = this.props,
|
|
723
|
+
error = _this$props8.error,
|
|
724
|
+
loading = _this$props8.loading,
|
|
725
|
+
items = _this$props8.items;
|
|
726
|
+
var content;
|
|
727
|
+
|
|
728
|
+
if (error) {
|
|
729
|
+
content = this.renderErrorMessage(error);
|
|
730
|
+
} else if (items.length === 0) {
|
|
731
|
+
content = this.renderEmptyMessage();
|
|
732
|
+
} else {
|
|
733
|
+
content = items.map(function (item, index) {
|
|
734
|
+
// if there's pagination the item's index must be adjusted to the where it is in the whole dataset
|
|
735
|
+
var tableItemIndex = hasPagination(_this4.props) && _this4.props.pagination.pageSize > 0 ? _this4.props.pagination.pageIndex * _this4.props.pagination.pageSize + index : index;
|
|
736
|
+
return _this4.renderItemRow(item, tableItemIndex);
|
|
737
|
+
});
|
|
774
738
|
}
|
|
775
739
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
740
|
+
return (0, _react2.jsx)(_services.RenderWithEuiTheme, null, function (theme) {
|
|
741
|
+
return (0, _react2.jsx)(_table.EuiTableBody, {
|
|
742
|
+
css: loading && (0, _basic_table.euiBasicTableBodyLoading)(theme)
|
|
743
|
+
}, content);
|
|
780
744
|
});
|
|
781
|
-
return (0, _react2.jsx)(_table.EuiTableBody, {
|
|
782
|
-
bodyRef: this.setTbody
|
|
783
|
-
}, rows);
|
|
784
745
|
}
|
|
785
746
|
}, {
|
|
786
|
-
key: "
|
|
787
|
-
value: function
|
|
747
|
+
key: "renderErrorMessage",
|
|
748
|
+
value: function renderErrorMessage(error) {
|
|
788
749
|
var colSpan = this.props.columns.length + (this.props.selection ? 1 : 0);
|
|
789
|
-
return (0, _react2.jsx)(_table.
|
|
750
|
+
return (0, _react2.jsx)(_table.EuiTableRow, null, (0, _react2.jsx)(_table.EuiTableRowCell, {
|
|
790
751
|
align: "center",
|
|
791
752
|
colSpan: colSpan,
|
|
792
753
|
mobileOptions: {
|
|
@@ -795,38 +756,38 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
795
756
|
}, (0, _react2.jsx)(_icon.EuiIcon, {
|
|
796
757
|
type: "minusInCircle",
|
|
797
758
|
color: "danger"
|
|
798
|
-
}), " ", error))
|
|
759
|
+
}), " ", error));
|
|
799
760
|
}
|
|
800
761
|
}, {
|
|
801
|
-
key: "
|
|
802
|
-
value: function
|
|
803
|
-
var _this$
|
|
804
|
-
columns = _this$
|
|
805
|
-
selection = _this$
|
|
806
|
-
noItemsMessage = _this$
|
|
762
|
+
key: "renderEmptyMessage",
|
|
763
|
+
value: function renderEmptyMessage() {
|
|
764
|
+
var _this$props9 = this.props,
|
|
765
|
+
columns = _this$props9.columns,
|
|
766
|
+
selection = _this$props9.selection,
|
|
767
|
+
noItemsMessage = _this$props9.noItemsMessage;
|
|
807
768
|
var colSpan = columns.length + (selection ? 1 : 0);
|
|
808
|
-
return (0, _react2.jsx)(_table.
|
|
769
|
+
return (0, _react2.jsx)(_table.EuiTableRow, null, (0, _react2.jsx)(_table.EuiTableRowCell, {
|
|
809
770
|
align: "center",
|
|
810
771
|
colSpan: colSpan,
|
|
811
772
|
mobileOptions: {
|
|
812
773
|
width: '100%'
|
|
813
774
|
}
|
|
814
|
-
}, noItemsMessage))
|
|
775
|
+
}, noItemsMessage));
|
|
815
776
|
}
|
|
816
777
|
}, {
|
|
817
778
|
key: "renderItemRow",
|
|
818
779
|
value: function renderItemRow(item, rowIndex) {
|
|
819
780
|
var _this5 = this;
|
|
820
781
|
|
|
821
|
-
var _this$
|
|
822
|
-
columns = _this$
|
|
823
|
-
selection = _this$
|
|
824
|
-
isSelectable = _this$
|
|
825
|
-
hasActions = _this$
|
|
826
|
-
rowHeader = _this$
|
|
827
|
-
_this$
|
|
828
|
-
itemIdToExpandedRowMap = _this$
|
|
829
|
-
isExpandable = _this$
|
|
782
|
+
var _this$props10 = this.props,
|
|
783
|
+
columns = _this$props10.columns,
|
|
784
|
+
selection = _this$props10.selection,
|
|
785
|
+
isSelectable = _this$props10.isSelectable,
|
|
786
|
+
hasActions = _this$props10.hasActions,
|
|
787
|
+
rowHeader = _this$props10.rowHeader,
|
|
788
|
+
_this$props10$itemIdT = _this$props10.itemIdToExpandedRowMap,
|
|
789
|
+
itemIdToExpandedRowMap = _this$props10$itemIdT === void 0 ? {} : _this$props10$itemIdT,
|
|
790
|
+
isExpandable = _this$props10.isExpandable;
|
|
830
791
|
var cells = [];
|
|
831
792
|
var itemIdCallback = this.props.itemId;
|
|
832
793
|
var itemId = getItemId(item, itemIdCallback) != null ? getItemId(item, itemIdCallback) : rowIndex;
|
|
@@ -978,7 +939,8 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
978
939
|
key: key,
|
|
979
940
|
align: "right",
|
|
980
941
|
textOnly: false,
|
|
981
|
-
hasActions: true
|
|
942
|
+
hasActions: true,
|
|
943
|
+
css: _basic_table.euiBasicTableActionsWrapper
|
|
982
944
|
}, tools);
|
|
983
945
|
}
|
|
984
946
|
}, {
|
|
@@ -1062,11 +1024,11 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
1062
1024
|
value: function renderPaginationBar() {
|
|
1063
1025
|
var _this8 = this;
|
|
1064
1026
|
|
|
1065
|
-
var _this$
|
|
1066
|
-
error = _this$
|
|
1067
|
-
pagination = _this$
|
|
1068
|
-
tableCaption = _this$
|
|
1069
|
-
onChange = _this$
|
|
1027
|
+
var _this$props11 = this.props,
|
|
1028
|
+
error = _this$props11.error,
|
|
1029
|
+
pagination = _this$props11.pagination,
|
|
1030
|
+
tableCaption = _this$props11.tableCaption,
|
|
1031
|
+
onChange = _this$props11.onChange;
|
|
1070
1032
|
|
|
1071
1033
|
if (!error && pagination && pagination.totalItemCount > 0) {
|
|
1072
1034
|
if (!onChange) {
|
|
@@ -1118,8 +1080,7 @@ var EuiBasicTable = /*#__PURE__*/function (_Component) {
|
|
|
1118
1080
|
}
|
|
1119
1081
|
|
|
1120
1082
|
return null;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1083
|
+
}
|
|
1123
1084
|
}]);
|
|
1124
1085
|
return EuiBasicTable;
|
|
1125
1086
|
}(_react.Component);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.safariLoadingWorkaround = exports.euiBasicTableBodyLoading = exports.euiBasicTableActionsWrapper = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _react = require("@emotion/react");
|
|
13
|
+
|
|
14
|
+
var _global_styling = require("../../global_styling");
|
|
15
|
+
|
|
16
|
+
var _templateObject;
|
|
17
|
+
|
|
18
|
+
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)."; }
|
|
19
|
+
|
|
20
|
+
var tableLoadingLine = (0, _react.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n from {\n ", "\n ", "\n }\n\n 20% {\n ", "\n ", "\n }\n\n 80% {\n ", "\n ", "\n }\n\n 100% {\n ", "\n ", "\n }\n"])), (0, _global_styling.logicalCSS)('left', 0), (0, _global_styling.logicalCSS)('width', 0), (0, _global_styling.logicalCSS)('left', 0), (0, _global_styling.logicalCSS)('width', '40%'), (0, _global_styling.logicalCSS)('left', '60%'), (0, _global_styling.logicalCSS)('width', '40%'), (0, _global_styling.logicalCSS)('left', '100%'), (0, _global_styling.logicalCSS)('width', 0));
|
|
21
|
+
|
|
22
|
+
var euiBasicTableBodyLoading = function euiBasicTableBodyLoading(_ref2) {
|
|
23
|
+
var euiTheme = _ref2.euiTheme;
|
|
24
|
+
return /*#__PURE__*/(0, _react.css)("position:relative;overflow:hidden;&::before{position:absolute;content:'';", (0, _global_styling.logicalCSS)('width', '100%'), " ", (0, _global_styling.logicalCSS)('height', euiTheme.border.width.thick), " background-color:", euiTheme.colors.primary, ";animation:", tableLoadingLine, " 1s linear infinite;", _global_styling.euiCantAnimate, "{animation-duration:2s;}};label:euiBasicTableBodyLoading;");
|
|
25
|
+
}; // Fix to make the loading indicator position correctly in Safari
|
|
26
|
+
// For whatever annoying reason, Safari doesn't respect `position: relative;`
|
|
27
|
+
// on `tbody` without `position: relative` on the parent `table`
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.euiBasicTableBodyLoading = euiBasicTableBodyLoading;
|
|
31
|
+
|
|
32
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
33
|
+
name: "6xbnw4-safariLoadingWorkaround",
|
|
34
|
+
styles: "position:relative;label:safariLoadingWorkaround;"
|
|
35
|
+
} : {
|
|
36
|
+
name: "6xbnw4-safariLoadingWorkaround",
|
|
37
|
+
styles: "position:relative;label:safariLoadingWorkaround;",
|
|
38
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var safariLoadingWorkaround = function safariLoadingWorkaround() {
|
|
42
|
+
return _ref;
|
|
43
|
+
}; // Unsets the extra height caused by tooltip/popover wrappers around table action buttons
|
|
44
|
+
// Without this, the row height jumps whenever actions are disabled
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
exports.safariLoadingWorkaround = safariLoadingWorkaround;
|
|
48
|
+
var euiBasicTableActionsWrapper = process.env.NODE_ENV === "production" ? {
|
|
49
|
+
name: "1mshepa-euiBasicTableActionsWrapper",
|
|
50
|
+
styles: "line-height:1;label:euiBasicTableActionsWrapper;"
|
|
51
|
+
} : {
|
|
52
|
+
name: "1mshepa-euiBasicTableActionsWrapper",
|
|
53
|
+
styles: "line-height:1;label:euiBasicTableActionsWrapper;",
|
|
54
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
55
|
+
};
|
|
56
|
+
exports.euiBasicTableActionsWrapper = euiBasicTableActionsWrapper;
|
|
@@ -11,6 +11,8 @@ exports.useDataGridColumnSelector = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
14
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
17
|
|
|
16
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -107,6 +109,7 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
|
|
|
107
109
|
}, [sortedColumns, columnSearchText, displayValues]);
|
|
108
110
|
var isDragEnabled = allowColumnReorder && columnSearchText.length === 0; // only allow drag-and-drop when not filtering columns
|
|
109
111
|
|
|
112
|
+
var dragHandleAriaLabel = (0, _i18n.useEuiI18n)('euiColumnSelector.dragHandleAriaLabel', 'Drag handle');
|
|
110
113
|
var buttonText = (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
111
114
|
token: "euiColumnSelector.button",
|
|
112
115
|
default: "Columns"
|
|
@@ -179,18 +182,23 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
|
|
|
179
182
|
key: id,
|
|
180
183
|
draggableId: id,
|
|
181
184
|
index: index,
|
|
182
|
-
isDragDisabled: !isDragEnabled
|
|
185
|
+
isDragDisabled: !isDragEnabled,
|
|
186
|
+
hasInteractiveChildren: true,
|
|
187
|
+
customDragHandle: true
|
|
183
188
|
}, function (provided, state) {
|
|
184
189
|
return (0, _react2.jsx)("div", {
|
|
185
190
|
className: "euiDataGridColumnSelector__item ".concat(state.isDragging && 'euiDataGridColumnSelector__item-isDragging'),
|
|
186
191
|
"data-test-subj": "dataGridColumnSelectorColumnItem-".concat(id)
|
|
187
192
|
}, (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
188
193
|
responsive: false,
|
|
189
|
-
gutterSize: "
|
|
194
|
+
gutterSize: "s",
|
|
190
195
|
alignItems: "center"
|
|
191
|
-
},
|
|
196
|
+
}, allowColumnHiding && (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
197
|
+
grow: false
|
|
198
|
+
}, (0, _react2.jsx)(_form.EuiSwitch, {
|
|
192
199
|
name: id,
|
|
193
200
|
label: displayValues[id] || id,
|
|
201
|
+
showLabel: false,
|
|
194
202
|
checked: visibleColumnIds.has(id),
|
|
195
203
|
compressed: true,
|
|
196
204
|
className: "euiSwitch--mini",
|
|
@@ -202,11 +210,18 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
|
|
|
202
210
|
setVisibleColumns(nextVisibleColumns);
|
|
203
211
|
},
|
|
204
212
|
"data-test-subj": "dataGridColumnSelectorToggleColumnVisibility-".concat(id)
|
|
205
|
-
})
|
|
213
|
+
})), (0, _react2.jsx)(_flex.EuiFlexItem // This extra column name flex item affords the column more grabbable real estate
|
|
214
|
+
// for mouse users, while hiding repetition for keyboard/screen reader users
|
|
215
|
+
, (0, _extends2.default)({}, provided.dragHandleProps, {
|
|
216
|
+
"aria-hidden": true,
|
|
217
|
+
tabIndex: -1
|
|
218
|
+
}), (0, _react2.jsx)("span", {
|
|
206
219
|
className: "euiDataGridColumnSelector__itemLabel"
|
|
207
|
-
}, id)), isDragEnabled && (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
220
|
+
}, displayValues[id] || id)), isDragEnabled && (0, _react2.jsx)(_flex.EuiFlexItem, (0, _extends2.default)({
|
|
208
221
|
grow: false
|
|
209
|
-
},
|
|
222
|
+
}, provided.dragHandleProps, {
|
|
223
|
+
"aria-label": dragHandleAriaLabel
|
|
224
|
+
}), (0, _react2.jsx)(_icon.EuiIcon, {
|
|
210
225
|
type: "grab",
|
|
211
226
|
color: "subdued"
|
|
212
227
|
}))));
|
|
@@ -73,7 +73,9 @@ var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSortingDraggab
|
|
|
73
73
|
var dragHandleAriaLabel = (0, _i18n.useEuiI18n)('euiColumnSortingDraggable.dragHandleAriaLabel', 'Drag handle');
|
|
74
74
|
return (0, _react2.jsx)(_drag_and_drop.EuiDraggable, (0, _extends2.default)({
|
|
75
75
|
draggableId: id,
|
|
76
|
-
index: index
|
|
76
|
+
index: index,
|
|
77
|
+
hasInteractiveChildren: true,
|
|
78
|
+
customDragHandle: true
|
|
77
79
|
}, rest), function (provided, state) {
|
|
78
80
|
return (0, _react2.jsx)("div", {
|
|
79
81
|
className: "euiDataGridColumnSorting__item ".concat(state.isDragging && 'euiDataGridColumnSorting__item-isDragging')
|
|
@@ -114,18 +116,25 @@ var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSortingDraggab
|
|
|
114
116
|
sorting.onSort(nextColumns);
|
|
115
117
|
}
|
|
116
118
|
});
|
|
117
|
-
})), (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
119
|
+
})), (0, _react2.jsx)(_flex.EuiFlexItem, (0, _extends2.default)({
|
|
120
|
+
className: "euiDataGridColumnSorting__name" // This extra column name flex item affords the column more grabbable real estate
|
|
121
|
+
// for mouse users, while hiding repetition for keyboard/screen reader users
|
|
122
|
+
|
|
123
|
+
}, provided.dragHandleProps, {
|
|
124
|
+
tabIndex: -1,
|
|
125
|
+
"aria-hidden": true
|
|
126
|
+
}), (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
127
|
+
gutterSize: "xs",
|
|
128
|
+
alignItems: "center",
|
|
129
|
+
responsive: false
|
|
130
|
+
}, (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
118
131
|
grow: false
|
|
119
132
|
}, (0, _react2.jsx)(_token.EuiToken, {
|
|
120
133
|
color: schemaDetails != null ? schemaDetails.color : undefined,
|
|
121
134
|
iconType: schemaDetails != null ? schemaDetails.icon : 'tokenString'
|
|
122
|
-
})), (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
123
|
-
"aria-hidden": true
|
|
124
|
-
}, (0, _react2.jsx)(_text.EuiText, {
|
|
135
|
+
})), (0, _react2.jsx)(_flex.EuiFlexItem, null, (0, _react2.jsx)(_text.EuiText, {
|
|
125
136
|
size: "xs"
|
|
126
|
-
}, (0, _react2.jsx)("p", null, display))), (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
127
|
-
className: "euiDataGridColumnSorting__orderButtons"
|
|
128
|
-
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
137
|
+
}, (0, _react2.jsx)("p", null, display))))), (0, _react2.jsx)(_flex.EuiFlexItem, null, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
129
138
|
token: "euiColumnSortingDraggable.toggleLegend",
|
|
130
139
|
default: "Select sorting method for {display}",
|
|
131
140
|
values: {
|
|
@@ -181,7 +181,7 @@ describe('EuiDataGrid', function () {
|
|
|
181
181
|
it('has zero violations on first render', function () {
|
|
182
182
|
cy.checkAxe();
|
|
183
183
|
});
|
|
184
|
-
it('has zero violations when the columns
|
|
184
|
+
it('has zero violations when the columns visibility menu is open', function () {
|
|
185
185
|
cy.get('button[data-test-subj="dataGridColumnSelectorButton"]').realClick();
|
|
186
186
|
cy.checkAxe();
|
|
187
187
|
});
|
|
@@ -234,9 +234,10 @@ describe('EuiDataGrid', function () {
|
|
|
234
234
|
cy.get('div[data-gridcell-visible-row-index="0"][data-gridcell-column-index="1"]').find('button.euiButtonIcon').last().realClick();
|
|
235
235
|
cy.checkAxe();
|
|
236
236
|
});
|
|
237
|
-
it('has zero violations when the
|
|
237
|
+
it('has zero violations on sort and when the columns sorting menu is open', function () {
|
|
238
238
|
cy.get('button.euiDataGridHeaderCell__button').last().realClick();
|
|
239
239
|
cy.get('button.euiListGroupItem__button').contains('Sort Alma to Debian').should('exist').realClick();
|
|
240
|
+
cy.get('button[data-test-subj="dataGridColumnSortingPopover"]').realClick();
|
|
240
241
|
cy.checkAxe();
|
|
241
242
|
});
|
|
242
243
|
it('has zero violations when fullscreen is open', function () {
|