@zendeskgarden/react-avatars 8.54.3 → 8.55.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.
package/dist/index.cjs.js CHANGED
@@ -11,8 +11,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var React = require('react');
13
13
  var PropTypes = require('prop-types');
14
- var styled = require('styled-components');
15
14
  var reactTheming = require('@zendeskgarden/react-theming');
15
+ var styled = require('styled-components');
16
16
  var polished = require('polished');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -263,7 +263,7 @@ var STATUS = ['available', 'away', 'transfers', 'offline'];
263
263
  var COMPONENT_ID$2 = 'avatars.text';
264
264
  var StyledText = styled__default["default"].span.attrs({
265
265
  'data-garden-id': COMPONENT_ID$2,
266
- 'data-garden-version': '8.54.3'
266
+ 'data-garden-version': '8.55.0'
267
267
  }).withConfig({
268
268
  displayName: "StyledText",
269
269
  componentId: "sc-1a6hivh-0"
@@ -337,7 +337,7 @@ var sizeStyles$1 = function sizeStyles(props) {
337
337
  padding = polished.math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
338
338
  break;
339
339
  }
340
- return styled.css(["border:", " ", ";border-radius:", ";min-width:", ";max-width:calc(2em + (", " * 3));height:", ";box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;line-height:", ";white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", " position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], borderWidth, props.theme.borderStyles.solid, height, height, borderWidth, height, height, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;', borderWidth, borderWidth, props.theme.rtl ? -1 : 1);
340
+ return styled.css(["border:", " ", ";border-radius:", ";min-width:", ";max-width:calc(2em + (", " * 3));height:", ";box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;line-height:", ";white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", " position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], borderWidth, props.theme.borderStyles.solid, height, height, borderWidth, height, height, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;', borderWidth, borderWidth, props.theme.rtl ? -1 : 1);
341
341
  };
342
342
  var colorStyles$1 = function colorStyles(props) {
343
343
  var foregroundColor = props.foregroundColor || props.theme.palette.white;
@@ -365,7 +365,7 @@ var colorStyles$1 = function colorStyles(props) {
365
365
  };
366
366
  var StyledStatusIndicator = styled__default["default"].div.attrs({
367
367
  'data-garden-id': COMPONENT_ID$1,
368
- 'data-garden-version': '8.54.3'
368
+ 'data-garden-version': '8.55.0'
369
369
  }).withConfig({
370
370
  displayName: "StyledStatusIndicator",
371
371
  componentId: "sc-16t9if3-0"
@@ -449,7 +449,7 @@ var sizeStyles = function sizeStyles(props) {
449
449
  };
450
450
  var StyledAvatar = styled__default["default"].figure.attrs({
451
451
  'data-garden-id': COMPONENT_ID,
452
- 'data-garden-version': '8.54.3'
452
+ 'data-garden-version': '8.55.0'
453
453
  }).withConfig({
454
454
  displayName: "StyledAvatar",
455
455
  componentId: "sc-608m04-0"
@@ -483,7 +483,7 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
483
483
  surfaceColor = _ref.surfaceColor,
484
484
  backgroundColor = _ref.backgroundColor,
485
485
  foregroundColor = _ref.foregroundColor,
486
- other = _objectWithoutProperties(_ref, _excluded);
486
+ props = _objectWithoutProperties(_ref, _excluded);
487
487
  var computedStatus = badge === undefined ? status : 'active';
488
488
  var ClockIcon = SvgClockStroke$1;
489
489
  var ArrowLeftIcon = SvgArrowLeftSmStroke$1;
@@ -491,6 +491,15 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
491
491
  ClockIcon = SvgClockStroke;
492
492
  ArrowLeftIcon = SvgArrowLeftSmStroke;
493
493
  }
494
+ var defaultStatusLabel = React.useMemo(function () {
495
+ var statusMessage = computedStatus;
496
+ if (computedStatus === 'active') {
497
+ var count = typeof badge === 'string' ? parseInt(badge, 10) : badge;
498
+ statusMessage = "active. ".concat(count > 0 ? "".concat(count, " notification").concat(count > 1 ? 's' : '') : 'no notifications');
499
+ }
500
+ return ['status'].concat(statusMessage || []).join(': ');
501
+ }, [computedStatus, badge]);
502
+ var statusLabel = reactTheming.useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel);
494
503
  return React__default["default"].createElement(StyledAvatar, _extends$4({
495
504
  ref: ref,
496
505
  isSystem: isSystem,
@@ -501,13 +510,17 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
501
510
  foregroundColor: foregroundColor,
502
511
  "aria-atomic": "true",
503
512
  "aria-live": "polite"
504
- }, other), React.Children.only(children), computedStatus && React__default["default"].createElement(StyledStatusIndicator, {
513
+ }, props), React.Children.only(children), computedStatus && React__default["default"].createElement(StyledStatusIndicator, {
505
514
  size: size,
506
515
  status: computedStatus,
507
516
  backgroundColor: backgroundColor,
508
517
  foregroundColor: foregroundColor,
509
- surfaceColor: surfaceColor
510
- }, computedStatus === 'active' ? React__default["default"].createElement("span", null, badge) : React__default["default"].createElement(React__default["default"].Fragment, null, computedStatus === 'away' ? React__default["default"].createElement(ClockIcon, {
518
+ surfaceColor: surfaceColor,
519
+ "aria-label": statusLabel,
520
+ role: "img"
521
+ }, computedStatus === 'active' ? React__default["default"].createElement("span", {
522
+ "aria-hidden": "true"
523
+ }, badge) : React__default["default"].createElement(React__default["default"].Fragment, null, computedStatus === 'away' ? React__default["default"].createElement(ClockIcon, {
511
524
  "data-icon-status": computedStatus
512
525
  }) : null, computedStatus === 'transfers' ? React__default["default"].createElement(ArrowLeftIcon, {
513
526
  "data-icon-status": computedStatus
@@ -521,7 +534,8 @@ AvatarComponent.propTypes = {
521
534
  isSystem: PropTypes__default["default"].bool,
522
535
  badge: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
523
536
  size: PropTypes__default["default"].oneOf(SIZE),
524
- status: PropTypes__default["default"].oneOf(STATUS)
537
+ status: PropTypes__default["default"].oneOf(STATUS),
538
+ statusLabel: PropTypes__default["default"].string
525
539
  };
526
540
  AvatarComponent.defaultProps = {
527
541
  size: 'medium'
package/dist/index.esm.js CHANGED
@@ -6,10 +6,10 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import React__default, { forwardRef, Children } from 'react';
9
+ import React__default, { forwardRef, useMemo, Children } from 'react';
10
10
  import PropTypes from 'prop-types';
11
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor, useText } from '@zendeskgarden/react-theming';
11
12
  import styled, { css, keyframes } from 'styled-components';
12
- import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
13
13
  import { math } from 'polished';
14
14
 
15
15
  function _extends$4() {
@@ -235,7 +235,7 @@ var STATUS = ['available', 'away', 'transfers', 'offline'];
235
235
  var COMPONENT_ID$2 = 'avatars.text';
236
236
  var StyledText = styled.span.attrs({
237
237
  'data-garden-id': COMPONENT_ID$2,
238
- 'data-garden-version': '8.54.3'
238
+ 'data-garden-version': '8.55.0'
239
239
  }).withConfig({
240
240
  displayName: "StyledText",
241
241
  componentId: "sc-1a6hivh-0"
@@ -309,7 +309,7 @@ var sizeStyles$1 = function sizeStyles(props) {
309
309
  padding = math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
310
310
  break;
311
311
  }
312
- return css(["border:", " ", ";border-radius:", ";min-width:", ";max-width:calc(2em + (", " * 3));height:", ";box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;line-height:", ";white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", " position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], borderWidth, props.theme.borderStyles.solid, height, height, borderWidth, height, height, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;', borderWidth, borderWidth, props.theme.rtl ? -1 : 1);
312
+ return css(["border:", " ", ";border-radius:", ";min-width:", ";max-width:calc(2em + (", " * 3));height:", ";box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;line-height:", ";white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", " position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], borderWidth, props.theme.borderStyles.solid, height, height, borderWidth, height, height, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;', borderWidth, borderWidth, props.theme.rtl ? -1 : 1);
313
313
  };
314
314
  var colorStyles$1 = function colorStyles(props) {
315
315
  var foregroundColor = props.foregroundColor || props.theme.palette.white;
@@ -337,7 +337,7 @@ var colorStyles$1 = function colorStyles(props) {
337
337
  };
338
338
  var StyledStatusIndicator = styled.div.attrs({
339
339
  'data-garden-id': COMPONENT_ID$1,
340
- 'data-garden-version': '8.54.3'
340
+ 'data-garden-version': '8.55.0'
341
341
  }).withConfig({
342
342
  displayName: "StyledStatusIndicator",
343
343
  componentId: "sc-16t9if3-0"
@@ -421,7 +421,7 @@ var sizeStyles = function sizeStyles(props) {
421
421
  };
422
422
  var StyledAvatar = styled.figure.attrs({
423
423
  'data-garden-id': COMPONENT_ID,
424
- 'data-garden-version': '8.54.3'
424
+ 'data-garden-version': '8.55.0'
425
425
  }).withConfig({
426
426
  displayName: "StyledAvatar",
427
427
  componentId: "sc-608m04-0"
@@ -455,7 +455,7 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
455
455
  surfaceColor = _ref.surfaceColor,
456
456
  backgroundColor = _ref.backgroundColor,
457
457
  foregroundColor = _ref.foregroundColor,
458
- other = _objectWithoutProperties(_ref, _excluded);
458
+ props = _objectWithoutProperties(_ref, _excluded);
459
459
  var computedStatus = badge === undefined ? status : 'active';
460
460
  var ClockIcon = SvgClockStroke$1;
461
461
  var ArrowLeftIcon = SvgArrowLeftSmStroke$1;
@@ -463,6 +463,15 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
463
463
  ClockIcon = SvgClockStroke;
464
464
  ArrowLeftIcon = SvgArrowLeftSmStroke;
465
465
  }
466
+ var defaultStatusLabel = useMemo(function () {
467
+ var statusMessage = computedStatus;
468
+ if (computedStatus === 'active') {
469
+ var count = typeof badge === 'string' ? parseInt(badge, 10) : badge;
470
+ statusMessage = "active. ".concat(count > 0 ? "".concat(count, " notification").concat(count > 1 ? 's' : '') : 'no notifications');
471
+ }
472
+ return ['status'].concat(statusMessage || []).join(': ');
473
+ }, [computedStatus, badge]);
474
+ var statusLabel = useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel);
466
475
  return React__default.createElement(StyledAvatar, _extends$4({
467
476
  ref: ref,
468
477
  isSystem: isSystem,
@@ -473,13 +482,17 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
473
482
  foregroundColor: foregroundColor,
474
483
  "aria-atomic": "true",
475
484
  "aria-live": "polite"
476
- }, other), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
485
+ }, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
477
486
  size: size,
478
487
  status: computedStatus,
479
488
  backgroundColor: backgroundColor,
480
489
  foregroundColor: foregroundColor,
481
- surfaceColor: surfaceColor
482
- }, computedStatus === 'active' ? React__default.createElement("span", null, badge) : React__default.createElement(React__default.Fragment, null, computedStatus === 'away' ? React__default.createElement(ClockIcon, {
490
+ surfaceColor: surfaceColor,
491
+ "aria-label": statusLabel,
492
+ role: "img"
493
+ }, computedStatus === 'active' ? React__default.createElement("span", {
494
+ "aria-hidden": "true"
495
+ }, badge) : React__default.createElement(React__default.Fragment, null, computedStatus === 'away' ? React__default.createElement(ClockIcon, {
483
496
  "data-icon-status": computedStatus
484
497
  }) : null, computedStatus === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
485
498
  "data-icon-status": computedStatus
@@ -493,7 +506,8 @@ AvatarComponent.propTypes = {
493
506
  isSystem: PropTypes.bool,
494
507
  badge: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
495
508
  size: PropTypes.oneOf(SIZE),
496
- status: PropTypes.oneOf(STATUS)
509
+ status: PropTypes.oneOf(STATUS),
510
+ statusLabel: PropTypes.string
497
511
  };
498
512
  AvatarComponent.defaultProps = {
499
513
  size: 'medium'
@@ -20,6 +20,8 @@ export interface IAvatarProps extends HTMLAttributes<HTMLElement> {
20
20
  size?: typeof SIZE[number];
21
21
  /** Applies status styling */
22
22
  status?: typeof STATUS[number];
23
+ /** Specifies the status label */
24
+ statusLabel?: string;
23
25
  /** Sets the badge text and applies active styling */
24
26
  badge?: string | number;
25
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-avatars",
3
- "version": "8.54.3",
3
+ "version": "8.55.0",
4
4
  "description": "Components relating to avatars in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -31,7 +31,7 @@
31
31
  "styled-components": "^4.2.0 || ^5.0.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@zendeskgarden/react-theming": "^8.54.3",
34
+ "@zendeskgarden/react-theming": "^8.55.0",
35
35
  "@zendeskgarden/svg-icons": "6.33.0"
36
36
  },
37
37
  "keywords": [
@@ -44,5 +44,5 @@
44
44
  "access": "public"
45
45
  },
46
46
  "zendeskgarden:src": "src/index.ts",
47
- "gitHead": "a0cee36de7275885b23776c0cb02dedeb63613b3"
47
+ "gitHead": "ec2cb4f499e02faadf6a4aa6ac94eaadf1d81015"
48
48
  }