@elastic/eui 70.2.4 → 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 (138) 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/flyout/flyout.a11y.js +92 -0
  12. package/es/components/image/image_fullscreen_wrapper.styles.js +3 -11
  13. package/es/components/modal/confirm_modal.js +11 -0
  14. package/es/components/modal/modal.a11y.js +70 -0
  15. package/es/components/modal/modal.js +17 -27
  16. package/es/components/modal/modal.styles.js +23 -0
  17. package/es/components/modal/modal_body.js +8 -0
  18. package/es/components/modal/modal_body.styles.js +16 -0
  19. package/es/components/modal/modal_footer.js +6 -0
  20. package/es/components/modal/modal_footer.styles.js +15 -0
  21. package/es/components/modal/modal_header.js +6 -0
  22. package/es/components/modal/modal_header.styles.js +14 -0
  23. package/es/components/modal/modal_header_title.js +3 -1
  24. package/es/components/page_template/outer/page_outer.js +1 -1
  25. package/es/components/page_template/page_template.js +28 -6
  26. package/es/components/popover/popover.a11y.js +83 -0
  27. package/es/components/search_bar/query/default_syntax.js +2 -1
  28. package/es/components/tabs/tabs.a11y.js +97 -0
  29. package/es/components/tree_view/tree_view.a11y.js +74 -0
  30. package/es/global_styling/utility/animations.js +5 -2
  31. package/eui.d.ts +58 -7
  32. package/i18ntokens.json +2 -2
  33. package/lib/components/accessibility/skip_link/skip_link.js +6 -5
  34. package/lib/components/badge/beta_badge/beta_badge.js +13 -4
  35. package/lib/components/badge/beta_badge/beta_badge.styles.js +25 -4
  36. package/lib/components/card/card.js +6 -1
  37. package/lib/components/card/card.styles.js +4 -4
  38. package/lib/components/date_picker/super_date_picker/super_date_picker.a11y.js +111 -0
  39. package/lib/components/flyout/flyout.a11y.js +94 -0
  40. package/lib/components/image/image_fullscreen_wrapper.styles.js +9 -10
  41. package/lib/components/modal/confirm_modal.js +13 -0
  42. package/lib/components/modal/modal.a11y.js +73 -0
  43. package/lib/components/modal/modal.js +17 -32
  44. package/lib/components/modal/modal.styles.js +36 -0
  45. package/lib/components/modal/modal_body.js +10 -0
  46. package/lib/components/modal/modal_body.styles.js +27 -0
  47. package/lib/components/modal/modal_footer.js +8 -0
  48. package/lib/components/modal/modal_footer.styles.js +26 -0
  49. package/lib/components/modal/modal_header.js +8 -0
  50. package/lib/components/modal/modal_header.styles.js +24 -0
  51. package/lib/components/modal/modal_header_title.js +4 -1
  52. package/lib/components/page_template/outer/page_outer.js +1 -1
  53. package/lib/components/page_template/page_template.js +32 -10
  54. package/lib/components/popover/popover.a11y.js +86 -0
  55. package/lib/components/search_bar/query/default_syntax.js +2 -1
  56. package/lib/components/tabs/tabs.a11y.js +98 -0
  57. package/lib/components/tree_view/tree_view.a11y.js +80 -0
  58. package/lib/global_styling/utility/animations.js +9 -3
  59. package/optimize/es/components/accessibility/skip_link/skip_link.js +6 -5
  60. package/optimize/es/components/badge/beta_badge/beta_badge.js +5 -2
  61. package/optimize/es/components/badge/beta_badge/beta_badge.styles.js +25 -4
  62. package/optimize/es/components/card/card.styles.js +4 -4
  63. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.a11y.js +98 -0
  64. package/optimize/es/components/flyout/flyout.a11y.js +77 -0
  65. package/optimize/es/components/image/image_fullscreen_wrapper.styles.js +3 -11
  66. package/optimize/es/components/modal/confirm_modal.js +6 -0
  67. package/optimize/es/components/modal/modal.a11y.js +60 -0
  68. package/optimize/es/components/modal/modal.js +17 -27
  69. package/optimize/es/components/modal/modal.styles.js +23 -0
  70. package/optimize/es/components/modal/modal_body.js +8 -0
  71. package/optimize/es/components/modal/modal_body.styles.js +16 -0
  72. package/optimize/es/components/modal/modal_footer.js +6 -0
  73. package/optimize/es/components/modal/modal_footer.styles.js +15 -0
  74. package/optimize/es/components/modal/modal_header.js +6 -0
  75. package/optimize/es/components/modal/modal_header.styles.js +14 -0
  76. package/optimize/es/components/modal/modal_header_title.js +3 -1
  77. package/optimize/es/components/page_template/page_template.js +5 -3
  78. package/optimize/es/components/popover/popover.a11y.js +73 -0
  79. package/optimize/es/components/search_bar/query/default_syntax.js +2 -1
  80. package/optimize/es/components/tabs/tabs.a11y.js +97 -0
  81. package/optimize/es/components/tree_view/tree_view.a11y.js +74 -0
  82. package/optimize/es/global_styling/utility/animations.js +5 -2
  83. package/optimize/lib/components/accessibility/skip_link/skip_link.js +6 -5
  84. package/optimize/lib/components/badge/beta_badge/beta_badge.js +7 -3
  85. package/optimize/lib/components/badge/beta_badge/beta_badge.styles.js +25 -4
  86. package/optimize/lib/components/card/card.styles.js +4 -4
  87. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.a11y.js +111 -0
  88. package/optimize/lib/components/flyout/flyout.a11y.js +84 -0
  89. package/optimize/lib/components/image/image_fullscreen_wrapper.styles.js +9 -12
  90. package/optimize/lib/components/modal/confirm_modal.js +8 -0
  91. package/optimize/lib/components/modal/modal.a11y.js +73 -0
  92. package/optimize/lib/components/modal/modal.js +17 -31
  93. package/optimize/lib/components/modal/modal.styles.js +36 -0
  94. package/optimize/lib/components/modal/modal_body.js +10 -0
  95. package/optimize/lib/components/modal/modal_body.styles.js +27 -0
  96. package/optimize/lib/components/modal/modal_footer.js +8 -0
  97. package/optimize/lib/components/modal/modal_footer.styles.js +26 -0
  98. package/optimize/lib/components/modal/modal_header.js +8 -0
  99. package/optimize/lib/components/modal/modal_header.styles.js +24 -0
  100. package/optimize/lib/components/modal/modal_header_title.js +4 -1
  101. package/optimize/lib/components/page_template/page_template.js +5 -3
  102. package/optimize/lib/components/popover/popover.a11y.js +86 -0
  103. package/optimize/lib/components/search_bar/query/default_syntax.js +2 -1
  104. package/optimize/lib/components/tabs/tabs.a11y.js +98 -0
  105. package/optimize/lib/components/tree_view/tree_view.a11y.js +80 -0
  106. package/optimize/lib/global_styling/utility/animations.js +9 -3
  107. package/package.json +5 -4
  108. package/src/components/index.scss +0 -1
  109. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  110. package/test-env/components/accessibility/skip_link/skip_link.js +6 -5
  111. package/test-env/components/badge/beta_badge/beta_badge.js +13 -4
  112. package/test-env/components/badge/beta_badge/beta_badge.styles.js +25 -4
  113. package/test-env/components/card/card.js +6 -1
  114. package/test-env/components/card/card.styles.js +4 -4
  115. package/test-env/components/date_picker/super_date_picker/super_date_picker.a11y.js +111 -0
  116. package/test-env/components/flyout/flyout.a11y.js +84 -0
  117. package/test-env/components/image/image_fullscreen_wrapper.styles.js +9 -12
  118. package/test-env/components/modal/confirm_modal.js +13 -0
  119. package/test-env/components/modal/modal.a11y.js +73 -0
  120. package/test-env/components/modal/modal.js +17 -31
  121. package/test-env/components/modal/modal.styles.js +36 -0
  122. package/test-env/components/modal/modal_body.js +10 -0
  123. package/test-env/components/modal/modal_body.styles.js +27 -0
  124. package/test-env/components/modal/modal_footer.js +8 -0
  125. package/test-env/components/modal/modal_footer.styles.js +26 -0
  126. package/test-env/components/modal/modal_header.js +8 -0
  127. package/test-env/components/modal/modal_header.styles.js +24 -0
  128. package/test-env/components/modal/modal_header_title.js +4 -1
  129. package/test-env/components/page_template/outer/page_outer.js +1 -1
  130. package/test-env/components/page_template/page_template.js +32 -10
  131. package/test-env/components/popover/popover.a11y.js +86 -0
  132. package/test-env/components/search_bar/query/default_syntax.js +2 -1
  133. package/test-env/components/tabs/tabs.a11y.js +98 -0
  134. package/test-env/components/tree_view/tree_view.a11y.js +80 -0
  135. package/test-env/global_styling/utility/animations.js +9 -3
  136. package/src/components/modal/_index.scss +0 -1
  137. package/src/components/modal/_modal.scss +0 -156
  138. package/src/themes/amsterdam/overrides/_modal.scss +0 -3
@@ -1,7 +1,7 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["className", "label", "color", "tooltipContent", "tooltipPosition", "anchorProps", "title", "iconType", "onClick", "onClickAriaLabel", "href", "rel", "target", "size"];
4
+ var _excluded = ["className", "label", "color", "tooltipContent", "tooltipPosition", "anchorProps", "title", "iconType", "onClick", "onClickAriaLabel", "href", "rel", "target", "size", "alignment"];
5
5
 
6
6
  /*
7
7
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -19,6 +19,7 @@ import { euiBetaBadgeStyles } from './beta_badge.styles';
19
19
  import { jsx as ___EmotionJSX } from "@emotion/react";
20
20
  export var COLORS = ['accent', 'subdued', 'hollow'];
21
21
  export var SIZES = ['s', 'm'];
22
+ export var ALIGNMENTS = ['baseline', 'middle'];
22
23
  export var EuiBetaBadge = function EuiBetaBadge(_ref) {
23
24
  var className = _ref.className,
24
25
  label = _ref.label,
@@ -37,6 +38,8 @@ export var EuiBetaBadge = function EuiBetaBadge(_ref) {
37
38
  target = _ref.target,
38
39
  _ref$size = _ref.size,
39
40
  size = _ref$size === void 0 ? 'm' : _ref$size,
41
+ _ref$alignment = _ref.alignment,
42
+ alignment = _ref$alignment === void 0 ? 'baseline' : _ref$alignment,
40
43
  rest = _objectWithoutProperties(_ref, _excluded);
41
44
 
42
45
  var euiTheme = useEuiTheme();
@@ -44,7 +47,7 @@ export var EuiBetaBadge = function EuiBetaBadge(_ref) {
44
47
  var isCircular = iconType || singleLetter;
45
48
  var classes = classNames('euiBetaBadge', className);
46
49
  var styles = euiBetaBadgeStyles(euiTheme);
47
- var cssStyles = [styles.euiBetaBadge, styles[color], styles[size], isCircular ? styles.badgeSizes.circle[size] : styles.badgeSizes.default[size]];
50
+ var cssStyles = [styles.euiBetaBadge, styles[color], styles[size], styles[alignment], isCircular ? styles.badgeSizes.circle[size] : styles.badgeSizes.default[size]];
48
51
  var icon;
49
52
 
50
53
  if (iconType) {
@@ -14,6 +14,24 @@ import { logicalCSS, euiFocusRing, euiFontSizeFromScale, euiTextTruncate, mathWi
14
14
  import { tint, isColorDark, hexToRgb } from '../../../services';
15
15
 
16
16
  var _ref = process.env.NODE_ENV === "production" ? {
17
+ name: "l1nme7-middle",
18
+ styles: "vertical-align:middle;label:middle;"
19
+ } : {
20
+ name: "l1nme7-middle",
21
+ styles: "vertical-align:middle;label:middle;",
22
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
23
+ };
24
+
25
+ var _ref2 = process.env.NODE_ENV === "production" ? {
26
+ name: "19hexhy-baseline",
27
+ styles: "vertical-align:baseline;label:baseline;"
28
+ } : {
29
+ name: "19hexhy-baseline",
30
+ styles: "vertical-align:baseline;label:baseline;",
31
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
32
+ };
33
+
34
+ var _ref3 = process.env.NODE_ENV === "production" ? {
17
35
  name: "pzpqqg-euiBetaBadge__icon",
18
36
  styles: "position:relative;transform:translate(0, -1px);label:euiBetaBadge__icon;"
19
37
  } : {
@@ -26,7 +44,7 @@ export var euiBetaBadgeStyles = function euiBetaBadgeStyles(euiThemeContext) {
26
44
  var euiTheme = euiThemeContext.euiTheme,
27
45
  colorMode = euiThemeContext.colorMode;
28
46
  return {
29
- euiBetaBadge: /*#__PURE__*/css("display:inline-block;vertical-align:super;border-radius:", euiTheme.size.l, ";cursor:default;font-weight:", euiTheme.font.weight.bold, ";text-transform:uppercase;letter-spacing:0.05em;text-align:center;", euiTextTruncate(), " &:focus{", euiFocusRing(euiThemeContext, 'outset', {
47
+ euiBetaBadge: /*#__PURE__*/css("display:inline-block;border-radius:", euiTheme.size.l, ";cursor:default;font-weight:", euiTheme.font.weight.bold, ";text-transform:uppercase;letter-spacing:0.05em;text-align:center;", euiTextTruncate(), " &:focus{", euiFocusRing(euiThemeContext, 'outset', {
30
48
  color: colorMode === 'DARK' ? euiTheme.colors.ghost : euiTheme.colors.ink
31
49
  }), ";};label:euiBetaBadge;"),
32
50
  // Colors
@@ -52,12 +70,15 @@ export var euiBetaBadgeStyles = function euiBetaBadgeStyles(euiThemeContext) {
52
70
  })), "\n ")
53
71
  }
54
72
  },
55
- euiBetaBadge__icon: _ref
73
+ euiBetaBadge__icon: _ref3,
74
+ // Alignments
75
+ baseline: _ref2,
76
+ middle: _ref
56
77
  };
57
78
  }; // Util for detecting text color based on badge bg color
58
79
 
59
- export var getBadgeColors = function getBadgeColors(backgroundColor, _ref2) {
60
- var euiTheme = _ref2.euiTheme;
80
+ export var getBadgeColors = function getBadgeColors(backgroundColor, _ref4) {
81
+ var euiTheme = _ref4.euiTheme;
61
82
  var textColor = isColorDark.apply(void 0, _toConsumableArray(hexToRgb(backgroundColor))) ? euiTheme.colors.ghost : euiTheme.colors.ink;
62
83
  return "\n background-color: ".concat(backgroundColor, ";\n color: ").concat(textColor, ";\n ");
63
84
  };
@@ -55,11 +55,11 @@ var _ref5 = process.env.NODE_ENV === "production" ? {
55
55
  };
56
56
 
57
57
  var _ref6 = process.env.NODE_ENV === "production" ? {
58
- name: "z24364-euiCard__main",
59
- styles: "display:flex;label:euiCard__main;"
58
+ name: "31kq8f-euiCard__main",
59
+ styles: "display:flex;inline-size:100%;label:euiCard__main;"
60
60
  } : {
61
- name: "z24364-euiCard__main",
62
- styles: "display:flex;label:euiCard__main;",
61
+ name: "31kq8f-euiCard__main",
62
+ styles: "display:flex;inline-size:100%;label:euiCard__main;",
63
63
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
64
64
  };
65
65
 
@@ -0,0 +1,98 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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
+ /// <reference types="../../../../cypress/support"/>
12
+ import React, { useState } from 'react';
13
+ import { EuiSuperDatePicker } from './super_date_picker';
14
+ import { jsx as ___EmotionJSX } from "@emotion/react";
15
+
16
+ var SuperDatePicker = function SuperDatePicker() {
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ isLoading = _useState2[0],
20
+ setIsLoading = _useState2[1];
21
+
22
+ var _useState3 = useState(true),
23
+ _useState4 = _slicedToArray(_useState3, 1),
24
+ showUpdateButton = _useState4[0];
25
+
26
+ var _useState5 = useState('now-30m'),
27
+ _useState6 = _slicedToArray(_useState5, 2),
28
+ start = _useState6[0],
29
+ setStart = _useState6[1];
30
+
31
+ var _useState7 = useState('now'),
32
+ _useState8 = _slicedToArray(_useState7, 2),
33
+ end = _useState8[0],
34
+ setEnd = _useState8[1];
35
+
36
+ var _useState9 = useState(true),
37
+ _useState10 = _slicedToArray(_useState9, 1),
38
+ showFill = _useState10[0];
39
+
40
+ var onTimeChange = function onTimeChange(_ref) {
41
+ var start = _ref.start,
42
+ end = _ref.end;
43
+ setStart(start);
44
+ setEnd(end);
45
+ setIsLoading(true);
46
+ startLoading();
47
+ };
48
+
49
+ var startLoading = function startLoading() {
50
+ setTimeout(stopLoading, 1000);
51
+ };
52
+
53
+ var stopLoading = function stopLoading() {
54
+ setIsLoading(false);
55
+ };
56
+
57
+ var datepickerProps = {
58
+ isLoading: isLoading,
59
+ start: start,
60
+ end: end,
61
+ onTimeChange: onTimeChange,
62
+ showUpdateButton: showUpdateButton
63
+ };
64
+ return ___EmotionJSX(EuiSuperDatePicker, _extends({}, datepickerProps, {
65
+ updateButtonProps: {
66
+ fill: showFill
67
+ }
68
+ }));
69
+ };
70
+
71
+ beforeEach(function () {
72
+ cy.mount(___EmotionJSX(SuperDatePicker, null));
73
+ cy.get('div.euiSuperDatePicker__flexWrapper').should('exist');
74
+ });
75
+ describe('EuiSuperDatePicker', function () {
76
+ describe('Automated accessibility check', function () {
77
+ it('has zero violations on render', function () {
78
+ cy.checkAxe();
79
+ });
80
+ it('has zero violations when quick select menu is open', function () {
81
+ cy.get('button.euiFormControlLayout__prepend').click();
82
+ cy.get('div.euiPanel').contains('Quick select').should('exist');
83
+ cy.checkAxe();
84
+ });
85
+ it('has zero violations when start / end date menus are open', function () {
86
+ cy.get('button.euiSuperDatePicker__prettyFormat').click();
87
+ cy.get('div.euiDatePopoverContent').should('exist');
88
+ cy.checkAxe();
89
+ cy.get('button.euiDatePopoverButton--start').click();
90
+ cy.get('button.euiDatePopoverButton--end').click();
91
+ cy.get('div.euiDatePopoverContent').should('exist');
92
+ cy.checkAxe();
93
+ cy.get('button.euiDatePopoverButton--end').click();
94
+ cy.get('div.euiDatePopoverContent').should('not.exist');
95
+ cy.checkAxe();
96
+ });
97
+ });
98
+ });
@@ -0,0 +1,77 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["children"];
5
+
6
+ /*
7
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
8
+ * or more contributor license agreements. Licensed under the Elastic License
9
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
10
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
11
+ * Side Public License, v 1.
12
+ */
13
+ /// <reference types="../../../cypress/support"/>
14
+ import React, { useState } from 'react';
15
+ import { EuiFlyout } from './flyout';
16
+ import { EuiButtonEmpty } from '../button';
17
+ import { jsx as ___EmotionJSX } from "@emotion/react";
18
+
19
+ var childrenDefault = ___EmotionJSX(React.Fragment, null, ___EmotionJSX("button", {
20
+ "data-test-subj": "itemA"
21
+ }, "Item A"), ___EmotionJSX("button", {
22
+ "data-test-subj": "itemB"
23
+ }, "Item B"), ___EmotionJSX("button", {
24
+ "data-test-subj": "itemC"
25
+ }, "Item C"), ___EmotionJSX("input", {
26
+ "data-test-subj": "itemD"
27
+ }));
28
+
29
+ var Flyout = function Flyout(_ref) {
30
+ var _ref$children = _ref.children,
31
+ children = _ref$children === void 0 ? childrenDefault : _ref$children,
32
+ rest = _objectWithoutProperties(_ref, _excluded);
33
+
34
+ var _useState = useState(false),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ isOpen = _useState2[0],
37
+ setIsOpen = _useState2[1];
38
+
39
+ var onButtonClick = function onButtonClick() {
40
+ return setIsOpen(!isOpen);
41
+ };
42
+
43
+ var button = ___EmotionJSX(EuiButtonEmpty, {
44
+ onClick: onButtonClick
45
+ }, "Toggle flyout");
46
+
47
+ return ___EmotionJSX("div", null, button, isOpen ? ___EmotionJSX(EuiFlyout, _extends({
48
+ "data-test-subj": "flyoutSpec",
49
+ onClose: function onClose() {
50
+ return setIsOpen(false);
51
+ }
52
+ }, rest), children) : null);
53
+ };
54
+
55
+ beforeEach(function () {
56
+ cy.mount(___EmotionJSX(Flyout, null));
57
+ cy.get('div.euiFlyout').should('not.exist');
58
+ });
59
+ describe('EuiFlyout', function () {
60
+ describe('Automated accessibility check', function () {
61
+ it('has zero violations on render', function () {
62
+ cy.checkAxe();
63
+ });
64
+ it('has zero violations when flyout is opened', function () {
65
+ cy.get('button.euiButtonEmpty').click();
66
+ cy.get('div.euiFlyout').should('exist');
67
+ cy.checkAxe();
68
+ });
69
+ it('has zero violations when flyout is closed', function () {
70
+ cy.get('button.euiButtonEmpty').click();
71
+ cy.get('div.euiFlyout').should('exist');
72
+ cy.get('button.euiFlyout__closeButton').click();
73
+ cy.get('div.euiFlyout').should('not.exist');
74
+ cy.checkAxe();
75
+ });
76
+ });
77
+ });
@@ -1,7 +1,3 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
- var _templateObject;
4
-
5
1
  /*
6
2
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
3
  * or more contributor license agreements. Licensed under the Elastic License
@@ -9,18 +5,14 @@ var _templateObject;
9
5
  * in compliance with, at your election, the Elastic License 2.0 or the Server
10
6
  * Side Public License, v 1.
11
7
  */
12
- import { css, keyframes } from '@emotion/react';
13
- import { logicalCSS, logicalTextAlignCSS, euiCanAnimate } from '../../global_styling';
8
+ import { css } from '@emotion/react';
9
+ import { logicalCSS, logicalTextAlignCSS, euiCanAnimate, euiAnimSlideInUp } from '../../global_styling';
14
10
  export var euiImageFullscreenWrapperStyles = function euiImageFullscreenWrapperStyles(euiThemeContext) {
15
11
  var euiTheme = euiThemeContext.euiTheme;
16
12
  return {
17
13
  // Base
18
- euiImageFullscreenWrapper: /*#__PURE__*/css(logicalCSS('max-height', '80vh'), ";", logicalCSS('max-width', '80vw'), ";", logicalTextAlignCSS('center'), ";line-height:0;", euiCanAnimate, "{animation:", euiImageFullScreen(euiTheme.size.xxxxl), " ", euiTheme.animation.extraSlow, " ", euiTheme.animation.bounce, ";}&:hover [class*='euiImageCaption']{text-decoration:underline;};label:euiImageFullscreenWrapper;"),
14
+ euiImageFullscreenWrapper: /*#__PURE__*/css(logicalCSS('max-height', '80vh'), ";", logicalCSS('max-width', '80vw'), ";", logicalTextAlignCSS('center'), ";line-height:0;", euiCanAnimate, "{animation:", euiAnimSlideInUp(euiTheme.size.xxxxl), " ", euiTheme.animation.extraSlow, " ", euiTheme.animation.bounce, ";}&:hover [class*='euiImageCaption']{text-decoration:underline;};label:euiImageFullscreenWrapper;"),
19
15
  // Sizes
20
16
  fullWidth: /*#__PURE__*/css(logicalCSS('width', '100%'), ";;label:fullWidth;")
21
17
  };
22
- };
23
-
24
- var euiImageFullScreen = function euiImageFullScreen(size) {
25
- return keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n opacity: 0;\n transform: translateY(", ");\n }\n\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])), size);
26
18
  };
@@ -17,6 +17,8 @@ import { EuiModalFooter } from './modal_footer';
17
17
  import { EuiModalHeader } from './modal_header';
18
18
  import { EuiModalHeaderTitle } from './modal_header_title';
19
19
  import { EuiModalBody } from './modal_body';
20
+ import { useEuiTheme } from '../../services';
21
+ import { euiModalStyles } from './modal.styles';
20
22
  import { EuiButton, EuiButtonEmpty } from '../button';
21
23
  import { EuiText } from '../text';
22
24
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -70,6 +72,9 @@ export var EuiConfirmModal = function EuiConfirmModal(_ref) {
70
72
  };
71
73
 
72
74
  var classes = classnames('euiModal--confirmation', className);
75
+ var euiTheme = useEuiTheme();
76
+ var styles = euiModalStyles(euiTheme);
77
+ var cssStyles = [styles.confirmation];
73
78
  var modalTitle;
74
79
 
75
80
  if (title) {
@@ -88,6 +93,7 @@ export var EuiConfirmModal = function EuiConfirmModal(_ref) {
88
93
 
89
94
  return ___EmotionJSX(EuiModal, _extends({
90
95
  className: classes,
96
+ css: cssStyles,
91
97
  onClose: onCancel
92
98
  }, rest), modalTitle, message && ___EmotionJSX(EuiModalBody, null, ___EmotionJSX(EuiText, {
93
99
  "data-test-subj": "confirmModalBodyText"
@@ -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 { EuiModal, EuiModalHeader, EuiModalHeaderTitle, EuiModalBody, EuiModalFooter } from './index';
13
+ import { EuiButton } from '../button';
14
+ import { jsx as ___EmotionJSX } from "@emotion/react";
15
+
16
+ var Modal = function Modal() {
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ isModalVisible = _useState2[0],
20
+ setIsModalVisible = _useState2[1];
21
+
22
+ var closeModal = function closeModal() {
23
+ return setIsModalVisible(false);
24
+ };
25
+
26
+ var showModal = function showModal() {
27
+ return setIsModalVisible(true);
28
+ };
29
+
30
+ var modalProps = {
31
+ title: 'Do this thing',
32
+ onClose: closeModal,
33
+ children: React
34
+ };
35
+ return ___EmotionJSX("div", null, ___EmotionJSX(EuiButton, {
36
+ onClick: showModal
37
+ }, "Show confirm modal"), isModalVisible && ___EmotionJSX(EuiModal, modalProps, ___EmotionJSX(EuiModalHeader, null, ___EmotionJSX(EuiModalHeaderTitle, null, ___EmotionJSX("h1", null, "Title of modal"))), ___EmotionJSX(EuiModalBody, null, ___EmotionJSX("p", null, "This is a simple modal body")), ___EmotionJSX(EuiModalFooter, null, ___EmotionJSX(EuiButton, {
38
+ onClick: closeModal,
39
+ fill: true
40
+ }, "Close"))));
41
+ };
42
+
43
+ beforeEach(function () {
44
+ cy.mount(___EmotionJSX(Modal, null));
45
+ cy.get('div.euiModal').should('not.exist');
46
+ cy.get('button.euiButton').click();
47
+ cy.get('div.euiModal').should('exist');
48
+ });
49
+ describe('EuiModal', function () {
50
+ describe('Automated accessibility check', function () {
51
+ it('has zero violations when modal is open', function () {
52
+ cy.checkAxe();
53
+ });
54
+ it('has zero violations when modal is closed', function () {
55
+ cy.get('div.euiModalFooter button.euiButton').click();
56
+ cy.get('div.euiModal').should('not.exist');
57
+ cy.checkAxe();
58
+ });
59
+ });
60
+ });
@@ -14,13 +14,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14
14
  * in compliance with, at your election, the Elastic License 2.0 or the Server
15
15
  * Side Public License, v 1.
16
16
  */
17
- import React, { useRef, useCallback } from 'react';
17
+ import React from 'react';
18
18
  import classnames from 'classnames';
19
- import { keys } from '../../services';
19
+ import { keys, useEuiTheme } from '../../services';
20
20
  import { EuiButtonIcon } from '../button';
21
21
  import { EuiFocusTrap } from '../focus_trap';
22
22
  import { EuiOverlayMask } from '../overlay_mask';
23
23
  import { EuiI18n } from '../i18n';
24
+ import { euiModalStyles } from './modal.styles';
24
25
  import { jsx as ___EmotionJSX } from "@emotion/react";
25
26
  export var EuiModal = function EuiModal(_ref) {
26
27
  var className = _ref.className,
@@ -32,19 +33,6 @@ export var EuiModal = function EuiModal(_ref) {
32
33
  style = _ref.style,
33
34
  rest = _objectWithoutProperties(_ref, _excluded);
34
35
 
35
- // TODO: Remove this onFocus scroll workaround after react-focus-on supports focusOptions
36
- // @see https://github.com/elastic/eui/issues/6304
37
- var bodyScrollTop = useRef(typeof window === 'undefined' ? undefined : window.scrollY // Account for SSR
38
- );
39
- var onFocus = useCallback(function () {
40
- if (bodyScrollTop.current != null) {
41
- window.scrollTo({
42
- top: bodyScrollTop.current
43
- });
44
- bodyScrollTop.current = undefined; // Unset after first auto focus
45
- }
46
- }, []);
47
-
48
36
  var onKeyDown = function onKeyDown(event) {
49
37
  if (event.key === keys.ESCAPE) {
50
38
  event.preventDefault();
@@ -53,28 +41,29 @@ export var EuiModal = function EuiModal(_ref) {
53
41
  }
54
42
  };
55
43
 
56
- var newStyle;
57
- var widthClassName;
44
+ var newStyle = style;
58
45
 
59
- if (maxWidth === true) {
60
- widthClassName = 'euiModal--maxWidth-default';
61
- } else if (maxWidth !== false) {
62
- var value = typeof maxWidth === 'number' ? "".concat(maxWidth, "px") : maxWidth;
63
- newStyle = _objectSpread(_objectSpread({}, style), {}, {
64
- maxWidth: value
46
+ if (typeof maxWidth !== 'boolean') {
47
+ newStyle = _objectSpread(_objectSpread({}, newStyle), {}, {
48
+ maxInlineSize: maxWidth
65
49
  });
66
50
  }
67
51
 
68
- var classes = classnames('euiModal', widthClassName, className);
52
+ var classes = classnames('euiModal', className);
53
+ var euiTheme = useEuiTheme();
54
+ var styles = euiModalStyles(euiTheme);
55
+ var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
56
+ var cssCloseIconStyles = [styles.euiModal__closeIcon];
69
57
  return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, {
70
58
  initialFocus: initialFocus,
71
- scrollLock: true
59
+ scrollLock: true,
60
+ preventScrollOnFocus: true
72
61
  }, ___EmotionJSX("div", _extends({
62
+ css: cssStyles,
73
63
  className: classes,
74
64
  onKeyDown: onKeyDown,
75
65
  tabIndex: 0,
76
- onFocus: onFocus,
77
- style: newStyle || style
66
+ style: newStyle
78
67
  }, rest), ___EmotionJSX(EuiI18n, {
79
68
  token: "euiModal.closeModal",
80
69
  default: "Closes this modal window"
@@ -82,6 +71,7 @@ export var EuiModal = function EuiModal(_ref) {
82
71
  return ___EmotionJSX(EuiButtonIcon, {
83
72
  iconType: "cross",
84
73
  onClick: onClose,
74
+ css: cssCloseIconStyles,
85
75
  className: "euiModal__closeIcon",
86
76
  color: "text",
87
77
  "aria-label": closeModal
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import { css } from '@emotion/react';
9
+ import { euiShadowXLarge } from '../../themes/amsterdam/global_styling/mixins';
10
+ import { euiCanAnimate, euiBreakpoint, euiAnimSlideInUp } from '../../global_styling';
11
+ import { euiFormVariables } from '../form/form.styles';
12
+ export var euiModalStyles = function euiModalStyles(euiThemeContext) {
13
+ var euiTheme = euiThemeContext.euiTheme;
14
+ return {
15
+ euiModal: /*#__PURE__*/css(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:", euiFormVariables(euiThemeContext).maxWidth, ";max-inline-size:calc(100vw - ", euiTheme.size.base, ");", euiCanAnimate, "{animation:", euiAnimSlideInUp(euiTheme.size.xxl), " ", euiTheme.animation.slow, " ", euiTheme.animation.bounce, ";}", 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;"),
16
+ // Variants
17
+ defaultMaxWidth: /*#__PURE__*/css("max-inline-size:min(\n ", euiTheme.breakpoint.m, "px,\n calc(100vw - ", euiTheme.size.base, ")\n );;label:defaultMaxWidth;"),
18
+ confirmation: /*#__PURE__*/css("min-inline-size:", euiFormVariables(euiThemeContext).maxWidth, ";", euiBreakpoint(euiThemeContext, ['xs', 's']), "{", euiShadowXLarge(euiThemeContext, {
19
+ reverse: true
20
+ }), " inset-block-start:auto;};label:confirmation;"),
21
+ euiModal__closeIcon: /*#__PURE__*/css("position:absolute;inset-inline-end:", euiTheme.size.xs, ";inset-block-start:", euiTheme.size.xs, ";z-index:3;;label:euiModal__closeIcon;")
22
+ };
23
+ };
@@ -11,6 +11,8 @@ var _excluded = ["className", "children"];
11
11
  */
12
12
  import React from 'react';
13
13
  import classnames from 'classnames';
14
+ import { useEuiTheme } from '../../services';
15
+ import { euiModalBodyStyles } from './modal_body.styles';
14
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
15
17
  export var EuiModalBody = function EuiModalBody(_ref) {
16
18
  var className = _ref.className,
@@ -18,9 +20,15 @@ export var EuiModalBody = function EuiModalBody(_ref) {
18
20
  rest = _objectWithoutProperties(_ref, _excluded);
19
21
 
20
22
  var classes = classnames('euiModalBody', className);
23
+ var euiTheme = useEuiTheme();
24
+ var styles = euiModalBodyStyles(euiTheme);
25
+ var cssStyles = [styles.euiModalBody];
26
+ var cssOverflowStyles = [styles.euiModalBody__overflow];
21
27
  return ___EmotionJSX("div", _extends({
28
+ css: cssStyles,
22
29
  className: classes
23
30
  }, rest), ___EmotionJSX("div", {
31
+ css: cssOverflowStyles,
24
32
  className: "euiModalBody__overflow"
25
33
  }, children));
26
34
  };
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import { css } from '@emotion/react';
9
+ import { euiYScrollWithShadows, euiBreakpoint } from '../../global_styling';
10
+ export var euiModalBodyStyles = function euiModalBodyStyles(euiThemeContext) {
11
+ var euiTheme = euiThemeContext.euiTheme;
12
+ return {
13
+ euiModalBody: /*#__PURE__*/css("flex-grow:1;overflow:hidden;display:flex;flex-direction:column;&:last-of-type .euiModalBody__overflow{padding-block-end:", euiTheme.size.l, ";};label:euiModalBody;"),
14
+ euiModalBody__overflow: /*#__PURE__*/css(euiYScrollWithShadows(euiThemeContext), ";padding-inline:", euiTheme.size.l, ";padding-block:", euiTheme.size.s, ";", euiBreakpoint(euiThemeContext, ['xs', 's']), "{padding-block-end:", euiTheme.size.l, ";};label:euiModalBody__overflow;")
15
+ };
16
+ };
@@ -11,6 +11,8 @@ var _excluded = ["className", "children"];
11
11
  */
12
12
  import React from 'react';
13
13
  import classnames from 'classnames';
14
+ import { useEuiTheme } from '../../services';
15
+ import { euiModalFooterStyles } from './modal_footer.styles';
14
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
15
17
  export var EuiModalFooter = function EuiModalFooter(_ref) {
16
18
  var className = _ref.className,
@@ -18,7 +20,11 @@ export var EuiModalFooter = function EuiModalFooter(_ref) {
18
20
  rest = _objectWithoutProperties(_ref, _excluded);
19
21
 
20
22
  var classes = classnames('euiModalFooter', className);
23
+ var euiTheme = useEuiTheme();
24
+ var styles = euiModalFooterStyles(euiTheme);
25
+ var cssStyles = [styles.euiModalFooter];
21
26
  return ___EmotionJSX("div", _extends({
27
+ css: cssStyles,
22
28
  className: classes
23
29
  }, rest), children);
24
30
  };
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import { css } from '@emotion/react';
9
+ import { euiBreakpoint } from '../../global_styling';
10
+ export var euiModalFooterStyles = function euiModalFooterStyles(euiThemeContext) {
11
+ var euiTheme = euiThemeContext.euiTheme;
12
+ return {
13
+ euiModalFooter: /*#__PURE__*/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, ";", 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;")
14
+ };
15
+ };
@@ -11,6 +11,8 @@ var _excluded = ["className", "children"];
11
11
  */
12
12
  import React from 'react';
13
13
  import classnames from 'classnames';
14
+ import { useEuiTheme } from '../../services';
15
+ import { euiModalHeaderStyles } from './modal_header.styles';
14
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
15
17
  export var EuiModalHeader = function EuiModalHeader(_ref) {
16
18
  var className = _ref.className,
@@ -18,7 +20,11 @@ export var EuiModalHeader = function EuiModalHeader(_ref) {
18
20
  rest = _objectWithoutProperties(_ref, _excluded);
19
21
 
20
22
  var classes = classnames('euiModalHeader', className);
23
+ var euiTheme = useEuiTheme();
24
+ var styles = euiModalHeaderStyles(euiTheme);
25
+ var cssStyles = [styles.euiModalHeader];
21
26
  return ___EmotionJSX("div", _extends({
27
+ css: cssStyles,
22
28
  className: classes
23
29
  }, rest), children);
24
30
  };
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import { css } from '@emotion/react';
9
+ export var euiModalHeaderStyles = function euiModalHeaderStyles(euiThemeContext) {
10
+ var euiTheme = euiThemeContext.euiTheme;
11
+ return {
12
+ euiModalHeader: /*#__PURE__*/css("display:flex;justify-content:space-between;align-items:center;padding-inline:", euiTheme.size.l, " ", euiTheme.size.xxl, ";padding-block:", euiTheme.size.l, " ", euiTheme.size.base, ";flex-grow:0;flex-shrink:0;&+.euiModalFooter{padding-block-start:", euiTheme.size.s, ";};label:euiModalHeader;")
13
+ };
14
+ };
@@ -11,6 +11,7 @@ var _excluded = ["className", "children"];
11
11
  */
12
12
  import React from 'react';
13
13
  import classnames from 'classnames';
14
+ import { EuiTitle } from '../title';
14
15
  import { jsx as ___EmotionJSX } from "@emotion/react";
15
16
  export var EuiModalHeaderTitle = function EuiModalHeaderTitle(_ref) {
16
17
  var className = _ref.className,
@@ -18,7 +19,8 @@ export var EuiModalHeaderTitle = function EuiModalHeaderTitle(_ref) {
18
19
  rest = _objectWithoutProperties(_ref, _excluded);
19
20
 
20
21
  var classes = classnames('euiModalHeader__title', className);
21
- return ___EmotionJSX("div", _extends({
22
+ return ___EmotionJSX(EuiTitle, _extends({
23
+ size: "m",
22
24
  className: classes
23
25
  }, rest), /*#__PURE__*/React.isValidElement(children) ? children : ___EmotionJSX("h1", null, children));
24
26
  };