@elastic/eui 70.2.3 → 70.3.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 (143) hide show
  1. package/dist/eui_theme_dark.css +0 -198
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +0 -198
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/accessibility/skip_link/skip_link.js +6 -5
  6. package/es/components/badge/beta_badge/beta_badge.js +11 -3
  7. package/es/components/badge/beta_badge/beta_badge.styles.js +25 -4
  8. package/es/components/card/card.js +6 -1
  9. package/es/components/card/card.styles.js +4 -4
  10. package/es/components/date_picker/super_date_picker/super_date_picker.a11y.js +109 -0
  11. package/es/components/flex/flex_group.styles.js +1 -1
  12. package/es/components/flyout/flyout.a11y.js +92 -0
  13. package/es/components/image/image_fullscreen_wrapper.styles.js +3 -11
  14. package/es/components/modal/confirm_modal.js +11 -0
  15. package/es/components/modal/modal.a11y.js +70 -0
  16. package/es/components/modal/modal.js +17 -27
  17. package/es/components/modal/modal.styles.js +23 -0
  18. package/es/components/modal/modal_body.js +8 -0
  19. package/es/components/modal/modal_body.styles.js +16 -0
  20. package/es/components/modal/modal_footer.js +6 -0
  21. package/es/components/modal/modal_footer.styles.js +15 -0
  22. package/es/components/modal/modal_header.js +6 -0
  23. package/es/components/modal/modal_header.styles.js +14 -0
  24. package/es/components/modal/modal_header_title.js +3 -1
  25. package/es/components/page_template/outer/page_outer.js +1 -1
  26. package/es/components/page_template/page_template.js +28 -6
  27. package/es/components/popover/popover.a11y.js +83 -0
  28. package/es/components/search_bar/query/default_syntax.js +2 -1
  29. package/es/components/tabs/tabs.a11y.js +97 -0
  30. package/es/components/tree_view/tree_view.a11y.js +74 -0
  31. package/es/global_styling/utility/animations.js +5 -2
  32. package/eui.d.ts +58 -7
  33. package/i18ntokens.json +2 -2
  34. package/lib/components/accessibility/skip_link/skip_link.js +6 -5
  35. package/lib/components/badge/beta_badge/beta_badge.js +13 -4
  36. package/lib/components/badge/beta_badge/beta_badge.styles.js +25 -4
  37. package/lib/components/card/card.js +6 -1
  38. package/lib/components/card/card.styles.js +4 -4
  39. package/lib/components/date_picker/super_date_picker/super_date_picker.a11y.js +111 -0
  40. package/lib/components/flex/flex_group.styles.js +1 -1
  41. package/lib/components/flyout/flyout.a11y.js +94 -0
  42. package/lib/components/image/image_fullscreen_wrapper.styles.js +9 -10
  43. package/lib/components/modal/confirm_modal.js +13 -0
  44. package/lib/components/modal/modal.a11y.js +73 -0
  45. package/lib/components/modal/modal.js +17 -32
  46. package/lib/components/modal/modal.styles.js +36 -0
  47. package/lib/components/modal/modal_body.js +10 -0
  48. package/lib/components/modal/modal_body.styles.js +27 -0
  49. package/lib/components/modal/modal_footer.js +8 -0
  50. package/lib/components/modal/modal_footer.styles.js +26 -0
  51. package/lib/components/modal/modal_header.js +8 -0
  52. package/lib/components/modal/modal_header.styles.js +24 -0
  53. package/lib/components/modal/modal_header_title.js +4 -1
  54. package/lib/components/page_template/outer/page_outer.js +1 -1
  55. package/lib/components/page_template/page_template.js +32 -10
  56. package/lib/components/popover/popover.a11y.js +86 -0
  57. package/lib/components/search_bar/query/default_syntax.js +2 -1
  58. package/lib/components/tabs/tabs.a11y.js +98 -0
  59. package/lib/components/tree_view/tree_view.a11y.js +80 -0
  60. package/lib/global_styling/utility/animations.js +9 -3
  61. package/optimize/es/components/accessibility/skip_link/skip_link.js +6 -5
  62. package/optimize/es/components/badge/beta_badge/beta_badge.js +5 -2
  63. package/optimize/es/components/badge/beta_badge/beta_badge.styles.js +25 -4
  64. package/optimize/es/components/card/card.styles.js +4 -4
  65. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.a11y.js +98 -0
  66. package/optimize/es/components/flex/flex_group.styles.js +1 -1
  67. package/optimize/es/components/flyout/flyout.a11y.js +77 -0
  68. package/optimize/es/components/image/image_fullscreen_wrapper.styles.js +3 -11
  69. package/optimize/es/components/modal/confirm_modal.js +6 -0
  70. package/optimize/es/components/modal/modal.a11y.js +60 -0
  71. package/optimize/es/components/modal/modal.js +17 -27
  72. package/optimize/es/components/modal/modal.styles.js +23 -0
  73. package/optimize/es/components/modal/modal_body.js +8 -0
  74. package/optimize/es/components/modal/modal_body.styles.js +16 -0
  75. package/optimize/es/components/modal/modal_footer.js +6 -0
  76. package/optimize/es/components/modal/modal_footer.styles.js +15 -0
  77. package/optimize/es/components/modal/modal_header.js +6 -0
  78. package/optimize/es/components/modal/modal_header.styles.js +14 -0
  79. package/optimize/es/components/modal/modal_header_title.js +3 -1
  80. package/optimize/es/components/page_template/page_template.js +5 -3
  81. package/optimize/es/components/popover/popover.a11y.js +73 -0
  82. package/optimize/es/components/search_bar/query/default_syntax.js +2 -1
  83. package/optimize/es/components/tabs/tabs.a11y.js +97 -0
  84. package/optimize/es/components/tree_view/tree_view.a11y.js +74 -0
  85. package/optimize/es/global_styling/utility/animations.js +5 -2
  86. package/optimize/lib/components/accessibility/skip_link/skip_link.js +6 -5
  87. package/optimize/lib/components/badge/beta_badge/beta_badge.js +7 -3
  88. package/optimize/lib/components/badge/beta_badge/beta_badge.styles.js +25 -4
  89. package/optimize/lib/components/card/card.styles.js +4 -4
  90. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.a11y.js +111 -0
  91. package/optimize/lib/components/flex/flex_group.styles.js +1 -1
  92. package/optimize/lib/components/flyout/flyout.a11y.js +84 -0
  93. package/optimize/lib/components/image/image_fullscreen_wrapper.styles.js +9 -12
  94. package/optimize/lib/components/modal/confirm_modal.js +8 -0
  95. package/optimize/lib/components/modal/modal.a11y.js +73 -0
  96. package/optimize/lib/components/modal/modal.js +17 -31
  97. package/optimize/lib/components/modal/modal.styles.js +36 -0
  98. package/optimize/lib/components/modal/modal_body.js +10 -0
  99. package/optimize/lib/components/modal/modal_body.styles.js +27 -0
  100. package/optimize/lib/components/modal/modal_footer.js +8 -0
  101. package/optimize/lib/components/modal/modal_footer.styles.js +26 -0
  102. package/optimize/lib/components/modal/modal_header.js +8 -0
  103. package/optimize/lib/components/modal/modal_header.styles.js +24 -0
  104. package/optimize/lib/components/modal/modal_header_title.js +4 -1
  105. package/optimize/lib/components/page_template/page_template.js +5 -3
  106. package/optimize/lib/components/popover/popover.a11y.js +86 -0
  107. package/optimize/lib/components/search_bar/query/default_syntax.js +2 -1
  108. package/optimize/lib/components/tabs/tabs.a11y.js +98 -0
  109. package/optimize/lib/components/tree_view/tree_view.a11y.js +80 -0
  110. package/optimize/lib/global_styling/utility/animations.js +9 -3
  111. package/package.json +5 -4
  112. package/src/components/index.scss +0 -1
  113. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  114. package/test-env/components/accessibility/skip_link/skip_link.js +6 -5
  115. package/test-env/components/badge/beta_badge/beta_badge.js +13 -4
  116. package/test-env/components/badge/beta_badge/beta_badge.styles.js +25 -4
  117. package/test-env/components/card/card.js +6 -1
  118. package/test-env/components/card/card.styles.js +4 -4
  119. package/test-env/components/date_picker/super_date_picker/super_date_picker.a11y.js +111 -0
  120. package/test-env/components/flex/flex_group.styles.js +1 -1
  121. package/test-env/components/flyout/flyout.a11y.js +84 -0
  122. package/test-env/components/image/image_fullscreen_wrapper.styles.js +9 -12
  123. package/test-env/components/modal/confirm_modal.js +13 -0
  124. package/test-env/components/modal/modal.a11y.js +73 -0
  125. package/test-env/components/modal/modal.js +17 -31
  126. package/test-env/components/modal/modal.styles.js +36 -0
  127. package/test-env/components/modal/modal_body.js +10 -0
  128. package/test-env/components/modal/modal_body.styles.js +27 -0
  129. package/test-env/components/modal/modal_footer.js +8 -0
  130. package/test-env/components/modal/modal_footer.styles.js +26 -0
  131. package/test-env/components/modal/modal_header.js +8 -0
  132. package/test-env/components/modal/modal_header.styles.js +24 -0
  133. package/test-env/components/modal/modal_header_title.js +4 -1
  134. package/test-env/components/page_template/outer/page_outer.js +1 -1
  135. package/test-env/components/page_template/page_template.js +32 -10
  136. package/test-env/components/popover/popover.a11y.js +86 -0
  137. package/test-env/components/search_bar/query/default_syntax.js +2 -1
  138. package/test-env/components/tabs/tabs.a11y.js +98 -0
  139. package/test-env/components/tree_view/tree_view.a11y.js +80 -0
  140. package/test-env/global_styling/utility/animations.js +9 -3
  141. package/src/components/modal/_index.scss +0 -1
  142. package/src/components/modal/_modal.scss +0 -156
  143. package/src/themes/amsterdam/overrides/_modal.scss +0 -3
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+
11
+ var _react = _interopRequireWildcard(require("react"));
12
+
13
+ var _super_date_picker = require("./super_date_picker");
14
+
15
+ var _react2 = require("@emotion/react");
16
+
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+
21
+ /*
22
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
+ * or more contributor license agreements. Licensed under the Elastic License
24
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
25
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
26
+ * Side Public License, v 1.
27
+ */
28
+ /// <reference types="../../../../cypress/support"/>
29
+ var SuperDatePicker = function SuperDatePicker() {
30
+ var _useState = (0, _react.useState)(false),
31
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
32
+ isLoading = _useState2[0],
33
+ setIsLoading = _useState2[1];
34
+
35
+ var _useState3 = (0, _react.useState)(true),
36
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 1),
37
+ showUpdateButton = _useState4[0];
38
+
39
+ var _useState5 = (0, _react.useState)('now-30m'),
40
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
41
+ start = _useState6[0],
42
+ setStart = _useState6[1];
43
+
44
+ var _useState7 = (0, _react.useState)('now'),
45
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
46
+ end = _useState8[0],
47
+ setEnd = _useState8[1];
48
+
49
+ var _useState9 = (0, _react.useState)(true),
50
+ _useState10 = (0, _slicedToArray2.default)(_useState9, 1),
51
+ showFill = _useState10[0];
52
+
53
+ var onTimeChange = function onTimeChange(_ref) {
54
+ var start = _ref.start,
55
+ end = _ref.end;
56
+ setStart(start);
57
+ setEnd(end);
58
+ setIsLoading(true);
59
+ startLoading();
60
+ };
61
+
62
+ var startLoading = function startLoading() {
63
+ setTimeout(stopLoading, 1000);
64
+ };
65
+
66
+ var stopLoading = function stopLoading() {
67
+ setIsLoading(false);
68
+ };
69
+
70
+ var datepickerProps = {
71
+ isLoading: isLoading,
72
+ start: start,
73
+ end: end,
74
+ onTimeChange: onTimeChange,
75
+ showUpdateButton: showUpdateButton
76
+ };
77
+ return (0, _react2.jsx)(_super_date_picker.EuiSuperDatePicker, (0, _extends2.default)({}, datepickerProps, {
78
+ updateButtonProps: {
79
+ fill: showFill
80
+ }
81
+ }));
82
+ };
83
+
84
+ beforeEach(function () {
85
+ cy.mount((0, _react2.jsx)(SuperDatePicker, null));
86
+ cy.get('div.euiSuperDatePicker__flexWrapper').should('exist');
87
+ });
88
+ describe('EuiSuperDatePicker', function () {
89
+ describe('Automated accessibility check', function () {
90
+ it('has zero violations on render', function () {
91
+ cy.checkAxe();
92
+ });
93
+ it('has zero violations when quick select menu is open', function () {
94
+ cy.get('button.euiFormControlLayout__prepend').click();
95
+ cy.get('div.euiPanel').contains('Quick select').should('exist');
96
+ cy.checkAxe();
97
+ });
98
+ it('has zero violations when start / end date menus are open', function () {
99
+ cy.get('button.euiSuperDatePicker__prettyFormat').click();
100
+ cy.get('div.euiDatePopoverContent').should('exist');
101
+ cy.checkAxe();
102
+ cy.get('button.euiDatePopoverButton--start').click();
103
+ cy.get('button.euiDatePopoverButton--end').click();
104
+ cy.get('div.euiDatePopoverContent').should('exist');
105
+ cy.checkAxe();
106
+ cy.get('button.euiDatePopoverButton--end').click();
107
+ cy.get('div.euiDatePopoverContent').should('not.exist');
108
+ cy.checkAxe();
109
+ });
110
+ });
111
+ });
@@ -168,7 +168,7 @@ var euiFlexGroupStyles = function euiFlexGroupStyles(euiThemeContext) {
168
168
  var euiTheme = euiThemeContext.euiTheme;
169
169
  return {
170
170
  euiFlexGroup: _ref17,
171
- responsive: /*#__PURE__*/(0, _react.css)((0, _global_styling.euiBreakpoint)(euiThemeContext, ['xs', 's']), "{flex-wrap:wrap;.euiFlexItem{", (0, _global_styling.logicalCSS)('width', '100%'), " flex-basis:100%;}};label:responsive;"),
171
+ responsive: /*#__PURE__*/(0, _react.css)((0, _global_styling.euiBreakpoint)(euiThemeContext, ['xs', 's']), "{flex-wrap:wrap;&>.euiFlexItem{", (0, _global_styling.logicalCSS)('width', '100%'), " flex-basis:100%;}};label:responsive;"),
172
172
  wrap: _ref16,
173
173
  gutterSizes: {
174
174
  none: /*#__PURE__*/(0, _react.css)(";label:none;"),
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+
11
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
+
13
+ var _react = _interopRequireWildcard(require("react"));
14
+
15
+ var _flyout = require("./flyout");
16
+
17
+ var _button = require("../button");
18
+
19
+ var _react2 = require("@emotion/react");
20
+
21
+ var _excluded = ["children"];
22
+
23
+ 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); }
24
+
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+
27
+ var childrenDefault = (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("button", {
28
+ "data-test-subj": "itemA"
29
+ }, "Item A"), (0, _react2.jsx)("button", {
30
+ "data-test-subj": "itemB"
31
+ }, "Item B"), (0, _react2.jsx)("button", {
32
+ "data-test-subj": "itemC"
33
+ }, "Item C"), (0, _react2.jsx)("input", {
34
+ "data-test-subj": "itemD"
35
+ }));
36
+
37
+ var Flyout = function Flyout(_ref) {
38
+ var _ref$children = _ref.children,
39
+ children = _ref$children === void 0 ? childrenDefault : _ref$children,
40
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
41
+
42
+ var _useState = (0, _react.useState)(false),
43
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
44
+ isOpen = _useState2[0],
45
+ setIsOpen = _useState2[1];
46
+
47
+ var onButtonClick = function onButtonClick() {
48
+ return setIsOpen(!isOpen);
49
+ };
50
+
51
+ var button = (0, _react2.jsx)(_button.EuiButtonEmpty, {
52
+ onClick: onButtonClick
53
+ }, "Toggle flyout");
54
+ return (0, _react2.jsx)("div", null, button, isOpen ? (0, _react2.jsx)(_flyout.EuiFlyout, (0, _extends2.default)({
55
+ "data-test-subj": "flyoutSpec",
56
+ onClose: function onClose() {
57
+ return setIsOpen(false);
58
+ }
59
+ }, rest), children) : null);
60
+ };
61
+
62
+ beforeEach(function () {
63
+ cy.mount((0, _react2.jsx)(Flyout, null));
64
+ cy.get('div.euiFlyout').should('not.exist');
65
+ });
66
+ describe('EuiFlyout', function () {
67
+ describe('Automated accessibility check', function () {
68
+ it('has zero violations on render', function () {
69
+ cy.checkAxe();
70
+ });
71
+ it('has zero violations when flyout is opened', function () {
72
+ cy.get('button.euiButtonEmpty').click();
73
+ cy.get('div.euiFlyout').should('exist');
74
+ cy.checkAxe();
75
+ });
76
+ it('has zero violations when flyout is closed', function () {
77
+ cy.get('button.euiButtonEmpty').click();
78
+ cy.get('div.euiFlyout').should('exist');
79
+ cy.get('button.euiFlyout__closeButton').click();
80
+ cy.get('div.euiFlyout').should('not.exist');
81
+ cy.checkAxe();
82
+ });
83
+ });
84
+ });
@@ -1,32 +1,29 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.euiImageFullscreenWrapperStyles = void 0;
9
7
 
10
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
-
12
8
  var _react = require("@emotion/react");
13
9
 
14
10
  var _global_styling = require("../../global_styling");
15
11
 
16
- var _templateObject;
17
-
12
+ /*
13
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
14
+ * or more contributor license agreements. Licensed under the Elastic License
15
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
16
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
17
+ * Side Public License, v 1.
18
+ */
18
19
  var euiImageFullscreenWrapperStyles = function euiImageFullscreenWrapperStyles(euiThemeContext) {
19
20
  var euiTheme = euiThemeContext.euiTheme;
20
21
  return {
21
22
  // Base
22
- euiImageFullscreenWrapper: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('max-height', '80vh'), ";", (0, _global_styling.logicalCSS)('max-width', '80vw'), ";", (0, _global_styling.logicalTextAlignCSS)('center'), ";line-height:0;", _global_styling.euiCanAnimate, "{animation:", euiImageFullScreen(euiTheme.size.xxxxl), " ", euiTheme.animation.extraSlow, " ", euiTheme.animation.bounce, ";}&:hover [class*='euiImageCaption']{text-decoration:underline;};label:euiImageFullscreenWrapper;"),
23
+ euiImageFullscreenWrapper: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('max-height', '80vh'), ";", (0, _global_styling.logicalCSS)('max-width', '80vw'), ";", (0, _global_styling.logicalTextAlignCSS)('center'), ";line-height:0;", _global_styling.euiCanAnimate, "{animation:", (0, _global_styling.euiAnimSlideInUp)(euiTheme.size.xxxxl), " ", euiTheme.animation.extraSlow, " ", euiTheme.animation.bounce, ";}&:hover [class*='euiImageCaption']{text-decoration:underline;};label:euiImageFullscreenWrapper;"),
23
24
  // Sizes
24
25
  fullWidth: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('width', '100%'), ";;label:fullWidth;")
25
26
  };
26
27
  };
27
28
 
28
- exports.euiImageFullscreenWrapperStyles = euiImageFullscreenWrapperStyles;
29
-
30
- var euiImageFullScreen = function euiImageFullScreen(size) {
31
- return (0, _react.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n 0% {\n opacity: 0;\n transform: translateY(", ");\n }\n\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])), size);
32
- };
29
+ exports.euiImageFullscreenWrapperStyles = euiImageFullscreenWrapperStyles;
@@ -31,6 +31,10 @@ var _modal_header_title = require("./modal_header_title");
31
31
 
32
32
  var _modal_body = require("./modal_body");
33
33
 
34
+ var _services = require("../../services");
35
+
36
+ var _modal2 = require("./modal.styles");
37
+
34
38
  var _button = require("../button");
35
39
 
36
40
  var _text = require("../text");
@@ -96,6 +100,9 @@ var EuiConfirmModal = function EuiConfirmModal(_ref) {
96
100
  };
97
101
 
98
102
  var classes = (0, _classnames.default)('euiModal--confirmation', className);
103
+ var euiTheme = (0, _services.useEuiTheme)();
104
+ var styles = (0, _modal2.euiModalStyles)(euiTheme);
105
+ var cssStyles = [styles.confirmation];
99
106
  var modalTitle;
100
107
 
101
108
  if (title) {
@@ -114,6 +121,7 @@ var EuiConfirmModal = function EuiConfirmModal(_ref) {
114
121
 
115
122
  return (0, _react2.jsx)(_modal.EuiModal, (0, _extends2.default)({
116
123
  className: classes,
124
+ css: cssStyles,
117
125
  onClose: onCancel
118
126
  }, rest), modalTitle, message && (0, _react2.jsx)(_modal_body.EuiModalBody, null, (0, _react2.jsx)(_text.EuiText, {
119
127
  "data-test-subj": "confirmModalBodyText"
@@ -145,6 +153,11 @@ EuiConfirmModal.propTypes = {
145
153
  onConfirm: _propTypes.default.func,
146
154
  confirmButtonDisabled: _propTypes.default.bool,
147
155
  className: _propTypes.default.string,
156
+
157
+ /**
158
+ * Allows focusing either the confirm or cancel button on modal initialization.
159
+ * Will take precedence over `initialFocus`, if `initialFocus` is passed.
160
+ */
148
161
  defaultFocusedButton: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.any.isRequired]),
149
162
  buttonColor: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.oneOf(["ghost"])]),
150
163
  // For docs only, will get passed with ...rest
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
+
9
+ var _react = _interopRequireWildcard(require("react"));
10
+
11
+ var _index = require("./index");
12
+
13
+ var _button = require("../button");
14
+
15
+ var _react2 = require("@emotion/react");
16
+
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+
21
+ /*
22
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
+ * or more contributor license agreements. Licensed under the Elastic License
24
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
25
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
26
+ * Side Public License, v 1.
27
+ */
28
+ /// <reference types="../../../cypress/support"/>
29
+ var Modal = function Modal() {
30
+ var _useState = (0, _react.useState)(false),
31
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
32
+ isModalVisible = _useState2[0],
33
+ setIsModalVisible = _useState2[1];
34
+
35
+ var closeModal = function closeModal() {
36
+ return setIsModalVisible(false);
37
+ };
38
+
39
+ var showModal = function showModal() {
40
+ return setIsModalVisible(true);
41
+ };
42
+
43
+ var modalProps = {
44
+ title: 'Do this thing',
45
+ onClose: closeModal,
46
+ children: _react.default
47
+ };
48
+ return (0, _react2.jsx)("div", null, (0, _react2.jsx)(_button.EuiButton, {
49
+ onClick: showModal
50
+ }, "Show confirm modal"), isModalVisible && (0, _react2.jsx)(_index.EuiModal, modalProps, (0, _react2.jsx)(_index.EuiModalHeader, null, (0, _react2.jsx)(_index.EuiModalHeaderTitle, null, (0, _react2.jsx)("h1", null, "Title of modal"))), (0, _react2.jsx)(_index.EuiModalBody, null, (0, _react2.jsx)("p", null, "This is a simple modal body")), (0, _react2.jsx)(_index.EuiModalFooter, null, (0, _react2.jsx)(_button.EuiButton, {
51
+ onClick: closeModal,
52
+ fill: true
53
+ }, "Close"))));
54
+ };
55
+
56
+ beforeEach(function () {
57
+ cy.mount((0, _react2.jsx)(Modal, null));
58
+ cy.get('div.euiModal').should('not.exist');
59
+ cy.get('button.euiButton').click();
60
+ cy.get('div.euiModal').should('exist');
61
+ });
62
+ describe('EuiModal', function () {
63
+ describe('Automated accessibility check', function () {
64
+ it('has zero violations when modal is open', function () {
65
+ cy.checkAxe();
66
+ });
67
+ it('has zero violations when modal is closed', function () {
68
+ cy.get('div.euiModalFooter button.euiButton').click();
69
+ cy.get('div.euiModal').should('not.exist');
70
+ cy.checkAxe();
71
+ });
72
+ });
73
+ });
@@ -2,8 +2,6 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
@@ -15,7 +13,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
13
 
16
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
15
 
18
- var _react = _interopRequireWildcard(require("react"));
16
+ var _react = _interopRequireDefault(require("react"));
19
17
 
20
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
21
19
 
@@ -31,14 +29,12 @@ var _overlay_mask = require("../overlay_mask");
31
29
 
32
30
  var _i18n = require("../i18n");
33
31
 
32
+ var _modal = require("./modal.styles");
33
+
34
34
  var _react2 = require("@emotion/react");
35
35
 
36
36
  var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "style"];
37
37
 
38
- 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); }
39
-
40
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
-
42
38
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
43
39
 
44
40
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -52,18 +48,6 @@ var EuiModal = function EuiModal(_ref) {
52
48
  maxWidth = _ref$maxWidth === void 0 ? true : _ref$maxWidth,
53
49
  style = _ref.style,
54
50
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
55
- // TODO: Remove this onFocus scroll workaround after react-focus-on supports focusOptions
56
- // @see https://github.com/elastic/eui/issues/6304
57
- var bodyScrollTop = (0, _react.useRef)(typeof window === 'undefined' ? undefined : window.scrollY // Account for SSR
58
- );
59
- var onFocus = (0, _react.useCallback)(function () {
60
- if (bodyScrollTop.current != null) {
61
- window.scrollTo({
62
- top: bodyScrollTop.current
63
- });
64
- bodyScrollTop.current = undefined; // Unset after first auto focus
65
- }
66
- }, []);
67
51
 
68
52
  var onKeyDown = function onKeyDown(event) {
69
53
  if (event.key === _services.keys.ESCAPE) {
@@ -73,28 +57,29 @@ var EuiModal = function EuiModal(_ref) {
73
57
  }
74
58
  };
75
59
 
76
- var newStyle;
77
- var widthClassName;
60
+ var newStyle = style;
78
61
 
79
- if (maxWidth === true) {
80
- widthClassName = 'euiModal--maxWidth-default';
81
- } else if (maxWidth !== false) {
82
- var value = typeof maxWidth === 'number' ? "".concat(maxWidth, "px") : maxWidth;
83
- newStyle = _objectSpread(_objectSpread({}, style), {}, {
84
- maxWidth: value
62
+ if (typeof maxWidth !== 'boolean') {
63
+ newStyle = _objectSpread(_objectSpread({}, newStyle), {}, {
64
+ maxInlineSize: maxWidth
85
65
  });
86
66
  }
87
67
 
88
- var classes = (0, _classnames.default)('euiModal', widthClassName, className);
68
+ var classes = (0, _classnames.default)('euiModal', className);
69
+ var euiTheme = (0, _services.useEuiTheme)();
70
+ var styles = (0, _modal.euiModalStyles)(euiTheme);
71
+ var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
72
+ var cssCloseIconStyles = [styles.euiModal__closeIcon];
89
73
  return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
90
74
  initialFocus: initialFocus,
91
- scrollLock: true
75
+ scrollLock: true,
76
+ preventScrollOnFocus: true
92
77
  }, (0, _react2.jsx)("div", (0, _extends2.default)({
78
+ css: cssStyles,
93
79
  className: classes,
94
80
  onKeyDown: onKeyDown,
95
81
  tabIndex: 0,
96
- onFocus: onFocus,
97
- style: newStyle || style
82
+ style: newStyle
98
83
  }, rest), (0, _react2.jsx)(_i18n.EuiI18n, {
99
84
  token: "euiModal.closeModal",
100
85
  default: "Closes this modal window"
@@ -102,6 +87,7 @@ var EuiModal = function EuiModal(_ref) {
102
87
  return (0, _react2.jsx)(_button.EuiButtonIcon, {
103
88
  iconType: "cross",
104
89
  onClick: onClose,
90
+ css: cssCloseIconStyles,
105
91
  className: "euiModal__closeIcon",
106
92
  color: "text",
107
93
  "aria-label": closeModal
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.euiModalStyles = void 0;
7
+
8
+ var _react = require("@emotion/react");
9
+
10
+ var _mixins = require("../../themes/amsterdam/global_styling/mixins");
11
+
12
+ var _global_styling = require("../../global_styling");
13
+
14
+ var _form = require("../form/form.styles");
15
+
16
+ /*
17
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
18
+ * or more contributor license agreements. Licensed under the Elastic License
19
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
20
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
21
+ * Side Public License, v 1.
22
+ */
23
+ var euiModalStyles = function euiModalStyles(euiThemeContext) {
24
+ var euiTheme = euiThemeContext.euiTheme;
25
+ return {
26
+ euiModal: /*#__PURE__*/(0, _react.css)((0, _mixins.euiShadowXLarge)(euiThemeContext), " display:flex;flex-direction:column;max-block-size:75vh;position:relative;background-color:", euiTheme.colors.emptyShade, ";border-radius:", euiTheme.border.radius.medium, ";z-index:", euiTheme.levels.modal, ";min-inline-size:", (0, _form.euiFormVariables)(euiThemeContext).maxWidth, ";max-inline-size:calc(100vw - ", euiTheme.size.base, ");", _global_styling.euiCanAnimate, "{animation:", (0, _global_styling.euiAnimSlideInUp)(euiTheme.size.xxl), " ", euiTheme.animation.slow, " ", euiTheme.animation.bounce, ";}", (0, _global_styling.euiBreakpoint)(euiThemeContext, ['xs', 's']), "{position:fixed;inset:0;border-radius:0;inline-size:100vw!important;min-inline-size:0!important;max-inline-size:none!important;max-block-size:100vh!important;}&:focus{outline:none;};label:euiModal;"),
27
+ // Variants
28
+ defaultMaxWidth: /*#__PURE__*/(0, _react.css)("max-inline-size:min(\n ", euiTheme.breakpoint.m, "px,\n calc(100vw - ", euiTheme.size.base, ")\n );;label:defaultMaxWidth;"),
29
+ confirmation: /*#__PURE__*/(0, _react.css)("min-inline-size:", (0, _form.euiFormVariables)(euiThemeContext).maxWidth, ";", (0, _global_styling.euiBreakpoint)(euiThemeContext, ['xs', 's']), "{", (0, _mixins.euiShadowXLarge)(euiThemeContext, {
30
+ reverse: true
31
+ }), " inset-block-start:auto;};label:confirmation;"),
32
+ euiModal__closeIcon: /*#__PURE__*/(0, _react.css)("position:absolute;inset-inline-end:", euiTheme.size.xs, ";inset-block-start:", euiTheme.size.xs, ";z-index:3;;label:euiModal__closeIcon;")
33
+ };
34
+ };
35
+
36
+ exports.euiModalStyles = euiModalStyles;
@@ -17,6 +17,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
+ var _services = require("../../services");
21
+
22
+ var _modal_body = require("./modal_body.styles");
23
+
20
24
  var _react2 = require("@emotion/react");
21
25
 
22
26
  var _excluded = ["className", "children"];
@@ -26,9 +30,15 @@ var EuiModalBody = function EuiModalBody(_ref) {
26
30
  children = _ref.children,
27
31
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
28
32
  var classes = (0, _classnames.default)('euiModalBody', className);
33
+ var euiTheme = (0, _services.useEuiTheme)();
34
+ var styles = (0, _modal_body.euiModalBodyStyles)(euiTheme);
35
+ var cssStyles = [styles.euiModalBody];
36
+ var cssOverflowStyles = [styles.euiModalBody__overflow];
29
37
  return (0, _react2.jsx)("div", (0, _extends2.default)({
38
+ css: cssStyles,
30
39
  className: classes
31
40
  }, rest), (0, _react2.jsx)("div", {
41
+ css: cssOverflowStyles,
32
42
  className: "euiModalBody__overflow"
33
43
  }, children));
34
44
  };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.euiModalBodyStyles = void 0;
7
+
8
+ var _react = require("@emotion/react");
9
+
10
+ var _global_styling = require("../../global_styling");
11
+
12
+ /*
13
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
14
+ * or more contributor license agreements. Licensed under the Elastic License
15
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
16
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
17
+ * Side Public License, v 1.
18
+ */
19
+ var euiModalBodyStyles = function euiModalBodyStyles(euiThemeContext) {
20
+ var euiTheme = euiThemeContext.euiTheme;
21
+ return {
22
+ euiModalBody: /*#__PURE__*/(0, _react.css)("flex-grow:1;overflow:hidden;display:flex;flex-direction:column;&:last-of-type .euiModalBody__overflow{padding-block-end:", euiTheme.size.l, ";};label:euiModalBody;"),
23
+ euiModalBody__overflow: /*#__PURE__*/(0, _react.css)((0, _global_styling.euiYScrollWithShadows)(euiThemeContext), ";padding-inline:", euiTheme.size.l, ";padding-block:", euiTheme.size.s, ";", (0, _global_styling.euiBreakpoint)(euiThemeContext, ['xs', 's']), "{padding-block-end:", euiTheme.size.l, ";};label:euiModalBody__overflow;")
24
+ };
25
+ };
26
+
27
+ exports.euiModalBodyStyles = euiModalBodyStyles;
@@ -17,6 +17,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
+ var _services = require("../../services");
21
+
22
+ var _modal_footer = require("./modal_footer.styles");
23
+
20
24
  var _react2 = require("@emotion/react");
21
25
 
22
26
  var _excluded = ["className", "children"];
@@ -26,7 +30,11 @@ var EuiModalFooter = function EuiModalFooter(_ref) {
26
30
  children = _ref.children,
27
31
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
28
32
  var classes = (0, _classnames.default)('euiModalFooter', className);
33
+ var euiTheme = (0, _services.useEuiTheme)();
34
+ var styles = (0, _modal_footer.euiModalFooterStyles)(euiTheme);
35
+ var cssStyles = [styles.euiModalFooter];
29
36
  return (0, _react2.jsx)("div", (0, _extends2.default)({
37
+ css: cssStyles,
30
38
  className: classes
31
39
  }, rest), children);
32
40
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.euiModalFooterStyles = void 0;
7
+
8
+ var _react = require("@emotion/react");
9
+
10
+ var _global_styling = require("../../global_styling");
11
+
12
+ /*
13
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
14
+ * or more contributor license agreements. Licensed under the Elastic License
15
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
16
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
17
+ * Side Public License, v 1.
18
+ */
19
+ var euiModalFooterStyles = function euiModalFooterStyles(euiThemeContext) {
20
+ var euiTheme = euiThemeContext.euiTheme;
21
+ return {
22
+ euiModalFooter: /*#__PURE__*/(0, _react.css)("display:flex;justify-content:flex-end;padding-block:", euiTheme.size.base, " ", euiTheme.size.l, ";padding-inline:", euiTheme.size.l, ";flex-grow:0;flex-shrink:0;gap:", euiTheme.size.base, ";", (0, _global_styling.euiBreakpoint)(euiThemeContext, ['xs', 's']), "{background:", euiTheme.colors.lightestShade, ";padding-block:", euiTheme.size.m, ";padding-inline:", euiTheme.size.l, ";justify-content:stretch;gap:", euiTheme.size.s, ";>*{flex:1;}};label:euiModalFooter;")
23
+ };
24
+ };
25
+
26
+ exports.euiModalFooterStyles = euiModalFooterStyles;
@@ -17,6 +17,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
+ var _services = require("../../services");
21
+
22
+ var _modal_header = require("./modal_header.styles");
23
+
20
24
  var _react2 = require("@emotion/react");
21
25
 
22
26
  var _excluded = ["className", "children"];
@@ -26,7 +30,11 @@ var EuiModalHeader = function EuiModalHeader(_ref) {
26
30
  children = _ref.children,
27
31
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
28
32
  var classes = (0, _classnames.default)('euiModalHeader', className);
33
+ var euiTheme = (0, _services.useEuiTheme)();
34
+ var styles = (0, _modal_header.euiModalHeaderStyles)(euiTheme);
35
+ var cssStyles = [styles.euiModalHeader];
29
36
  return (0, _react2.jsx)("div", (0, _extends2.default)({
37
+ css: cssStyles,
30
38
  className: classes
31
39
  }, rest), children);
32
40
  };