@elastic/eui 107.0.0 → 107.0.1

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 (32) hide show
  1. package/es/components/badge/beta_badge/beta_badge.js +1 -0
  2. package/es/components/basic_table/basic_table.styles.js +6 -4
  3. package/es/components/code/code_syntax.styles.js +1 -1
  4. package/es/components/icon/icon.js +31 -14
  5. package/es/components/icon/icon_map.js +1 -1
  6. package/es/components/table/table_row.styles.js +3 -3
  7. package/eui.d.ts +1 -1
  8. package/lib/components/badge/beta_badge/beta_badge.js +1 -0
  9. package/lib/components/basic_table/basic_table.styles.js +5 -3
  10. package/lib/components/code/code_syntax.styles.js +1 -1
  11. package/lib/components/icon/icon.js +31 -14
  12. package/lib/components/icon/icon_map.js +1 -1
  13. package/lib/components/table/table_row.styles.js +3 -3
  14. package/optimize/es/components/badge/beta_badge/beta_badge.js +1 -0
  15. package/optimize/es/components/basic_table/basic_table.styles.js +6 -4
  16. package/optimize/es/components/code/code_syntax.styles.js +1 -1
  17. package/optimize/es/components/icon/icon.js +31 -14
  18. package/optimize/es/components/icon/icon_map.js +1 -1
  19. package/optimize/es/components/table/table_row.styles.js +3 -3
  20. package/optimize/lib/components/badge/beta_badge/beta_badge.js +1 -0
  21. package/optimize/lib/components/basic_table/basic_table.styles.js +5 -3
  22. package/optimize/lib/components/code/code_syntax.styles.js +1 -1
  23. package/optimize/lib/components/icon/icon.js +31 -14
  24. package/optimize/lib/components/icon/icon_map.js +1 -1
  25. package/optimize/lib/components/table/table_row.styles.js +3 -3
  26. package/package/eui.d.ts +33359 -0
  27. package/package.json +2 -2
  28. package/test-env/components/badge/beta_badge/beta_badge.js +1 -0
  29. package/test-env/components/basic_table/basic_table.styles.js +5 -3
  30. package/test-env/components/code/code_syntax.styles.js +1 -1
  31. package/test-env/components/icon/icon_map.js +1 -1
  32. package/test-env/components/table/table_row.styles.js +3 -3
@@ -30,7 +30,7 @@ var _services = require("../../services");
30
30
  var _named_colors = require("./named_colors");
31
31
  var _icon = require("./icon.styles");
32
32
  var _react3 = require("@emotion/react");
33
- var _excluded = ["type", "size", "color", "className", "tabIndex", "title", "onIconLoad", "style", "stylesMemoizer"];
33
+ var _excluded = ["type", "size", "color", "className", "tabIndex", "title", "role", "onIconLoad", "style", "stylesMemoizer", "aria-hidden", "titleId"];
34
34
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
35
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
36
36
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -194,9 +194,12 @@ var EuiIconClass = exports.EuiIconClass = /*#__PURE__*/function (_PureComponent)
194
194
  className = _this$props.className,
195
195
  tabIndex = _this$props.tabIndex,
196
196
  title = _this$props.title,
197
+ role = _this$props.role,
197
198
  onIconLoad = _this$props.onIconLoad,
198
199
  style = _this$props.style,
199
200
  stylesMemoizer = _this$props.stylesMemoizer,
201
+ ariaHidden = _this$props['aria-hidden'],
202
+ titleId = _this$props.titleId,
200
203
  rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
201
204
  var _this$state = this.state,
202
205
  isLoading = _this$state.isLoading,
@@ -221,41 +224,55 @@ var EuiIconClass = exports.EuiIconClass = /*#__PURE__*/function (_PureComponent)
221
224
  var styles = stylesMemoizer(_icon.euiIconStyles);
222
225
  var cssStyles = [styles.euiIcon, styles[size], color && (0, _named_colors.isNamedColor)(color) && styles[color], isCustomColor && styles.customColor, isElasticLogoOutline && styles.logoElasticOutline, isAppIcon && !appIconHasColor && styles.app, isLoading && styles.isLoading, !isLoading && neededLoading && styles.isLoaded];
223
226
  var icon = this.state.icon || _empty.icon;
227
+ var isAriaHidden = [true, 'true'].includes(ariaHidden !== null && ariaHidden !== void 0 ? ariaHidden : false);
228
+ var isPresentationOnly = !(title || this.props['aria-label'] || this.props['aria-labelledby']) || ['none', 'presentation'].includes(role !== null && role !== void 0 ? role : '') || isAriaHidden;
229
+ var accessibleTitle = isPresentationOnly ? undefined : title;
230
+
231
+ // implicitly set the ARIA role for the icon only if:
232
+ // - The user did NOT provide a `role` prop
233
+ // - `aria-hidden` is NOT true
234
+ // This ensures user-supplied `role` and `aria-hidden` always take precedence.
235
+ // If set, role is:
236
+ // - 'presentation' for decorative icons
237
+ // - 'img' for meaningful icons
238
+ var accessibleRole = function () {
239
+ if (isAriaHidden) return undefined;
240
+ if (isPresentationOnly) return 'presentation';
241
+ return 'img';
242
+ }();
224
243
  if (typeof icon === 'string') {
225
244
  return (0, _react3.jsx)("img", (0, _extends2.default)({
226
- alt: title ? title : '',
245
+ alt: accessibleTitle,
227
246
  src: icon,
228
247
  className: classes,
229
248
  css: cssStyles,
230
249
  style: style,
231
- tabIndex: tabIndex
250
+ tabIndex: tabIndex,
251
+ role: role !== null && role !== void 0 ? role : accessibleRole,
252
+ "aria-hidden": ariaHidden
232
253
  }, rest));
233
254
  } else {
234
255
  var Svg = icon;
235
256
 
236
- // If there is no aria-label, aria-labelledby, or title it gets aria-hidden true
237
- var isAriaHidden = !(this.props['aria-label'] || this.props['aria-labelledby'] || this.props.title);
238
-
239
257
  // If no aria-label or aria-labelledby is provided but there's a title, a titleId is generated
240
258
  // The svg aria-labelledby attribute gets this titleId
241
259
  // The svg title element gets this titleId as an id
242
- var titleId = !this.props['aria-label'] && !this.props['aria-labelledby'] && title ? {
243
- titleId: generateId()
260
+ var accessibleTitleId = !this.props['aria-label'] && !this.props['aria-labelledby'] && title ? {
261
+ titleId: titleId || generateId()
244
262
  } : undefined;
245
263
  return (0, _react3.jsx)(Svg, (0, _extends2.default)({
246
264
  className: classes,
247
265
  style: optionalCustomStyles,
248
266
  css: cssStyles,
249
267
  tabIndex: tabIndex,
250
- role: "img",
251
- title: title
252
- }, titleId, {
268
+ title: accessibleTitle,
269
+ role: role !== null && role !== void 0 ? role : accessibleRole,
270
+ "aria-hidden": ariaHidden
271
+ }, accessibleTitleId, {
253
272
  "data-icon-type": iconTitle,
254
273
  "data-is-loaded": isLoaded || undefined,
255
274
  "data-is-loading": isLoading || undefined
256
- }, rest, {
257
- "aria-hidden": isAriaHidden || rest['aria-hidden']
258
- }));
275
+ }, rest));
259
276
  }
260
277
  }
261
278
  }]);
@@ -507,7 +507,7 @@ var typeToPathMap = exports.typeToPathMap = {
507
507
  vulnerabilityManagementApp: 'app_vulnerability_management',
508
508
  warning: 'warning',
509
509
  warningFilled: 'warning',
510
- // NOTE: To be deprecated in favor of `export`
510
+ // NOTE: To be deprecated in favor of `warning`
511
511
  watchesApp: 'app_watches',
512
512
  web: 'web',
513
513
  wordWrap: 'wordWrap',
@@ -53,7 +53,7 @@ var euiTableRowStyles = exports.euiTableRowStyles = function euiTableRowStyles(e
53
53
  * Right column styles + border
54
54
  * Used for cell actions and row expander arrow
55
55
  */
56
- hasRightColumn: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-right', mobileSizes.actions.width), " &::after{content:'';position:absolute;", (0, _global_styling.logicalCSS)('vertical', 0), " ", (0, _global_styling.logicalCSS)('right', mobileSizes.actions.width), " ", (0, _global_styling.logicalCSS)('border-right', euiTheme.border.thin), ";};label:hasRightColumn;"),
56
+ hasRightColumn: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('padding-right', mobileSizes.actions.width), " &::before{content:'';position:absolute;", (0, _global_styling.logicalCSS)('vertical', 0), " ", (0, _global_styling.logicalCSS)('right', mobileSizes.actions.width), " ", (0, _global_styling.logicalCSS)('border-right', euiTheme.border.thin), ";};label:hasRightColumn;"),
57
57
  /**
58
58
  * Bottom of card - expanded rows
59
59
  */
@@ -61,8 +61,8 @@ var euiTableRowStyles = exports.euiTableRowStyles = function euiTableRowStyles(e
61
61
  // On mobile, visually move the expanded row to join up with the
62
62
  // preceding table row via negative margins
63
63
  'margin-top', (0, _global_styling.mathWithUnits)([cellContentPadding, euiTheme.border.width.thin], function (x, y) {
64
- return (x + y) * -1;
65
- })), (0, _global_styling.logicalCSS)('padding-left', cellContentPadding), " ", (0, _global_styling.logicalCSS)('border-top', euiTheme.border.thin), " ", (0, _global_styling.logicalCSS)('border-top-left-radius', 0), " ", (0, _global_styling.logicalCSS)('border-top-right-radius', 0), ">.euiTableRowCell{", (0, _global_styling.logicalCSS)('width', '100%'), ";}", expandedAnimationCss, ";;label:expanded;")
64
+ return (x + y * 2) * -1;
65
+ })), (0, _global_styling.logicalCSS)('padding-left', cellContentPadding), " ", (0, _global_styling.logicalCSS)('border-top', euiTheme.border.thin), " ", (0, _global_styling.logicalCSS)('border-top-left-radius', 0), " ", (0, _global_styling.logicalCSS)('border-top-right-radius', 0), " &:after{", (0, _global_styling.logicalCSS)('border-top', 'none'), ";}clip-path:polygon(-50% 0, 150% 0, 150% 100vh, -50% 100vh);>.euiTableRowCell{", (0, _global_styling.logicalCSS)('width', '100%'), ";}", expandedAnimationCss, ";;label:expanded;")
66
66
  }
67
67
  };
68
68
  };