@elastic/eui-theme-common 4.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/lib/cjs/global_styling/functions/shadows.d.ts +12 -0
  2. package/lib/cjs/global_styling/functions/shadows.js +49 -4
  3. package/lib/cjs/global_styling/mixins/borders.d.ts +23 -0
  4. package/lib/cjs/global_styling/mixins/borders.js +50 -0
  5. package/lib/cjs/global_styling/mixins/index.d.ts +1 -0
  6. package/lib/cjs/global_styling/mixins/index.js +11 -0
  7. package/lib/cjs/global_styling/mixins/shadow.d.ts +22 -14
  8. package/lib/cjs/global_styling/mixins/shadow.js +142 -68
  9. package/lib/cjs/global_styling/variables/borders.d.ts +1 -1
  10. package/lib/cjs/global_styling/variables/components.d.ts +0 -1
  11. package/lib/cjs/global_styling/variables/flags.d.ts +2 -6
  12. package/lib/cjs/global_styling/variables/shadow.d.ts +52 -0
  13. package/lib/cjs/global_styling/variables/shadow.js +8 -2
  14. package/lib/cjs/global_styling/variables/typography.d.ts +1 -1
  15. package/lib/cjs/services/theme/types.d.ts +8 -1
  16. package/lib/cjs/services/vis_color_store.d.ts +3 -7
  17. package/lib/cjs/services/vis_color_store.js +4 -15
  18. package/lib/cjs/services/vis_color_store.test.js +1 -5
  19. package/lib/cjs/utils.d.ts +22 -1
  20. package/lib/cjs/utils.js +39 -1
  21. package/lib/cjs/utils.test.js +38 -0
  22. package/lib/esm/global_styling/functions/shadows.d.ts +12 -0
  23. package/lib/esm/global_styling/functions/shadows.js +40 -1
  24. package/lib/esm/global_styling/mixins/borders.d.ts +23 -0
  25. package/lib/esm/global_styling/mixins/borders.js +50 -0
  26. package/lib/esm/global_styling/mixins/index.d.ts +1 -0
  27. package/lib/esm/global_styling/mixins/index.js +1 -0
  28. package/lib/esm/global_styling/mixins/shadow.d.ts +22 -14
  29. package/lib/esm/global_styling/mixins/shadow.js +126 -81
  30. package/lib/esm/global_styling/variables/borders.d.ts +1 -1
  31. package/lib/esm/global_styling/variables/components.d.ts +0 -1
  32. package/lib/esm/global_styling/variables/flags.d.ts +2 -6
  33. package/lib/esm/global_styling/variables/shadow.d.ts +52 -0
  34. package/lib/esm/global_styling/variables/shadow.js +1 -0
  35. package/lib/esm/global_styling/variables/typography.d.ts +1 -1
  36. package/lib/esm/services/theme/types.d.ts +8 -1
  37. package/lib/esm/services/vis_color_store.d.ts +3 -7
  38. package/lib/esm/services/vis_color_store.js +3 -12
  39. package/lib/esm/services/vis_color_store.test.js +1 -5
  40. package/lib/esm/utils.d.ts +22 -1
  41. package/lib/esm/utils.js +31 -0
  42. package/lib/esm/utils.test.js +22 -1
  43. package/package.json +1 -1
  44. package/src/global_styling/mixins/_index.scss +0 -7
  45. package/src/global_styling/mixins/_states.scss +1 -1
  46. package/src/global_styling/variables/_index.scss +0 -1
  47. package/src/global_styling/mixins/_button.scss +0 -149
  48. package/src/global_styling/mixins/_form.scss +0 -272
  49. package/src/global_styling/mixins/_link.scss +0 -11
  50. package/src/global_styling/mixins/_loading.scss +0 -6
  51. package/src/global_styling/mixins/_panel.scss +0 -55
  52. package/src/global_styling/mixins/_range.scss +0 -59
  53. package/src/global_styling/mixins/_shadow.scss +0 -100
  54. package/src/global_styling/variables/_shadows.scss +0 -2
@@ -1,2 +1,14 @@
1
1
  import { EuiThemeColorModeStandard } from '../../services/theme/types';
2
2
  export declare const getShadowColor: (color: string, opacity: number, colorMode: EuiThemeColorModeStandard) => string;
3
+ /**
4
+ * Converts a `box-shadow` string to a `filter: drop-shadow()` string.
5
+ *
6
+ * @todo check whether this is actually needed in +2025, the original code replacing
7
+ * box-shadow with filter: drop-shadow() had the following comment:
8
+ * > Using only one drop-shadow filter instead of multiple is more
9
+ * > performant & prevents Safari bugs
10
+ *
11
+ * @param boxShadow The `box-shadow` string to convert.
12
+ * @returns The converted `filter` string.
13
+ */
14
+ export declare const boxShadowToFilterDropShadow: (boxShadow: string) => string;
@@ -3,22 +3,67 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getShadowColor = void 0;
6
+ exports.getShadowColor = exports.boxShadowToFilterDropShadow = void 0;
7
7
  var _chromaJs = _interopRequireDefault(require("chroma-js"));
8
8
  var _types = require("../../services/theme/types");
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
- /*
10
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /*
11
16
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
17
  * or more contributor license agreements. Licensed under the Elastic License
13
18
  * 2.0 and the Server Side Public License, v 1; you may not use this file except
14
19
  * in compliance with, at your election, the Elastic License 2.0 or the Server
15
20
  * Side Public License, v 1.
16
21
  */
17
-
18
22
  // Create a CSS color value using whose opacity is determined based
19
23
  // on either a light or dark theme. We use a multiplier
20
- // of 1 for light themes and 2.5 for dark themes
24
+ // of 1 for light themes and 3.5 for dark themes
21
25
  var getShadowColor = exports.getShadowColor = function getShadowColor(color, opacity, colorMode) {
22
26
  var themeOpacity = colorMode === _types.COLOR_MODES_STANDARD.dark ? opacity * 3.5 : opacity * 1;
23
27
  return (0, _chromaJs["default"])(color).alpha(themeOpacity).css();
28
+ };
29
+
30
+ /**
31
+ * Converts a `box-shadow` string to a `filter: drop-shadow()` string.
32
+ *
33
+ * @todo check whether this is actually needed in +2025, the original code replacing
34
+ * box-shadow with filter: drop-shadow() had the following comment:
35
+ * > Using only one drop-shadow filter instead of multiple is more
36
+ * > performant & prevents Safari bugs
37
+ *
38
+ * @param boxShadow The `box-shadow` string to convert.
39
+ * @returns The converted `filter` string.
40
+ */
41
+ var boxShadowToFilterDropShadow = exports.boxShadowToFilterDropShadow = function boxShadowToFilterDropShadow(boxShadow) {
42
+ var dropShadows = boxShadow.split(/,(?![^(]*\))/) // split by comma, but not inside parentheses
43
+ .map(function (shadow) {
44
+ shadow = shadow.trim();
45
+ // remove `inset`, not supported by drop-shadow
46
+ if (shadow.startsWith('inset ')) {
47
+ shadow = shadow.slice(6);
48
+ }
49
+ // can be complex (hsl, rgb, etc.), used AI for this
50
+ var colorMatch = shadow.match(/(hsl|rgb)a?\(.*\)|#[0-9a-fA-F]{3,8}|[a-zA-Z]+$/);
51
+ var color;
52
+ var parts;
53
+ if (colorMatch) {
54
+ color = colorMatch[0];
55
+ parts = shadow.substring(0, colorMatch.index).trim().split(/\s+/);
56
+ } else {
57
+ color = '#000'; // fallback to black
58
+ parts = shadow.trim().split(/\s+/);
59
+ }
60
+ // drop-shadow doesn't support spread, so we only take x, y, blur
61
+ var _parts = parts,
62
+ _parts2 = _slicedToArray(_parts, 3),
63
+ x = _parts2[0],
64
+ y = _parts2[1],
65
+ blur = _parts2[2];
66
+ return "drop-shadow(".concat(x, " ").concat(y, " ").concat(blur, " ").concat(color, ")");
67
+ }).join(' ');
68
+ return "filter: ".concat(dropShadows, ";");
24
69
  };
@@ -0,0 +1,23 @@
1
+ import { UseEuiTheme } from '../../services/theme/types';
2
+ export declare const getBorderSide: (side: BorderSides) => string;
3
+ export declare type BorderSides = 'left' | 'right' | 'top' | 'bottom' | 'horizontal' | 'vertical' | 'all';
4
+ /**
5
+ * Defines styles for floating boarders applied in DARK mode via EUI shadow utils
6
+ */
7
+ export declare const euiShadowFloatingBorderStyles: (euiThemeContext: UseEuiTheme, options: {
8
+ side?: BorderSides;
9
+ borderColor?: string;
10
+ borderWidth?: string;
11
+ borderStyle?: string;
12
+ }) => string;
13
+ /**
14
+ * Shared style for floating borders.
15
+ * Uses a pseudo element with `border` attribute to prevent both dimension changes due to
16
+ * the border width as well as visible gaps due to the need of a transparent border in LIGHT mode.
17
+ */
18
+ export declare const euiBorderStyles: (euiThemeContext: UseEuiTheme, options: {
19
+ side?: BorderSides;
20
+ borderColor?: string;
21
+ borderWidth?: string;
22
+ borderStyle?: string;
23
+ }) => string;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBorderSide = exports.euiShadowFloatingBorderStyles = exports.euiBorderStyles = void 0;
7
+ /*
8
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
9
+ * or more contributor license agreements. Licensed under the Elastic License
10
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
11
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
12
+ * Side Public License, v 1.
13
+ */
14
+
15
+ var logicalSide = {
16
+ left: 'inline-start',
17
+ right: 'inline-end',
18
+ top: 'block-start',
19
+ bottom: 'block-end',
20
+ horizontal: 'inline',
21
+ vertical: 'block'
22
+ };
23
+ var getBorderSide = exports.getBorderSide = function getBorderSide(side) {
24
+ return side === 'all' ? 'border' : "border-".concat(logicalSide[side]);
25
+ };
26
+ /**
27
+ * Defines styles for floating boarders applied in DARK mode via EUI shadow utils
28
+ */
29
+ var euiShadowFloatingBorderStyles = exports.euiShadowFloatingBorderStyles = function euiShadowFloatingBorderStyles(euiThemeContext, options) {
30
+ return "\n /* create a containing block without using `position` to prevent CSS specificity issues and unexpected overrides;\n `transform: translateZ(0)` is the least likely to affect other behaviors (overflow, layout) */\n transform: translateZ(0);\n\n ".concat(euiBorderStyles(euiThemeContext, options), "\n ");
31
+ };
32
+
33
+ /**
34
+ * Shared style for floating borders.
35
+ * Uses a pseudo element with `border` attribute to prevent both dimension changes due to
36
+ * the border width as well as visible gaps due to the need of a transparent border in LIGHT mode.
37
+ */
38
+ var euiBorderStyles = exports.euiBorderStyles = function euiBorderStyles(euiThemeContext, options) {
39
+ var euiTheme = euiThemeContext.euiTheme;
40
+ var _options$side = options.side,
41
+ side = _options$side === void 0 ? 'all' : _options$side,
42
+ _options$borderColor = options.borderColor,
43
+ borderColor = _options$borderColor === void 0 ? euiTheme.border.color : _options$borderColor,
44
+ _options$borderWidth = options.borderWidth,
45
+ borderWidth = _options$borderWidth === void 0 ? euiTheme.border.width.thin : _options$borderWidth,
46
+ _options$borderStyle = options.borderStyle,
47
+ borderStyle = _options$borderStyle === void 0 ? 'solid' : _options$borderStyle;
48
+ var borderProperty = getBorderSide(side);
49
+ return "\n &::after {\n content: '';\n position: absolute;\n inset: 0;\n /* ensure to keep on top of flush content */\n z-index: 0;\n ".concat(borderProperty, ": ").concat(borderWidth, " ").concat(borderStyle, " ").concat(borderColor, ";\n border-radius: inherit;\n pointer-events: none;\n }\n ");
50
+ };
@@ -1 +1,2 @@
1
1
  export * from './shadow';
2
+ export * from './borders';
@@ -13,4 +13,15 @@ Object.keys(_shadow).forEach(function (key) {
13
13
  return _shadow[key];
14
14
  }
15
15
  });
16
+ });
17
+ var _borders = require("./borders");
18
+ Object.keys(_borders).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _borders[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _borders[key];
25
+ }
26
+ });
16
27
  });
@@ -1,45 +1,53 @@
1
1
  import type { UseEuiTheme } from '../../services/theme/types';
2
2
  import { _EuiThemeShadowSize } from '../variables/shadow';
3
+ import { BorderSides } from './borders';
3
4
  export interface EuiShadowOptions {
5
+ /** @deprecated */
4
6
  color?: string;
7
+ /** @default `down` */
8
+ direction?: 'down' | 'up';
5
9
  /**
6
10
  * Note: not supported by all shadow utilities.
7
11
  */
8
12
  property?: 'box-shadow' | 'filter';
9
13
  borderAllInHighContrastMode?: boolean;
14
+ border?: BorderSides | 'none';
10
15
  }
11
16
  /**
12
- * euiSlightShadow
17
+ * x-small shadow
13
18
  */
14
- export declare const euiShadowXSmall: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
19
+ export declare const euiShadowXSmall: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
15
20
  /**
16
- * bottomShadowSmall
21
+ * small shadow
17
22
  */
18
- export declare const euiShadowSmall: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
23
+ export declare const euiShadowSmall: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
19
24
  /**
20
- * bottomShadowMedium
25
+ * medium shadow
21
26
  */
22
- export declare const euiShadowMedium: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
27
+ export declare const euiShadowMedium: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
23
28
  /**
24
- * bottomShadow
29
+ * large shadow
25
30
  */
26
- export declare const euiShadowLarge: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
31
+ export declare const euiShadowLarge: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
27
32
  /**
28
- * bottomShadowLarge
33
+ * x-large shadow
29
34
  */
30
35
  export interface EuiShadowXLarge extends EuiShadowOptions {
31
36
  reverse?: boolean;
32
37
  }
33
- export declare const euiShadowXLarge: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowXLarge | undefined) => string;
38
+ export declare const euiShadowXLarge: (euiThemeContext: UseEuiTheme, options?: EuiShadowXLarge | undefined) => string;
34
39
  /**
35
- * slightShadowHover
40
+ * flat shadow
41
+ * @deprecated - use euiShadowHover instead
36
42
  */
37
- export declare const euiSlightShadowHover: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
43
+ export declare const euiSlightShadowHover: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
38
44
  /**
39
- * bottomShadowFlat
45
+ * @deprecated - use euiShadowXSmall instead
40
46
  *
41
47
  * Similar to shadow medium but without the bottom depth.
42
48
  * Useful for popovers that drop UP rather than DOWN.
43
49
  */
44
- export declare const euiShadowFlat: ({ euiTheme, colorMode, highContrastMode }: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
50
+ export declare const euiShadowFlat: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
45
51
  export declare const euiShadow: (euiThemeContext: UseEuiTheme, size?: _EuiThemeShadowSize, options?: EuiShadowOptions | undefined) => string;
52
+ /** Hover shadows */
53
+ export declare const euiShadowHover: (euiThemeContext: UseEuiTheme, size?: _EuiThemeShadowSize | 'base', options?: EuiShadowOptions | undefined) => string;
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.euiSlightShadowHover = exports.euiShadowXSmall = exports.euiShadowXLarge = exports.euiShadowSmall = exports.euiShadowMedium = exports.euiShadowLarge = exports.euiShadowFlat = exports.euiShadow = void 0;
6
+ exports.euiSlightShadowHover = exports.euiShadowXSmall = exports.euiShadowXLarge = exports.euiShadowSmall = exports.euiShadowMedium = exports.euiShadowLarge = exports.euiShadowHover = exports.euiShadowFlat = exports.euiShadow = void 0;
7
7
  var _functions = require("../functions");
8
+ var _borders = require("./borders");
8
9
  /*
9
10
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
11
  * or more contributor license agreements. Licensed under the Elastic License
@@ -14,118 +15,134 @@ var _functions = require("../functions");
14
15
  */
15
16
 
16
17
  /**
17
- * euiSlightShadow
18
+ * x-small shadow
18
19
  */
19
- var euiShadowXSmall = exports.euiShadowXSmall = function euiShadowXSmall(_ref, options) {
20
- var euiTheme = _ref.euiTheme,
21
- colorMode = _ref.colorMode,
22
- highContrastMode = _ref.highContrastMode;
20
+ var euiShadowXSmall = exports.euiShadowXSmall = function euiShadowXSmall(euiThemeContext, options) {
21
+ var _options$direction;
22
+ var euiTheme = euiThemeContext.euiTheme,
23
+ highContrastMode = euiThemeContext.highContrastMode;
23
24
  if (highContrastMode) {
24
- return _highContrastBorder(euiTheme, options);
25
+ return _highContrastBorder(euiThemeContext, options);
25
26
  }
26
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
27
- return "\nbox-shadow:\n 0 .8px .8px ".concat((0, _functions.getShadowColor)(color, 0.04, colorMode), ",\n 0 2.3px 2px ").concat((0, _functions.getShadowColor)(color, 0.03, colorMode), ";\n");
27
+ var direction = (_options$direction = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction !== void 0 ? _options$direction : 'down';
28
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.xs[direction], {
29
+ border: options === null || options === void 0 ? void 0 : options.border
30
+ });
28
31
  };
29
32
 
30
33
  /**
31
- * bottomShadowSmall
34
+ * small shadow
32
35
  */
33
- var euiShadowSmall = exports.euiShadowSmall = function euiShadowSmall(_ref2, options) {
34
- var euiTheme = _ref2.euiTheme,
35
- colorMode = _ref2.colorMode,
36
- highContrastMode = _ref2.highContrastMode;
36
+ var euiShadowSmall = exports.euiShadowSmall = function euiShadowSmall(euiThemeContext, options) {
37
+ var _options$direction2;
38
+ var euiTheme = euiThemeContext.euiTheme,
39
+ highContrastMode = euiThemeContext.highContrastMode;
37
40
  if (highContrastMode) {
38
- return _highContrastBorder(euiTheme, options);
41
+ return _highContrastBorder(euiThemeContext, options);
39
42
  }
40
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
41
- return "\nbox-shadow:\n 0 .7px 1.4px ".concat((0, _functions.getShadowColor)(color, 0.07, colorMode), ",\n 0 1.9px 4px ").concat((0, _functions.getShadowColor)(color, 0.05, colorMode), ",\n 0 4.5px 10px ").concat((0, _functions.getShadowColor)(color, 0.05, colorMode), ";\n");
43
+ var direction = (_options$direction2 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction2 !== void 0 ? _options$direction2 : 'down';
44
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.s[direction], {
45
+ border: options === null || options === void 0 ? void 0 : options.border
46
+ });
42
47
  };
43
48
 
44
49
  /**
45
- * bottomShadowMedium
50
+ * medium shadow
46
51
  */
47
- var euiShadowMedium = exports.euiShadowMedium = function euiShadowMedium(_ref3, options) {
48
- var euiTheme = _ref3.euiTheme,
49
- colorMode = _ref3.colorMode,
50
- highContrastMode = _ref3.highContrastMode;
52
+ var euiShadowMedium = exports.euiShadowMedium = function euiShadowMedium(euiThemeContext, options) {
53
+ var _options$direction3;
54
+ var euiTheme = euiThemeContext.euiTheme,
55
+ highContrastMode = euiThemeContext.highContrastMode;
51
56
  if (highContrastMode) {
52
- return _highContrastBorder(euiTheme, options);
57
+ return _highContrastBorder(euiThemeContext, options);
53
58
  }
54
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
59
+ var direction = (_options$direction3 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction3 !== void 0 ? _options$direction3 : 'down';
60
+ var boxShadow = euiTheme.shadows.m[direction];
55
61
  if ((options === null || options === void 0 ? void 0 : options.property) === 'filter') {
56
- // Using only one drop-shadow filter instead of multiple is more performant & prevents Safari bugs
57
- return "filter: drop-shadow(0 5.7px 9px ".concat((0, _functions.getShadowColor)(color, 0.2, colorMode), ");");
58
- } else {
59
- return "box-shadow:\n 0 .9px 4px ".concat((0, _functions.getShadowColor)(color, 0.08, colorMode), ",\n 0 2.6px 8px ").concat((0, _functions.getShadowColor)(color, 0.06, colorMode), ",\n 0 5.7px 12px ").concat((0, _functions.getShadowColor)(color, 0.05, colorMode), ",\n 0 15px 15px ").concat((0, _functions.getShadowColor)(color, 0.04, colorMode), ";");
62
+ return boxShadow ? _shadowStyles(euiThemeContext, (0, _functions.boxShadowToFilterDropShadow)(boxShadow), {
63
+ border: options === null || options === void 0 ? void 0 : options.border,
64
+ type: 'filter'
65
+ }) : '';
60
66
  }
67
+ return _shadowStyles(euiThemeContext, boxShadow, {
68
+ border: options === null || options === void 0 ? void 0 : options.border
69
+ });
61
70
  };
62
71
 
63
72
  /**
64
- * bottomShadow
73
+ * large shadow
65
74
  */
66
- var euiShadowLarge = exports.euiShadowLarge = function euiShadowLarge(_ref4, options) {
67
- var euiTheme = _ref4.euiTheme,
68
- colorMode = _ref4.colorMode,
69
- highContrastMode = _ref4.highContrastMode;
75
+ var euiShadowLarge = exports.euiShadowLarge = function euiShadowLarge(euiThemeContext, options) {
76
+ var _options$direction4;
77
+ var euiTheme = euiThemeContext.euiTheme,
78
+ highContrastMode = euiThemeContext.highContrastMode;
70
79
  if (highContrastMode) {
71
- return _highContrastBorder(euiTheme, options);
80
+ return _highContrastBorder(euiThemeContext, options);
72
81
  }
73
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
74
- return "\nbox-shadow:\n 0 1px 5px ".concat((0, _functions.getShadowColor)(color, 0.1, colorMode), ",\n 0 3.6px 13px ").concat((0, _functions.getShadowColor)(color, 0.07, colorMode), ",\n 0 8.4px 23px ").concat((0, _functions.getShadowColor)(color, 0.06, colorMode), ",\n 0 23px 35px ").concat((0, _functions.getShadowColor)(color, 0.05, colorMode), ";\n");
82
+ var direction = (_options$direction4 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction4 !== void 0 ? _options$direction4 : 'down';
83
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.l[direction], {
84
+ border: options === null || options === void 0 ? void 0 : options.border
85
+ });
75
86
  };
76
87
 
77
88
  /**
78
- * bottomShadowLarge
89
+ * x-large shadow
79
90
  */
80
91
 
81
- var euiShadowXLarge = exports.euiShadowXLarge = function euiShadowXLarge(_ref5, options) {
82
- var _options$reverse;
83
- var euiTheme = _ref5.euiTheme,
84
- colorMode = _ref5.colorMode,
85
- highContrastMode = _ref5.highContrastMode;
92
+ var euiShadowXLarge = exports.euiShadowXLarge = function euiShadowXLarge(euiThemeContext, options) {
93
+ var _options$direction5;
94
+ var euiTheme = euiThemeContext.euiTheme,
95
+ highContrastMode = euiThemeContext.highContrastMode;
86
96
  if (highContrastMode) {
87
- return _highContrastBorder(euiTheme, options);
97
+ return _highContrastBorder(euiThemeContext, options);
88
98
  }
89
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
90
- var reverse = (_options$reverse = options === null || options === void 0 ? void 0 : options.reverse) !== null && _options$reverse !== void 0 ? _options$reverse : false;
91
- return "\nbox-shadow:\n 0 ".concat(reverse ? '-' : '', "2.7px 9px ").concat((0, _functions.getShadowColor)(color, 0.13, colorMode), ",\n 0 ").concat(reverse ? '-' : '', "9.4px 24px ").concat((0, _functions.getShadowColor)(color, 0.09, colorMode), ",\n 0 ").concat(reverse ? '-' : '', "21.8px 43px ").concat((0, _functions.getShadowColor)(color, 0.08, colorMode), ";\n");
99
+ var direction = (_options$direction5 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction5 !== void 0 ? _options$direction5 : 'down';
100
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.xl[direction], {
101
+ border: options === null || options === void 0 ? void 0 : options.border
102
+ });
92
103
  };
93
104
 
94
105
  /**
95
- * slightShadowHover
106
+ * flat shadow
107
+ * @deprecated - use euiShadowHover instead
96
108
  */
97
- var euiSlightShadowHover = exports.euiSlightShadowHover = function euiSlightShadowHover(_ref6, options) {
98
- var euiTheme = _ref6.euiTheme,
99
- colorMode = _ref6.colorMode,
100
- highContrastMode = _ref6.highContrastMode;
109
+ var euiSlightShadowHover = exports.euiSlightShadowHover = function euiSlightShadowHover(euiThemeContext, options) {
110
+ var _options$direction6;
111
+ var euiTheme = euiThemeContext.euiTheme,
112
+ highContrastMode = euiThemeContext.highContrastMode;
101
113
  if (highContrastMode) {
102
- return _highContrastBorder(euiTheme, options);
114
+ return _highContrastBorder(euiThemeContext, options);
103
115
  }
104
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
105
- return "\nbox-shadow:\n 0 1px 5px ".concat((0, _functions.getShadowColor)(color, 0.1, colorMode), ",\n 0 3.6px 13px ").concat((0, _functions.getShadowColor)(color, 0.07, colorMode), ",\n 0 8.4px 23px ").concat((0, _functions.getShadowColor)(color, 0.06, colorMode), ",\n 0 23px 35px ").concat((0, _functions.getShadowColor)(color, 0.05, colorMode), ";\n");
116
+ var direction = (_options$direction6 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction6 !== void 0 ? _options$direction6 : 'down';
117
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.s[direction], {
118
+ border: options === null || options === void 0 ? void 0 : options.border
119
+ });
106
120
  };
107
121
 
108
122
  /**
109
- * bottomShadowFlat
123
+ * @deprecated - use euiShadowXSmall instead
110
124
  *
111
125
  * Similar to shadow medium but without the bottom depth.
112
126
  * Useful for popovers that drop UP rather than DOWN.
113
127
  */
114
- var euiShadowFlat = exports.euiShadowFlat = function euiShadowFlat(_ref7, options) {
115
- var euiTheme = _ref7.euiTheme,
116
- colorMode = _ref7.colorMode,
117
- highContrastMode = _ref7.highContrastMode;
128
+ var euiShadowFlat = exports.euiShadowFlat = function euiShadowFlat(euiThemeContext, options) {
129
+ var _options$direction7, _euiTheme$shadows$fla;
130
+ var euiTheme = euiThemeContext.euiTheme,
131
+ highContrastMode = euiThemeContext.highContrastMode;
118
132
  if (highContrastMode) {
119
- return _highContrastBorder(euiTheme, options);
133
+ return _highContrastBorder(euiThemeContext, options);
120
134
  }
121
- var color = (options === null || options === void 0 ? void 0 : options.color) || euiTheme.colors.shadow;
122
- return "\nbox-shadow:\n 0 0 .8px ".concat((0, _functions.getShadowColor)(color, 0.06, colorMode), ",\n 0 0 2px ").concat((0, _functions.getShadowColor)(color, 0.04, colorMode), ",\n 0 0 5px ").concat((0, _functions.getShadowColor)(color, 0.04, colorMode), ",\n 0 0 17px ").concat((0, _functions.getShadowColor)(color, 0.03, colorMode), ";\n");
135
+ var direction = (_options$direction7 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction7 !== void 0 ? _options$direction7 : 'down';
136
+ var value = (_euiTheme$shadows$fla = euiTheme.shadows.flat) === null || _euiTheme$shadows$fla === void 0 ? void 0 : _euiTheme$shadows$fla[direction];
137
+ return _shadowStyles(euiThemeContext, value, {
138
+ border: options === null || options === void 0 ? void 0 : options.border
139
+ });
123
140
  };
124
141
  var euiShadow = exports.euiShadow = function euiShadow(euiThemeContext) {
125
142
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'l';
126
143
  var options = arguments.length > 2 ? arguments[2] : undefined;
127
144
  if (euiThemeContext.highContrastMode) {
128
- return _highContrastBorder(euiThemeContext.euiTheme, options);
145
+ return _highContrastBorder(euiThemeContext, options);
129
146
  }
130
147
  switch (size) {
131
148
  case 'xs':
@@ -144,15 +161,72 @@ var euiShadow = exports.euiShadow = function euiShadow(euiThemeContext) {
144
161
  }
145
162
  };
146
163
 
164
+ /** Hover shadows */
165
+ var euiShadowHover = exports.euiShadowHover = function euiShadowHover(euiThemeContext) {
166
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'base';
167
+ var options = arguments.length > 2 ? arguments[2] : undefined;
168
+ if (euiThemeContext.highContrastMode) {
169
+ return _highContrastBorder(euiThemeContext, options);
170
+ }
171
+ switch (size) {
172
+ case 'base':
173
+ return _euiShadowHover(euiThemeContext, 'base', options);
174
+ case 'xs':
175
+ return _euiShadowHover(euiThemeContext, 's', options);
176
+ case 's':
177
+ return _euiShadowHover(euiThemeContext, 'm', options);
178
+ case 'm':
179
+ return _euiShadowHover(euiThemeContext, 'l', options);
180
+ case 'l':
181
+ return _euiShadowHover(euiThemeContext, 'xl', options);
182
+ case 'xl':
183
+ return _euiShadowHover(euiThemeContext, 'xxl', options);
184
+ default:
185
+ console.warn('Please provide a valid size option to useEuiShadow');
186
+ return '';
187
+ }
188
+ };
189
+ var _euiShadowHover = function _euiShadowHover(euiThemeContext) {
190
+ var _options$direction8;
191
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'l';
192
+ var options = arguments.length > 2 ? arguments[2] : undefined;
193
+ var euiTheme = euiThemeContext.euiTheme,
194
+ highContrastMode = euiThemeContext.highContrastMode;
195
+ if (highContrastMode) {
196
+ return _highContrastBorder(euiThemeContext, options);
197
+ }
198
+ var direction = (_options$direction8 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction8 !== void 0 ? _options$direction8 : 'down';
199
+ var shadow = size === 'base' ? euiTheme.shadows.hover.base[direction] : size === 'xxl' ? euiTheme.shadows.hover.xl[direction] : euiTheme.shadows[size][direction];
200
+ return _shadowStyles(euiThemeContext, shadow, {
201
+ border: options === null || options === void 0 ? void 0 : options.border
202
+ });
203
+ };
204
+
147
205
  /**
148
206
  * Internal utilities for replacing shadows with high contrast borders instead.
149
207
  * NOTE: Windows' high contrast themes ignore *all* `box-shadow` CSS,
150
208
  * so we use `border` CSS explicitly instead of shadows
151
209
  */
152
210
 
153
- var _highContrastBorder = function _highContrastBorder(_ref8) {
154
- var border = _ref8.border;
155
- var _ref9 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
156
- borderAllInHighContrastMode = _ref9.borderAllInHighContrastMode;
157
- return borderAllInHighContrastMode ? "border: ".concat(border.thin, ";") : "border-block-end: ".concat(border.thin, ";");
211
+ var _highContrastBorder = function _highContrastBorder(euiThemeContext) {
212
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
213
+ _ref$border = _ref.border,
214
+ border = _ref$border === void 0 ? 'all' : _ref$border,
215
+ borderAllInHighContrastMode = _ref.borderAllInHighContrastMode;
216
+ var euiTheme = euiThemeContext.euiTheme;
217
+ var hasFullBorder = borderAllInHighContrastMode || border && border !== 'none';
218
+ return hasFullBorder ? "border: ".concat(euiTheme.border.thin, ";") : "border-block-end: ".concat(euiTheme.border.thin, ";");
219
+ };
220
+ var _shadowStyles = function _shadowStyles(euiThemeContext, shadow, options) {
221
+ var euiTheme = euiThemeContext.euiTheme;
222
+ var isRefreshVariant = euiTheme.flags.shadowVariant === 'refresh';
223
+ var _options$border = options.border,
224
+ border = _options$border === void 0 ? 'all' : _options$border,
225
+ _options$type = options.type,
226
+ type = _options$type === void 0 ? 'box-shadow' : _options$type;
227
+ var borderStyle = euiThemeContext.colorMode === 'DARK' && border !== 'none' ? "".concat((0, _borders.euiShadowFloatingBorderStyles)(euiThemeContext, {
228
+ side: border !== null && border !== void 0 ? border : 'all'
229
+ })) : '';
230
+ var shadowStyle = type === 'filter' ? shadow : "box-shadow: ".concat(shadow, ";");
231
+ return "\n ".concat(shadowStyle, ";\n ").concat(isRefreshVariant && borderStyle, ";\n ");
158
232
  };
@@ -15,7 +15,7 @@ export interface _EuiThemeBorderWidthValues {
15
15
  export interface _EuiThemeBorderRadiusValues {
16
16
  /**
17
17
  * Primary corner radius size
18
- * - Default value: 4px (6px in Amsterdam)
18
+ * - Default value: 4px
19
19
  */
20
20
  medium: CSSProperties['borderRadius'];
21
21
  /**
@@ -67,7 +67,6 @@ export declare type _EuiThemeComponentColors = {
67
67
  filterSelectItemBackgroundFocusDisabled: ColorModeSwitch;
68
68
  flyoutFooterBackground: ColorModeSwitch;
69
69
  flyoutCloseButtonInsideBackground: ColorModeSwitch;
70
- keyPadMenuItemBackgroundDisabledSelect: ColorModeSwitch;
71
70
  listGroupItemBackgroundPrimaryActive: ColorModeSwitch;
72
71
  listGroupItemBackgroundSubduedActive: ColorModeSwitch;
73
72
  listGroupItemBackgroundHover: ColorModeSwitch;
@@ -1,11 +1,7 @@
1
1
  export declare type EuiThemeVariantFlags = {
2
- buttonVariant: 'classic' | 'refresh';
3
- formVariant: 'classic' | 'refresh';
2
+ shadowVariant: 'classic' | 'refresh';
4
3
  };
5
4
  /**
6
5
  * Theme specific setting flags
7
6
  */
8
- export declare type _EuiThemeFlags = {
9
- hasGlobalFocusColor: boolean;
10
- hasVisColorAdjustment: boolean;
11
- } & EuiThemeVariantFlags;
7
+ export declare type _EuiThemeFlags = EuiThemeVariantFlags;
@@ -1,5 +1,9 @@
1
+ import { CSSProperties } from 'react';
2
+ import { ColorModeSwitch } from '../../services/theme/types';
1
3
  export declare const EuiThemeShadowSizes: readonly ["xs", "s", "m", "l", "xl"];
2
4
  export declare type _EuiThemeShadowSize = (typeof EuiThemeShadowSizes)[number];
5
+ export declare const EuiThemeShadowHoverSizes: readonly ["s", "m", "l", "xl", "xxl"];
6
+ export declare type _EuiThemeShadowHoverSize = (typeof EuiThemeShadowHoverSizes)[number];
3
7
  /**
4
8
  * Shadow t-shirt sizes descriptions
5
9
  */
@@ -9,3 +13,51 @@ export interface _EuiThemeShadowCustomColor {
9
13
  property?: 'box-shadow' | 'filter';
10
14
  borderAllInHighContrastMode?: boolean;
11
15
  }
16
+ export declare type _EuiThemeShadow = {
17
+ /** Default direction of the shadow */
18
+ down: CSSProperties['boxShadow'];
19
+ /** Reverse direction */
20
+ up: CSSProperties['boxShadow'];
21
+ };
22
+ export declare type _EuiThemeShadows = ColorModeSwitch<{
23
+ colors: {
24
+ base: string;
25
+ };
26
+ xs: _EuiThemeShadow;
27
+ s: _EuiThemeShadow;
28
+ m: _EuiThemeShadow;
29
+ l: _EuiThemeShadow;
30
+ xl: _EuiThemeShadow;
31
+ hover: {
32
+ base: _EuiThemeShadow;
33
+ xl: _EuiThemeShadow;
34
+ };
35
+ /** @deprecated - Defined only to support the legacy `euiShadowFlat` mixin;
36
+ * will be removed in the future
37
+ */
38
+ flat: _EuiThemeShadow;
39
+ }>;
40
+ /**
41
+ * Represents a single shadow
42
+ * @see https://tr.designtokens.org/format/#shadow
43
+ */
44
+ export declare type _EuiThemeShadowLayer = {
45
+ opacity: number;
46
+ x: number;
47
+ y: number;
48
+ blur: number;
49
+ spread: number;
50
+ };
51
+ export declare type _EuiThemeShadowPrimitive = {
52
+ light: _EuiThemeShadowLayer[];
53
+ dark: _EuiThemeShadowLayer[];
54
+ };
55
+ export declare type _EuiThemeShadowPrimitives = {
56
+ xs: _EuiThemeShadowPrimitive;
57
+ s: _EuiThemeShadowPrimitive;
58
+ m: _EuiThemeShadowPrimitive;
59
+ l: _EuiThemeShadowPrimitive;
60
+ xl: _EuiThemeShadowPrimitive;
61
+ xxl: _EuiThemeShadowPrimitive;
62
+ flat: _EuiThemeShadowPrimitive;
63
+ };