@activecollab/components 1.0.315 → 1.0.317
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/cjs/components/Avatar/Avatar.js +28 -3
- package/dist/cjs/components/Avatar/Avatar.js.map +1 -1
- package/dist/cjs/components/Avatar/Styles.js +2 -6
- package/dist/cjs/components/Avatar/Styles.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/esm/components/Avatar/Avatar.js +22 -4
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/Avatar/Styles.d.ts +1 -2
- package/dist/esm/components/Avatar/Styles.d.ts.map +1 -1
- package/dist/esm/components/Avatar/Styles.js +2 -6
- package/dist/esm/components/Avatar/Styles.js.map +1 -1
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,11 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.Avatar = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _Loaders = require("../Loaders");
|
|
9
10
|
var _Styles = require("./Styles");
|
|
10
11
|
var _excluded = ["url", "alt", "size", "className", "imgClassName", "children"];
|
|
11
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
14
|
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); }
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
19
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
21
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
22
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
23
|
/**
|
|
@@ -48,16 +55,34 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
48
55
|
imgClassName = _ref.imgClassName,
|
|
49
56
|
children = _ref.children,
|
|
50
57
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
58
|
+
var _useState = (0, _react.useState)(false),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
imageLoaded = _useState2[0],
|
|
61
|
+
setImageLoaded = _useState2[1];
|
|
51
62
|
return /*#__PURE__*/_react.default.createElement(_Styles.StyledWrapper, {
|
|
52
63
|
className: className
|
|
53
64
|
}, children, /*#__PURE__*/_react.default.createElement(_Styles.StyledAvatar, _extends({
|
|
54
|
-
size: size,
|
|
55
65
|
ref: ref,
|
|
56
66
|
src: url,
|
|
57
67
|
alt: alt,
|
|
68
|
+
width: size,
|
|
69
|
+
height: size,
|
|
70
|
+
onLoad: function onLoad() {
|
|
71
|
+
setImageLoaded(true);
|
|
72
|
+
},
|
|
58
73
|
role: "img",
|
|
59
|
-
className: imgClassName
|
|
60
|
-
|
|
74
|
+
className: imgClassName,
|
|
75
|
+
style: {
|
|
76
|
+
display: imageLoaded ? "block" : "none"
|
|
77
|
+
}
|
|
78
|
+
}, rest)), !imageLoaded && /*#__PURE__*/_react.default.createElement(_Loaders.LinearLoader, {
|
|
79
|
+
"data-testid": "loader",
|
|
80
|
+
style: {
|
|
81
|
+
width: size,
|
|
82
|
+
height: size,
|
|
83
|
+
borderRadius: "100%"
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
61
86
|
});
|
|
62
87
|
exports.Avatar = Avatar;
|
|
63
88
|
Avatar.displayName = "Avatar";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","names":["Avatar","forwardRef","ref","url","alt","size","className","imgClassName","children","rest","displayName"],"sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, PropsWithChildren } from \"react\";\nimport { StyledAvatar, StyledWrapper } from \"./Styles\";\n\nexport interface AvatarProps extends React.ComponentPropsWithoutRef<\"img\"> {\n /** Path url. */\n url: string;\n /** Alt text. */\n alt?: string;\n /** Image size. */\n size?: number;\n /** Custom class. */\n className?: string;\n /** img custom class. */\n imgClassName?: string;\n}\n\n/**\n * @component Avatar\n * @description\n * The Avatar component is used to represent user, and displays the profile picture, initials or fallback icon.\n *\n * @prop {url} - The image url of the Avatar.\n * @prop {size} - controls the size of an Avatar (width and height) in pixels.\n * @prop {alt} - alt attribute of the img.\n * @prop {imgClassName} - class name that attaches to img element nested in Wrapper\n *\n * @example\n * <Avatar url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\" alt=\"Profile picture of John\" />\n *\n * @example\n * <Avatar\n * url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\"\n * alt=\"Profile picture of John\">\n * <Badge size={8} backgroundColor=\"green\" position=\"bottom-left\" />\n * </Avatar>\n *\n * @see\n * https://system.activecollab.com/?path=/story/components-button-indicators-avatar--avatar\n * @see\n * https://design.activecollab.com/docs/components/avatar\n */\nexport const Avatar = forwardRef<\n HTMLImageElement,\n PropsWithChildren<AvatarProps>\n>(\n (\n {\n url,\n alt = \"Avatar Image\",\n size = 24,\n className,\n imgClassName,\n children,\n ...rest\n },\n ref\n ) => (\n <StyledWrapper className={className}>\n
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":["Avatar","forwardRef","ref","url","alt","size","className","imgClassName","children","rest","useState","imageLoaded","setImageLoaded","display","width","height","borderRadius","displayName"],"sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, PropsWithChildren, useState } from \"react\";\nimport { LinearLoader } from \"../Loaders\";\nimport { StyledAvatar, StyledWrapper } from \"./Styles\";\n\nexport interface AvatarProps extends React.ComponentPropsWithoutRef<\"img\"> {\n /** Path url. */\n url: string;\n /** Alt text. */\n alt?: string;\n /** Image size. */\n size?: number;\n /** Custom class. */\n className?: string;\n /** img custom class. */\n imgClassName?: string;\n}\n\n/**\n * @component Avatar\n * @description\n * The Avatar component is used to represent user, and displays the profile picture, initials or fallback icon.\n *\n * @prop {url} - The image url of the Avatar.\n * @prop {size} - controls the size of an Avatar (width and height) in pixels.\n * @prop {alt} - alt attribute of the img.\n * @prop {imgClassName} - class name that attaches to img element nested in Wrapper\n *\n * @example\n * <Avatar url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\" alt=\"Profile picture of John\" />\n *\n * @example\n * <Avatar\n * url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\"\n * alt=\"Profile picture of John\">\n * <Badge size={8} backgroundColor=\"green\" position=\"bottom-left\" />\n * </Avatar>\n *\n * @see\n * https://system.activecollab.com/?path=/story/components-button-indicators-avatar--avatar\n * @see\n * https://design.activecollab.com/docs/components/avatar\n */\nexport const Avatar = forwardRef<\n HTMLImageElement,\n PropsWithChildren<AvatarProps>\n>(\n (\n {\n url,\n alt = \"Avatar Image\",\n size = 24,\n className,\n imgClassName,\n children,\n ...rest\n },\n ref\n ) => {\n const [imageLoaded, setImageLoaded] = useState<boolean>(false);\n\n return (\n <StyledWrapper className={className}>\n {children}\n\n <StyledAvatar\n ref={ref}\n src={url}\n alt={alt}\n width={size}\n height={size}\n onLoad={() => {\n setImageLoaded(true);\n }}\n role=\"img\"\n className={imgClassName}\n style={{ display: imageLoaded ? \"block\" : \"none\" }}\n {...rest}\n />\n {!imageLoaded && (\n <LinearLoader\n data-testid=\"loader\"\n style={{ width: size, height: size, borderRadius: \"100%\" }}\n />\n )}\n </StyledWrapper>\n );\n }\n);\n\nAvatar.displayName = \"Avatar\";\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAAuD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAevD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,MAAM,gBAAG,IAAAC,iBAAU,EAI9B,gBAUEC,GAAG,EACA;EAAA,IATDC,GAAG,QAAHA,GAAG;IAAA,gBACHC,GAAG;IAAHA,GAAG,yBAAG,cAAc;IAAA,iBACpBC,IAAI;IAAJA,IAAI,0BAAG,EAAE;IACTC,SAAS,QAATA,SAAS;IACTC,YAAY,QAAZA,YAAY;IACZC,QAAQ,QAARA,QAAQ;IACLC,IAAI;EAIT,gBAAsC,IAAAC,eAAQ,EAAU,KAAK,CAAC;IAAA;IAAvDC,WAAW;IAAEC,cAAc;EAElC,oBACE,6BAAC,qBAAa;IAAC,SAAS,EAAEN;EAAU,GACjCE,QAAQ,eAET,6BAAC,oBAAY;IACX,GAAG,EAAEN,GAAI;IACT,GAAG,EAAEC,GAAI;IACT,GAAG,EAAEC,GAAI;IACT,KAAK,EAAEC,IAAK;IACZ,MAAM,EAAEA,IAAK;IACb,MAAM,EAAE,kBAAM;MACZO,cAAc,CAAC,IAAI,CAAC;IACtB,CAAE;IACF,IAAI,EAAC,KAAK;IACV,SAAS,EAAEL,YAAa;IACxB,KAAK,EAAE;MAAEM,OAAO,EAAEF,WAAW,GAAG,OAAO,GAAG;IAAO;EAAE,GAC/CF,IAAI,EACR,EACD,CAACE,WAAW,iBACX,6BAAC,qBAAY;IACX,eAAY,QAAQ;IACpB,KAAK,EAAE;MAAEG,KAAK,EAAET,IAAI;MAAEU,MAAM,EAAEV,IAAI;MAAEW,YAAY,EAAE;IAAO;EAAE,EAE9D,CACa;AAEpB,CAAC,CACF;AAAC;AAEFhB,MAAM,CAACiB,WAAW,GAAG,QAAQ"}
|
|
@@ -9,15 +9,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
9
9
|
var StyledWrapper = _styledComponents.default.span.withConfig({
|
|
10
10
|
displayName: "Styles__StyledWrapper",
|
|
11
11
|
componentId: "sc-5x2tyd-0"
|
|
12
|
-
})(["display:inline-flex;
|
|
12
|
+
})(["display:inline-flex;border-radius:100%;position:relative;"]);
|
|
13
13
|
exports.StyledWrapper = StyledWrapper;
|
|
14
14
|
var StyledAvatar = _styledComponents.default.img.withConfig({
|
|
15
15
|
displayName: "Styles__StyledAvatar",
|
|
16
16
|
componentId: "sc-5x2tyd-1"
|
|
17
|
-
})(["border-radius:100%;object-fit:cover;
|
|
18
|
-
return props.size + "px";
|
|
19
|
-
}, function (props) {
|
|
20
|
-
return props.size + "px";
|
|
21
|
-
});
|
|
17
|
+
})(["border-radius:100%;object-fit:cover;"]);
|
|
22
18
|
exports.StyledAvatar = StyledAvatar;
|
|
23
19
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["StyledWrapper","styled","span","StyledAvatar","img"
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["StyledWrapper","styled","span","StyledAvatar","img"],"sources":["../../../../src/components/Avatar/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\n\nexport const StyledWrapper = styled.span`\n display: inline-flex;\n border-radius: 100%;\n position: relative;\n`;\n\nexport const StyledAvatar = styled.img`\n border-radius: 100%;\n object-fit: cover;\n`;\n"],"mappings":";;;;;;AAAA;AAAuC;AAEhC,IAAMA,aAAa,GAAGC,yBAAM,CAACC,IAAI;EAAA;EAAA;AAAA,iEAIvC;AAAC;AAEK,IAAMC,YAAY,GAAGF,yBAAM,CAACG,GAAG;EAAA;EAAA;AAAA,4CAGrC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC;IACxE,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,MAAM;;0CA6ClB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
var _excluded = ["url", "alt", "size", "className", "imgClassName", "children"];
|
|
4
|
-
import React, { forwardRef } from "react";
|
|
4
|
+
import React, { forwardRef, useState } from "react";
|
|
5
|
+
import { LinearLoader } from "../Loaders";
|
|
5
6
|
import { StyledAvatar, StyledWrapper } from "./Styles";
|
|
6
7
|
/**
|
|
7
8
|
* @component Avatar
|
|
@@ -38,16 +39,33 @@ export var Avatar = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
38
39
|
imgClassName = _ref.imgClassName,
|
|
39
40
|
children = _ref.children,
|
|
40
41
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
42
|
+
var _useState = useState(false),
|
|
43
|
+
imageLoaded = _useState[0],
|
|
44
|
+
setImageLoaded = _useState[1];
|
|
41
45
|
return /*#__PURE__*/React.createElement(StyledWrapper, {
|
|
42
46
|
className: className
|
|
43
47
|
}, children, /*#__PURE__*/React.createElement(StyledAvatar, _extends({
|
|
44
|
-
size: size,
|
|
45
48
|
ref: ref,
|
|
46
49
|
src: url,
|
|
47
50
|
alt: alt,
|
|
51
|
+
width: size,
|
|
52
|
+
height: size,
|
|
53
|
+
onLoad: function onLoad() {
|
|
54
|
+
setImageLoaded(true);
|
|
55
|
+
},
|
|
48
56
|
role: "img",
|
|
49
|
-
className: imgClassName
|
|
50
|
-
|
|
57
|
+
className: imgClassName,
|
|
58
|
+
style: {
|
|
59
|
+
display: imageLoaded ? "block" : "none"
|
|
60
|
+
}
|
|
61
|
+
}, rest)), !imageLoaded && /*#__PURE__*/React.createElement(LinearLoader, {
|
|
62
|
+
"data-testid": "loader",
|
|
63
|
+
style: {
|
|
64
|
+
width: size,
|
|
65
|
+
height: size,
|
|
66
|
+
borderRadius: "100%"
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
51
69
|
});
|
|
52
70
|
Avatar.displayName = "Avatar";
|
|
53
71
|
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","names":["React","forwardRef","StyledAvatar","StyledWrapper","Avatar","ref","url","alt","size","className","imgClassName","children","rest","displayName"],"sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, PropsWithChildren } from \"react\";\nimport { StyledAvatar, StyledWrapper } from \"./Styles\";\n\nexport interface AvatarProps extends React.ComponentPropsWithoutRef<\"img\"> {\n /** Path url. */\n url: string;\n /** Alt text. */\n alt?: string;\n /** Image size. */\n size?: number;\n /** Custom class. */\n className?: string;\n /** img custom class. */\n imgClassName?: string;\n}\n\n/**\n * @component Avatar\n * @description\n * The Avatar component is used to represent user, and displays the profile picture, initials or fallback icon.\n *\n * @prop {url} - The image url of the Avatar.\n * @prop {size} - controls the size of an Avatar (width and height) in pixels.\n * @prop {alt} - alt attribute of the img.\n * @prop {imgClassName} - class name that attaches to img element nested in Wrapper\n *\n * @example\n * <Avatar url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\" alt=\"Profile picture of John\" />\n *\n * @example\n * <Avatar\n * url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\"\n * alt=\"Profile picture of John\">\n * <Badge size={8} backgroundColor=\"green\" position=\"bottom-left\" />\n * </Avatar>\n *\n * @see\n * https://system.activecollab.com/?path=/story/components-button-indicators-avatar--avatar\n * @see\n * https://design.activecollab.com/docs/components/avatar\n */\nexport const Avatar = forwardRef<\n HTMLImageElement,\n PropsWithChildren<AvatarProps>\n>(\n (\n {\n url,\n alt = \"Avatar Image\",\n size = 24,\n className,\n imgClassName,\n children,\n ...rest\n },\n ref\n ) => (\n <StyledWrapper className={className}>\n
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":["React","forwardRef","useState","LinearLoader","StyledAvatar","StyledWrapper","Avatar","ref","url","alt","size","className","imgClassName","children","rest","imageLoaded","setImageLoaded","display","width","height","borderRadius","displayName"],"sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, PropsWithChildren, useState } from \"react\";\nimport { LinearLoader } from \"../Loaders\";\nimport { StyledAvatar, StyledWrapper } from \"./Styles\";\n\nexport interface AvatarProps extends React.ComponentPropsWithoutRef<\"img\"> {\n /** Path url. */\n url: string;\n /** Alt text. */\n alt?: string;\n /** Image size. */\n size?: number;\n /** Custom class. */\n className?: string;\n /** img custom class. */\n imgClassName?: string;\n}\n\n/**\n * @component Avatar\n * @description\n * The Avatar component is used to represent user, and displays the profile picture, initials or fallback icon.\n *\n * @prop {url} - The image url of the Avatar.\n * @prop {size} - controls the size of an Avatar (width and height) in pixels.\n * @prop {alt} - alt attribute of the img.\n * @prop {imgClassName} - class name that attaches to img element nested in Wrapper\n *\n * @example\n * <Avatar url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\" alt=\"Profile picture of John\" />\n *\n * @example\n * <Avatar\n * url=\"https://faces-img.xcdn.link/image-lorem-face-954.jpg\"\n * alt=\"Profile picture of John\">\n * <Badge size={8} backgroundColor=\"green\" position=\"bottom-left\" />\n * </Avatar>\n *\n * @see\n * https://system.activecollab.com/?path=/story/components-button-indicators-avatar--avatar\n * @see\n * https://design.activecollab.com/docs/components/avatar\n */\nexport const Avatar = forwardRef<\n HTMLImageElement,\n PropsWithChildren<AvatarProps>\n>(\n (\n {\n url,\n alt = \"Avatar Image\",\n size = 24,\n className,\n imgClassName,\n children,\n ...rest\n },\n ref\n ) => {\n const [imageLoaded, setImageLoaded] = useState<boolean>(false);\n\n return (\n <StyledWrapper className={className}>\n {children}\n\n <StyledAvatar\n ref={ref}\n src={url}\n alt={alt}\n width={size}\n height={size}\n onLoad={() => {\n setImageLoaded(true);\n }}\n role=\"img\"\n className={imgClassName}\n style={{ display: imageLoaded ? \"block\" : \"none\" }}\n {...rest}\n />\n {!imageLoaded && (\n <LinearLoader\n data-testid=\"loader\"\n style={{ width: size, height: size, borderRadius: \"100%\" }}\n />\n )}\n </StyledWrapper>\n );\n }\n);\n\nAvatar.displayName = \"Avatar\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAqBC,QAAQ,QAAQ,OAAO;AACtE,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,YAAY,EAAEC,aAAa,QAAQ,UAAU;AAetD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,MAAM,gBAAGL,UAAU,CAI9B,gBAUEM,GAAG,EACA;EAAA,IATDC,GAAG,QAAHA,GAAG;IAAA,gBACHC,GAAG;IAAHA,GAAG,yBAAG,cAAc;IAAA,iBACpBC,IAAI;IAAJA,IAAI,0BAAG,EAAE;IACTC,SAAS,QAATA,SAAS;IACTC,YAAY,QAAZA,YAAY;IACZC,QAAQ,QAARA,QAAQ;IACLC,IAAI;EAIT,gBAAsCZ,QAAQ,CAAU,KAAK,CAAC;IAAvDa,WAAW;IAAEC,cAAc;EAElC,oBACE,oBAAC,aAAa;IAAC,SAAS,EAAEL;EAAU,GACjCE,QAAQ,eAET,oBAAC,YAAY;IACX,GAAG,EAAEN,GAAI;IACT,GAAG,EAAEC,GAAI;IACT,GAAG,EAAEC,GAAI;IACT,KAAK,EAAEC,IAAK;IACZ,MAAM,EAAEA,IAAK;IACb,MAAM,EAAE,kBAAM;MACZM,cAAc,CAAC,IAAI,CAAC;IACtB,CAAE;IACF,IAAI,EAAC,KAAK;IACV,SAAS,EAAEJ,YAAa;IACxB,KAAK,EAAE;MAAEK,OAAO,EAAEF,WAAW,GAAG,OAAO,GAAG;IAAO;EAAE,GAC/CD,IAAI,EACR,EACD,CAACC,WAAW,iBACX,oBAAC,YAAY;IACX,eAAY,QAAQ;IACpB,KAAK,EAAE;MAAEG,KAAK,EAAER,IAAI;MAAES,MAAM,EAAET,IAAI;MAAEU,YAAY,EAAE;IAAO;EAAE,EAE9D,CACa;AAEpB,CAAC,CACF;AAEDd,MAAM,CAACe,WAAW,GAAG,QAAQ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AvatarProps } from "./Avatar";
|
|
2
1
|
export declare const StyledWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
3
|
-
export declare const StyledAvatar: import("styled-components").StyledComponent<"img", any,
|
|
2
|
+
export declare const StyledAvatar: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
4
3
|
//# sourceMappingURL=Styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Avatar/Styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Avatar/Styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,qEAIzB,CAAC;AAEF,eAAO,MAAM,YAAY,oEAGxB,CAAC"}
|
|
@@ -2,13 +2,9 @@ import styled from "styled-components";
|
|
|
2
2
|
export var StyledWrapper = styled.span.withConfig({
|
|
3
3
|
displayName: "Styles__StyledWrapper",
|
|
4
4
|
componentId: "sc-5x2tyd-0"
|
|
5
|
-
})(["display:inline-flex;
|
|
5
|
+
})(["display:inline-flex;border-radius:100%;position:relative;"]);
|
|
6
6
|
export var StyledAvatar = styled.img.withConfig({
|
|
7
7
|
displayName: "Styles__StyledAvatar",
|
|
8
8
|
componentId: "sc-5x2tyd-1"
|
|
9
|
-
})(["border-radius:100%;object-fit:cover;
|
|
10
|
-
return props.size + "px";
|
|
11
|
-
}, function (props) {
|
|
12
|
-
return props.size + "px";
|
|
13
|
-
});
|
|
9
|
+
})(["border-radius:100%;object-fit:cover;"]);
|
|
14
10
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["styled","StyledWrapper","span","StyledAvatar","img"
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","StyledWrapper","span","StyledAvatar","img"],"sources":["../../../../src/components/Avatar/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\n\nexport const StyledWrapper = styled.span`\n display: inline-flex;\n border-radius: 100%;\n position: relative;\n`;\n\nexport const StyledAvatar = styled.img`\n border-radius: 100%;\n object-fit: cover;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,IAAMC,aAAa,GAAGD,MAAM,CAACE,IAAI;EAAA;EAAA;AAAA,iEAIvC;AAED,OAAO,IAAMC,YAAY,GAAGH,MAAM,CAACI,GAAG;EAAA;EAAA;AAAA,4CAGrC"}
|
package/dist/index.js
CHANGED
|
@@ -9752,15 +9752,11 @@
|
|
|
9752
9752
|
var StyledWrapper = styled__default["default"].span.withConfig({
|
|
9753
9753
|
displayName: "Styles__StyledWrapper",
|
|
9754
9754
|
componentId: "sc-5x2tyd-0"
|
|
9755
|
-
})(["display:inline-flex;
|
|
9755
|
+
})(["display:inline-flex;border-radius:100%;position:relative;"]);
|
|
9756
9756
|
var StyledAvatar = styled__default["default"].img.withConfig({
|
|
9757
9757
|
displayName: "Styles__StyledAvatar",
|
|
9758
9758
|
componentId: "sc-5x2tyd-1"
|
|
9759
|
-
})(["border-radius:100%;object-fit:cover;
|
|
9760
|
-
return props.size + "px";
|
|
9761
|
-
}, function (props) {
|
|
9762
|
-
return props.size + "px";
|
|
9763
|
-
});
|
|
9759
|
+
})(["border-radius:100%;object-fit:cover;"]);
|
|
9764
9760
|
|
|
9765
9761
|
var _excluded$O = ["url", "alt", "size", "className", "imgClassName", "children"];
|
|
9766
9762
|
/**
|
|
@@ -9798,16 +9794,34 @@
|
|
|
9798
9794
|
imgClassName = _ref.imgClassName,
|
|
9799
9795
|
children = _ref.children,
|
|
9800
9796
|
rest = _objectWithoutProperties(_ref, _excluded$O);
|
|
9797
|
+
var _useState = React.useState(false),
|
|
9798
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
9799
|
+
imageLoaded = _useState2[0],
|
|
9800
|
+
setImageLoaded = _useState2[1];
|
|
9801
9801
|
return /*#__PURE__*/React__default["default"].createElement(StyledWrapper, {
|
|
9802
9802
|
className: className
|
|
9803
9803
|
}, children, /*#__PURE__*/React__default["default"].createElement(StyledAvatar, _extends({
|
|
9804
|
-
size: size,
|
|
9805
9804
|
ref: ref,
|
|
9806
9805
|
src: url,
|
|
9807
9806
|
alt: alt,
|
|
9807
|
+
width: size,
|
|
9808
|
+
height: size,
|
|
9809
|
+
onLoad: function onLoad() {
|
|
9810
|
+
setImageLoaded(true);
|
|
9811
|
+
},
|
|
9808
9812
|
role: "img",
|
|
9809
|
-
className: imgClassName
|
|
9810
|
-
|
|
9813
|
+
className: imgClassName,
|
|
9814
|
+
style: {
|
|
9815
|
+
display: imageLoaded ? "block" : "none"
|
|
9816
|
+
}
|
|
9817
|
+
}, rest)), !imageLoaded && /*#__PURE__*/React__default["default"].createElement(LinearLoader, {
|
|
9818
|
+
"data-testid": "loader",
|
|
9819
|
+
style: {
|
|
9820
|
+
width: size,
|
|
9821
|
+
height: size,
|
|
9822
|
+
borderRadius: "100%"
|
|
9823
|
+
}
|
|
9824
|
+
}));
|
|
9811
9825
|
});
|
|
9812
9826
|
Avatar.displayName = "Avatar";
|
|
9813
9827
|
|