@ember-eui/core 16.0.1 → 16.0.3

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 (141) hide show
  1. package/declarations/-private/associate-form-row-label.d.ts +9 -0
  2. package/declarations/-private/associate-form-row-label.d.ts.map +1 -0
  3. package/declarations/-private/vis-colors.d.ts +8 -0
  4. package/declarations/-private/vis-colors.d.ts.map +1 -0
  5. package/declarations/components/eui-aspect-ratio.d.ts +5 -0
  6. package/declarations/components/eui-aspect-ratio.d.ts.map +1 -1
  7. package/declarations/components/eui-avatar.d.ts +6 -0
  8. package/declarations/components/eui-avatar.d.ts.map +1 -1
  9. package/declarations/components/eui-basic-table.d.ts.map +1 -1
  10. package/declarations/components/eui-color-picker.d.ts +3 -0
  11. package/declarations/components/eui-color-picker.d.ts.map +1 -1
  12. package/declarations/components/eui-color-stops/thumb.d.ts +3 -1
  13. package/declarations/components/eui-color-stops/thumb.d.ts.map +1 -1
  14. package/declarations/components/eui-combo-box/trigger/input.d.ts +9 -0
  15. package/declarations/components/eui-combo-box/trigger/input.d.ts.map +1 -1
  16. package/declarations/components/eui-combo-box/trigger.d.ts +13 -0
  17. package/declarations/components/eui-combo-box/trigger.d.ts.map +1 -1
  18. package/declarations/components/eui-combo-box.d.ts +26 -0
  19. package/declarations/components/eui-combo-box.d.ts.map +1 -1
  20. package/declarations/components/eui-data-grid/body.d.ts +2 -0
  21. package/declarations/components/eui-data-grid/body.d.ts.map +1 -1
  22. package/declarations/components/eui-data-grid.d.ts.map +1 -1
  23. package/declarations/components/eui-dual-range.d.ts +2 -0
  24. package/declarations/components/eui-dual-range.d.ts.map +1 -1
  25. package/declarations/components/eui-focus-trap.d.ts +1 -0
  26. package/declarations/components/eui-focus-trap.d.ts.map +1 -1
  27. package/declarations/components/eui-global-toast-list.d.ts +8 -1
  28. package/declarations/components/eui-global-toast-list.d.ts.map +1 -1
  29. package/declarations/components/eui-markdown-editor-drop-zone.d.ts.map +1 -1
  30. package/declarations/components/eui-markdown-editor.d.ts.map +1 -1
  31. package/declarations/components/eui-markdown-format.d.ts +2 -0
  32. package/declarations/components/eui-markdown-format.d.ts.map +1 -1
  33. package/declarations/components/eui-overlay-mask.d.ts +5 -2
  34. package/declarations/components/eui-overlay-mask.d.ts.map +1 -1
  35. package/declarations/components/eui-popover.d.ts +5 -1
  36. package/declarations/components/eui-popover.d.ts.map +1 -1
  37. package/declarations/components/eui-range.d.ts +3 -0
  38. package/declarations/components/eui-range.d.ts.map +1 -1
  39. package/declarations/components/eui-saturation.d.ts +3 -1
  40. package/declarations/components/eui-saturation.d.ts.map +1 -1
  41. package/declarations/components/eui-search-bar/field-value-selection-filter.d.ts.map +1 -1
  42. package/declarations/components/eui-text-color.d.ts +6 -0
  43. package/declarations/components/eui-text-color.d.ts.map +1 -1
  44. package/declarations/components/eui-text.d.ts.map +1 -1
  45. package/declarations/components/eui-token.d.ts +11 -0
  46. package/declarations/components/eui-token.d.ts.map +1 -1
  47. package/declarations/components/eui-tool-tip.d.ts +1 -2
  48. package/declarations/components/eui-tool-tip.d.ts.map +1 -1
  49. package/declarations/modifiers/outside-click-detector.d.ts +3 -0
  50. package/declarations/modifiers/outside-click-detector.d.ts.map +1 -1
  51. package/declarations/modifiers/resize-observer.d.ts +3 -0
  52. package/declarations/modifiers/resize-observer.d.ts.map +1 -1
  53. package/declarations/services/eui-config.d.ts +5 -0
  54. package/declarations/services/eui-config.d.ts.map +1 -1
  55. package/declarations/utils/common.d.ts +42 -0
  56. package/declarations/utils/common.d.ts.map +1 -0
  57. package/declarations/utils/css-mappings/eui-avatar.d.ts +1 -1
  58. package/declarations/utils/css-mappings/eui-text.d.ts +1 -0
  59. package/declarations/utils/css-mappings/eui-text.d.ts.map +1 -1
  60. package/declarations/utils/eui/combo-box.d.ts +1 -1
  61. package/declarations/utils/eui/combo-box.d.ts.map +1 -1
  62. package/declarations/utils/eui/content-blocks.d.ts +14 -0
  63. package/declarations/utils/eui/content-blocks.d.ts.map +1 -0
  64. package/declarations/utils/eui/flyout-manager/reducer.d.ts.map +1 -1
  65. package/declarations/utils/eui/styles.d.ts +5 -0
  66. package/declarations/utils/eui/styles.d.ts.map +1 -1
  67. package/declarations/utils/retain-document-listener.d.ts +8 -0
  68. package/declarations/utils/retain-document-listener.d.ts.map +1 -0
  69. package/declarations/utils/token-map.d.ts +11 -0
  70. package/declarations/utils/token-map.d.ts.map +1 -0
  71. package/declarations/utils/transition.d.ts +1 -1
  72. package/declarations/utils/transition.d.ts.map +1 -1
  73. package/dist/components/eui-aspect-ratio.js +20 -5
  74. package/dist/components/eui-aspect-ratio.js.map +1 -1
  75. package/dist/components/eui-avatar.js +16 -4
  76. package/dist/components/eui-avatar.js.map +1 -1
  77. package/dist/components/eui-basic-table.js +4 -2
  78. package/dist/components/eui-basic-table.js.map +1 -1
  79. package/dist/components/eui-color-picker.js +8 -2
  80. package/dist/components/eui-color-picker.js.map +1 -1
  81. package/dist/components/eui-color-stops/thumb.js +17 -5
  82. package/dist/components/eui-color-stops/thumb.js.map +1 -1
  83. package/dist/components/eui-combo-box/trigger/input.js +23 -2
  84. package/dist/components/eui-combo-box/trigger/input.js.map +1 -1
  85. package/dist/components/eui-combo-box/trigger.js +32 -2
  86. package/dist/components/eui-combo-box/trigger.js.map +1 -1
  87. package/dist/components/eui-combo-box.js +40 -5
  88. package/dist/components/eui-combo-box.js.map +1 -1
  89. package/dist/components/eui-data-grid/body.js +21 -1
  90. package/dist/components/eui-data-grid/body.js.map +1 -1
  91. package/dist/components/eui-data-grid.js +6 -4
  92. package/dist/components/eui-data-grid.js.map +1 -1
  93. package/dist/components/eui-dual-range.js +5 -2
  94. package/dist/components/eui-dual-range.js.map +1 -1
  95. package/dist/components/eui-focus-trap.js +4 -1
  96. package/dist/components/eui-focus-trap.js.map +1 -1
  97. package/dist/components/eui-global-toast-list.js +33 -5
  98. package/dist/components/eui-global-toast-list.js.map +1 -1
  99. package/dist/components/eui-markdown-editor-drop-zone.js +2 -0
  100. package/dist/components/eui-markdown-editor-drop-zone.js.map +1 -1
  101. package/dist/components/eui-markdown-editor.js +3 -1
  102. package/dist/components/eui-markdown-editor.js.map +1 -1
  103. package/dist/components/eui-markdown-format.js +9 -3
  104. package/dist/components/eui-markdown-format.js.map +1 -1
  105. package/dist/components/eui-overlay-mask.js +2 -0
  106. package/dist/components/eui-overlay-mask.js.map +1 -1
  107. package/dist/components/eui-popover.js +22 -2
  108. package/dist/components/eui-popover.js.map +1 -1
  109. package/dist/components/eui-range.js +10 -3
  110. package/dist/components/eui-range.js.map +1 -1
  111. package/dist/components/eui-saturation.js +16 -4
  112. package/dist/components/eui-saturation.js.map +1 -1
  113. package/dist/components/eui-search-bar/field-value-selection-filter.js +8 -3
  114. package/dist/components/eui-search-bar/field-value-selection-filter.js.map +1 -1
  115. package/dist/components/eui-text-color.js +20 -6
  116. package/dist/components/eui-text-color.js.map +1 -1
  117. package/dist/components/eui-text.js +6 -3
  118. package/dist/components/eui-text.js.map +1 -1
  119. package/dist/components/eui-token.js +31 -17
  120. package/dist/components/eui-token.js.map +1 -1
  121. package/dist/components/eui-tool-tip.js +9 -17
  122. package/dist/components/eui-tool-tip.js.map +1 -1
  123. package/dist/icons-DCTZo11a.js.map +1 -1
  124. package/dist/modifiers/outside-click-detector.js +12 -2
  125. package/dist/modifiers/outside-click-detector.js.map +1 -1
  126. package/dist/modifiers/resize-observer.js +19 -4
  127. package/dist/modifiers/resize-observer.js.map +1 -1
  128. package/dist/services/eui-config.js.map +1 -1
  129. package/dist/utils/eui/combo-box.js +6 -2
  130. package/dist/utils/eui/combo-box.js.map +1 -1
  131. package/dist/utils/eui/flyout-manager/reducer.js +7 -1
  132. package/dist/utils/eui/flyout-manager/reducer.js.map +1 -1
  133. package/dist/utils/eui/styles.js +5 -0
  134. package/dist/utils/eui/styles.js.map +1 -1
  135. package/dist/utils/retain-document-listener.js +30 -0
  136. package/dist/utils/retain-document-listener.js.map +1 -0
  137. package/dist/utils/transition.js +8 -3
  138. package/dist/utils/transition.js.map +1 -1
  139. package/package.json +2 -2
  140. package/declarations/modifiers/open-collapsible-nav.d.ts +0 -9
  141. package/declarations/modifiers/open-collapsible-nav.d.ts.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { cached } from '@glimmer/tracking';
3
+ import style from 'ember-style-modifier/modifiers/style';
3
4
  import { getEuiThemeContext } from '../utils/emotion/consume.js';
4
5
  import { euiClass } from '../utils/eui/styles.js';
5
6
  import { precompileTemplate } from '@ember/template-compilation';
@@ -12,18 +13,29 @@ import { n } from 'decorator-transforms/runtime-esm';
12
13
  * wrapper takes those styles and its content fills it.
13
14
  */
14
15
  class EuiAspectRatio extends Component {
15
- get classes() {
16
+ /**
17
+ * The ratio and max width go inline, as upstream's `style`: a class per
18
+ * ratio would stay in the style cache for good.
19
+ */
20
+ get inlineStyle() {
16
21
  const {
17
22
  width,
18
23
  height,
19
24
  maxWidth
20
25
  } = this.args;
26
+ const inline = {
27
+ aspectRatio: `${width} / ${height}`
28
+ };
29
+ if (maxWidth !== undefined) {
30
+ inline['maxInlineSize'] = typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth;
31
+ }
32
+ return inline;
33
+ }
34
+ get classes() {
21
35
  return `euiAspectRatio ${euiClass(getEuiThemeContext(this), {
22
36
  boxSizing: 'border-box',
23
- aspectRatio: `${width} / ${height}`,
24
37
  blockSize: 'auto',
25
38
  inlineSize: '100%',
26
- maxInlineSize: typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth,
27
39
  // block, so an inline iframe/img adds no line-box descender space
28
40
  '& > *': {
29
41
  boxSizing: 'border-box',
@@ -37,8 +49,11 @@ class EuiAspectRatio extends Component {
37
49
  n(this.prototype, "classes", [cached]);
38
50
  }
39
51
  static {
40
- setComponentTemplate(precompileTemplate("<div class={{this.classes}} ...attributes>{{yield}}</div>", {
41
- strictMode: true
52
+ setComponentTemplate(precompileTemplate("<div class={{this.classes}} ...attributes {{style this.inlineStyle}}>{{yield}}</div>", {
53
+ strictMode: true,
54
+ scope: () => ({
55
+ style
56
+ })
42
57
  }), this);
43
58
  }
44
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eui-aspect-ratio.js","sources":["../../src/components/eui-aspect-ratio.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\n\nimport { getEuiThemeContext } from '../utils/emotion/consume.ts';\nimport { euiClass } from '../utils/eui/styles.ts';\n\n/**\n * Keeps its content (an iframe, video, image or map) at a fixed aspect\n * ratio while it takes the available width.\n */\nexport interface EuiAspectRatioSignature {\n Element: HTMLDivElement;\n Args: {\n /** Width part of the ratio, e.g. `16` for 16:9. */\n width: number;\n /** Height part of the ratio, e.g. `9` for 16:9. */\n height: number;\n /** Maximum width, e.g. `500` (px) or `'50%'`. */\n maxWidth?: number | string;\n };\n Blocks: {\n /** One element that fills the box, e.g. an `<iframe>`. */\n default: [];\n };\n}\n\n/**\n * Upstream clones its only child and gives it `aspect-ratio`, `height: auto`,\n * `width: 100%` and `max-width` (logical). Ember cannot clone a block, so the\n * wrapper takes those styles and its content fills it.\n */\nexport default class EuiAspectRatio extends Component<EuiAspectRatioSignature> {\n @cached\n get classes() {\n const { width, height, maxWidth } = this.args;\n return `euiAspectRatio ${euiClass(getEuiThemeContext(this), {\n boxSizing: 'border-box',\n aspectRatio: `${width} / ${height}`,\n blockSize: 'auto',\n inlineSize: '100%',\n maxInlineSize: typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth,\n // block, so an inline iframe/img adds no line-box descender space\n '& > *': {\n boxSizing: 'border-box',\n display: 'block',\n inlineSize: '100%',\n blockSize: '100%'\n }\n })}`;\n }\n\n <template>\n <div class={{this.classes}} ...attributes>{{yield}}</div>\n </template>\n}\n"],"names":["EuiAspectRatio","Component","classes","width","height","maxWidth","args","euiClass","getEuiThemeContext","boxSizing","aspectRatio","blockSize","inlineSize","maxInlineSize","display","n","prototype","cached","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;;;AA0BA;;;;;AAKe,MAAMA,cAAA,SAAuBC,SAAA,CAAU;EACpD,IACIC,OAAAA,GAAU;IACZ,MAAM;MAAEC,KAAK;MAAEC,MAAM;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACC,IAAI;AAC7C,IAAA,OAAO,kBAAkBC,QAAA,CAASC,kBAAA,CAAmB,IAAI,CAAA,EAAG;AAC1DC,MAAAA,SAAA,EAAW,YAAA;AACXC,MAAAA,WAAA,EAAa,CAAA,EAAGP,KAAA,CAAA,GAAA,EAAWC,MAAA,CAAA,CAAQ;AACnCO,MAAAA,SAAA,EAAW,MAAA;AACXC,MAAAA,UAAA,EAAY,MAAA;MACZC,aAAA,EAAe,OAAOR,QAAA,KAAa,QAAA,GAAW,CAAA,EAAGA,QAAA,CAAA,EAAA,CAAY,GAAGA,QAAA;AAChE;AACA,MAAA,OAAA,EAAS;AACPI,QAAAA,SAAA,EAAW,YAAA;AACXK,QAAAA,OAAA,EAAS,OAAA;AACTF,QAAAA,UAAA,EAAY,MAAA;AACZD,QAAAA,SAAA,EAAW;AACb;AACF,KAAA,CAAA,CAAA,CAAI;AACN,EAAA;AAAA,EAAA;IAAAI,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAjBCC,MAAA,CAAA,CAAA;AAAA;AAmBD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,2DAAA,EAEA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"eui-aspect-ratio.js","sources":["../../src/components/eui-aspect-ratio.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\n\nimport style from 'ember-style-modifier/modifiers/style';\n\nimport { getEuiThemeContext } from '../utils/emotion/consume.ts';\nimport { euiClass } from '../utils/eui/styles.ts';\n\n/**\n * Keeps its content (an iframe, video, image or map) at a fixed aspect\n * ratio while it takes the available width.\n */\nexport interface EuiAspectRatioSignature {\n Element: HTMLDivElement;\n Args: {\n /** Width part of the ratio, e.g. `16` for 16:9. */\n width: number;\n /** Height part of the ratio, e.g. `9` for 16:9. */\n height: number;\n /** Maximum width, e.g. `500` (px) or `'50%'`. */\n maxWidth?: number | string;\n };\n Blocks: {\n /** One element that fills the box, e.g. an `<iframe>`. */\n default: [];\n };\n}\n\n/**\n * Upstream clones its only child and gives it `aspect-ratio`, `height: auto`,\n * `width: 100%` and `max-width` (logical). Ember cannot clone a block, so the\n * wrapper takes those styles and its content fills it.\n */\nexport default class EuiAspectRatio extends Component<EuiAspectRatioSignature> {\n /**\n * The ratio and max width go inline, as upstream's `style`: a class per\n * ratio would stay in the style cache for good.\n */\n get inlineStyle(): Record<string, string> {\n const { width, height, maxWidth } = this.args;\n const inline: Record<string, string> = {\n aspectRatio: `${width} / ${height}`\n };\n if (maxWidth !== undefined) {\n inline['maxInlineSize'] =\n typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth;\n }\n return inline;\n }\n\n @cached\n get classes() {\n return `euiAspectRatio ${euiClass(getEuiThemeContext(this), {\n boxSizing: 'border-box',\n blockSize: 'auto',\n inlineSize: '100%',\n // block, so an inline iframe/img adds no line-box descender space\n '& > *': {\n boxSizing: 'border-box',\n display: 'block',\n inlineSize: '100%',\n blockSize: '100%'\n }\n })}`;\n }\n\n <template>\n <div class={{this.classes}} ...attributes {{style this.inlineStyle}}>{{yield}}</div>\n </template>\n}\n"],"names":["EuiAspectRatio","Component","inlineStyle","width","height","maxWidth","args","inline","aspectRatio","undefined","classes","euiClass","getEuiThemeContext","boxSizing","blockSize","inlineSize","display","n","prototype","cached","setComponentTemplate","precompileTemplate","strictMode","scope","style"],"mappings":";;;;;;;;;AA4BA;;;;;AAKe,MAAMA,cAAA,SAAuBC,SAAA,CAAU;AACpD;;;AAGC;EACD,IAAIC,WAAAA,GAAsC;IACxC,MAAM;MAAEC,KAAK;MAAEC,MAAM;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACC,IAAI;AAC7C,IAAA,MAAMC,MAA6B,GAAI;AACrCC,MAAAA,WAAA,EAAa,CAAA,EAAGL,KAAA,CAAA,GAAA,EAAWC,MAAA,CAAA;KAC7B;IACA,IAAIC,aAAaI,SAAA,EAAW;AAC1BF,MAAAA,MAAM,CAAC,eAAA,CAAgB,GACrB,OAAOF,QAAA,KAAa,WAAW,CAAA,EAAGA,QAAA,CAAA,EAAA,CAAY,GAAGA,QAAA;AACrD,IAAA;AACA,IAAA,OAAOE,MAAA;AACT,EAAA;EAEA,IACIG,OAAAA,GAAU;AACZ,IAAA,OAAO,kBAAkBC,QAAA,CAASC,kBAAA,CAAmB,IAAI,CAAA,EAAG;AAC1DC,MAAAA,SAAA,EAAW,YAAA;AACXC,MAAAA,SAAA,EAAW,MAAA;AACXC,MAAAA,UAAA,EAAY,MAAA;AACZ;AACA,MAAA,OAAA,EAAS;AACPF,QAAAA,SAAA,EAAW,YAAA;AACXG,QAAAA,OAAA,EAAS,OAAA;AACTD,QAAAA,UAAA,EAAY,MAAA;AACZD,QAAAA,SAAA,EAAW;AACb;AACF,KAAA,CAAA,CAAA,CAAI;AACN,EAAA;AAAA,EAAA;IAAAG,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAdCC,MAAA,CAAA,CAAA;AAAA;AAgBD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,sFAAA,EAEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -1,6 +1,7 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { cached } from '@glimmer/tracking';
3
3
  import { warn } from '@ember/debug';
4
+ import style from 'ember-style-modifier/modifiers/style';
4
5
  import { hexToRgb } from '../helpers/hex-to-rgb.js';
5
6
  import { isColorDark } from '../helpers/is-color-dark.js';
6
7
  import { isValidHex } from '../helpers/is-valid-hex.js';
@@ -69,6 +70,18 @@ function oneOf(values, value, fallback) {
69
70
  color: textColor
70
71
  };
71
72
  }
73
+ /**
74
+ * `avatarStyle` as inline styles (upstream sets them through `style`).
75
+ * Per-avatar values such as image URLs stay out of the shared style cache,
76
+ * which would otherwise keep one class per URL or color for good.
77
+ */
78
+ get inlineStyle() {
79
+ const inline = {};
80
+ for (const [key, value] of Object.entries(this.avatarStyle ?? {})) {
81
+ if (value !== undefined) inline[key] = value;
82
+ }
83
+ return inline;
84
+ }
72
85
  get isForcedColors() {
73
86
  return this.context.upstream.highContrastMode === 'forced';
74
87
  }
@@ -95,13 +108,11 @@ function oneOf(values, value, fallback) {
95
108
  const reset = {
96
109
  boxSizing: 'border-box'
97
110
  };
98
- // Upstream sets these inline; a class keeps the caller's `style` intact.
99
- const avatarStyle = this.avatarStyle;
100
111
  // Background colors are ignored in Windows forced-colors themes.
101
112
  const highContrastBorder = this.isForcedColors ? {
102
113
  border: context.upstream.euiTheme.border.thin
103
114
  } : undefined;
104
- return `euiAvatar ${euiClass(context, reset, styles['euiAvatar'], styles[type], styles[size], styles[casing], color === 'plain' && styles['plain'], color === 'subdued' && styles['subdued'], isDisabled && styles['isDisabled'], avatarStyle, highContrastBorder, this.args.css)}`;
115
+ return `euiAvatar ${euiClass(context, reset, styles['euiAvatar'], styles[type], styles[size], styles[casing], color === 'plain' && styles['plain'], color === 'subdued' && styles['subdued'], isDisabled && styles['isDisabled'], highContrastBorder, this.args.css)}`;
105
116
  }
106
117
  static {
107
118
  n(this.prototype, "classes", [cached]);
@@ -132,9 +143,10 @@ function oneOf(values, value, fallback) {
132
143
  }
133
144
  }
134
145
  /** The avatar element, with or without its tooltip anchor. */
135
- const AvatarNode = setComponentTemplate(precompileTemplate("<div class={{@avatar.classes}} aria-label={{if @avatar.args.isDisabled undefined @avatar.args.name}} role={{if @avatar.args.isDisabled \"presentation\" \"img\"}} ...attributes>\n {{#unless @avatar.args.imageUrl}}\n {{#if @avatar.args.iconType}}\n <EuiIcon @iconClasses=\"euiAvatar__icon\" @size={{@avatar.iconSize}} @type={{@avatar.args.iconType}} @color={{@avatar.iconColor}} aria-hidden=\"true\" />\n {{else}}\n <span aria-hidden=\"true\">{{@avatar.initials}}</span>\n {{/if}}\n {{/unless}}\n</div>", {
146
+ const AvatarNode = setComponentTemplate(precompileTemplate("<div class={{@avatar.classes}} aria-label={{if @avatar.args.isDisabled undefined @avatar.args.name}} role={{if @avatar.args.isDisabled \"presentation\" \"img\"}} ...attributes {{style @avatar.inlineStyle}}>\n {{#unless @avatar.args.imageUrl}}\n {{#if @avatar.args.iconType}}\n <EuiIcon @iconClasses=\"euiAvatar__icon\" @size={{@avatar.iconSize}} @type={{@avatar.args.iconType}} @color={{@avatar.iconColor}} aria-hidden=\"true\" />\n {{else}}\n <span aria-hidden=\"true\">{{@avatar.initials}}</span>\n {{/if}}\n {{/unless}}\n</div>", {
136
147
  strictMode: true,
137
148
  scope: () => ({
149
+ style,
138
150
  EuiIcon
139
151
  })
140
152
  }), templateOnly());
@@ -1 +1 @@
1
- {"version":3,"file":"eui-avatar.js","sources":["../../src/components/eui-avatar.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { warn } from '@ember/debug';\n\nimport { hexToRgb } from '../helpers/hex-to-rgb.ts';\nimport { isColorDark } from '../helpers/is-color-dark.ts';\nimport { isValidHex } from '../helpers/is-valid-hex.ts';\nimport { toInitials } from '../helpers/to-initials.ts';\nimport { getEuiThemeContext } from '../utils/emotion/consume.ts';\nimport { useEuiPaletteColorBlindBehindText } from '../utils/color/eui_palettes.ts';\nimport { euiClass, useEuiBorealisStyles } from '../utils/eui/styles.ts';\nimport type { EuiCss } from '../utils/eui/styles.ts';\nimport { euiAvatarStyles } from '../utils/eui/styles.generated.ts';\nimport EuiIcon from './eui-icon.gts';\nimport EuiToolTip from './eui-tool-tip.gts';\n\nimport type { TOC } from '@ember/component/template-only';\nimport type { CSSObject } from '@emotion/css/create-instance';\nimport type { SerializedStyles } from '@emotion/serialize';\nimport type { EuiIconSignature } from './eui-icon';\n\nexport const SIZES = ['s', 'm', 'l', 'xl'] as const;\nexport const TYPES = ['space', 'user'] as const;\nexport const CASING = ['capitalize', 'uppercase', 'lowercase', 'none'] as const;\n\nexport type EuiAvatarSize = (typeof SIZES)[number];\nexport type EuiAvatarType = (typeof TYPES)[number];\nexport type EuiAvatarCasing = (typeof CASING)[number];\n\ntype AvatarStyles = Record<string, SerializedStyles> & {\n tooltip: Record<string, SerializedStyles>;\n};\n\nfunction oneOf<T extends string>(\n values: readonly T[],\n value: unknown,\n fallback: T\n): T {\n return (values as readonly unknown[]).includes(value) ? (value as T) : fallback;\n}\n\nexport interface EuiAvatarSignature {\n Element: HTMLDivElement;\n Args: {\n /**\n * Full name of the user or space. Used as the accessible label and the\n * tooltip content, for the initials and to pick a background color.\n */\n name?: string;\n /**\n * Background color as a hex value (`'#DA8B45'`), `'plain'` (the page's\n * background color), `'subdued'` (a light gray), or `null` (the default\n * gray). Defaults to one of the theme's visualization colors, picked\n * from `@name`; the text color is chosen for contrast.\n */\n color?: string | null;\n /**\n * Color of the `@iconType` icon, any `EuiIcon` color. Defaults to the\n * text color picked for the background; `null` keeps the icon's own\n * colors (for multi-color logos).\n */\n iconColor?: string | null;\n /**\n * Size of the `@iconType` icon. Defaults to `@size`.\n */\n iconSize?: EuiIconSignature['Args']['size'];\n /**\n * Shows an icon instead of initials, e.g. `'logoElastic'` for a space.\n * Anything `EuiIcon`'s `@type` accepts.\n */\n iconType?: EuiIconSignature['Args']['type'];\n /**\n * Image shown as the avatar (as a background image), instead of initials.\n */\n imageUrl?: string;\n /**\n * Custom initials (max 2 characters) instead of the ones computed from\n * `@name`.\n */\n initials?: string;\n /**\n * Greys the avatar out and hides it from assistive technology.\n */\n isDisabled?: boolean;\n /**\n * `'s'` (24px), `'m'` (32px), `'l'` (40px) or `'xl'` (64px). Defaults\n * to `'m'`.\n */\n size?: EuiAvatarSize;\n /**\n * `'user'` renders a circle, `'space'` a rounded square.\n * Defaults to `'user'`.\n */\n type?: EuiAvatarType;\n /**\n * Text transform of the initials: `'capitalize'`, `'uppercase'`,\n * `'lowercase'` or `'none'`. Defaults to `'uppercase'` for users and\n * `'none'` for spaces.\n */\n casing?: EuiAvatarCasing;\n /**\n * Number of initials to compute from `@name`, `1` or `2`. Defaults to\n * the number of words in the name, up to 2.\n */\n initialsLength?: 1 | 2;\n /** Same as `@initialsLength` (the former name). */\n initialLength?: 1 | 2;\n /**\n * Extra styles composed last into this component's class (like upstream's\n * `css` prop). Prefer this to an extra class when styling it from a parent.\n */\n css?: EuiCss;\n };\n}\n\n/** Native Ember avatar using the upstream EUI 123 / Borealis styles. */\nexport default class EuiAvatar extends Component<EuiAvatarSignature> {\n get context() {\n return getEuiThemeContext(this);\n }\n\n get type(): EuiAvatarType {\n return oneOf(TYPES, this.args.type, 'user');\n }\n\n get initials(): string | null {\n const { initials } = this.args;\n\n if (initials && initials.length > 2) {\n warn(\n 'EuiAvatar only accepts a max of 2 characters for the initials as a string. It is displaying only the first 2 characters.',\n { id: 'EuiAvatar-initials-excedeed' }\n );\n }\n\n return toInitials(\n this.args.name ?? '',\n this.args.initialsLength ?? this.args.initialLength,\n initials\n );\n }\n\n /**\n * Upstream `avatarStyle`: the image, or a background color (by default a\n * visualization color picked from the name) with a contrasting text color.\n */\n get avatarStyle(): { backgroundImage?: string; backgroundColor?: string; color?: string } | undefined {\n const { color, imageUrl } = this.args;\n\n if (imageUrl) return { backgroundImage: `url(${imageUrl})` };\n\n if (color === 'plain' || color === 'subdued' || color === null) {\n return undefined;\n }\n\n if (color && !isValidHex(color)) {\n warn(\n 'EuiAvatar needs to pass a valid color. This can either be a three or six character hex value',\n false,\n { id: 'EuiAvatar-invalid-color' }\n );\n }\n\n const visColors = useEuiPaletteColorBlindBehindText(this.context.upstream);\n const name = this.args.name ?? '';\n const assignedColor =\n color || (visColors[Math.floor(name.length % visColors.length)] as string);\n const textColor = isColorDark(...hexToRgb(assignedColor))\n ? '#FFFFFF'\n : '#000000';\n\n return { backgroundColor: assignedColor, color: textColor };\n }\n\n get isForcedColors(): boolean {\n return this.context.upstream.highContrastMode === 'forced';\n }\n\n /** Upstream `styles.tooltip[type]`: the anchor rounds like the avatar. */\n @cached\n get tooltipCss(): EuiCss {\n const styles = useEuiBorealisStyles(\n this.context,\n euiAvatarStyles as unknown as (\n ...args: Parameters<typeof euiAvatarStyles>\n ) => AvatarStyles\n );\n\n return styles['tooltip']![this.type];\n }\n\n @cached\n get classes(): string {\n const context = this.context;\n const styles = useEuiBorealisStyles(\n context,\n euiAvatarStyles as unknown as (\n ...args: Parameters<typeof euiAvatarStyles>\n ) => AvatarStyles\n );\n const type = this.type;\n const size = oneOf(SIZES, this.args.size, 'm');\n const casing = oneOf(\n CASING,\n this.args.casing,\n type === 'space' ? 'none' : 'uppercase'\n );\n const { color, isDisabled } = this.args;\n // The React global reset makes every element border-box; without it the\n // forced-colors border would grow the avatar.\n const reset: CSSObject = { boxSizing: 'border-box' };\n // Upstream sets these inline; a class keeps the caller's `style` intact.\n const avatarStyle = this.avatarStyle as CSSObject | undefined;\n // Background colors are ignored in Windows forced-colors themes.\n const highContrastBorder: CSSObject | undefined = this.isForcedColors\n ? { border: context.upstream.euiTheme.border.thin }\n : undefined;\n\n return `euiAvatar ${euiClass(\n context,\n reset,\n styles['euiAvatar'],\n styles[type],\n styles[size],\n styles[casing],\n color === 'plain' && styles['plain'],\n color === 'subdued' && styles['subdued'],\n isDisabled && styles['isDisabled'],\n avatarStyle,\n highContrastBorder,\n this.args.css\n )}`;\n }\n\n get iconSize(): EuiIconSignature['Args']['size'] {\n return this.args.iconSize ?? oneOf(SIZES, this.args.size, 'm');\n }\n\n /** Upstream `iconCustomColor`. */\n get iconColor(): string | undefined {\n if (this.isForcedColors) {\n return this.context.upstream.euiTheme.colors.fullShade;\n }\n\n const { iconColor } = this.args;\n\n if (iconColor === null) return undefined;\n if (iconColor) return iconColor;\n\n return this.avatarStyle?.color;\n }\n\n <template>\n {{#if @name}}\n {{! upstream: the name is a visual tooltip; the avatar already has an\n aria-label }}\n <EuiToolTip\n @content={{@name}}\n @anchorCss={{this.tooltipCss}}\n @disableScreenReaderOutput={{true}}\n >\n <AvatarNode @avatar={{this}} ...attributes />\n </EuiToolTip>\n {{else}}\n <AvatarNode @avatar={{this}} ...attributes />\n {{/if}}\n </template>\n}\n\n/** The avatar element, with or without its tooltip anchor. */\nconst AvatarNode: TOC<{\n Element: HTMLDivElement;\n Args: { avatar: EuiAvatar };\n}> = <template>\n <div\n class={{@avatar.classes}}\n aria-label={{if @avatar.args.isDisabled undefined @avatar.args.name}}\n role={{if @avatar.args.isDisabled \"presentation\" \"img\"}}\n ...attributes\n >\n {{#unless @avatar.args.imageUrl}}\n {{#if @avatar.args.iconType}}\n <EuiIcon\n @iconClasses=\"euiAvatar__icon\"\n @size={{@avatar.iconSize}}\n @type={{@avatar.args.iconType}}\n @color={{@avatar.iconColor}}\n aria-hidden=\"true\"\n />\n {{else}}\n <span aria-hidden=\"true\">{{@avatar.initials}}</span>\n {{/if}}\n {{/unless}}\n </div>\n</template>;\n"],"names":["SIZES","TYPES","CASING","oneOf","values","value","fallback","includes","EuiAvatar","Component","context","getEuiThemeContext","type","args","initials","length","warn","id","toInitials","name","initialsLength","initialLength","avatarStyle","color","imageUrl","backgroundImage","undefined","isValidHex","visColors","useEuiPaletteColorBlindBehindText","upstream","assignedColor","Math","floor","textColor","isColorDark","hexToRgb","backgroundColor","isForcedColors","highContrastMode","tooltipCss","styles","useEuiBorealisStyles","euiAvatarStyles","n","prototype","cached","classes","size","casing","isDisabled","reset","boxSizing","highContrastBorder","border","euiTheme","thin","euiClass","css","iconSize","iconColor","colors","fullShade","setComponentTemplate","precompileTemplate","strictMode","scope","EuiToolTip","AvatarNode","EuiIcon","templateOnly"],"mappings":";;;;;;;;;;;;;;;;;;AAqBO,MAAMA,KAAA,GAAQ,CAAC,GAAA,EAAK,GA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,QAAQ,IAAIxD,KAAA,CAAMH,KAAA,EAAO,IAAI,CAACa,IAAI,CAACmC,IAAI,EAAE,GAAA,CAAA;AAC5D,EAAA;AAEA;EACA,IAAIY,SAAAA,GAAgC;IAClC,IAAI,IAAI,CAACtB,cAAc,EAAE;MACvB,OAAO,IAAI,CAAC5B,OAAO,CAACoB,QAAQ,CAACyB,QAAQ,CAACM,MAAM,CAACC,SAAS;AACxD,IAAA;IAEA,MAAM;AAAEF,MAAAA;KAAW,GAAG,IAAI,CAAC/C,IAAI;AAE/B,IAAA,IAAI+C,SAAA,KAAc,MAAM,OAAOlC,SAAA;IAC/B,IAAIkC,WAAW,OAAOA,SAAA;AAEtB,IAAA,OAAO,IAAI,CAACtC,WAAW,EAAEC,KAAA;AAC3B,EAAA;AAEA,EAAA;IAAAwC,oBAAA,CAAAC,kBAAA,CAAA,+VAAA,EAcA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,UAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA;AACA,MAAMA,UAGD,GAAAL,oBAAA,CAAAC,kBAAA,CAAA,2gBAAA,EAqBL;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAG,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;;"}
1
+ {"version":3,"file":"eui-avatar.js","sources":["../../src/components/eui-avatar.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { warn } from '@ember/debug';\n\nimport style from 'ember-style-modifier/modifiers/style';\n\nimport { hexToRgb } from '../helpers/hex-to-rgb.ts';\nimport { isColorDark } from '../helpers/is-color-dark.ts';\nimport { isValidHex } from '../helpers/is-valid-hex.ts';\nimport { toInitials } from '../helpers/to-initials.ts';\nimport { getEuiThemeContext } from '../utils/emotion/consume.ts';\nimport { useEuiPaletteColorBlindBehindText } from '../utils/color/eui_palettes.ts';\nimport { euiClass, useEuiBorealisStyles } from '../utils/eui/styles.ts';\nimport type { EuiCss } from '../utils/eui/styles.ts';\nimport { euiAvatarStyles } from '../utils/eui/styles.generated.ts';\nimport EuiIcon from './eui-icon.gts';\nimport EuiToolTip from './eui-tool-tip.gts';\n\nimport type { TOC } from '@ember/component/template-only';\nimport type { CSSObject } from '@emotion/css/create-instance';\nimport type { SerializedStyles } from '@emotion/serialize';\nimport type { EuiIconSignature } from './eui-icon';\n\nexport const SIZES = ['s', 'm', 'l', 'xl'] as const;\nexport const TYPES = ['space', 'user'] as const;\nexport const CASING = ['capitalize', 'uppercase', 'lowercase', 'none'] as const;\n\nexport type EuiAvatarSize = (typeof SIZES)[number];\nexport type EuiAvatarType = (typeof TYPES)[number];\nexport type EuiAvatarCasing = (typeof CASING)[number];\n\ntype AvatarStyles = Record<string, SerializedStyles> & {\n tooltip: Record<string, SerializedStyles>;\n};\n\nfunction oneOf<T extends string>(\n values: readonly T[],\n value: unknown,\n fallback: T\n): T {\n return (values as readonly unknown[]).includes(value) ? (value as T) : fallback;\n}\n\nexport interface EuiAvatarSignature {\n Element: HTMLDivElement;\n Args: {\n /**\n * Full name of the user or space. Used as the accessible label and the\n * tooltip content, for the initials and to pick a background color.\n */\n name?: string;\n /**\n * Background color as a hex value (`'#DA8B45'`), `'plain'` (the page's\n * background color), `'subdued'` (a light gray), or `null` (the default\n * gray). Defaults to one of the theme's visualization colors, picked\n * from `@name`; the text color is chosen for contrast.\n */\n color?: string | null;\n /**\n * Color of the `@iconType` icon, any `EuiIcon` color. Defaults to the\n * text color picked for the background; `null` keeps the icon's own\n * colors (for multi-color logos).\n */\n iconColor?: string | null;\n /**\n * Size of the `@iconType` icon. Defaults to `@size`.\n */\n iconSize?: EuiIconSignature['Args']['size'];\n /**\n * Shows an icon instead of initials, e.g. `'logoElastic'` for a space.\n * Anything `EuiIcon`'s `@type` accepts.\n */\n iconType?: EuiIconSignature['Args']['type'];\n /**\n * Image shown as the avatar (as a background image), instead of initials.\n */\n imageUrl?: string;\n /**\n * Custom initials (max 2 characters) instead of the ones computed from\n * `@name`.\n */\n initials?: string;\n /**\n * Greys the avatar out and hides it from assistive technology.\n */\n isDisabled?: boolean;\n /**\n * `'s'` (24px), `'m'` (32px), `'l'` (40px) or `'xl'` (64px). Defaults\n * to `'m'`.\n */\n size?: EuiAvatarSize;\n /**\n * `'user'` renders a circle, `'space'` a rounded square.\n * Defaults to `'user'`.\n */\n type?: EuiAvatarType;\n /**\n * Text transform of the initials: `'capitalize'`, `'uppercase'`,\n * `'lowercase'` or `'none'`. Defaults to `'uppercase'` for users and\n * `'none'` for spaces.\n */\n casing?: EuiAvatarCasing;\n /**\n * Number of initials to compute from `@name`, `1` or `2`. Defaults to\n * the number of words in the name, up to 2.\n */\n initialsLength?: 1 | 2;\n /** Same as `@initialsLength` (the former name). */\n initialLength?: 1 | 2;\n /**\n * Extra styles composed last into this component's class (like upstream's\n * `css` prop). Prefer this to an extra class when styling it from a parent.\n */\n css?: EuiCss;\n };\n}\n\n/** Native Ember avatar using the upstream EUI 123 / Borealis styles. */\nexport default class EuiAvatar extends Component<EuiAvatarSignature> {\n get context() {\n return getEuiThemeContext(this);\n }\n\n get type(): EuiAvatarType {\n return oneOf(TYPES, this.args.type, 'user');\n }\n\n get initials(): string | null {\n const { initials } = this.args;\n\n if (initials && initials.length > 2) {\n warn(\n 'EuiAvatar only accepts a max of 2 characters for the initials as a string. It is displaying only the first 2 characters.',\n { id: 'EuiAvatar-initials-excedeed' }\n );\n }\n\n return toInitials(\n this.args.name ?? '',\n this.args.initialsLength ?? this.args.initialLength,\n initials\n );\n }\n\n /**\n * Upstream `avatarStyle`: the image, or a background color (by default a\n * visualization color picked from the name) with a contrasting text color.\n */\n get avatarStyle(): { backgroundImage?: string; backgroundColor?: string; color?: string } | undefined {\n const { color, imageUrl } = this.args;\n\n if (imageUrl) return { backgroundImage: `url(${imageUrl})` };\n\n if (color === 'plain' || color === 'subdued' || color === null) {\n return undefined;\n }\n\n if (color && !isValidHex(color)) {\n warn(\n 'EuiAvatar needs to pass a valid color. This can either be a three or six character hex value',\n false,\n { id: 'EuiAvatar-invalid-color' }\n );\n }\n\n const visColors = useEuiPaletteColorBlindBehindText(this.context.upstream);\n const name = this.args.name ?? '';\n const assignedColor =\n color || (visColors[Math.floor(name.length % visColors.length)] as string);\n const textColor = isColorDark(...hexToRgb(assignedColor))\n ? '#FFFFFF'\n : '#000000';\n\n return { backgroundColor: assignedColor, color: textColor };\n }\n\n /**\n * `avatarStyle` as inline styles (upstream sets them through `style`).\n * Per-avatar values such as image URLs stay out of the shared style cache,\n * which would otherwise keep one class per URL or color for good.\n */\n get inlineStyle(): Record<string, string> {\n const inline: Record<string, string> = {};\n for (const [key, value] of Object.entries(this.avatarStyle ?? {})) {\n if (value !== undefined) inline[key] = value;\n }\n return inline;\n }\n\n get isForcedColors(): boolean {\n return this.context.upstream.highContrastMode === 'forced';\n }\n\n /** Upstream `styles.tooltip[type]`: the anchor rounds like the avatar. */\n @cached\n get tooltipCss(): EuiCss {\n const styles = useEuiBorealisStyles(\n this.context,\n euiAvatarStyles as unknown as (\n ...args: Parameters<typeof euiAvatarStyles>\n ) => AvatarStyles\n );\n\n return styles['tooltip']![this.type];\n }\n\n @cached\n get classes(): string {\n const context = this.context;\n const styles = useEuiBorealisStyles(\n context,\n euiAvatarStyles as unknown as (\n ...args: Parameters<typeof euiAvatarStyles>\n ) => AvatarStyles\n );\n const type = this.type;\n const size = oneOf(SIZES, this.args.size, 'm');\n const casing = oneOf(\n CASING,\n this.args.casing,\n type === 'space' ? 'none' : 'uppercase'\n );\n const { color, isDisabled } = this.args;\n // The React global reset makes every element border-box; without it the\n // forced-colors border would grow the avatar.\n const reset: CSSObject = { boxSizing: 'border-box' };\n // Background colors are ignored in Windows forced-colors themes.\n const highContrastBorder: CSSObject | undefined = this.isForcedColors\n ? { border: context.upstream.euiTheme.border.thin }\n : undefined;\n\n return `euiAvatar ${euiClass(\n context,\n reset,\n styles['euiAvatar'],\n styles[type],\n styles[size],\n styles[casing],\n color === 'plain' && styles['plain'],\n color === 'subdued' && styles['subdued'],\n isDisabled && styles['isDisabled'],\n highContrastBorder,\n this.args.css\n )}`;\n }\n\n get iconSize(): EuiIconSignature['Args']['size'] {\n return this.args.iconSize ?? oneOf(SIZES, this.args.size, 'm');\n }\n\n /** Upstream `iconCustomColor`. */\n get iconColor(): string | undefined {\n if (this.isForcedColors) {\n return this.context.upstream.euiTheme.colors.fullShade;\n }\n\n const { iconColor } = this.args;\n\n if (iconColor === null) return undefined;\n if (iconColor) return iconColor;\n\n return this.avatarStyle?.color;\n }\n\n <template>\n {{#if @name}}\n {{! upstream: the name is a visual tooltip; the avatar already has an\n aria-label }}\n <EuiToolTip\n @content={{@name}}\n @anchorCss={{this.tooltipCss}}\n @disableScreenReaderOutput={{true}}\n >\n <AvatarNode @avatar={{this}} ...attributes />\n </EuiToolTip>\n {{else}}\n <AvatarNode @avatar={{this}} ...attributes />\n {{/if}}\n </template>\n}\n\n/** The avatar element, with or without its tooltip anchor. */\nconst AvatarNode: TOC<{\n Element: HTMLDivElement;\n Args: { avatar: EuiAvatar };\n}> = <template>\n <div\n class={{@avatar.classes}}\n aria-label={{if @avatar.args.isDisabled undefined @avatar.args.name}}\n role={{if @avatar.args.isDisabled \"presentation\" \"img\"}}\n ...attributes\n {{style @avatar.inlineStyle}}\n >\n {{#unless @avatar.args.imageUrl}}\n {{#if @avatar.args.iconType}}\n <EuiIcon\n @iconClasses=\"euiAvatar__icon\"\n @size={{@avatar.iconSize}}\n @type={{@avatar.args.iconType}}\n @color={{@avatar.iconColor}}\n aria-hidden=\"true\"\n />\n {{else}}\n <span aria-hidden=\"true\">{{@avatar.initials}}</span>\n {{/if}}\n {{/unless}}\n </div>\n</template>;\n"],"names":["SIZES","TYPES","CASING","oneOf","values","value","fallback","includes","EuiAvatar","Component","context","getEuiThemeContext","type","args","initials","length","warn","id","toInitials","name","initialsLength","initialLength","avatarStyle","color","imageUrl","backgroundImage","undefined","isValidHex","visColors","useEuiPaletteColorBlindBehindText","upstream","assignedColor","Math","floor","textColor","isColorDark","hexToRgb","backgroundColor","inlineStyle","inline","key","Object","entries","isForcedColors","highContrastMode","tooltipCss","styles","useEuiBorealisStyles","euiAvatarStyles","n","prototype","cached","classes","size","casing","isDisabled","reset","boxSizing","highContrastBorder","border","euiTheme","thin","euiClass","css","iconSize","iconColor","colors","fullShade","setComponentTemplate","precompileTemplate","strictMode","scope","EuiToolTip","AvatarNode","style","EuiIcon","templateOnly"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBO,MAAMA,KAAA,GAAQ,CAAC,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,IAAA;MACxBC,KAAA,GAAQ,CAAC,OAAA,EAAS,MAAA;AACxB,MAAMC,MAAA,GAAS,CAAC,YAAA,EAAc,WAAA,EAAa,WAAA,EAAa,MAAA;AAU/D,SAASC,KAAAA,CACPC,MAAoB,EACpBC,KAAc,EACdC,QAAW,EACV;EACD,OAAQF,MAAA,CAA8BG,QAAQ,CAACF,KAAA,CAAA,GAAUA,KAAA,GAAcC,QAAA;AACzE;AA4EA,wEACe,MAAME,SAAA,SAAkBC,SAAA,CAAU;EAC/C,IAAIC,OAAAA,GAAU;IACZ,OAAOC,mBAAmB,IAAI,CAAA;AAChC,EAAA;EAEA,IAAIC,OAAsB;IACxB,OAAOT,MAAMF,KAAA,EAAO,IAAI,CAACY,IAAI,CAACD,IAAI,EAAE,MAAA,CAAA;AACtC,EAAA;EAEA,IAAIE,QAAAA,GAA0B;IAC5B,MAAM;AAAEA,MAAAA;KAAU,GAAG,IAAI,CAACD,IAAI;AAE9B,IAAA,IAAIC,QAAA,IAAYA,QAAA,CAASC,MAAM,GAAG,CAAA,EAAG;MACnCC,IAAA,CACE,0HAAA,EACA;AAAEC,QAAAA,EAAA,EAAI;AAA8B,OAAA,CAAA;AAExC,IAAA;IAEA,OAAOC,WAC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VAAA,EAcA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,UAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA;AACA,MAAMA,UAGD,GAAAL,oBAAA,CAAAC,kBAAA,CAAA,yiBAAA,EAsBL;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAG,KAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;;"}
@@ -1,3 +1,4 @@
1
+ import { registerDestructor } from '@ember/destroyable';
1
2
  import Component from '@glimmer/component';
2
3
  import { tracked, cached } from '@glimmer/tracking';
3
4
  import { fn } from '@ember/helper';
@@ -10,6 +11,7 @@ import { getItemId, getAlignForDataType, getRowProps, getRendererForDataType, sp
10
11
  import TableNode from '../-private/table-node.js';
11
12
  import { euiTablePaginationDefaults } from '../-private/table-pagination-defaults.js';
12
13
  import TabularCopyMarker from '../-private/tabular-copy-marker.js';
14
+ import { retainDocumentListener } from '../utils/retain-document-listener.js';
13
15
  import { onTabularCopy } from '../utils/data-grid/tabular-copy.js';
14
16
  import { randomId } from '../-private/random-id.js';
15
17
  import { getEuiThemeContext } from '../utils/emotion/consume.js';
@@ -74,8 +76,8 @@ class EuiBasicTable extends Component {
74
76
  constructor(owner, args) {
75
77
  super(owner, args);
76
78
  // tabs/newlines for copied selections (upstream `OverrideCopiedTabularContent`
77
- // registers it on the document; static handler: deduped)
78
- document.addEventListener('copy', onTabularCopy);
79
+ // registers it on the document; static handler, ref-counted across instances)
80
+ registerDestructor(this, retainDocumentListener('copy', onTabularCopy));
79
81
  }
80
82
  /** Uncontrolled selection, `null` until the user (or `initialSelected`) sets it. */
81
83
  static {