@elastic/eui 87.1.0 → 87.2.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 (56) hide show
  1. package/dist/eui_theme_dark.css +0 -234
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +0 -234
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/page_template/page_template.js +2 -1
  6. package/es/components/resizable_container/index.js +2 -1
  7. package/es/components/resizable_container/resizable_button.js +81 -50
  8. package/es/components/resizable_container/resizable_button.styles.js +66 -0
  9. package/es/components/resizable_container/resizable_collapse_button.js +24 -14
  10. package/es/components/resizable_container/resizable_collapse_button.styles.js +85 -0
  11. package/es/components/steps/step.styles.js +5 -5
  12. package/es/services/accessibility/html_id_generator.js +19 -3
  13. package/es/themes/amsterdam/global_styling/mixins/shadow.js +0 -1
  14. package/eui.d.ts +113 -19
  15. package/i18ntokens.json +10 -10
  16. package/lib/components/page_template/page_template.js +2 -1
  17. package/lib/components/resizable_container/index.js +8 -1
  18. package/lib/components/resizable_container/resizable_button.js +83 -51
  19. package/lib/components/resizable_container/resizable_button.styles.js +71 -0
  20. package/lib/components/resizable_container/resizable_collapse_button.js +24 -14
  21. package/lib/components/resizable_container/resizable_collapse_button.styles.js +90 -0
  22. package/lib/components/steps/step.styles.js +5 -5
  23. package/lib/services/accessibility/html_id_generator.js +21 -2
  24. package/lib/themes/amsterdam/global_styling/mixins/shadow.js +0 -1
  25. package/optimize/es/components/page_template/page_template.js +2 -1
  26. package/optimize/es/components/resizable_container/index.js +2 -1
  27. package/optimize/es/components/resizable_container/resizable_button.js +61 -44
  28. package/optimize/es/components/resizable_container/resizable_button.styles.js +66 -0
  29. package/optimize/es/components/resizable_container/resizable_collapse_button.js +19 -11
  30. package/optimize/es/components/resizable_container/resizable_collapse_button.styles.js +85 -0
  31. package/optimize/es/components/steps/step.styles.js +5 -5
  32. package/optimize/es/services/accessibility/html_id_generator.js +19 -3
  33. package/optimize/es/themes/amsterdam/global_styling/mixins/shadow.js +0 -1
  34. package/optimize/lib/components/page_template/page_template.js +2 -1
  35. package/optimize/lib/components/resizable_container/index.js +8 -1
  36. package/optimize/lib/components/resizable_container/resizable_button.js +63 -45
  37. package/optimize/lib/components/resizable_container/resizable_button.styles.js +71 -0
  38. package/optimize/lib/components/resizable_container/resizable_collapse_button.js +19 -11
  39. package/optimize/lib/components/resizable_container/resizable_collapse_button.styles.js +90 -0
  40. package/optimize/lib/components/steps/step.styles.js +5 -5
  41. package/optimize/lib/services/accessibility/html_id_generator.js +21 -2
  42. package/optimize/lib/themes/amsterdam/global_styling/mixins/shadow.js +0 -1
  43. package/package.json +13 -13
  44. package/src/components/index.scss +0 -1
  45. package/test-env/components/page_template/page_template.js +2 -1
  46. package/test-env/components/resizable_container/index.js +8 -1
  47. package/test-env/components/resizable_container/resizable_button.js +83 -51
  48. package/test-env/components/resizable_container/resizable_button.styles.js +71 -0
  49. package/test-env/components/resizable_container/resizable_collapse_button.js +19 -14
  50. package/test-env/components/resizable_container/resizable_collapse_button.styles.js +90 -0
  51. package/test-env/components/steps/step.styles.js +5 -5
  52. package/test-env/themes/amsterdam/global_styling/mixins/shadow.js +0 -1
  53. package/src/components/resizable_container/_index.scss +0 -3
  54. package/src/components/resizable_container/_resizable_button.scss +0 -129
  55. package/src/components/resizable_container/_resizable_collapse_button.scss +0 -145
  56. package/src/components/resizable_container/_variables.scss +0 -2
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.euiResizableCollapseButtonStyles = void 0;
7
+ var _react = require("@emotion/react");
8
+ var _global_styling = require("../../global_styling");
9
+ var _amsterdam = require("../../themes/amsterdam");
10
+ 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)."; } /*
11
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
+ * or more contributor license agreements. Licensed under the Elastic License
13
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
14
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
15
+ * Side Public License, v 1.
16
+ */
17
+ var _ref = process.env.NODE_ENV === "production" ? {
18
+ name: "fuwsll-euiResizableCollapseButton",
19
+ styles: "z-index:2;position:absolute;&:focus{animation:none;};label:euiResizableCollapseButton;"
20
+ } : {
21
+ name: "fuwsll-euiResizableCollapseButton",
22
+ styles: "z-index:2;position:absolute;&:focus{animation:none;};label:euiResizableCollapseButton;",
23
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
24
+ };
25
+ var euiResizableCollapseButtonStyles = function euiResizableCollapseButtonStyles(euiThemeContext) {
26
+ var euiTheme = euiThemeContext.euiTheme;
27
+ var buttonSize = euiTheme.size.l;
28
+ var centeringOffset = (0, _global_styling.mathWithUnits)(buttonSize, function (x) {
29
+ return x / -2;
30
+ }); // Use negative margins instead of transforms to avoid having to override EuiButtonIcon's CSS
31
+ var buttonOffset = euiTheme.size.base;
32
+ return {
33
+ euiResizableCollapseButton: _ref,
34
+ collapsible: {
35
+ collapsible: /*#__PURE__*/(0, _react.css)("background:", euiTheme.colors.emptyShade, ";", (0, _amsterdam.euiShadowXSmall)(euiThemeContext), " &:focus{", (0, _amsterdam.euiSlightShadowHover)(euiThemeContext), ";};label:collapsible;"),
36
+ horizontal: {
37
+ after: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('right', 0), " ", (0, _global_styling.logicalCSS)('margin-right', centeringOffset), ";;label:after;"),
38
+ before: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('left', 0), " ", (0, _global_styling.logicalCSS)('margin-left', centeringOffset), ";;label:before;"),
39
+ middle: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('top', '50%'), " ", (0, _global_styling.logicalCSS)('margin-top', centeringOffset), ";;label:middle;"),
40
+ top: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('top', 0), " ", (0, _global_styling.logicalCSS)('margin-top', buttonOffset), ";;label:top;"),
41
+ bottom: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('bottom', 0), " ", (0, _global_styling.logicalCSS)('margin-bottom', buttonOffset), ";;label:bottom;"),
42
+ // `left/right` aren't valid positions for the horizontal direction,
43
+ // so we're using getters to fall back to the `middle` CSS
44
+ get left() {
45
+ return this.middle;
46
+ },
47
+ get right() {
48
+ return this.middle;
49
+ }
50
+ },
51
+ vertical: {
52
+ after: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('top', '100%'), " ", (0, _global_styling.logicalCSS)('margin-top', centeringOffset), ";;label:after;"),
53
+ before: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('bottom', '100%'), " ", (0, _global_styling.logicalCSS)('margin-bottom', centeringOffset), ";;label:before;"),
54
+ middle: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('left', '50%'), " ", (0, _global_styling.logicalCSS)('margin-left', centeringOffset), ";;label:middle;"),
55
+ left: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('left', 0), " ", (0, _global_styling.logicalCSS)('margin-left', buttonOffset), ";;label:left;"),
56
+ right: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('right', 0), " ", (0, _global_styling.logicalCSS)('margin-right', buttonOffset), ";;label:right;"),
57
+ // `top/bottom` aren't valid positions for the horizontal direction,
58
+ // so we're using getters to fall back to the `middle` CSS
59
+ get top() {
60
+ return this.middle;
61
+ },
62
+ get bottom() {
63
+ return this.middle;
64
+ }
65
+ }
66
+ },
67
+ collapsed: {
68
+ // When collapsed, the button itself is the full collapsed area
69
+ // and we use flex to align the icon within
70
+ collapsed: /*#__PURE__*/(0, _react.css)("border-radius:0;", (0, _global_styling.logicalCSS)('top', 0), ";;label:collapsed;"),
71
+ horizontal: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('height', '100%'), ";;label:horizontal;"),
72
+ vertical: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('width', '100%'), ";;label:vertical;"),
73
+ horizontalPositions: {
74
+ top: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-top', buttonOffset), " align-items:flex-start;;label:top;"),
75
+ bottom: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-bottom', buttonOffset), " align-items:flex-end;;label:bottom;"),
76
+ middle: /*#__PURE__*/(0, _react.css)(";label:middle;"),
77
+ left: /*#__PURE__*/(0, _react.css)(";label:left;"),
78
+ right: /*#__PURE__*/(0, _react.css)(";label:right;")
79
+ },
80
+ verticalPositions: {
81
+ left: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-left', buttonOffset), " justify-content:flex-start;;label:left;"),
82
+ right: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-right', buttonOffset), " justify-content:flex-end;;label:right;"),
83
+ middle: /*#__PURE__*/(0, _react.css)(";label:middle;"),
84
+ top: /*#__PURE__*/(0, _react.css)(";label:top;"),
85
+ bottom: /*#__PURE__*/(0, _react.css)(";label:bottom;")
86
+ }
87
+ }
88
+ };
89
+ };
90
+ exports.euiResizableCollapseButtonStyles = euiResizableCollapseButtonStyles;
@@ -48,7 +48,7 @@ exports.euiStepStyles = euiStepStyles;
48
48
  var euiStepContentStyles = function euiStepContentStyles(euiThemeContext) {
49
49
  var euiTheme = euiThemeContext.euiTheme;
50
50
  var euiStep = euiStepVariables(euiTheme);
51
- var styles = {
51
+ return {
52
52
  euiStep__content: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('margin-top', euiTheme.size.s), " ", (0, _global_styling.logicalCSS)('padding-top', euiTheme.size.base), " ", (0, _global_styling.logicalCSS)('padding-bottom', (0, _global_styling.mathWithUnits)([euiTheme.size.xl, euiTheme.size.s], function (x, y) {
53
53
  return x + y;
54
54
  })), " ", (0, _global_styling.logicalCSS)('padding-right', euiTheme.size.base), ";;label:euiStep__content;"),
@@ -58,16 +58,16 @@ var euiStepContentStyles = function euiStepContentStyles(euiThemeContext) {
58
58
  })), (0, _global_styling.logicalCSS)('margin-left', (0, _global_styling.mathWithUnits)(euiStep.numberSize, function (x) {
59
59
  return x / 2;
60
60
  })), ";;label:m;"),
61
- s: /*#__PURE__*/(0, _react.css)(";label:s;"),
62
- // s is the same as m, so we'll programmatically duplicate it below
61
+ // `s` is the same as `m` - use a getter to duplicate its content
62
+ get s() {
63
+ return this.m;
64
+ },
63
65
  xs: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-left', (0, _global_styling.mathWithUnits)([euiStep.numberXSSize, euiStep.numberMargin], function (x, y) {
64
66
  return x / 2 + y;
65
67
  })), (0, _global_styling.logicalCSS)('margin-left', (0, _global_styling.mathWithUnits)(euiStep.numberXSSize, function (x) {
66
68
  return x / 2;
67
69
  })), ";;label:xs;")
68
70
  };
69
- styles.s = styles.m;
70
- return styles;
71
71
  };
72
72
  exports.euiStepContentStyles = euiStepContentStyles;
73
73
  var euiStepTitleStyles = function euiStepTitleStyles(euiThemeContext) {
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.htmlIdGenerator = htmlIdGenerator;
7
8
  exports.useGeneratedHtmlId = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
8
10
  var _uuid = require("uuid");
9
- var _react = require("react");
11
+ 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); }
12
+ 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; }
10
13
  /*
11
14
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
15
  * or more contributor license agreements. Licensed under the Elastic License
@@ -38,7 +41,8 @@ function htmlIdGenerator() {
38
41
  * This prevents IDs from being re-randomized on every component update.
39
42
  */
40
43
 
41
- var useGeneratedHtmlId = function useGeneratedHtmlId() {
44
+ // We can remove this deprecated hook once EUI no longer needs to support React 16-17
45
+ var useDeprecatedGeneratedHtmlId = function useDeprecatedGeneratedHtmlId() {
42
46
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
43
47
  prefix = _ref.prefix,
44
48
  suffix = _ref.suffix,
@@ -47,4 +51,19 @@ var useGeneratedHtmlId = function useGeneratedHtmlId() {
47
51
  return conditionalId || htmlIdGenerator(prefix)(suffix);
48
52
  }, [conditionalId, prefix, suffix]);
49
53
  };
54
+ var useNewGeneratedHtmlId = function useNewGeneratedHtmlId() {
55
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
56
+ _ref2$prefix = _ref2.prefix,
57
+ prefix = _ref2$prefix === void 0 ? '' : _ref2$prefix,
58
+ _ref2$suffix = _ref2.suffix,
59
+ suffix = _ref2$suffix === void 0 ? '' : _ref2$suffix,
60
+ conditionalId = _ref2.conditionalId;
61
+ // Using the default export and dot notation here is intentional
62
+ // to prevent React <18 import errors.
63
+ var id = _react.default.useId();
64
+ return (0, _react.useMemo)(function () {
65
+ return conditionalId || "".concat(prefix).concat(id).concat(suffix);
66
+ }, [id, conditionalId, prefix, suffix]);
67
+ };
68
+ var useGeneratedHtmlId = 'useId' in _react.default ? useNewGeneratedHtmlId : useDeprecatedGeneratedHtmlId;
50
69
  exports.useGeneratedHtmlId = useGeneratedHtmlId;
@@ -87,7 +87,6 @@ var euiShadowXLarge = function euiShadowXLarge(_ref9) {
87
87
 
88
88
  /**
89
89
  * slightShadowHover
90
- * TODO: I think this is only used by panels/cards in the Amsterdam theme, move there
91
90
  */
92
91
  exports.euiShadowXLarge = euiShadowXLarge;
93
92
  var euiSlightShadowHover = function euiSlightShadowHover(_ref11) {
@@ -116,7 +116,8 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
116
116
  return {
117
117
  restrictWidth: restrictWidth,
118
118
  paddingSize: paddingSize,
119
- parent: "#".concat(pageInnerId)
119
+ // pageInnerId may contain colons that are parsed as pseudo-elements if not escaped
120
+ parent: "#".concat(CSS.escape(pageInnerId))
120
121
  };
121
122
  };
122
123
  var innerPanelled = function innerPanelled() {
@@ -6,4 +6,5 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
 
9
- export { EuiResizableContainer } from './resizable_container';
9
+ export { EuiResizableContainer } from './resizable_container';
10
+ export { EuiResizableButton } from './resizable_button';
@@ -1,7 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["isHorizontal", "className", "id", "registration", "disabled", "onFocus", "onBlur"];
4
+ var _excluded = ["isHorizontal", "alignIndicator", "className"],
5
+ _excluded2 = ["registration", "id", "disabled", "onFocus"];
5
6
  /*
6
7
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
8
  * or more contributor license agreements. Licensed under the Elastic License
@@ -10,21 +11,56 @@ var _excluded = ["isHorizontal", "className", "id", "registration", "disabled",
10
11
  * Side Public License, v 1.
11
12
  */
12
13
 
13
- import React, { useCallback, useMemo, useRef } from 'react';
14
+ import React, { useCallback, useMemo, useRef, forwardRef } from 'react';
14
15
  import classNames from 'classnames';
15
16
  import { EuiI18n } from '../i18n';
16
- import { useGeneratedHtmlId } from '../../services';
17
+ import { useEuiTheme, useGeneratedHtmlId } from '../../services';
17
18
  import { useEuiResizableContainerContext } from './context';
19
+ import { euiResizableButtonStyles } from './resizable_button.styles';
18
20
  import { jsx as ___EmotionJSX } from "@emotion/react";
19
- export var EuiResizableButton = function EuiResizableButton(_ref) {
21
+ /**
22
+ * A generic button for indicating/facilitating resizable content,
23
+ * usable outside of the EuiResizableContainer context
24
+ */
25
+ export var EuiResizableButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
20
26
  var isHorizontal = _ref.isHorizontal,
27
+ _ref$alignIndicator = _ref.alignIndicator,
28
+ alignIndicator = _ref$alignIndicator === void 0 ? 'center' : _ref$alignIndicator,
21
29
  className = _ref.className,
22
- id = _ref.id,
23
- registration = _ref.registration,
24
- disabled = _ref.disabled,
25
- onFocus = _ref.onFocus,
26
- onBlur = _ref.onBlur,
27
30
  rest = _objectWithoutProperties(_ref, _excluded);
31
+ var classes = classNames('euiResizableButton', className);
32
+ var euiTheme = useEuiTheme();
33
+ var styles = euiResizableButtonStyles(euiTheme);
34
+ var cssStyles = [styles.euiResizableButton, isHorizontal ? styles.horizontal : styles.vertical, styles.alignIndicator[alignIndicator]];
35
+ return ___EmotionJSX(EuiI18n, {
36
+ tokens: ['euiResizableButton.horizontalResizerAriaLabel', 'euiResizableButton.verticalResizerAriaLabel'],
37
+ defaults: ['Press the left or right arrow keys to adjust panels size', 'Press the up or down arrow keys to adjust panels size']
38
+ }, function (_ref2) {
39
+ var _ref3 = _slicedToArray(_ref2, 2),
40
+ horizontalResizerAriaLabel = _ref3[0],
41
+ verticalResizerAriaLabel = _ref3[1];
42
+ return ___EmotionJSX("button", _extends({
43
+ ref: ref,
44
+ "aria-label": isHorizontal ? horizontalResizerAriaLabel : verticalResizerAriaLabel,
45
+ className: classes,
46
+ css: cssStyles,
47
+ "data-test-subj": "euiResizableButton",
48
+ type: "button"
49
+ }, rest));
50
+ });
51
+ });
52
+ EuiResizableButton.displayName = 'EuiResizableButton';
53
+
54
+ /**
55
+ * Resizer button specific to controlled EuiResizableContainer usage
56
+ */
57
+
58
+ export var EuiResizableButtonControlled = function EuiResizableButtonControlled(_ref4) {
59
+ var registration = _ref4.registration,
60
+ id = _ref4.id,
61
+ disabled = _ref4.disabled,
62
+ _onFocus = _ref4.onFocus,
63
+ rest = _objectWithoutProperties(_ref4, _excluded2);
28
64
  var resizerId = useGeneratedHtmlId({
29
65
  prefix: 'resizable-button',
30
66
  conditionalId: id
@@ -36,13 +72,9 @@ export var EuiResizableButton = function EuiResizableButton(_ref) {
36
72
  } : _useEuiResizableConta2,
37
73
  resizers = _useEuiResizableConta3.resizers;
38
74
  var isDisabled = useMemo(function () {
39
- return disabled || resizers[resizerId] && resizers[resizerId].isDisabled;
75
+ var _resizers$resizerId;
76
+ return disabled || ((_resizers$resizerId = resizers[resizerId]) === null || _resizers$resizerId === void 0 ? void 0 : _resizers$resizerId.isDisabled);
40
77
  }, [resizers, resizerId, disabled]);
41
- var classes = classNames('euiResizableButton', {
42
- 'euiResizableButton--vertical': !isHorizontal,
43
- 'euiResizableButton--horizontal': isHorizontal,
44
- 'euiResizableButton--disabled': isDisabled
45
- }, className);
46
78
  var previousRef = useRef();
47
79
  var onRef = useCallback(function (ref) {
48
80
  if (!registration) return;
@@ -61,35 +93,20 @@ export var EuiResizableButton = function EuiResizableButton(_ref) {
61
93
  }
62
94
  }
63
95
  }, [registration, resizerId, disabled]);
64
- var setFocus = function setFocus(e) {
65
- return e.currentTarget.focus();
66
- };
67
- var handleFocus = function handleFocus() {
68
- onFocus && onFocus(resizerId);
69
- };
70
- return ___EmotionJSX(EuiI18n, {
71
- tokens: ['euiResizableButton.horizontalResizerAriaLabel', 'euiResizableButton.verticalResizerAriaLabel'],
72
- defaults: ['Press left or right to adjust panels size', 'Press up or down to adjust panels size']
73
- }, function (_ref2) {
74
- var _ref3 = _slicedToArray(_ref2, 2),
75
- horizontalResizerAriaLabel = _ref3[0],
76
- verticalResizerAriaLabel = _ref3[1];
77
- return ___EmotionJSX("button", _extends({
78
- id: resizerId,
79
- ref: onRef,
80
- "aria-label": isHorizontal ? horizontalResizerAriaLabel : verticalResizerAriaLabel,
81
- className: classes,
82
- "data-test-subj": "euiResizableButton",
83
- type: "button",
84
- onClick: setFocus,
85
- onFocus: handleFocus,
86
- onBlur: onBlur,
87
- disabled: isDisabled
88
- }, rest));
89
- });
96
+ return ___EmotionJSX(EuiResizableButton, _extends({
97
+ id: resizerId,
98
+ ref: onRef,
99
+ disabled: isDisabled,
100
+ onClick: function onClick(e) {
101
+ return e.currentTarget.focus();
102
+ },
103
+ onFocus: function onFocus() {
104
+ return _onFocus === null || _onFocus === void 0 ? void 0 : _onFocus(resizerId);
105
+ }
106
+ }, rest));
90
107
  };
91
- export function euiResizableButtonWithControls(controls) {
108
+ export var euiResizableButtonWithControls = function euiResizableButtonWithControls(controls) {
92
109
  return function (props) {
93
- return ___EmotionJSX(EuiResizableButton, _extends({}, controls, props));
110
+ return ___EmotionJSX(EuiResizableButtonControlled, _extends({}, controls, props));
94
111
  };
95
- }
112
+ };
@@ -0,0 +1,66 @@
1
+ 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)."; }
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+
10
+ import { css } from '@emotion/react';
11
+ import { transparentize } from '../../services';
12
+ import { logicalCSS, mathWithUnits, euiCanAnimate } from '../../global_styling';
13
+ var _ref = process.env.NODE_ENV === "production" ? {
14
+ name: "1fvu7sv-end",
15
+ styles: "align-items:flex-end;label:end;"
16
+ } : {
17
+ name: "1fvu7sv-end",
18
+ styles: "align-items:flex-end;label:end;",
19
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
20
+ };
21
+ var _ref2 = process.env.NODE_ENV === "production" ? {
22
+ name: "h0ntv8-start",
23
+ styles: "align-items:flex-start;label:start;"
24
+ } : {
25
+ name: "h0ntv8-start",
26
+ styles: "align-items:flex-start;label:start;",
27
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
28
+ };
29
+ var _ref3 = process.env.NODE_ENV === "production" ? {
30
+ name: "8391db-center",
31
+ styles: "align-items:center;label:center;"
32
+ } : {
33
+ name: "8391db-center",
34
+ styles: "align-items:center;label:center;",
35
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
36
+ };
37
+ export var euiResizableButtonStyles = function euiResizableButtonStyles(euiThemeContext) {
38
+ var euiTheme = euiThemeContext.euiTheme;
39
+ var buttonSize = euiTheme.size.base;
40
+ var grabHandleWidth = euiTheme.size.m;
41
+ var grabHandleHeight = euiTheme.border.width.thin;
42
+ var transitionSpeed = euiTheme.animation.fast;
43
+ var transition = "".concat(transitionSpeed, " ease");
44
+ return {
45
+ // Mimics the "grab" icon with CSS psuedo-elements.
46
+ // 1. The "grab" icon transforms into a thicker straight line on :hover and :focus
47
+ // 2. Start/end aligned handles should have a slight margin offset that disappears on hover/focus
48
+ // 3. CSS hack to smooth out/anti-alias the 1px wide handles at various zoom levels
49
+ euiResizableButton: /*#__PURE__*/css("z-index:1;flex-shrink:0;display:flex;justify-content:center;gap:", mathWithUnits(grabHandleHeight, function (x) {
50
+ return x * 2;
51
+ }), ";&:disabled{display:none;}&:hover,&:focus{gap:0;justify-content:center;}", euiCanAnimate, "{transition:gap ", transition, ",justify-content ", transition, ";}&::before,&::after{content:'';display:block;background-color:", euiTheme.colors.darkestShade, ";transform:translateZ(0);", euiCanAnimate, "{transition:width ", transition, ",height ", transition, ",margin ", transition, ",background-color ", transition, ";}}&:hover{&::before,&::after{background-color:", euiTheme.colors.mediumShade, ";", euiCanAnimate, "{transition-delay:", transitionSpeed, ";}}}&:focus,&:active{background-color:", transparentize(euiTheme.colors.primary, 0.1), ";&::before,&::after{background-color:", euiTheme.colors.primary, ";", euiCanAnimate, "{transition:width ", transition, ",height ", transition, ";transition-delay:", mathWithUnits(transitionSpeed, function (x) {
52
+ return x / 2;
53
+ }), ";}}};label:euiResizableButton;"),
54
+ horizontal: /*#__PURE__*/css("cursor:col-resize;", logicalCSS('height', '100%'), " ", logicalCSS('width', buttonSize), " margin-inline:", mathWithUnits(buttonSize, function (x) {
55
+ return x / -2;
56
+ }), ";&::before,&::after{", logicalCSS('width', grabHandleHeight), " ", logicalCSS('height', grabHandleWidth), " margin-block:", euiTheme.size.base, ";}&:hover,&:focus,&:active{&::before,&::after{", logicalCSS('height', '100%'), " margin-block:0;transform:none;}};label:horizontal;"),
57
+ vertical: /*#__PURE__*/css("flex-direction:column;cursor:row-resize;", logicalCSS('width', '100%'), " ", logicalCSS('height', buttonSize), " margin-block:", mathWithUnits(buttonSize, function (x) {
58
+ return x / -2;
59
+ }), ";&::before,&::after{", logicalCSS('height', grabHandleHeight), " ", logicalCSS('width', grabHandleWidth), " margin-inline:", euiTheme.size.base, ";}&:hover,&:focus,&:active{&::before,&::after{", logicalCSS('width', '100%'), " margin-inline:0;transform:none;}};label:vertical;"),
60
+ alignIndicator: {
61
+ center: _ref3,
62
+ start: _ref2,
63
+ end: _ref
64
+ }
65
+ };
66
+ };
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  var _excluded = ["className", "externalPosition", "internalPosition", "direction", "isVisible", "isCollapsed"];
4
5
  /*
@@ -11,11 +12,15 @@ var _excluded = ["className", "externalPosition", "internalPosition", "direction
11
12
 
12
13
  import React from 'react';
13
14
  import classNames from 'classnames';
15
+ import { useEuiTheme } from '../../services';
14
16
  import { EuiButtonIcon } from '../button';
17
+ import { euiScreenReaderOnlyStyles } from '../accessibility/screen_reader_only/screen_reader_only.styles';
18
+ import { euiResizableCollapseButtonStyles } from './resizable_collapse_button.styles';
15
19
  import { jsx as ___EmotionJSX } from "@emotion/react";
16
20
  export var EuiResizableCollapseButton = function EuiResizableCollapseButton(_ref) {
17
21
  var className = _ref.className,
18
- externalPosition = _ref.externalPosition,
22
+ _ref$externalPosition = _ref.externalPosition,
23
+ externalPosition = _ref$externalPosition === void 0 ? 'before' : _ref$externalPosition,
19
24
  _ref$internalPosition = _ref.internalPosition,
20
25
  internalPosition = _ref$internalPosition === void 0 ? 'middle' : _ref$internalPosition,
21
26
  _ref$direction = _ref.direction,
@@ -24,14 +29,15 @@ export var EuiResizableCollapseButton = function EuiResizableCollapseButton(_ref
24
29
  isCollapsed = _ref.isCollapsed,
25
30
  rest = _objectWithoutProperties(_ref, _excluded);
26
31
  var isHorizontal = direction === 'horizontal';
27
- var classes = classNames('euiResizableToggleButton', "euiResizableToggleButton--".concat(direction), "euiResizableToggleButton--".concat(externalPosition), "euiResizableToggleButton--".concat(internalPosition), {
28
- 'euiResizableToggleButton-isVisible': isVisible,
29
- 'euiResizableToggleButton-isCollapsed': isCollapsed
30
- }, className);
31
-
32
- // Default to simiple grab icon in case there is no externalPosition specified
33
- var COLLAPSED_ICON = isHorizontal ? 'grab' : 'grabHorizontal';
34
- var NOT_COLLAPSED_ICON = isHorizontal ? 'grab' : 'grabHorizontal';
32
+ var showOnFocus = !isCollapsed && !isVisible;
33
+ var screenReaderOnlyStyles = euiScreenReaderOnlyStyles(showOnFocus).euiScreenReaderOnly;
34
+ var euiTheme = useEuiTheme();
35
+ var styles = euiResizableCollapseButtonStyles(euiTheme);
36
+ var collapsedStyles = [styles.collapsed.collapsed, styles.collapsed[direction], styles.collapsed["".concat(direction, "Positions")][internalPosition]];
37
+ var collapsibleStyles = [styles.collapsible.collapsible, styles.collapsible[direction][externalPosition], styles.collapsible[direction][internalPosition]];
38
+ var cssStyles = [styles.euiResizableCollapseButton, showOnFocus && screenReaderOnlyStyles].concat(_toConsumableArray(isCollapsed ? collapsedStyles : collapsibleStyles));
39
+ var COLLAPSED_ICON = '';
40
+ var NOT_COLLAPSED_ICON = '';
35
41
  switch (externalPosition) {
36
42
  case 'before':
37
43
  COLLAPSED_ICON = isHorizontal ? 'menuLeft' : 'menuUp';
@@ -42,11 +48,13 @@ export var EuiResizableCollapseButton = function EuiResizableCollapseButton(_ref
42
48
  NOT_COLLAPSED_ICON = isHorizontal ? 'menuLeft' : 'menuUp';
43
49
  break;
44
50
  }
51
+ var classes = classNames('euiResizableCollapseButton', className);
45
52
  return ___EmotionJSX(EuiButtonIcon, _extends({
46
53
  display: isCollapsed ? 'empty' : 'base',
47
- color: "text"
48
- }, rest, {
54
+ color: "text",
49
55
  className: classes,
56
+ css: cssStyles
57
+ }, rest, {
50
58
  iconType: isCollapsed ? COLLAPSED_ICON : NOT_COLLAPSED_ICON
51
59
  }));
52
60
  };
@@ -0,0 +1,85 @@
1
+ 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)."; }
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+
10
+ import { css } from '@emotion/react';
11
+ import { logicalCSS, mathWithUnits } from '../../global_styling';
12
+ import { euiShadowXSmall, euiSlightShadowHover } from '../../themes/amsterdam';
13
+ var _ref = process.env.NODE_ENV === "production" ? {
14
+ name: "fuwsll-euiResizableCollapseButton",
15
+ styles: "z-index:2;position:absolute;&:focus{animation:none;};label:euiResizableCollapseButton;"
16
+ } : {
17
+ name: "fuwsll-euiResizableCollapseButton",
18
+ styles: "z-index:2;position:absolute;&:focus{animation:none;};label:euiResizableCollapseButton;",
19
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
20
+ };
21
+ export var euiResizableCollapseButtonStyles = function euiResizableCollapseButtonStyles(euiThemeContext) {
22
+ var euiTheme = euiThemeContext.euiTheme;
23
+ var buttonSize = euiTheme.size.l;
24
+ var centeringOffset = mathWithUnits(buttonSize, function (x) {
25
+ return x / -2;
26
+ }); // Use negative margins instead of transforms to avoid having to override EuiButtonIcon's CSS
27
+ var buttonOffset = euiTheme.size.base;
28
+ return {
29
+ euiResizableCollapseButton: _ref,
30
+ collapsible: {
31
+ collapsible: /*#__PURE__*/css("background:", euiTheme.colors.emptyShade, ";", euiShadowXSmall(euiThemeContext), " &:focus{", euiSlightShadowHover(euiThemeContext), ";};label:collapsible;"),
32
+ horizontal: {
33
+ after: /*#__PURE__*/css(logicalCSS('right', 0), " ", logicalCSS('margin-right', centeringOffset), ";;label:after;"),
34
+ before: /*#__PURE__*/css(logicalCSS('left', 0), " ", logicalCSS('margin-left', centeringOffset), ";;label:before;"),
35
+ middle: /*#__PURE__*/css(logicalCSS('top', '50%'), " ", logicalCSS('margin-top', centeringOffset), ";;label:middle;"),
36
+ top: /*#__PURE__*/css(logicalCSS('top', 0), " ", logicalCSS('margin-top', buttonOffset), ";;label:top;"),
37
+ bottom: /*#__PURE__*/css(logicalCSS('bottom', 0), " ", logicalCSS('margin-bottom', buttonOffset), ";;label:bottom;"),
38
+ // `left/right` aren't valid positions for the horizontal direction,
39
+ // so we're using getters to fall back to the `middle` CSS
40
+ get left() {
41
+ return this.middle;
42
+ },
43
+ get right() {
44
+ return this.middle;
45
+ }
46
+ },
47
+ vertical: {
48
+ after: /*#__PURE__*/css(logicalCSS('top', '100%'), " ", logicalCSS('margin-top', centeringOffset), ";;label:after;"),
49
+ before: /*#__PURE__*/css(logicalCSS('bottom', '100%'), " ", logicalCSS('margin-bottom', centeringOffset), ";;label:before;"),
50
+ middle: /*#__PURE__*/css(logicalCSS('left', '50%'), " ", logicalCSS('margin-left', centeringOffset), ";;label:middle;"),
51
+ left: /*#__PURE__*/css(logicalCSS('left', 0), " ", logicalCSS('margin-left', buttonOffset), ";;label:left;"),
52
+ right: /*#__PURE__*/css(logicalCSS('right', 0), " ", logicalCSS('margin-right', buttonOffset), ";;label:right;"),
53
+ // `top/bottom` aren't valid positions for the horizontal direction,
54
+ // so we're using getters to fall back to the `middle` CSS
55
+ get top() {
56
+ return this.middle;
57
+ },
58
+ get bottom() {
59
+ return this.middle;
60
+ }
61
+ }
62
+ },
63
+ collapsed: {
64
+ // When collapsed, the button itself is the full collapsed area
65
+ // and we use flex to align the icon within
66
+ collapsed: /*#__PURE__*/css("border-radius:0;", logicalCSS('top', 0), ";;label:collapsed;"),
67
+ horizontal: /*#__PURE__*/css(logicalCSS('height', '100%'), ";;label:horizontal;"),
68
+ vertical: /*#__PURE__*/css(logicalCSS('width', '100%'), ";;label:vertical;"),
69
+ horizontalPositions: {
70
+ top: /*#__PURE__*/css(logicalCSS('padding-top', buttonOffset), " align-items:flex-start;;label:top;"),
71
+ bottom: /*#__PURE__*/css(logicalCSS('padding-bottom', buttonOffset), " align-items:flex-end;;label:bottom;"),
72
+ middle: /*#__PURE__*/css(";label:middle;"),
73
+ left: /*#__PURE__*/css(";label:left;"),
74
+ right: /*#__PURE__*/css(";label:right;")
75
+ },
76
+ verticalPositions: {
77
+ left: /*#__PURE__*/css(logicalCSS('padding-left', buttonOffset), " justify-content:flex-start;;label:left;"),
78
+ right: /*#__PURE__*/css(logicalCSS('padding-right', buttonOffset), " justify-content:flex-end;;label:right;"),
79
+ middle: /*#__PURE__*/css(";label:middle;"),
80
+ top: /*#__PURE__*/css(";label:top;"),
81
+ bottom: /*#__PURE__*/css(";label:bottom;")
82
+ }
83
+ }
84
+ };
85
+ };
@@ -40,7 +40,7 @@ export var euiStepStyles = function euiStepStyles(euiThemeContext) {
40
40
  export var euiStepContentStyles = function euiStepContentStyles(euiThemeContext) {
41
41
  var euiTheme = euiThemeContext.euiTheme;
42
42
  var euiStep = euiStepVariables(euiTheme);
43
- var styles = {
43
+ return {
44
44
  euiStep__content: /*#__PURE__*/css(logicalCSS('margin-top', euiTheme.size.s), " ", logicalCSS('padding-top', euiTheme.size.base), " ", logicalCSS('padding-bottom', mathWithUnits([euiTheme.size.xl, euiTheme.size.s], function (x, y) {
45
45
  return x + y;
46
46
  })), " ", logicalCSS('padding-right', euiTheme.size.base), ";;label:euiStep__content;"),
@@ -50,16 +50,16 @@ export var euiStepContentStyles = function euiStepContentStyles(euiThemeContext)
50
50
  })), logicalCSS('margin-left', mathWithUnits(euiStep.numberSize, function (x) {
51
51
  return x / 2;
52
52
  })), ";;label:m;"),
53
- s: /*#__PURE__*/css(";label:s;"),
54
- // s is the same as m, so we'll programmatically duplicate it below
53
+ // `s` is the same as `m` - use a getter to duplicate its content
54
+ get s() {
55
+ return this.m;
56
+ },
55
57
  xs: /*#__PURE__*/css(logicalCSS('padding-left', mathWithUnits([euiStep.numberXSSize, euiStep.numberMargin], function (x, y) {
56
58
  return x / 2 + y;
57
59
  })), logicalCSS('margin-left', mathWithUnits(euiStep.numberXSSize, function (x) {
58
60
  return x / 2;
59
61
  })), ";;label:xs;")
60
62
  };
61
- styles.s = styles.m;
62
- return styles;
63
63
  };
64
64
  export var euiStepTitleStyles = function euiStepTitleStyles(euiThemeContext) {
65
65
  var euiTheme = euiThemeContext.euiTheme;
@@ -6,8 +6,8 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
 
9
+ import React, { useMemo } from 'react';
9
10
  import { v1 as uuidv1 } from 'uuid';
10
- import { useMemo } from 'react';
11
11
 
12
12
  /**
13
13
  * This function returns a function to generate ids.
@@ -32,7 +32,8 @@ export function htmlIdGenerator() {
32
32
  * This prevents IDs from being re-randomized on every component update.
33
33
  */
34
34
 
35
- export var useGeneratedHtmlId = function useGeneratedHtmlId() {
35
+ // We can remove this deprecated hook once EUI no longer needs to support React 16-17
36
+ var useDeprecatedGeneratedHtmlId = function useDeprecatedGeneratedHtmlId() {
36
37
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
37
38
  prefix = _ref.prefix,
38
39
  suffix = _ref.suffix,
@@ -40,4 +41,19 @@ export var useGeneratedHtmlId = function useGeneratedHtmlId() {
40
41
  return useMemo(function () {
41
42
  return conditionalId || htmlIdGenerator(prefix)(suffix);
42
43
  }, [conditionalId, prefix, suffix]);
43
- };
44
+ };
45
+ var useNewGeneratedHtmlId = function useNewGeneratedHtmlId() {
46
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
47
+ _ref2$prefix = _ref2.prefix,
48
+ prefix = _ref2$prefix === void 0 ? '' : _ref2$prefix,
49
+ _ref2$suffix = _ref2.suffix,
50
+ suffix = _ref2$suffix === void 0 ? '' : _ref2$suffix,
51
+ conditionalId = _ref2.conditionalId;
52
+ // Using the default export and dot notation here is intentional
53
+ // to prevent React <18 import errors.
54
+ var id = React.useId();
55
+ return useMemo(function () {
56
+ return conditionalId || "".concat(prefix).concat(id).concat(suffix);
57
+ }, [id, conditionalId, prefix, suffix]);
58
+ };
59
+ export var useGeneratedHtmlId = 'useId' in React ? useNewGeneratedHtmlId : useDeprecatedGeneratedHtmlId;
@@ -78,7 +78,6 @@ export var euiShadowXLarge = function euiShadowXLarge(_ref9) {
78
78
 
79
79
  /**
80
80
  * slightShadowHover
81
- * TODO: I think this is only used by panels/cards in the Amsterdam theme, move there
82
81
  */
83
82
  export var euiSlightShadowHover = function euiSlightShadowHover(_ref11) {
84
83
  var euiTheme = _ref11.euiTheme,