@zendeskgarden/react-avatars 9.0.0-next.2 → 9.0.0-next.21
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/esm/elements/Avatar.js +93 -0
- package/dist/esm/elements/StatusIndicator.js +67 -0
- package/dist/esm/elements/components/Text.js +21 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/arrow-left-sm-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/clock-stroke.svg.js +33 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/arrow-left-sm-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/clock-stroke.svg.js +33 -0
- package/dist/esm/styled/StyledAvatar.js +101 -0
- package/dist/esm/styled/StyledStandaloneStatus.js +23 -0
- package/dist/esm/styled/StyledStandaloneStatusCaption.js +26 -0
- package/dist/esm/styled/StyledStandaloneStatusIndicator.js +25 -0
- package/dist/esm/styled/StyledStatusIndicator.js +59 -0
- package/dist/esm/styled/StyledStatusIndicatorBase.js +53 -0
- package/dist/esm/styled/StyledText.js +22 -0
- package/dist/esm/styled/utility.js +93 -0
- package/dist/esm/types/index.js +10 -0
- package/dist/index.cjs.js +160 -105
- package/dist/typings/styled/StyledAvatar.d.ts +7 -2
- package/dist/typings/styled/StyledStatusIndicator.d.ts +4 -2
- package/dist/typings/styled/utility.d.ts +3 -3
- package/package.json +9 -8
- package/dist/index.esm.js +0 -471
package/dist/index.esm.js
DELETED
|
@@ -1,471 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import React__default, { forwardRef, useMemo, Children } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { retrieveComponentStyles, DEFAULT_THEME, getColor, getLineHeight, useText } from '@zendeskgarden/react-theming';
|
|
12
|
-
import styled, { keyframes, css } from 'styled-components';
|
|
13
|
-
import { math } from 'polished';
|
|
14
|
-
|
|
15
|
-
function _extends$4() {
|
|
16
|
-
_extends$4 = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for (var key in source) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends$4.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var _g$1;
|
|
31
|
-
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); }
|
|
32
|
-
var SvgClockStroke$1 = function SvgClockStroke(props) {
|
|
33
|
-
return /*#__PURE__*/React.createElement("svg", _extends$3({
|
|
34
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
-
width: 12,
|
|
36
|
-
height: 12,
|
|
37
|
-
focusable: "false",
|
|
38
|
-
viewBox: "0 0 12 12",
|
|
39
|
-
"aria-hidden": "true"
|
|
40
|
-
}, props), _g$1 || (_g$1 = /*#__PURE__*/React.createElement("g", {
|
|
41
|
-
fill: "none",
|
|
42
|
-
stroke: "currentColor"
|
|
43
|
-
}, /*#__PURE__*/React.createElement("circle", {
|
|
44
|
-
cx: 6,
|
|
45
|
-
cy: 6,
|
|
46
|
-
r: 5.5
|
|
47
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
48
|
-
strokeLinecap: "round",
|
|
49
|
-
strokeLinejoin: "round",
|
|
50
|
-
d: "M5.5 3v3.5H8"
|
|
51
|
-
}))));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var _g;
|
|
55
|
-
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); }
|
|
56
|
-
var SvgClockStroke = function SvgClockStroke(props) {
|
|
57
|
-
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
58
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
-
width: 16,
|
|
60
|
-
height: 16,
|
|
61
|
-
focusable: "false",
|
|
62
|
-
viewBox: "0 0 16 16",
|
|
63
|
-
"aria-hidden": "true"
|
|
64
|
-
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
65
|
-
fill: "none",
|
|
66
|
-
stroke: "currentColor"
|
|
67
|
-
}, /*#__PURE__*/React.createElement("circle", {
|
|
68
|
-
cx: 8,
|
|
69
|
-
cy: 8,
|
|
70
|
-
r: 7.5
|
|
71
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
72
|
-
strokeLinecap: "round",
|
|
73
|
-
strokeLinejoin: "round",
|
|
74
|
-
d: "M7.5 3v5.5H11"
|
|
75
|
-
}))));
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
var _path$1;
|
|
79
|
-
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); }
|
|
80
|
-
var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
|
|
81
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
82
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
83
|
-
width: 12,
|
|
84
|
-
height: 12,
|
|
85
|
-
focusable: "false",
|
|
86
|
-
viewBox: "0 0 12 12",
|
|
87
|
-
"aria-hidden": "true"
|
|
88
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
89
|
-
fill: "currentColor",
|
|
90
|
-
d: "M2.146 6.854a.5.5 0 0 1 0-.708l2-2a.5.5 0 1 1 .708.708L3.707 6H9.5a.5.5 0 0 1 0 1H3.707l1.147 1.146a.5.5 0 1 1-.708.708l-2-2Z"
|
|
91
|
-
})));
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var _path;
|
|
95
|
-
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); }
|
|
96
|
-
var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
97
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
98
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
99
|
-
width: 16,
|
|
100
|
-
height: 16,
|
|
101
|
-
focusable: "false",
|
|
102
|
-
viewBox: "0 0 16 16",
|
|
103
|
-
"aria-hidden": "true"
|
|
104
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
105
|
-
fill: "currentColor",
|
|
106
|
-
d: "M3.146 8.854a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L4.707 8H12.5a.5.5 0 0 1 0 1H4.707l2.147 2.146a.5.5 0 1 1-.708.707l-3-3Z"
|
|
107
|
-
})));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
|
|
111
|
-
const STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
112
|
-
|
|
113
|
-
const COMPONENT_ID$6 = 'avatars.text';
|
|
114
|
-
const StyledText = styled.span.attrs({
|
|
115
|
-
'data-garden-id': COMPONENT_ID$6,
|
|
116
|
-
'data-garden-version': '9.0.0-next.2'
|
|
117
|
-
}).withConfig({
|
|
118
|
-
displayName: "StyledText",
|
|
119
|
-
componentId: "sc-1a6hivh-0"
|
|
120
|
-
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
121
|
-
StyledText.defaultProps = {
|
|
122
|
-
theme: DEFAULT_THEME
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const [xxs$1, xs$1, s$1, m$1, l$1] = SIZE;
|
|
126
|
-
const TRANSITION_DURATION = 0.25;
|
|
127
|
-
function getStatusColor(type, theme) {
|
|
128
|
-
switch (type) {
|
|
129
|
-
case 'active':
|
|
130
|
-
return getColor('crimson', 400, theme);
|
|
131
|
-
case 'available':
|
|
132
|
-
return getColor('mint', 400, theme);
|
|
133
|
-
case 'away':
|
|
134
|
-
return getColor('orange', 400, theme);
|
|
135
|
-
case 'transfers':
|
|
136
|
-
return getColor('azure', 400, theme);
|
|
137
|
-
case 'offline':
|
|
138
|
-
return getColor('grey', 500, theme);
|
|
139
|
-
default:
|
|
140
|
-
return 'transparent';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function getStatusBorderOffset(props) {
|
|
144
|
-
return props.size === xxs$1 ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
|
|
145
|
-
}
|
|
146
|
-
function getStatusSize(props, offset) {
|
|
147
|
-
const isActive = props.type === 'active';
|
|
148
|
-
switch (props.size) {
|
|
149
|
-
case xxs$1:
|
|
150
|
-
return math(`${props.theme.space.base}px - ${offset}`);
|
|
151
|
-
case xs$1:
|
|
152
|
-
return math(`${props.theme.space.base * 2}px - (${offset} * 2)`);
|
|
153
|
-
case s$1:
|
|
154
|
-
return math(`${props.theme.space.base * 3}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
155
|
-
case m$1:
|
|
156
|
-
case l$1:
|
|
157
|
-
return math(`${props.theme.space.base * 4}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
158
|
-
default:
|
|
159
|
-
return '0';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function includes(array, element) {
|
|
163
|
-
return array.includes(element);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const COMPONENT_ID$5 = 'avatars.status-indicator.base';
|
|
167
|
-
const iconFadeIn = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
168
|
-
const sizeStyles$3 = props => {
|
|
169
|
-
const offset = getStatusBorderOffset(props);
|
|
170
|
-
const size = getStatusSize(props, offset);
|
|
171
|
-
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);
|
|
172
|
-
};
|
|
173
|
-
const colorStyles$2 = props => {
|
|
174
|
-
let backgroundColor = getStatusColor(props.type, props.theme);
|
|
175
|
-
let borderColor = backgroundColor;
|
|
176
|
-
if (props.type === 'offline') {
|
|
177
|
-
borderColor = getStatusColor(props.type, props.theme);
|
|
178
|
-
backgroundColor = props.theme.palette.white;
|
|
179
|
-
}
|
|
180
|
-
return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
|
|
181
|
-
};
|
|
182
|
-
const StyledStatusIndicatorBase = styled.div.attrs({
|
|
183
|
-
'data-garden-id': COMPONENT_ID$5,
|
|
184
|
-
'data-garden-version': '9.0.0-next.2'
|
|
185
|
-
}).withConfig({
|
|
186
|
-
displayName: "StyledStatusIndicatorBase",
|
|
187
|
-
componentId: "sc-1rininy-0"
|
|
188
|
-
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
189
|
-
StyledStatusIndicatorBase.defaultProps = {
|
|
190
|
-
theme: DEFAULT_THEME,
|
|
191
|
-
size: 'small'
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const COMPONENT_ID$4 = 'avatars.status_indicator';
|
|
195
|
-
const [xxs, xs, s, m, l] = SIZE;
|
|
196
|
-
const sizeStyles$2 = props => {
|
|
197
|
-
const isVisible = !includes([xxs, xs], props.size);
|
|
198
|
-
const borderWidth = getStatusBorderOffset(props);
|
|
199
|
-
let padding = '0';
|
|
200
|
-
if (props.size === s) {
|
|
201
|
-
padding = math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
|
|
202
|
-
} else if (includes([m, l], props.size)) {
|
|
203
|
-
padding = math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
|
|
204
|
-
}
|
|
205
|
-
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;');
|
|
206
|
-
};
|
|
207
|
-
const colorStyles$1 = props => {
|
|
208
|
-
const {
|
|
209
|
-
theme,
|
|
210
|
-
type,
|
|
211
|
-
size,
|
|
212
|
-
borderColor,
|
|
213
|
-
surfaceColor
|
|
214
|
-
} = props;
|
|
215
|
-
let boxShadow = theme.shadows.sm(surfaceColor || (type ? theme.colors.background : theme.palette.white));
|
|
216
|
-
if (size === xxs) {
|
|
217
|
-
boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
|
|
218
|
-
}
|
|
219
|
-
return css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
|
|
220
|
-
};
|
|
221
|
-
const StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
222
|
-
'data-garden-id': COMPONENT_ID$4,
|
|
223
|
-
'data-garden-version': '9.0.0-next.2'
|
|
224
|
-
}).withConfig({
|
|
225
|
-
displayName: "StyledStatusIndicator",
|
|
226
|
-
componentId: "sc-16t9if3-0"
|
|
227
|
-
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
228
|
-
StyledStatusIndicator.defaultProps = {
|
|
229
|
-
size: 'medium',
|
|
230
|
-
theme: DEFAULT_THEME
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const COMPONENT_ID$3 = 'avatars.avatar';
|
|
234
|
-
const badgeStyles = props => {
|
|
235
|
-
const [xxs, xs, s, m, l] = SIZE;
|
|
236
|
-
let position = `${props.theme.space.base * -1}px`;
|
|
237
|
-
switch (props.size) {
|
|
238
|
-
case s:
|
|
239
|
-
case m:
|
|
240
|
-
position = math(`${position} + 2`);
|
|
241
|
-
break;
|
|
242
|
-
case xxs:
|
|
243
|
-
case xs:
|
|
244
|
-
case l:
|
|
245
|
-
position = math(`${position} + 3`);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
const animation = keyframes(["0%{transform:scale(.1);}"]);
|
|
249
|
-
return css(["position:absolute;", ":", ";bottom:", ";transition:all ", "s ease-in-out;", ""], props.theme.rtl ? 'left' : 'right', position, position, TRANSITION_DURATION, props.status === 'active' && css(["animation:", " ", "s ease-in-out;"], animation, TRANSITION_DURATION * 1.5));
|
|
250
|
-
};
|
|
251
|
-
const colorStyles = props => {
|
|
252
|
-
const statusColor = getStatusColor(props.status, props.theme);
|
|
253
|
-
const backgroundColor = props.backgroundColor || 'transparent';
|
|
254
|
-
const foregroundColor = props.foregroundColor || props.theme.palette.white;
|
|
255
|
-
const surfaceColor = props.status ? props.surfaceColor || props.theme.colors.background : 'transparent';
|
|
256
|
-
return css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
257
|
-
};
|
|
258
|
-
const sizeStyles$1 = props => {
|
|
259
|
-
let boxShadow;
|
|
260
|
-
let borderRadius;
|
|
261
|
-
let size;
|
|
262
|
-
let fontSize;
|
|
263
|
-
let svgSize;
|
|
264
|
-
if (props.size === 'extraextrasmall') {
|
|
265
|
-
boxShadow = `0 0 0 ${math(`${props.theme.shadowWidths.sm} - 1`)}`;
|
|
266
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
267
|
-
size = `${props.theme.space.base * 4}px`;
|
|
268
|
-
fontSize = 0;
|
|
269
|
-
svgSize = `${props.theme.space.base * 3}px`;
|
|
270
|
-
} else if (props.size === 'extrasmall') {
|
|
271
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
272
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
273
|
-
size = `${props.theme.space.base * 6}px`;
|
|
274
|
-
fontSize = props.theme.fontSizes.sm;
|
|
275
|
-
svgSize = `${props.theme.space.base * 3}px`;
|
|
276
|
-
} else if (props.size === 'small') {
|
|
277
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
278
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
279
|
-
size = `${props.theme.space.base * 8}px`;
|
|
280
|
-
fontSize = props.theme.fontSizes.md;
|
|
281
|
-
svgSize = `${props.theme.space.base * 3}px`;
|
|
282
|
-
} else if (props.size === 'large') {
|
|
283
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
284
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} + 1`) : '50%';
|
|
285
|
-
size = `${props.theme.space.base * 12}px`;
|
|
286
|
-
fontSize = props.theme.fontSizes.xl;
|
|
287
|
-
svgSize = `${props.theme.space.base * 6}px`;
|
|
288
|
-
} else {
|
|
289
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
290
|
-
borderRadius = props.isSystem ? props.theme.borderRadii.md : '50%';
|
|
291
|
-
size = `${props.theme.space.base * 10}px`;
|
|
292
|
-
fontSize = props.theme.fontSizes.lg;
|
|
293
|
-
svgSize = `${props.theme.space.base * 4}px`;
|
|
294
|
-
}
|
|
295
|
-
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);
|
|
296
|
-
};
|
|
297
|
-
const StyledAvatar = styled.figure.attrs({
|
|
298
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
299
|
-
'data-garden-version': '9.0.0-next.2'
|
|
300
|
-
}).withConfig({
|
|
301
|
-
displayName: "StyledAvatar",
|
|
302
|
-
componentId: "sc-608m04-0"
|
|
303
|
-
})(["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, props => sizeStyles$1(props), props => colorStyles(props), TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
304
|
-
StyledAvatar.defaultProps = {
|
|
305
|
-
size: 'medium',
|
|
306
|
-
theme: DEFAULT_THEME
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
const COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
310
|
-
const StyledStandaloneStatus = styled.figure.attrs({
|
|
311
|
-
'data-garden-id': COMPONENT_ID$2,
|
|
312
|
-
'data-garden-version': '9.0.0-next.2'
|
|
313
|
-
}).withConfig({
|
|
314
|
-
displayName: "StyledStandaloneStatus",
|
|
315
|
-
componentId: "sc-1ow4nfj-0"
|
|
316
|
-
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
317
|
-
StyledStandaloneStatus.defaultProps = {
|
|
318
|
-
theme: DEFAULT_THEME
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const COMPONENT_ID$1 = 'avatars.status-indicator.caption';
|
|
322
|
-
function sizeStyles(props) {
|
|
323
|
-
const marginRule = `margin-${props.theme.rtl ? 'right' : 'left'}: ${props.theme.space.base * 2}px;`;
|
|
324
|
-
return css(["", " line-height:", ";font-size:", ";"], marginRule, getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
|
|
325
|
-
}
|
|
326
|
-
const StyledStandaloneStatusCaption = styled.figcaption.attrs({
|
|
327
|
-
'data-garden-id': COMPONENT_ID$1,
|
|
328
|
-
'data-garden-version': '9.0.0-next.2'
|
|
329
|
-
}).withConfig({
|
|
330
|
-
displayName: "StyledStandaloneStatusCaption",
|
|
331
|
-
componentId: "sc-aalyk1-0"
|
|
332
|
-
})(["", " ", ";"], sizeStyles, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
333
|
-
StyledStandaloneStatusCaption.defaultProps = {
|
|
334
|
-
theme: DEFAULT_THEME
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
const COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
338
|
-
const StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
339
|
-
'data-garden-id': COMPONENT_ID,
|
|
340
|
-
'data-garden-version': '9.0.0-next.2'
|
|
341
|
-
}).withConfig({
|
|
342
|
-
displayName: "StyledStandaloneStatusIndicator",
|
|
343
|
-
componentId: "sc-1xt1heq-0"
|
|
344
|
-
})(["position:relative;box-sizing:content-box;margin-top:", ";", ";"], props => `calc((${props.theme.lineHeights.md} - ${getStatusSize(props, '0')}) / 2)`, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
345
|
-
StyledStandaloneStatusIndicator.defaultProps = {
|
|
346
|
-
type: 'offline',
|
|
347
|
-
theme: DEFAULT_THEME
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const TextComponent = forwardRef((props, ref) => React__default.createElement(StyledText, _extends$4({
|
|
351
|
-
ref: ref
|
|
352
|
-
}, props)));
|
|
353
|
-
TextComponent.displayName = 'Avatar.Text';
|
|
354
|
-
const Text = TextComponent;
|
|
355
|
-
|
|
356
|
-
const AvatarComponent = forwardRef((_ref, ref) => {
|
|
357
|
-
let {
|
|
358
|
-
isSystem,
|
|
359
|
-
size,
|
|
360
|
-
status,
|
|
361
|
-
children,
|
|
362
|
-
badge,
|
|
363
|
-
surfaceColor,
|
|
364
|
-
backgroundColor,
|
|
365
|
-
foregroundColor,
|
|
366
|
-
...props
|
|
367
|
-
} = _ref;
|
|
368
|
-
const computedStatus = badge === undefined ? status : 'active';
|
|
369
|
-
let ClockIcon = SvgClockStroke$1;
|
|
370
|
-
let ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
371
|
-
if (['large', 'medium'].includes(size)) {
|
|
372
|
-
ClockIcon = SvgClockStroke;
|
|
373
|
-
ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
374
|
-
}
|
|
375
|
-
const defaultStatusLabel = useMemo(() => {
|
|
376
|
-
let statusMessage = computedStatus;
|
|
377
|
-
if (computedStatus === 'active') {
|
|
378
|
-
const count = typeof badge === 'string' ? parseInt(badge, 10) : badge;
|
|
379
|
-
statusMessage = `active. ${count > 0 ? `${count} notification${count > 1 ? 's' : ''}` : 'no notifications'}`;
|
|
380
|
-
}
|
|
381
|
-
return ['status'].concat(statusMessage || []).join(': ');
|
|
382
|
-
}, [computedStatus, badge]);
|
|
383
|
-
const shouldValidate = computedStatus !== undefined;
|
|
384
|
-
const statusLabel = useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
|
|
385
|
-
return React__default.createElement(StyledAvatar, _extends$4({
|
|
386
|
-
ref: ref,
|
|
387
|
-
isSystem: isSystem,
|
|
388
|
-
size: size,
|
|
389
|
-
status: computedStatus,
|
|
390
|
-
surfaceColor: surfaceColor,
|
|
391
|
-
backgroundColor: backgroundColor,
|
|
392
|
-
foregroundColor: foregroundColor,
|
|
393
|
-
"aria-atomic": "true",
|
|
394
|
-
"aria-live": "polite"
|
|
395
|
-
}, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
|
|
396
|
-
size: size,
|
|
397
|
-
type: computedStatus,
|
|
398
|
-
surfaceColor: surfaceColor,
|
|
399
|
-
"aria-label": statusLabel,
|
|
400
|
-
as: "figcaption"
|
|
401
|
-
}, computedStatus === 'active' ? React__default.createElement("span", {
|
|
402
|
-
"aria-hidden": "true"
|
|
403
|
-
}, badge) : React__default.createElement(React__default.Fragment, null, computedStatus === 'away' ? React__default.createElement(ClockIcon, {
|
|
404
|
-
"data-icon-status": computedStatus
|
|
405
|
-
}) : null, computedStatus === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
406
|
-
"data-icon-status": computedStatus
|
|
407
|
-
}) : null)));
|
|
408
|
-
});
|
|
409
|
-
AvatarComponent.displayName = 'Avatar';
|
|
410
|
-
AvatarComponent.propTypes = {
|
|
411
|
-
backgroundColor: PropTypes.string,
|
|
412
|
-
foregroundColor: PropTypes.string,
|
|
413
|
-
surfaceColor: PropTypes.string,
|
|
414
|
-
isSystem: PropTypes.bool,
|
|
415
|
-
badge: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
416
|
-
size: PropTypes.oneOf(SIZE),
|
|
417
|
-
status: PropTypes.oneOf(STATUS),
|
|
418
|
-
statusLabel: PropTypes.string
|
|
419
|
-
};
|
|
420
|
-
AvatarComponent.defaultProps = {
|
|
421
|
-
size: 'medium'
|
|
422
|
-
};
|
|
423
|
-
const Avatar = AvatarComponent;
|
|
424
|
-
Avatar.Text = Text;
|
|
425
|
-
|
|
426
|
-
const StatusIndicator = forwardRef((_ref, ref) => {
|
|
427
|
-
let {
|
|
428
|
-
children,
|
|
429
|
-
type,
|
|
430
|
-
isCompact,
|
|
431
|
-
'aria-label': label,
|
|
432
|
-
...props
|
|
433
|
-
} = _ref;
|
|
434
|
-
let ClockIcon = SvgClockStroke;
|
|
435
|
-
let ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
436
|
-
if (isCompact) {
|
|
437
|
-
ClockIcon = SvgClockStroke$1;
|
|
438
|
-
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
439
|
-
}
|
|
440
|
-
const defaultLabel = useMemo(() => ['status'].concat(type || []).join(': '), [type]);
|
|
441
|
-
const ariaLabel = useText(StatusIndicator, {
|
|
442
|
-
'aria-label': label
|
|
443
|
-
}, 'aria-label', defaultLabel);
|
|
444
|
-
return (
|
|
445
|
-
React__default.createElement(StyledStandaloneStatus, _extends$4({
|
|
446
|
-
role: "status",
|
|
447
|
-
ref: ref
|
|
448
|
-
}, props), React__default.createElement(StyledStandaloneStatusIndicator, {
|
|
449
|
-
role: "img",
|
|
450
|
-
type: type,
|
|
451
|
-
size: isCompact ? 'small' : 'medium',
|
|
452
|
-
"aria-label": ariaLabel
|
|
453
|
-
}, type === 'away' ? React__default.createElement(ClockIcon, {
|
|
454
|
-
"data-icon-status": type,
|
|
455
|
-
"aria-hidden": "true"
|
|
456
|
-
}) : null, type === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
457
|
-
"data-icon-status": type,
|
|
458
|
-
"aria-hidden": "true"
|
|
459
|
-
}) : null), children && React__default.createElement(StyledStandaloneStatusCaption, null, children))
|
|
460
|
-
);
|
|
461
|
-
});
|
|
462
|
-
StatusIndicator.displayName = 'StatusIndicator';
|
|
463
|
-
StatusIndicator.propTypes = {
|
|
464
|
-
type: PropTypes.oneOf(STATUS),
|
|
465
|
-
isCompact: PropTypes.bool
|
|
466
|
-
};
|
|
467
|
-
StatusIndicator.defaultProps = {
|
|
468
|
-
type: 'offline'
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
export { Avatar, StatusIndicator };
|