@zendeskgarden/react-avatars 8.55.0 → 8.57.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/README.md CHANGED
@@ -16,7 +16,7 @@ npm install react react-dom styled-components @zendeskgarden/react-theming
16
16
 
17
17
  ```jsx
18
18
  import { ThemeProvider } from '@zendeskgarden/react-theming';
19
- import { Avatar } from '@zendeskgarden/react-avatars';
19
+ import { Avatar, StatusIndicator } from '@zendeskgarden/react-avatars';
20
20
 
21
21
  /**
22
22
  * Place a `ThemeProvider` at the root of your React application
@@ -25,5 +25,9 @@ import { Avatar } from '@zendeskgarden/react-avatars';
25
25
  <Avatar>
26
26
  <img src="images/user.png" alt="Example Avatar" />
27
27
  </Avatar>
28
+
29
+ <StatusIndicator type="available" aria-label="status: online">
30
+ Available
31
+ </StatusIndicator>
28
32
  </ThemeProvider>;
29
33
  ```
package/dist/index.cjs.js CHANGED
@@ -41,7 +41,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
41
41
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
42
42
 
43
43
  function _extends$4() {
44
- _extends$4 = Object.assign || function (target) {
44
+ _extends$4 = Object.assign ? Object.assign.bind() : function (target) {
45
45
  for (var i = 1; i < arguments.length; i++) {
46
46
  var source = arguments[i];
47
47
 
@@ -54,7 +54,6 @@ function _extends$4() {
54
54
 
55
55
  return target;
56
56
  };
57
-
58
57
  return _extends$4.apply(this, arguments);
59
58
  }
60
59
 
@@ -98,22 +97,10 @@ function _slicedToArray(arr, i) {
98
97
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
99
98
  }
100
99
 
101
- function _toConsumableArray(arr) {
102
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
103
- }
104
-
105
- function _arrayWithoutHoles(arr) {
106
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
107
- }
108
-
109
100
  function _arrayWithHoles(arr) {
110
101
  if (Array.isArray(arr)) return arr;
111
102
  }
112
103
 
113
- function _iterableToArray(iter) {
114
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
115
- }
116
-
117
104
  function _iterableToArrayLimit(arr, i) {
118
105
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
119
106
 
@@ -161,17 +148,13 @@ function _arrayLikeToArray(arr, len) {
161
148
  return arr2;
162
149
  }
163
150
 
164
- function _nonIterableSpread() {
165
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
166
- }
167
-
168
151
  function _nonIterableRest() {
169
152
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
170
153
  }
171
154
 
172
155
  var _g$1;
173
156
 
174
- function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
157
+ function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
175
158
 
176
159
  var SvgClockStroke$1 = function SvgClockStroke(props) {
177
160
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$3({
@@ -197,7 +180,7 @@ var SvgClockStroke$1 = function SvgClockStroke(props) {
197
180
 
198
181
  var _g;
199
182
 
200
- function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
183
+ function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
201
184
 
202
185
  var SvgClockStroke = function SvgClockStroke(props) {
203
186
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
@@ -223,7 +206,7 @@ var SvgClockStroke = function SvgClockStroke(props) {
223
206
 
224
207
  var _path$1;
225
208
 
226
- function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
209
+ function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
227
210
 
228
211
  var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
229
212
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
@@ -241,7 +224,7 @@ var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
241
224
 
242
225
  var _path;
243
226
 
244
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
227
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
245
228
 
246
229
  var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
247
230
  return /*#__PURE__*/React__namespace.createElement("svg", _extends({
@@ -260,125 +243,143 @@ var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
260
243
  var SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
261
244
  var STATUS = ['available', 'away', 'transfers', 'offline'];
262
245
 
263
- var COMPONENT_ID$2 = 'avatars.text';
246
+ var COMPONENT_ID$6 = 'avatars.text';
264
247
  var StyledText = styled__default["default"].span.attrs({
265
- 'data-garden-id': COMPONENT_ID$2,
266
- 'data-garden-version': '8.55.0'
248
+ 'data-garden-id': COMPONENT_ID$6,
249
+ 'data-garden-version': '8.57.0'
267
250
  }).withConfig({
268
251
  displayName: "StyledText",
269
252
  componentId: "sc-1a6hivh-0"
270
253
  })(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], function (props) {
271
- return reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props);
254
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props);
272
255
  });
273
256
  StyledText.defaultProps = {
274
257
  theme: reactTheming.DEFAULT_THEME
275
258
  };
276
259
 
277
- var _ref$1 = ['active'].concat(_toConsumableArray(STATUS)),
278
- active$1 = _ref$1[0],
279
- available$1 = _ref$1[1],
280
- away$1 = _ref$1[2],
281
- transfers$1 = _ref$1[3],
282
- offline$1 = _ref$1[4];
283
- function getStatusColor(status) {
284
- var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : reactTheming.DEFAULT_THEME;
285
- switch (status) {
286
- case active$1:
260
+ var _SIZE$1 = _slicedToArray(SIZE, 5),
261
+ xxs$1 = _SIZE$1[0],
262
+ xs$1 = _SIZE$1[1],
263
+ s$1 = _SIZE$1[2],
264
+ m$1 = _SIZE$1[3],
265
+ l$1 = _SIZE$1[4];
266
+ var TRANSITION_DURATION = 0.25;
267
+ function getStatusColor(type, theme) {
268
+ switch (type) {
269
+ case 'active':
287
270
  return reactTheming.getColor('crimson', 400, theme);
288
- case available$1:
271
+ case 'available':
289
272
  return reactTheming.getColor('mint', 400, theme);
290
- case away$1:
273
+ case 'away':
291
274
  return reactTheming.getColor('orange', 400, theme);
292
- case transfers$1:
275
+ case 'transfers':
293
276
  return reactTheming.getColor('azure', 400, theme);
294
- case offline$1:
277
+ case 'offline':
295
278
  return reactTheming.getColor('grey', 500, theme);
296
279
  default:
297
280
  return 'transparent';
298
281
  }
299
282
  }
283
+ function getStatusBorderOffset(props) {
284
+ return props.size === xxs$1 ? polished.math("".concat(props.theme.shadowWidths.sm, " - 1")) : props.theme.shadowWidths.sm;
285
+ }
286
+ function getStatusSize(props, offset) {
287
+ var isActive = props.type === 'active';
288
+ switch (props.size) {
289
+ case xxs$1:
290
+ return polished.math("".concat(props.theme.space.base, "px - ").concat(offset));
291
+ case xs$1:
292
+ return polished.math("".concat(props.theme.space.base * 2, "px - (").concat(offset, " * 2)"));
293
+ case s$1:
294
+ return polished.math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
295
+ case m$1:
296
+ case l$1:
297
+ return polished.math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
298
+ default:
299
+ return '0';
300
+ }
301
+ }
302
+ function includes(array, element) {
303
+ return array.includes(element);
304
+ }
300
305
 
301
- var COMPONENT_ID$1 = 'avatars.status_indicator';
306
+ var COMPONENT_ID$5 = 'avatars.status-indicator.base';
307
+ var iconFadeIn = styled.keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
308
+ var sizeStyles$3 = function sizeStyles(props) {
309
+ var offset = getStatusBorderOffset(props);
310
+ var size = getStatusSize(props, offset);
311
+ return styled.css(["border:", " ", ";border-radius:", ";width:", ";min-width:", ";height:", ";line-height:", ";& > svg{position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;animation:", " ", "s;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], offset, props.theme.borderStyles.solid, size, size, size, size, size, offset, offset, iconFadeIn, TRANSITION_DURATION, props.theme.rtl ? -1 : 1);
312
+ };
313
+ var colorStyles$2 = function colorStyles(props) {
314
+ var backgroundColor = getStatusColor(props.type, props.theme);
315
+ var borderColor = backgroundColor;
316
+ if (props.type === 'offline') {
317
+ borderColor = getStatusColor(props.type, props.theme);
318
+ backgroundColor = props.theme.palette.white;
319
+ }
320
+ return styled.css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
321
+ };
322
+ var StyledStatusIndicatorBase = styled__default["default"].div.attrs({
323
+ 'data-garden-id': COMPONENT_ID$5,
324
+ 'data-garden-version': '8.57.0'
325
+ }).withConfig({
326
+ displayName: "StyledStatusIndicatorBase",
327
+ componentId: "sc-1rininy-0"
328
+ })(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, function (props) {
329
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props);
330
+ });
331
+ StyledStatusIndicatorBase.defaultProps = {
332
+ theme: reactTheming.DEFAULT_THEME,
333
+ size: 'small'
334
+ };
335
+
336
+ var COMPONENT_ID$4 = 'avatars.status_indicator';
302
337
  var _SIZE = _slicedToArray(SIZE, 5),
303
338
  xxs = _SIZE[0],
304
339
  xs = _SIZE[1],
305
340
  s = _SIZE[2],
306
341
  m = _SIZE[3],
307
342
  l = _SIZE[4];
308
- var _ref = ['active'].concat(_toConsumableArray(STATUS)),
309
- active = _ref[0],
310
- available = _ref[1],
311
- away = _ref[2],
312
- transfers = _ref[3],
313
- offline = _ref[4];
314
- var sizeStyles$1 = function sizeStyles(props) {
315
- var isActive = props.status === 'active';
316
- var isVisible = true;
317
- var height = '0';
343
+ var sizeStyles$2 = function sizeStyles(props) {
344
+ var isVisible = !includes([xxs, xs], props.size);
345
+ var borderWidth = getStatusBorderOffset(props);
318
346
  var padding = '0';
319
- var borderWidth = props.theme.shadowWidths.sm;
320
- switch (props.size) {
321
- case xxs:
322
- isVisible = false;
323
- borderWidth = polished.math("".concat(borderWidth, " - 1"));
324
- height = polished.math("".concat(props.theme.space.base, "px - ").concat(borderWidth));
325
- break;
326
- case xs:
327
- isVisible = false;
328
- height = polished.math("".concat(props.theme.space.base * 2, "px - (").concat(borderWidth, " * 2)"));
329
- break;
330
- case s:
331
- height = polished.math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
332
- padding = polished.math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
333
- break;
334
- case m:
335
- case l:
336
- height = polished.math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
337
- padding = polished.math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
338
- break;
347
+ if (props.size === s) {
348
+ padding = polished.math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
349
+ } else if (includes([m, l], props.size)) {
350
+ padding = polished.math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
339
351
  }
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);
352
+ return styled.css(["max-width:calc(2em + (", " * 3));box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;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{", "}"], borderWidth, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;');
341
353
  };
342
354
  var colorStyles$1 = function colorStyles(props) {
343
- var foregroundColor = props.foregroundColor || props.theme.palette.white;
344
- var surfaceColor = props.surfaceColor || (props.status ? props.theme.colors.background : props.theme.palette.white);
345
- var backgroundColor = props.backgroundColor || 'transparent';
346
- var borderColor = props.borderColor || backgroundColor;
347
- var boxShadow = props.theme.shadows.sm(surfaceColor);
348
- if (props.size === xxs) {
349
- boxShadow = boxShadow.replace(props.theme.shadowWidths.sm, '1px');
350
- }
351
- switch (props.status) {
352
- case available:
353
- case active:
354
- case away:
355
- case transfers:
356
- backgroundColor = getStatusColor(props.status, props.theme);
357
- borderColor = backgroundColor;
358
- break;
359
- case offline:
360
- borderColor = getStatusColor(props.status, props.theme);
361
- backgroundColor = props.theme.palette.white;
362
- break;
355
+ var theme = props.theme,
356
+ type = props.type,
357
+ size = props.size,
358
+ foregroundColor = props.foregroundColor,
359
+ backgroundColor = props.backgroundColor,
360
+ borderColor = props.borderColor,
361
+ surfaceColor = props.surfaceColor;
362
+ var boxShadow = theme.shadows.sm(surfaceColor || (type ? theme.colors.background : theme.palette.white));
363
+ if (size === xxs) {
364
+ boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
363
365
  }
364
366
  return styled.css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, boxShadow, backgroundColor, foregroundColor);
365
367
  };
366
- var StyledStatusIndicator = styled__default["default"].div.attrs({
367
- 'data-garden-id': COMPONENT_ID$1,
368
- 'data-garden-version': '8.55.0'
368
+ var StyledStatusIndicator = styled__default["default"](StyledStatusIndicatorBase).attrs({
369
+ 'data-garden-id': COMPONENT_ID$4,
370
+ 'data-garden-version': '8.57.0'
369
371
  }).withConfig({
370
372
  displayName: "StyledStatusIndicator",
371
373
  componentId: "sc-16t9if3-0"
372
- })(["", " ", " transition:inherit;", ";"], sizeStyles$1, colorStyles$1, function (props) {
373
- return reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props);
374
+ })(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, function (props) {
375
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props);
374
376
  });
375
377
  StyledStatusIndicator.defaultProps = {
376
378
  size: 'medium',
377
379
  theme: reactTheming.DEFAULT_THEME
378
380
  };
379
381
 
380
- var COMPONENT_ID = 'avatars.avatar';
381
- var TRANSITION_DURATION = 0.25;
382
+ var COMPONENT_ID$3 = 'avatars.avatar';
382
383
  var badgeStyles = function badgeStyles(props) {
383
384
  var _SIZE = _slicedToArray(SIZE, 5),
384
385
  xxs = _SIZE[0],
@@ -408,7 +409,7 @@ var colorStyles = function colorStyles(props) {
408
409
  var surfaceColor = props.status ? props.surfaceColor || props.theme.colors.background : 'transparent';
409
410
  return styled.css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
410
411
  };
411
- var sizeStyles = function sizeStyles(props) {
412
+ var sizeStyles$1 = function sizeStyles(props) {
412
413
  var boxShadow;
413
414
  var borderRadius;
414
415
  var size;
@@ -448,23 +449,72 @@ var sizeStyles = function sizeStyles(props) {
448
449
  return styled.css(["border-radius:", ";width:", " !important;height:", " !important;::before{box-shadow:", ";}& > svg{font-size:", ";}& ", "{line-height:", ";font-size:", ";}"], borderRadius, size, size, boxShadow, svgSize, StyledText, size, fontSize);
449
450
  };
450
451
  var StyledAvatar = styled__default["default"].figure.attrs({
451
- 'data-garden-id': COMPONENT_ID,
452
- 'data-garden-version': '8.55.0'
452
+ 'data-garden-id': COMPONENT_ID$3,
453
+ 'data-garden-version': '8.57.0'
453
454
  }).withConfig({
454
455
  displayName: "StyledAvatar",
455
456
  componentId: "sc-608m04-0"
456
457
  })(["display:inline-flex;position:relative;align-items:center;justify-content:center;transition:box-shadow ", "s ease-in-out,color 0.1s ease-in-out;margin:0;vertical-align:middle;box-sizing:border-box;", ";", ";&::before{position:absolute;top:0;left:0;transition:box-shadow ", "s ease-in-out;content:'';}&::before,&& > img{border-radius:inherit;width:100%;height:100%;}&& > img{box-sizing:inherit;vertical-align:bottom;object-fit:cover;}&& > svg{width:1em;height:1em;}& > ", "{", ";}", ";"], TRANSITION_DURATION, function (props) {
457
- return sizeStyles(props);
458
+ return sizeStyles$1(props);
458
459
  }, function (props) {
459
460
  return colorStyles(props);
460
461
  }, TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, function (props) {
461
- return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
462
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props);
462
463
  });
463
464
  StyledAvatar.defaultProps = {
464
465
  size: 'medium',
465
466
  theme: reactTheming.DEFAULT_THEME
466
467
  };
467
468
 
469
+ var COMPONENT_ID$2 = 'avatars.status-indicator.status';
470
+ var StyledStandaloneStatus = styled__default["default"].figure.attrs({
471
+ 'data-garden-id': COMPONENT_ID$2,
472
+ 'data-garden-version': '8.57.0'
473
+ }).withConfig({
474
+ displayName: "StyledStandaloneStatus",
475
+ componentId: "sc-1ow4nfj-0"
476
+ })(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, function (props) {
477
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props);
478
+ });
479
+ StyledStandaloneStatus.defaultProps = {
480
+ theme: reactTheming.DEFAULT_THEME
481
+ };
482
+
483
+ var COMPONENT_ID$1 = 'avatars.status-indicator.caption';
484
+ function sizeStyles(props) {
485
+ var marginRule = "margin-".concat(props.theme.rtl ? 'right' : 'left', ": ").concat(props.theme.space.base * 2, "px;");
486
+ return styled.css(["", " line-height:", ";font-size:", ";"], marginRule, reactTheming.getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
487
+ }
488
+ var StyledStandaloneStatusCaption = styled__default["default"].figcaption.attrs({
489
+ 'data-garden-id': COMPONENT_ID$1,
490
+ 'data-garden-version': '8.57.0'
491
+ }).withConfig({
492
+ displayName: "StyledStandaloneStatusCaption",
493
+ componentId: "sc-aalyk1-0"
494
+ })(["", " ", ";"], sizeStyles, function (props) {
495
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props);
496
+ });
497
+ StyledStandaloneStatusCaption.defaultProps = {
498
+ theme: reactTheming.DEFAULT_THEME
499
+ };
500
+
501
+ var COMPONENT_ID = 'avatars.status-indicator.indicator';
502
+ var StyledStandaloneStatusIndicator = styled__default["default"](StyledStatusIndicatorBase).attrs({
503
+ 'data-garden-id': COMPONENT_ID,
504
+ 'data-garden-version': '8.57.0'
505
+ }).withConfig({
506
+ displayName: "StyledStandaloneStatusIndicator",
507
+ componentId: "sc-1xt1heq-0"
508
+ })(["position:relative;margin-top:", ";", ";"], function (props) {
509
+ return "calc((".concat(props.theme.lineHeights.md, " - ").concat(getStatusSize(props, '0'), ") / 2)");
510
+ }, function (props) {
511
+ return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
512
+ });
513
+ StyledStandaloneStatusIndicator.defaultProps = {
514
+ type: 'offline',
515
+ theme: reactTheming.DEFAULT_THEME
516
+ };
517
+
468
518
  var TextComponent = React.forwardRef(function (props, ref) {
469
519
  return React__default["default"].createElement(StyledText, _extends$4({
470
520
  ref: ref
@@ -473,7 +523,7 @@ var TextComponent = React.forwardRef(function (props, ref) {
473
523
  TextComponent.displayName = 'Avatar.Text';
474
524
  var Text = TextComponent;
475
525
 
476
- var _excluded = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
526
+ var _excluded$1 = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
477
527
  var AvatarComponent = React.forwardRef(function (_ref, ref) {
478
528
  var isSystem = _ref.isSystem,
479
529
  size = _ref.size,
@@ -483,7 +533,7 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
483
533
  surfaceColor = _ref.surfaceColor,
484
534
  backgroundColor = _ref.backgroundColor,
485
535
  foregroundColor = _ref.foregroundColor,
486
- props = _objectWithoutProperties(_ref, _excluded);
536
+ props = _objectWithoutProperties(_ref, _excluded$1);
487
537
  var computedStatus = badge === undefined ? status : 'active';
488
538
  var ClockIcon = SvgClockStroke$1;
489
539
  var ArrowLeftIcon = SvgArrowLeftSmStroke$1;
@@ -512,7 +562,7 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
512
562
  "aria-live": "polite"
513
563
  }, props), React.Children.only(children), computedStatus && React__default["default"].createElement(StyledStatusIndicator, {
514
564
  size: size,
515
- status: computedStatus,
565
+ type: computedStatus,
516
566
  backgroundColor: backgroundColor,
517
567
  foregroundColor: foregroundColor,
518
568
  surfaceColor: surfaceColor,
@@ -543,4 +593,50 @@ AvatarComponent.defaultProps = {
543
593
  var Avatar = AvatarComponent;
544
594
  Avatar.Text = Text;
545
595
 
596
+ var _excluded = ["children", "type", "isCompact", "aria-label"];
597
+ var StatusIndicatorComponent = React.forwardRef(function (_ref, ref) {
598
+ var children = _ref.children,
599
+ type = _ref.type,
600
+ isCompact = _ref.isCompact,
601
+ label = _ref['aria-label'],
602
+ props = _objectWithoutProperties(_ref, _excluded);
603
+ var ClockIcon = SvgClockStroke;
604
+ var ArrowLeftIcon = SvgArrowLeftSmStroke;
605
+ if (isCompact) {
606
+ ClockIcon = SvgClockStroke$1;
607
+ ArrowLeftIcon = SvgArrowLeftSmStroke$1;
608
+ }
609
+ var defaultLabel = React.useMemo(function () {
610
+ return ['status'].concat(type || []).join(': ');
611
+ }, [type]);
612
+ var ariaLabel = reactTheming.useText(StatusIndicatorComponent, {
613
+ 'aria-label': label
614
+ }, 'aria-label', defaultLabel);
615
+ return React__default["default"].createElement(StyledStandaloneStatus, _extends$4({
616
+ role: "status",
617
+ ref: ref
618
+ }, props), React__default["default"].createElement(StyledStandaloneStatusIndicator, {
619
+ role: "img",
620
+ type: type,
621
+ size: isCompact ? 'small' : 'medium',
622
+ "aria-label": ariaLabel
623
+ }, type === 'away' ? React__default["default"].createElement(ClockIcon, {
624
+ "data-icon-status": type,
625
+ "aria-hidden": "true"
626
+ }) : null, type === 'transfers' ? React__default["default"].createElement(ArrowLeftIcon, {
627
+ "data-icon-status": type,
628
+ "aria-hidden": "true"
629
+ }) : null), children && React__default["default"].createElement(StyledStandaloneStatusCaption, null, children));
630
+ });
631
+ StatusIndicatorComponent.displayName = 'StatusIndicator';
632
+ StatusIndicatorComponent.propTypes = {
633
+ type: PropTypes__default["default"].oneOf(STATUS),
634
+ isCompact: PropTypes__default["default"].bool
635
+ };
636
+ StatusIndicatorComponent.defaultProps = {
637
+ type: 'offline'
638
+ };
639
+ var StatusIndicator = StatusIndicatorComponent;
640
+
546
641
  exports.Avatar = Avatar;
642
+ exports.StatusIndicator = StatusIndicator;
package/dist/index.esm.js CHANGED
@@ -8,12 +8,12 @@
8
8
  import * as React from 'react';
9
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';
12
- import styled, { css, keyframes } from 'styled-components';
11
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor, getLineHeight, useText } from '@zendeskgarden/react-theming';
12
+ import styled, { keyframes, css } from 'styled-components';
13
13
  import { math } from 'polished';
14
14
 
15
15
  function _extends$4() {
16
- _extends$4 = Object.assign || function (target) {
16
+ _extends$4 = Object.assign ? Object.assign.bind() : function (target) {
17
17
  for (var i = 1; i < arguments.length; i++) {
18
18
  var source = arguments[i];
19
19
 
@@ -26,7 +26,6 @@ function _extends$4() {
26
26
 
27
27
  return target;
28
28
  };
29
-
30
29
  return _extends$4.apply(this, arguments);
31
30
  }
32
31
 
@@ -70,22 +69,10 @@ function _slicedToArray(arr, i) {
70
69
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
71
70
  }
72
71
 
73
- function _toConsumableArray(arr) {
74
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
75
- }
76
-
77
- function _arrayWithoutHoles(arr) {
78
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
79
- }
80
-
81
72
  function _arrayWithHoles(arr) {
82
73
  if (Array.isArray(arr)) return arr;
83
74
  }
84
75
 
85
- function _iterableToArray(iter) {
86
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
87
- }
88
-
89
76
  function _iterableToArrayLimit(arr, i) {
90
77
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
91
78
 
@@ -133,17 +120,13 @@ function _arrayLikeToArray(arr, len) {
133
120
  return arr2;
134
121
  }
135
122
 
136
- function _nonIterableSpread() {
137
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
138
- }
139
-
140
123
  function _nonIterableRest() {
141
124
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
142
125
  }
143
126
 
144
127
  var _g$1;
145
128
 
146
- function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
129
+ function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
147
130
 
148
131
  var SvgClockStroke$1 = function SvgClockStroke(props) {
149
132
  return /*#__PURE__*/React.createElement("svg", _extends$3({
@@ -169,7 +152,7 @@ var SvgClockStroke$1 = function SvgClockStroke(props) {
169
152
 
170
153
  var _g;
171
154
 
172
- function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
155
+ function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
173
156
 
174
157
  var SvgClockStroke = function SvgClockStroke(props) {
175
158
  return /*#__PURE__*/React.createElement("svg", _extends$2({
@@ -195,7 +178,7 @@ var SvgClockStroke = function SvgClockStroke(props) {
195
178
 
196
179
  var _path$1;
197
180
 
198
- function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
181
+ function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
199
182
 
200
183
  var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
201
184
  return /*#__PURE__*/React.createElement("svg", _extends$1({
@@ -213,7 +196,7 @@ var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
213
196
 
214
197
  var _path;
215
198
 
216
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
199
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
217
200
 
218
201
  var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
219
202
  return /*#__PURE__*/React.createElement("svg", _extends({
@@ -232,125 +215,143 @@ var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
232
215
  var SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
233
216
  var STATUS = ['available', 'away', 'transfers', 'offline'];
234
217
 
235
- var COMPONENT_ID$2 = 'avatars.text';
218
+ var COMPONENT_ID$6 = 'avatars.text';
236
219
  var StyledText = styled.span.attrs({
237
- 'data-garden-id': COMPONENT_ID$2,
238
- 'data-garden-version': '8.55.0'
220
+ 'data-garden-id': COMPONENT_ID$6,
221
+ 'data-garden-version': '8.57.0'
239
222
  }).withConfig({
240
223
  displayName: "StyledText",
241
224
  componentId: "sc-1a6hivh-0"
242
225
  })(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], function (props) {
243
- return retrieveComponentStyles(COMPONENT_ID$2, props);
226
+ return retrieveComponentStyles(COMPONENT_ID$6, props);
244
227
  });
245
228
  StyledText.defaultProps = {
246
229
  theme: DEFAULT_THEME
247
230
  };
248
231
 
249
- var _ref$1 = ['active'].concat(_toConsumableArray(STATUS)),
250
- active$1 = _ref$1[0],
251
- available$1 = _ref$1[1],
252
- away$1 = _ref$1[2],
253
- transfers$1 = _ref$1[3],
254
- offline$1 = _ref$1[4];
255
- function getStatusColor(status) {
256
- var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THEME;
257
- switch (status) {
258
- case active$1:
232
+ var _SIZE$1 = _slicedToArray(SIZE, 5),
233
+ xxs$1 = _SIZE$1[0],
234
+ xs$1 = _SIZE$1[1],
235
+ s$1 = _SIZE$1[2],
236
+ m$1 = _SIZE$1[3],
237
+ l$1 = _SIZE$1[4];
238
+ var TRANSITION_DURATION = 0.25;
239
+ function getStatusColor(type, theme) {
240
+ switch (type) {
241
+ case 'active':
259
242
  return getColor('crimson', 400, theme);
260
- case available$1:
243
+ case 'available':
261
244
  return getColor('mint', 400, theme);
262
- case away$1:
245
+ case 'away':
263
246
  return getColor('orange', 400, theme);
264
- case transfers$1:
247
+ case 'transfers':
265
248
  return getColor('azure', 400, theme);
266
- case offline$1:
249
+ case 'offline':
267
250
  return getColor('grey', 500, theme);
268
251
  default:
269
252
  return 'transparent';
270
253
  }
271
254
  }
255
+ function getStatusBorderOffset(props) {
256
+ return props.size === xxs$1 ? math("".concat(props.theme.shadowWidths.sm, " - 1")) : props.theme.shadowWidths.sm;
257
+ }
258
+ function getStatusSize(props, offset) {
259
+ var isActive = props.type === 'active';
260
+ switch (props.size) {
261
+ case xxs$1:
262
+ return math("".concat(props.theme.space.base, "px - ").concat(offset));
263
+ case xs$1:
264
+ return math("".concat(props.theme.space.base * 2, "px - (").concat(offset, " * 2)"));
265
+ case s$1:
266
+ return math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
267
+ case m$1:
268
+ case l$1:
269
+ return math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
270
+ default:
271
+ return '0';
272
+ }
273
+ }
274
+ function includes(array, element) {
275
+ return array.includes(element);
276
+ }
272
277
 
273
- var COMPONENT_ID$1 = 'avatars.status_indicator';
278
+ var COMPONENT_ID$5 = 'avatars.status-indicator.base';
279
+ var iconFadeIn = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
280
+ var sizeStyles$3 = function sizeStyles(props) {
281
+ var offset = getStatusBorderOffset(props);
282
+ var size = getStatusSize(props, offset);
283
+ return css(["border:", " ", ";border-radius:", ";width:", ";min-width:", ";height:", ";line-height:", ";& > svg{position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;animation:", " ", "s;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], offset, props.theme.borderStyles.solid, size, size, size, size, size, offset, offset, iconFadeIn, TRANSITION_DURATION, props.theme.rtl ? -1 : 1);
284
+ };
285
+ var colorStyles$2 = function colorStyles(props) {
286
+ var backgroundColor = getStatusColor(props.type, props.theme);
287
+ var borderColor = backgroundColor;
288
+ if (props.type === 'offline') {
289
+ borderColor = getStatusColor(props.type, props.theme);
290
+ backgroundColor = props.theme.palette.white;
291
+ }
292
+ return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
293
+ };
294
+ var StyledStatusIndicatorBase = styled.div.attrs({
295
+ 'data-garden-id': COMPONENT_ID$5,
296
+ 'data-garden-version': '8.57.0'
297
+ }).withConfig({
298
+ displayName: "StyledStatusIndicatorBase",
299
+ componentId: "sc-1rininy-0"
300
+ })(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, function (props) {
301
+ return retrieveComponentStyles(COMPONENT_ID$5, props);
302
+ });
303
+ StyledStatusIndicatorBase.defaultProps = {
304
+ theme: DEFAULT_THEME,
305
+ size: 'small'
306
+ };
307
+
308
+ var COMPONENT_ID$4 = 'avatars.status_indicator';
274
309
  var _SIZE = _slicedToArray(SIZE, 5),
275
310
  xxs = _SIZE[0],
276
311
  xs = _SIZE[1],
277
312
  s = _SIZE[2],
278
313
  m = _SIZE[3],
279
314
  l = _SIZE[4];
280
- var _ref = ['active'].concat(_toConsumableArray(STATUS)),
281
- active = _ref[0],
282
- available = _ref[1],
283
- away = _ref[2],
284
- transfers = _ref[3],
285
- offline = _ref[4];
286
- var sizeStyles$1 = function sizeStyles(props) {
287
- var isActive = props.status === 'active';
288
- var isVisible = true;
289
- var height = '0';
315
+ var sizeStyles$2 = function sizeStyles(props) {
316
+ var isVisible = !includes([xxs, xs], props.size);
317
+ var borderWidth = getStatusBorderOffset(props);
290
318
  var padding = '0';
291
- var borderWidth = props.theme.shadowWidths.sm;
292
- switch (props.size) {
293
- case xxs:
294
- isVisible = false;
295
- borderWidth = math("".concat(borderWidth, " - 1"));
296
- height = math("".concat(props.theme.space.base, "px - ").concat(borderWidth));
297
- break;
298
- case xs:
299
- isVisible = false;
300
- height = math("".concat(props.theme.space.base * 2, "px - (").concat(borderWidth, " * 2)"));
301
- break;
302
- case s:
303
- height = math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
304
- padding = math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
305
- break;
306
- case m:
307
- case l:
308
- height = math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
309
- padding = math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
310
- break;
319
+ if (props.size === s) {
320
+ padding = math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
321
+ } else if (includes([m, l], props.size)) {
322
+ padding = math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
311
323
  }
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);
324
+ return css(["max-width:calc(2em + (", " * 3));box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;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{", "}"], borderWidth, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;');
313
325
  };
314
326
  var colorStyles$1 = function colorStyles(props) {
315
- var foregroundColor = props.foregroundColor || props.theme.palette.white;
316
- var surfaceColor = props.surfaceColor || (props.status ? props.theme.colors.background : props.theme.palette.white);
317
- var backgroundColor = props.backgroundColor || 'transparent';
318
- var borderColor = props.borderColor || backgroundColor;
319
- var boxShadow = props.theme.shadows.sm(surfaceColor);
320
- if (props.size === xxs) {
321
- boxShadow = boxShadow.replace(props.theme.shadowWidths.sm, '1px');
322
- }
323
- switch (props.status) {
324
- case available:
325
- case active:
326
- case away:
327
- case transfers:
328
- backgroundColor = getStatusColor(props.status, props.theme);
329
- borderColor = backgroundColor;
330
- break;
331
- case offline:
332
- borderColor = getStatusColor(props.status, props.theme);
333
- backgroundColor = props.theme.palette.white;
334
- break;
327
+ var theme = props.theme,
328
+ type = props.type,
329
+ size = props.size,
330
+ foregroundColor = props.foregroundColor,
331
+ backgroundColor = props.backgroundColor,
332
+ borderColor = props.borderColor,
333
+ surfaceColor = props.surfaceColor;
334
+ var boxShadow = theme.shadows.sm(surfaceColor || (type ? theme.colors.background : theme.palette.white));
335
+ if (size === xxs) {
336
+ boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
335
337
  }
336
338
  return css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, boxShadow, backgroundColor, foregroundColor);
337
339
  };
338
- var StyledStatusIndicator = styled.div.attrs({
339
- 'data-garden-id': COMPONENT_ID$1,
340
- 'data-garden-version': '8.55.0'
340
+ var StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
341
+ 'data-garden-id': COMPONENT_ID$4,
342
+ 'data-garden-version': '8.57.0'
341
343
  }).withConfig({
342
344
  displayName: "StyledStatusIndicator",
343
345
  componentId: "sc-16t9if3-0"
344
- })(["", " ", " transition:inherit;", ";"], sizeStyles$1, colorStyles$1, function (props) {
345
- return retrieveComponentStyles(COMPONENT_ID$1, props);
346
+ })(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, function (props) {
347
+ return retrieveComponentStyles(COMPONENT_ID$4, props);
346
348
  });
347
349
  StyledStatusIndicator.defaultProps = {
348
350
  size: 'medium',
349
351
  theme: DEFAULT_THEME
350
352
  };
351
353
 
352
- var COMPONENT_ID = 'avatars.avatar';
353
- var TRANSITION_DURATION = 0.25;
354
+ var COMPONENT_ID$3 = 'avatars.avatar';
354
355
  var badgeStyles = function badgeStyles(props) {
355
356
  var _SIZE = _slicedToArray(SIZE, 5),
356
357
  xxs = _SIZE[0],
@@ -380,7 +381,7 @@ var colorStyles = function colorStyles(props) {
380
381
  var surfaceColor = props.status ? props.surfaceColor || props.theme.colors.background : 'transparent';
381
382
  return css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
382
383
  };
383
- var sizeStyles = function sizeStyles(props) {
384
+ var sizeStyles$1 = function sizeStyles(props) {
384
385
  var boxShadow;
385
386
  var borderRadius;
386
387
  var size;
@@ -420,23 +421,72 @@ var sizeStyles = function sizeStyles(props) {
420
421
  return css(["border-radius:", ";width:", " !important;height:", " !important;::before{box-shadow:", ";}& > svg{font-size:", ";}& ", "{line-height:", ";font-size:", ";}"], borderRadius, size, size, boxShadow, svgSize, StyledText, size, fontSize);
421
422
  };
422
423
  var StyledAvatar = styled.figure.attrs({
423
- 'data-garden-id': COMPONENT_ID,
424
- 'data-garden-version': '8.55.0'
424
+ 'data-garden-id': COMPONENT_ID$3,
425
+ 'data-garden-version': '8.57.0'
425
426
  }).withConfig({
426
427
  displayName: "StyledAvatar",
427
428
  componentId: "sc-608m04-0"
428
429
  })(["display:inline-flex;position:relative;align-items:center;justify-content:center;transition:box-shadow ", "s ease-in-out,color 0.1s ease-in-out;margin:0;vertical-align:middle;box-sizing:border-box;", ";", ";&::before{position:absolute;top:0;left:0;transition:box-shadow ", "s ease-in-out;content:'';}&::before,&& > img{border-radius:inherit;width:100%;height:100%;}&& > img{box-sizing:inherit;vertical-align:bottom;object-fit:cover;}&& > svg{width:1em;height:1em;}& > ", "{", ";}", ";"], TRANSITION_DURATION, function (props) {
429
- return sizeStyles(props);
430
+ return sizeStyles$1(props);
430
431
  }, function (props) {
431
432
  return colorStyles(props);
432
433
  }, TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, function (props) {
433
- return retrieveComponentStyles(COMPONENT_ID, props);
434
+ return retrieveComponentStyles(COMPONENT_ID$3, props);
434
435
  });
435
436
  StyledAvatar.defaultProps = {
436
437
  size: 'medium',
437
438
  theme: DEFAULT_THEME
438
439
  };
439
440
 
441
+ var COMPONENT_ID$2 = 'avatars.status-indicator.status';
442
+ var StyledStandaloneStatus = styled.figure.attrs({
443
+ 'data-garden-id': COMPONENT_ID$2,
444
+ 'data-garden-version': '8.57.0'
445
+ }).withConfig({
446
+ displayName: "StyledStandaloneStatus",
447
+ componentId: "sc-1ow4nfj-0"
448
+ })(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, function (props) {
449
+ return retrieveComponentStyles(COMPONENT_ID$2, props);
450
+ });
451
+ StyledStandaloneStatus.defaultProps = {
452
+ theme: DEFAULT_THEME
453
+ };
454
+
455
+ var COMPONENT_ID$1 = 'avatars.status-indicator.caption';
456
+ function sizeStyles(props) {
457
+ var marginRule = "margin-".concat(props.theme.rtl ? 'right' : 'left', ": ").concat(props.theme.space.base * 2, "px;");
458
+ return css(["", " line-height:", ";font-size:", ";"], marginRule, getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
459
+ }
460
+ var StyledStandaloneStatusCaption = styled.figcaption.attrs({
461
+ 'data-garden-id': COMPONENT_ID$1,
462
+ 'data-garden-version': '8.57.0'
463
+ }).withConfig({
464
+ displayName: "StyledStandaloneStatusCaption",
465
+ componentId: "sc-aalyk1-0"
466
+ })(["", " ", ";"], sizeStyles, function (props) {
467
+ return retrieveComponentStyles(COMPONENT_ID$1, props);
468
+ });
469
+ StyledStandaloneStatusCaption.defaultProps = {
470
+ theme: DEFAULT_THEME
471
+ };
472
+
473
+ var COMPONENT_ID = 'avatars.status-indicator.indicator';
474
+ var StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
475
+ 'data-garden-id': COMPONENT_ID,
476
+ 'data-garden-version': '8.57.0'
477
+ }).withConfig({
478
+ displayName: "StyledStandaloneStatusIndicator",
479
+ componentId: "sc-1xt1heq-0"
480
+ })(["position:relative;margin-top:", ";", ";"], function (props) {
481
+ return "calc((".concat(props.theme.lineHeights.md, " - ").concat(getStatusSize(props, '0'), ") / 2)");
482
+ }, function (props) {
483
+ return retrieveComponentStyles(COMPONENT_ID, props);
484
+ });
485
+ StyledStandaloneStatusIndicator.defaultProps = {
486
+ type: 'offline',
487
+ theme: DEFAULT_THEME
488
+ };
489
+
440
490
  var TextComponent = forwardRef(function (props, ref) {
441
491
  return React__default.createElement(StyledText, _extends$4({
442
492
  ref: ref
@@ -445,7 +495,7 @@ var TextComponent = forwardRef(function (props, ref) {
445
495
  TextComponent.displayName = 'Avatar.Text';
446
496
  var Text = TextComponent;
447
497
 
448
- var _excluded = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
498
+ var _excluded$1 = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
449
499
  var AvatarComponent = forwardRef(function (_ref, ref) {
450
500
  var isSystem = _ref.isSystem,
451
501
  size = _ref.size,
@@ -455,7 +505,7 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
455
505
  surfaceColor = _ref.surfaceColor,
456
506
  backgroundColor = _ref.backgroundColor,
457
507
  foregroundColor = _ref.foregroundColor,
458
- props = _objectWithoutProperties(_ref, _excluded);
508
+ props = _objectWithoutProperties(_ref, _excluded$1);
459
509
  var computedStatus = badge === undefined ? status : 'active';
460
510
  var ClockIcon = SvgClockStroke$1;
461
511
  var ArrowLeftIcon = SvgArrowLeftSmStroke$1;
@@ -484,7 +534,7 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
484
534
  "aria-live": "polite"
485
535
  }, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
486
536
  size: size,
487
- status: computedStatus,
537
+ type: computedStatus,
488
538
  backgroundColor: backgroundColor,
489
539
  foregroundColor: foregroundColor,
490
540
  surfaceColor: surfaceColor,
@@ -515,4 +565,49 @@ AvatarComponent.defaultProps = {
515
565
  var Avatar = AvatarComponent;
516
566
  Avatar.Text = Text;
517
567
 
518
- export { Avatar };
568
+ var _excluded = ["children", "type", "isCompact", "aria-label"];
569
+ var StatusIndicatorComponent = forwardRef(function (_ref, ref) {
570
+ var children = _ref.children,
571
+ type = _ref.type,
572
+ isCompact = _ref.isCompact,
573
+ label = _ref['aria-label'],
574
+ props = _objectWithoutProperties(_ref, _excluded);
575
+ var ClockIcon = SvgClockStroke;
576
+ var ArrowLeftIcon = SvgArrowLeftSmStroke;
577
+ if (isCompact) {
578
+ ClockIcon = SvgClockStroke$1;
579
+ ArrowLeftIcon = SvgArrowLeftSmStroke$1;
580
+ }
581
+ var defaultLabel = useMemo(function () {
582
+ return ['status'].concat(type || []).join(': ');
583
+ }, [type]);
584
+ var ariaLabel = useText(StatusIndicatorComponent, {
585
+ 'aria-label': label
586
+ }, 'aria-label', defaultLabel);
587
+ return React__default.createElement(StyledStandaloneStatus, _extends$4({
588
+ role: "status",
589
+ ref: ref
590
+ }, props), React__default.createElement(StyledStandaloneStatusIndicator, {
591
+ role: "img",
592
+ type: type,
593
+ size: isCompact ? 'small' : 'medium',
594
+ "aria-label": ariaLabel
595
+ }, type === 'away' ? React__default.createElement(ClockIcon, {
596
+ "data-icon-status": type,
597
+ "aria-hidden": "true"
598
+ }) : null, type === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
599
+ "data-icon-status": type,
600
+ "aria-hidden": "true"
601
+ }) : null), children && React__default.createElement(StyledStandaloneStatusCaption, null, children));
602
+ });
603
+ StatusIndicatorComponent.displayName = 'StatusIndicator';
604
+ StatusIndicatorComponent.propTypes = {
605
+ type: PropTypes.oneOf(STATUS),
606
+ isCompact: PropTypes.bool
607
+ };
608
+ StatusIndicatorComponent.defaultProps = {
609
+ type: 'offline'
610
+ };
611
+ var StatusIndicator = StatusIndicatorComponent;
612
+
613
+ export { Avatar, StatusIndicator };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React from 'react';
8
+ import { IStatusIndicatorProps } from '../types';
9
+ export declare const StatusIndicator: React.ForwardRefExoticComponent<IStatusIndicatorProps & React.RefAttributes<HTMLElement>>;
@@ -5,4 +5,5 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  export { Avatar } from './elements/Avatar';
8
- export type { IAvatarProps } from './types';
8
+ export { StatusIndicator } from './elements/StatusIndicator';
9
+ export type { IAvatarProps, IStatusIndicatorProps } from './types';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { ThemeProps, DefaultTheme } from 'styled-components';
8
+ export declare const StyledStandaloneStatus: import("styled-components").StyledComponent<"figure", DefaultTheme, {
9
+ 'data-garden-id': string;
10
+ 'data-garden-version': string;
11
+ } & ThemeProps<DefaultTheme>, "data-garden-id" | "data-garden-version">;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { ThemeProps, DefaultTheme } from 'styled-components';
8
+ export declare const StyledStandaloneStatusCaption: import("styled-components").StyledComponent<"figcaption", DefaultTheme, {
9
+ 'data-garden-id': string;
10
+ 'data-garden-version': string;
11
+ } & ThemeProps<DefaultTheme>, "data-garden-id" | "data-garden-version">;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { IStyledStatusIndicatorProps } from './utility';
8
+ export declare const StyledStandaloneStatusIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
9
+ 'data-garden-id': string;
10
+ 'data-garden-version': string;
11
+ } & IStyledStatusIndicatorProps & {
12
+ 'data-garden-id': string;
13
+ 'data-garden-version': string;
14
+ }, "data-garden-id" | "data-garden-version">;
@@ -6,11 +6,15 @@
6
6
  */
7
7
  import { DefaultTheme } from 'styled-components';
8
8
  import { IAvatarProps } from '../types';
9
+ import { IStyledStatusIndicatorProps } from './utility';
9
10
  export interface IStatusIndicatorProps extends Omit<IAvatarProps, 'badge' | 'isSystem' | 'status'> {
10
- readonly status?: IAvatarProps['status'] | 'active';
11
+ readonly type?: IStyledStatusIndicatorProps['type'];
11
12
  borderColor?: string;
12
13
  }
13
14
  export declare const StyledStatusIndicator: import("styled-components").StyledComponent<"div", DefaultTheme, {
14
15
  'data-garden-id': string;
15
16
  'data-garden-version': string;
17
+ } & IStyledStatusIndicatorProps & {
18
+ 'data-garden-id': string;
19
+ 'data-garden-version': string;
16
20
  } & IStatusIndicatorProps, "data-garden-id" | "data-garden-version">;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { IStyledStatusIndicatorProps } from './utility';
8
+ export declare const StyledStatusIndicatorBase: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
9
+ 'data-garden-id': string;
10
+ 'data-garden-version': string;
11
+ } & IStyledStatusIndicatorProps, "data-garden-id" | "data-garden-version">;
@@ -5,5 +5,8 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  export * from './StyledAvatar';
8
+ export * from './StyledStandaloneStatus';
9
+ export * from './StyledStandaloneStatusCaption';
10
+ export * from './StyledStandaloneStatusIndicator';
8
11
  export * from './StyledStatusIndicator';
9
12
  export * from './StyledText';
@@ -4,5 +4,14 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { STATUS } from '../types';
8
- export declare function getStatusColor(status: typeof STATUS[number] | 'active' | undefined, theme?: import("@zendeskgarden/react-theming").IGardenTheme): string;
7
+ import { ThemeProps, DefaultTheme } from 'styled-components';
8
+ import { IAvatarProps } from '../types';
9
+ export declare const TRANSITION_DURATION = 0.25;
10
+ export interface IStyledStatusIndicatorProps extends ThemeProps<DefaultTheme> {
11
+ readonly size?: IAvatarProps['size'];
12
+ readonly type?: IAvatarProps['status'] | 'active';
13
+ }
14
+ export declare function getStatusColor(type?: IStyledStatusIndicatorProps['type'], theme?: IStyledStatusIndicatorProps['theme']): string;
15
+ export declare function getStatusBorderOffset(props: IStyledStatusIndicatorProps): string;
16
+ export declare function getStatusSize(props: IStyledStatusIndicatorProps, offset: string): string;
17
+ export declare function includes<T extends U, U>(array: readonly T[], element: U): element is T;
@@ -25,3 +25,9 @@ export interface IAvatarProps extends HTMLAttributes<HTMLElement> {
25
25
  /** Sets the badge text and applies active styling */
26
26
  badge?: string | number;
27
27
  }
28
+ export interface IStatusIndicatorProps extends HTMLAttributes<HTMLElement> {
29
+ /** Applies status type for styling and default aria-label */
30
+ type?: typeof STATUS[number];
31
+ /** Applies compact styling */
32
+ isCompact?: boolean;
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-avatars",
3
- "version": "8.55.0",
3
+ "version": "8.57.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.55.0",
34
+ "@zendeskgarden/react-theming": "^8.57.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": "ec2cb4f499e02faadf6a4aa6ac94eaadf1d81015"
47
+ "gitHead": "165b6a453118f93e9e760642b632ce3d31e3a231"
48
48
  }