@activecollab/components 1.0.295 → 1.0.296

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.
@@ -7,51 +7,123 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.AvatarGroup = void 0;
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _Tooltip = require("../Tooltip");
10
11
  var _Typography = require("../Typography/Typography");
11
12
  var _Styles = require("./Styles");
12
13
  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); }
13
14
  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; }
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- 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); }
16
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
- var AvatarGroup = function AvatarGroup(_ref) {
19
+ var AvatarGroup = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
20
+ var _Children$toArray;
20
21
  var limit = _ref.limit,
21
22
  _ref$size = _ref.size,
22
23
  size = _ref$size === void 0 ? 34 : _ref$size,
23
24
  children = _ref.children,
24
- counterProps = _ref.counterProps;
25
- // always display counter with min +2 as +1 can require 1 more Avatar
25
+ _ref$hasTooltip = _ref.hasTooltip,
26
+ hasTooltip = _ref$hasTooltip === void 0 ? false : _ref$hasTooltip;
27
+ // always display counter with min +2 as +1 can takes space of an 1 more Avatar
26
28
  var minChildren = _react.Children.count(children) - limit > 1 ? false : true;
29
+ // gap between Avatars
30
+ var gap = 8;
27
31
  var _children = minChildren ? _react.Children.toArray(children) : _react.Children.toArray(children).slice(0, limit);
28
32
  var handleVariant = (0, _react.useMemo)(function () {
29
33
  if (size >= 34) return "Caption 1";
30
34
  return "Caption 2";
31
35
  }, [size]);
32
- return /*#__PURE__*/_react.default.createElement(_Styles.AvatarGroupsStyles, null, _children.map(function (child) {
33
- var item = child;
36
+
37
+ // get all names indexed above limit number from alt tag on Avatar for counter tooltip
38
+ var nameArr = (_Children$toArray = _react.Children.toArray(children)) === null || _Children$toArray === void 0 ? void 0 : _Children$toArray.slice(limit).map(function (item) {
39
+ var _ref2 = item,
40
+ props = _ref2.props;
41
+ return props.alt;
42
+ });
43
+
44
+ // render React Element with tooltip or without
45
+ var renderAvatars = function renderAvatars(item) {
46
+ var tooltipText = item.props.alt;
47
+ var alt = "Image of ".concat(tooltipText);
48
+ if (hasTooltip) {
49
+ return /*#__PURE__*/_react.default.createElement(_Tooltip.Tooltip, {
50
+ title: tooltipText
51
+ }, /*#__PURE__*/(0, _react.cloneElement)(item, _objectSpread(_objectSpread({}, item.props), {}, {
52
+ size: size,
53
+ alt: alt,
54
+ style: {
55
+ marginLeft: "-".concat(gap, "px"),
56
+ outline: "1px solid var(--page-paper-main)"
57
+ }
58
+ })));
59
+ }
34
60
  return /*#__PURE__*/(0, _react.cloneElement)(item, _objectSpread(_objectSpread({}, item.props), {}, {
35
61
  size: size,
62
+ alt: alt,
36
63
  style: {
37
- marginInlineStart: "-8px",
64
+ marginLeft: "-".concat(gap, "px"),
38
65
  outline: "1px solid var(--page-paper-main)"
39
66
  }
40
67
  }));
41
- }), limit >= _react.Children.count(children) || minChildren ? null : /*#__PURE__*/_react.default.createElement(_StyledLengthCountStyles, _extends({
42
- size: size,
43
- role: "status",
44
- "aria-label": "Rest of the users"
45
- }, counterProps), /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
46
- variant: handleVariant,
47
- weight: "medium"
48
- }, "+", _react.Children.count(children) - limit)));
49
- };
68
+ };
69
+
70
+ // render Tooltip if hasTooltip is true
71
+ var renderCounter = function renderCounter() {
72
+ if (hasTooltip) {
73
+ return /*#__PURE__*/_react.default.createElement(_StyledTooltip, {
74
+ title: nameArr.join("\n")
75
+ }, /*#__PURE__*/_react.default.createElement(_StyledLengthCountStyles, {
76
+ size: size,
77
+ role: "status",
78
+ "aria-label": "Rest of the users",
79
+ $_css: "-".concat(gap, "px")
80
+ }, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
81
+ variant: handleVariant,
82
+ weight: "medium"
83
+ }, "+", _react.Children.count(children) - limit)));
84
+ }
85
+ return /*#__PURE__*/_react.default.createElement(_StyledLengthCountStyles2, {
86
+ size: size,
87
+ role: "status",
88
+ "aria-label": "Rest of the users",
89
+ $_css2: "-".concat(gap, "px")
90
+ }, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
91
+ variant: handleVariant,
92
+ weight: "medium"
93
+ }, "+", _react.Children.count(children) - limit));
94
+ };
95
+ return /*#__PURE__*/_react.default.createElement(_Styles.AvatarGroupsStyles, {
96
+ hasTooltip: hasTooltip,
97
+ gap: gap,
98
+ ref: ref
99
+ }, _children.map(function (child) {
100
+ var item = child;
101
+ return renderAvatars(item);
102
+ }), limit >= _react.Children.count(children) || minChildren ? null : renderCounter());
103
+ });
50
104
  exports.AvatarGroup = AvatarGroup;
51
- var _StyledLengthCountStyles = (0, _styledComponents.default)(_Styles.LengthCountStyles).withConfig({
52
- displayName: "AvatarGroup___StyledLengthCountStyles",
105
+ AvatarGroup.displayName = "AvatarGroup";
106
+ var _StyledTooltip = (0, _styledComponents.default)(_Tooltip.Tooltip).withConfig({
107
+ displayName: "AvatarGroup___StyledTooltip",
53
108
  componentId: "sc-1rsx1j5-0"
54
109
  })({
55
- marginInlineStart: "-8px"
110
+ whiteSpace: "break-spaces",
111
+ lineHeight: "18px"
112
+ });
113
+ var _StyledLengthCountStyles = (0, _styledComponents.default)(_Styles.LengthCountStyles).withConfig({
114
+ displayName: "AvatarGroup___StyledLengthCountStyles",
115
+ componentId: "sc-1rsx1j5-1"
116
+ })(function (p) {
117
+ return {
118
+ marginLeft: p.$_css
119
+ };
120
+ });
121
+ var _StyledLengthCountStyles2 = (0, _styledComponents.default)(_Styles.LengthCountStyles).withConfig({
122
+ displayName: "AvatarGroup___StyledLengthCountStyles2",
123
+ componentId: "sc-1rsx1j5-2"
124
+ })(function (p) {
125
+ return {
126
+ marginLeft: p.$_css2
127
+ };
56
128
  });
57
129
  //# sourceMappingURL=AvatarGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvatarGroup.js","names":["AvatarGroup","limit","size","children","counterProps","minChildren","Children","count","_children","toArray","slice","handleVariant","useMemo","map","child","item","cloneElement","props","style","marginInlineStart","outline"],"sources":["../../../../src/components/AvatarGroup/AvatarGroup.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n PropsWithChildren,\n ReactElement,\n useMemo,\n} from \"react\";\nimport { AvatarProps } from \"../Avatar/Avatar\";\nimport { Typography } from \"../Typography/Typography\";\nimport { AvatarGroupsStyles, LengthCountStyles } from \"./Styles\";\n\nexport interface AvatarGroupsProps {\n limit: number;\n size?: number;\n counterProps?: HTMLAttributes<HTMLDivElement> & {\n [dataAttibute: `data-${string}`]: string;\n };\n}\n\nexport const AvatarGroup = ({\n limit,\n size = 34,\n children,\n counterProps,\n}: PropsWithChildren<AvatarGroupsProps>) => {\n // always display counter with min +2 as +1 can require 1 more Avatar\n const minChildren = Children.count(children) - limit > 1 ? false : true;\n const _children = minChildren\n ? Children.toArray(children)\n : Children.toArray(children).slice(0, limit);\n\n const handleVariant = useMemo(() => {\n if (size >= 34) return \"Caption 1\";\n return \"Caption 2\";\n }, [size]);\n\n return (\n <AvatarGroupsStyles>\n {_children.map((child) => {\n const item = child as ReactElement<AvatarProps>;\n\n return cloneElement(item, {\n ...item.props,\n size: size,\n style: {\n marginInlineStart: \"-8px\",\n outline: \"1px solid var(--page-paper-main)\",\n },\n });\n })}\n\n {limit >= Children.count(children) || minChildren ? null : (\n <LengthCountStyles\n size={size}\n role=\"status\"\n aria-label=\"Rest of the users\"\n css={{ marginInlineStart: \"-8px\" }}\n {...counterProps}\n >\n <Typography variant={handleVariant} weight=\"medium\">\n +{Children.count(children) - limit}\n </Typography>\n </LengthCountStyles>\n )}\n </AvatarGroupsStyles>\n );\n};\n"],"mappings":";;;;;;;;AAAA;AASA;AACA;AAAiE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAU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AK,CACvB,CAEhB,CACkB;AAEzB,CAAC;AAAC;AAAA;EAAA;EAAA;AAAA,GAVa;EAAEkB,iBAAiB,EAAE;AAAO,CAAC"}
1
+ {"version":3,"file":"AvatarGroup.js","names":["AvatarGroup","forwardRef","ref","limit","size","children","hasTooltip","minChildren","Children","count","gap","_children","toArray","slice","handleVariant","useMemo","nameArr","map","item","props","alt","renderAvatars","tooltipText","cloneElement","style","marginLeft","outline","renderCounter","join","child","displayName","whiteSpace","lineHeight"],"sources":["../../../../src/components/AvatarGroup/AvatarGroup.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n PropsWithChildren,\n ReactElement,\n useMemo,\n forwardRef,\n} from \"react\";\nimport { AvatarProps } from \"../Avatar/Avatar\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Typography } from \"../Typography/Typography\";\nimport { AvatarGroupsStyles, LengthCountStyles } from \"./Styles\";\n\nexport interface AvatarGroupsProps {\n limit: number;\n size?: number;\n hasTooltip?: boolean;\n}\n\nexport const AvatarGroup = forwardRef<\n HTMLDivElement,\n PropsWithChildren<AvatarGroupsProps>\n>(({ limit, size = 34, children, hasTooltip = false }, ref) => {\n // always display counter with min +2 as +1 can takes space of an 1 more Avatar\n const minChildren = Children.count(children) - limit > 1 ? false : true;\n // gap between Avatars\n const gap = 8;\n\n const _children = minChildren\n ? Children.toArray(children)\n : Children.toArray(children).slice(0, limit);\n\n const handleVariant = useMemo(() => {\n if (size >= 34) return \"Caption 1\";\n return \"Caption 2\";\n }, [size]);\n\n // get all names indexed above limit number from alt tag on Avatar for counter tooltip\n const nameArr = Children.toArray(children)\n ?.slice(limit)\n .map((item) => {\n const { props } = item as ReactElement;\n return props.alt;\n });\n\n // render React Element with tooltip or without\n const renderAvatars = (item: ReactElement) => {\n const tooltipText = item.props.alt;\n const alt = `Image of ${tooltipText}`;\n\n if (hasTooltip) {\n return (\n <Tooltip title={tooltipText}>\n {cloneElement(item, {\n ...item.props,\n size: size,\n alt: alt,\n style: {\n marginLeft: `-${gap}px`,\n outline: \"1px solid var(--page-paper-main)\",\n },\n })}\n </Tooltip>\n );\n }\n return cloneElement(item, {\n ...item.props,\n size: size,\n alt: alt,\n style: {\n marginLeft: `-${gap}px`,\n outline: \"1px solid var(--page-paper-main)\",\n },\n });\n };\n\n // render Tooltip if hasTooltip is true\n const renderCounter = () => {\n if (hasTooltip) {\n return (\n <Tooltip\n title={nameArr.join(\"\\n\")}\n css={{\n whiteSpace: \"break-spaces\",\n lineHeight: \"18px\",\n }}\n >\n <LengthCountStyles\n size={size}\n role=\"status\"\n aria-label=\"Rest of the users\"\n css={{\n marginLeft: `-${gap}px`,\n }}\n >\n <Typography variant={handleVariant} weight=\"medium\">\n +{Children.count(children) - limit}\n </Typography>\n </LengthCountStyles>\n </Tooltip>\n );\n }\n return (\n <LengthCountStyles\n size={size}\n role=\"status\"\n aria-label=\"Rest of the users\"\n css={{\n marginLeft: `-${gap}px`,\n }}\n >\n <Typography variant={handleVariant} weight=\"medium\">\n +{Children.count(children) - limit}\n </Typography>\n </LengthCountStyles>\n );\n };\n\n return (\n <AvatarGroupsStyles hasTooltip={hasTooltip} gap={gap} ref={ref}>\n {_children.map((child) => {\n const item = child as ReactElement<AvatarProps>;\n\n return renderAvatars(item);\n })}\n\n {limit >= Children.count(children) || minChildren\n ? null\n : renderCounter()}\n </AvatarGroupsStyles>\n );\n});\n\nAvatarGroup.displayName = \"AvatarGroup\";\n"],"mappings":";;;;;;;;AAAA;AASA;AACA;AACA;AAAiE;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ1D,IAAMA,WAAW,gBAAG,IAAAC,iBAAU,EAGnC,gBAAqDC,GAAG,EAAK;EAAA;EAAA,IAA1DC,KAAK,QAALA,KAAK;IAAA,iBAAEC,IAAI;IAAJA,IAAI,0BAAG,EAAE;IAAEC,QAAQ,QAARA,QAAQ;IAAA,uBAAEC,UAAU;IAAVA,UAAU,gCAAG,KAAK;EACjD;EACA,IAAMC,WAAW,GAAGC,eAAQ,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A,GAnDzB;EACHC,UAAU,EAAE,cAAc;EAC1BC,UAAU,EAAE;AACd,CAAC;AAAA;EAAA;EAAA;AAAA;EAAA,OAMM;IACHP,UAAU;EACZ,CAAC;AAAA;AAAA;EAAA;EAAA;AAAA;EAAA,OAcA;IACHA,UAAU;EACZ,CAAC;AAAA"}
@@ -10,7 +10,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
10
10
  var AvatarGroupsStyles = _styledComponents.default.div.withConfig({
11
11
  displayName: "Styles__AvatarGroupsStyles",
12
12
  componentId: "sc-1padv46-0"
13
- })(["display:flex;cursor:pointer;width:fit-content;", ""], _FontStyle.FontStyle);
13
+ })(["", " align-items:center;cursor:pointer;display:flex;justify-content:center;position:relative;user-select:none;width:fit-content;&::before{border-radius:5px;background-color:", ";content:\"\";height:100%;margin-left:", "px;opacity:0;padding:5px 0;position:absolute;transition:opacity 0.2s ease-in-out;width:", ";}&:hover::before{opacity:1;}"], _FontStyle.FontStyle, function (props) {
14
+ return !props.hasTooltip && "var(--color-theme-300)";
15
+ }, function (_ref) {
16
+ var gap = _ref.gap;
17
+ return -gap;
18
+ }, function (_ref2) {
19
+ var gap = _ref2.gap;
20
+ return "calc(100% + ".concat(gap * 2, "px + 5px)");
21
+ });
14
22
  exports.AvatarGroupsStyles = AvatarGroupsStyles;
15
23
  var LengthCountStyles = _styledComponents.default.div.withConfig({
16
24
  displayName: "Styles__LengthCountStyles",
@@ -1 +1 @@
1
- {"version":3,"file":"Styles.js","names":["AvatarGroupsStyles","styled","div","FontStyle","LengthCountStyles","props","size"],"sources":["../../../../src/components/AvatarGroup/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const AvatarGroupsStyles = styled.div`\n display: flex;\n cursor: pointer;\n width: fit-content;\n ${FontStyle}\n`;\n\ninterface LengthCountStylesProps {\n size: number;\n}\n\nexport const LengthCountStyles = styled.div<LengthCountStylesProps>`\n align-items: center;\n background-color: var(--color-theme-400);\n block-size: ${(props) => props.size + \"px\"};\n border-radius: var(--ac-br-rounded);\n display: flex;\n inline-size: ${(props) => props.size + \"px\"};\n justify-content: center;\n outline: 1px solid var(--page-paper-main);\n z-index: 99;\n`;\n"],"mappings":";;;;;;AAAA;AACA;AAAyC;AAElC,IAAMA,kBAAkB,GAAGC,yBAAM,CAACC,GAAG;EAAA;EAAA;AAAA,2DAIxCC,oBAAS,CACZ;AAAC;AAMK,IAAMC,iBAAiB,GAAGH,yBAAM,CAACC,GAAG;EAAA;EAAA;AAAA,gOAG3B,UAACG,KAAK;EAAA,OAAKA,KAAK,CAACC,IAAI,GAAG,IAAI;AAAA,GAG3B,UAACD,KAAK;EAAA,OAAKA,KAAK,CAACC,IAAI,GAAG,IAAI;AAAA,EAI5C;AAAC"}
1
+ {"version":3,"file":"Styles.js","names":["AvatarGroupsStyles","styled","div","FontStyle","props","hasTooltip","gap","LengthCountStyles","size"],"sources":["../../../../src/components/AvatarGroup/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const AvatarGroupsStyles = styled.div<{\n hasTooltip: boolean;\n gap: number;\n}>`\n ${FontStyle}\n align-items: center;\n cursor: pointer;\n display: flex;\n justify-content: center;\n position: relative;\n user-select: none;\n width: fit-content;\n\n &::before {\n border-radius: 5px;\n background-color: ${(props) =>\n !props.hasTooltip && \"var(--color-theme-300)\"};\n content: \"\";\n height: 100%;\n margin-left: ${({ gap }) => -gap}px;\n opacity: 0;\n padding: 5px 0;\n position: absolute;\n transition: opacity 0.2s ease-in-out;\n // 5px represents padding px\n width: ${({ gap }) => `calc(100% + ${gap * 2}px + 5px)`};\n }\n\n &:hover::before {\n opacity: 1;\n }\n`;\n\ninterface LengthCountStylesProps {\n size: number;\n}\n\nexport const LengthCountStyles = styled.div<LengthCountStylesProps>`\n align-items: center;\n background-color: var(--color-theme-400);\n block-size: ${(props) => props.size + \"px\"};\n border-radius: var(--ac-br-rounded);\n display: flex;\n inline-size: ${(props) => props.size + \"px\"};\n justify-content: center;\n outline: 1px solid var(--page-paper-main);\n z-index: 99;\n`;\n"],"mappings":";;;;;;AAAA;AACA;AAAyC;AAElC,IAAMA,kBAAkB,GAAGC,yBAAM,CAACC,GAAG;EAAA;EAAA;AAAA,4VAIxCC,oBAAS,EAWW,UAACC,KAAK;EAAA,OACxB,CAACA,KAAK,CAACC,UAAU,IAAI,wBAAwB;AAAA,GAGhC;EAAA,IAAGC,GAAG,QAAHA,GAAG;EAAA,OAAO,CAACA,GAAG;AAAA,GAMvB;EAAA,IAAGA,GAAG,SAAHA,GAAG;EAAA,6BAAsBA,GAAG,GAAG,CAAC;AAAA,CAAW,CAM1D;AAAC;AAMK,IAAMC,iBAAiB,GAAGN,yBAAM,CAACC,GAAG;EAAA;EAAA;AAAA,gOAG3B,UAACE,KAAK;EAAA,OAAKA,KAAK,CAACI,IAAI,GAAG,IAAI;AAAA,GAG3B,UAACJ,KAAK;EAAA,OAAKA,KAAK,CAACI,IAAI,GAAG,IAAI;AAAA,EAI5C;AAAC"}
@@ -1,10 +1,10 @@
1
- import { HTMLAttributes, PropsWithChildren } from "react";
1
+ import React from "react";
2
2
  export interface AvatarGroupsProps {
3
3
  limit: number;
4
4
  size?: number;
5
- counterProps?: HTMLAttributes<HTMLDivElement> & {
6
- [dataAttibute: `data-${string}`]: string;
7
- };
5
+ hasTooltip?: boolean;
8
6
  }
9
- export declare const AvatarGroup: ({ limit, size, children, counterProps, }: PropsWithChildren<AvatarGroupsProps>) => JSX.Element;
7
+ export declare const AvatarGroup: React.ForwardRefExoticComponent<AvatarGroupsProps & {
8
+ children?: React.ReactNode;
9
+ } & React.RefAttributes<HTMLDivElement>>;
10
10
  //# sourceMappingURL=AvatarGroup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvatarGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/AvatarGroup/AvatarGroup.tsx"],"names":[],"mappings":"AAAA,OAAc,EAGZ,cAAc,EACd,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AAKf,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;QAC9C,CAAC,YAAY,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,CAAC;KAC1C,CAAC;CACH;AAED,eAAO,MAAM,WAAW,6CAKrB,kBAAkB,iBAAiB,CAAC,gBA0CtC,CAAC"}
1
+ {"version":3,"file":"AvatarGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/AvatarGroup/AvatarGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAMf,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,WAAW;;wCAgHtB,CAAC"}
@@ -1,43 +1,118 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _styled3 from "styled-components";
3
+ import _styled2 from "styled-components";
2
4
  import _styled from "styled-components";
3
- import React, { Children, cloneElement, useMemo } from "react";
5
+ import React, { Children, cloneElement, useMemo, forwardRef } from "react";
6
+ import { Tooltip } from "../Tooltip";
4
7
  import { Typography } from "../Typography/Typography";
5
8
  import { AvatarGroupsStyles, LengthCountStyles } from "./Styles";
6
- export var AvatarGroup = function AvatarGroup(_ref) {
9
+ export var AvatarGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
+ var _Children$toArray;
7
11
  var limit = _ref.limit,
8
12
  _ref$size = _ref.size,
9
13
  size = _ref$size === void 0 ? 34 : _ref$size,
10
14
  children = _ref.children,
11
- counterProps = _ref.counterProps;
12
- // always display counter with min +2 as +1 can require 1 more Avatar
15
+ _ref$hasTooltip = _ref.hasTooltip,
16
+ hasTooltip = _ref$hasTooltip === void 0 ? false : _ref$hasTooltip;
17
+ // always display counter with min +2 as +1 can takes space of an 1 more Avatar
13
18
  var minChildren = Children.count(children) - limit > 1 ? false : true;
19
+ // gap between Avatars
20
+ var gap = 8;
14
21
  var _children = minChildren ? Children.toArray(children) : Children.toArray(children).slice(0, limit);
15
22
  var handleVariant = useMemo(function () {
16
23
  if (size >= 34) return "Caption 1";
17
24
  return "Caption 2";
18
25
  }, [size]);
19
- return /*#__PURE__*/React.createElement(AvatarGroupsStyles, null, _children.map(function (child) {
20
- var item = child;
26
+
27
+ // get all names indexed above limit number from alt tag on Avatar for counter tooltip
28
+ var nameArr = (_Children$toArray = Children.toArray(children)) == null ? void 0 : _Children$toArray.slice(limit).map(function (item) {
29
+ var _ref2 = item,
30
+ props = _ref2.props;
31
+ return props.alt;
32
+ });
33
+
34
+ // render React Element with tooltip or without
35
+ var renderAvatars = function renderAvatars(item) {
36
+ var tooltipText = item.props.alt;
37
+ var alt = "Image of " + tooltipText;
38
+ if (hasTooltip) {
39
+ return /*#__PURE__*/React.createElement(Tooltip, {
40
+ title: tooltipText
41
+ }, /*#__PURE__*/cloneElement(item, _extends({}, item.props, {
42
+ size: size,
43
+ alt: alt,
44
+ style: {
45
+ marginLeft: "-" + gap + "px",
46
+ outline: "1px solid var(--page-paper-main)"
47
+ }
48
+ })));
49
+ }
21
50
  return /*#__PURE__*/cloneElement(item, _extends({}, item.props, {
22
51
  size: size,
52
+ alt: alt,
23
53
  style: {
24
- marginInlineStart: "-8px",
54
+ marginLeft: "-" + gap + "px",
25
55
  outline: "1px solid var(--page-paper-main)"
26
56
  }
27
57
  }));
28
- }), limit >= Children.count(children) || minChildren ? null : /*#__PURE__*/React.createElement(_StyledLengthCountStyles, _extends({
29
- size: size,
30
- role: "status",
31
- "aria-label": "Rest of the users"
32
- }, counterProps), /*#__PURE__*/React.createElement(Typography, {
33
- variant: handleVariant,
34
- weight: "medium"
35
- }, "+", Children.count(children) - limit)));
36
- };
37
- var _StyledLengthCountStyles = _styled(LengthCountStyles).withConfig({
38
- displayName: "AvatarGroup___StyledLengthCountStyles",
58
+ };
59
+
60
+ // render Tooltip if hasTooltip is true
61
+ var renderCounter = function renderCounter() {
62
+ if (hasTooltip) {
63
+ return /*#__PURE__*/React.createElement(_StyledTooltip, {
64
+ title: nameArr.join("\n")
65
+ }, /*#__PURE__*/React.createElement(_StyledLengthCountStyles, {
66
+ size: size,
67
+ role: "status",
68
+ "aria-label": "Rest of the users",
69
+ $_css: "-" + gap + "px"
70
+ }, /*#__PURE__*/React.createElement(Typography, {
71
+ variant: handleVariant,
72
+ weight: "medium"
73
+ }, "+", Children.count(children) - limit)));
74
+ }
75
+ return /*#__PURE__*/React.createElement(_StyledLengthCountStyles2, {
76
+ size: size,
77
+ role: "status",
78
+ "aria-label": "Rest of the users",
79
+ $_css2: "-" + gap + "px"
80
+ }, /*#__PURE__*/React.createElement(Typography, {
81
+ variant: handleVariant,
82
+ weight: "medium"
83
+ }, "+", Children.count(children) - limit));
84
+ };
85
+ return /*#__PURE__*/React.createElement(AvatarGroupsStyles, {
86
+ hasTooltip: hasTooltip,
87
+ gap: gap,
88
+ ref: ref
89
+ }, _children.map(function (child) {
90
+ var item = child;
91
+ return renderAvatars(item);
92
+ }), limit >= Children.count(children) || minChildren ? null : renderCounter());
93
+ });
94
+ AvatarGroup.displayName = "AvatarGroup";
95
+ var _StyledTooltip = _styled(Tooltip).withConfig({
96
+ displayName: "AvatarGroup___StyledTooltip",
39
97
  componentId: "sc-1rsx1j5-0"
40
98
  })({
41
- marginInlineStart: "-8px"
99
+ whiteSpace: "break-spaces",
100
+ lineHeight: "18px"
101
+ });
102
+ var _StyledLengthCountStyles = _styled(LengthCountStyles).withConfig({
103
+ displayName: "AvatarGroup___StyledLengthCountStyles",
104
+ componentId: "sc-1rsx1j5-1"
105
+ })(function (p) {
106
+ return {
107
+ marginLeft: p.$_css
108
+ };
109
+ });
110
+ var _StyledLengthCountStyles2 = _styled(LengthCountStyles).withConfig({
111
+ displayName: "AvatarGroup___StyledLengthCountStyles2",
112
+ componentId: "sc-1rsx1j5-2"
113
+ })(function (p) {
114
+ return {
115
+ marginLeft: p.$_css2
116
+ };
42
117
  });
43
118
  //# sourceMappingURL=AvatarGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvatarGroup.js","names":["React","Children","cloneElement","useMemo","Typography","AvatarGroupsStyles","LengthCountStyles","AvatarGroup","limit","size","children","counterProps","minChildren","count","_children","toArray","slice","handleVariant","map","child","item","props","style","marginInlineStart","outline"],"sources":["../../../../src/components/AvatarGroup/AvatarGroup.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n PropsWithChildren,\n ReactElement,\n useMemo,\n} from \"react\";\nimport { AvatarProps } from \"../Avatar/Avatar\";\nimport { Typography } from \"../Typography/Typography\";\nimport { AvatarGroupsStyles, LengthCountStyles } from \"./Styles\";\n\nexport interface AvatarGroupsProps {\n limit: number;\n size?: number;\n counterProps?: HTMLAttributes<HTMLDivElement> & {\n [dataAttibute: `data-${string}`]: string;\n };\n}\n\nexport const AvatarGroup = ({\n limit,\n size = 34,\n children,\n counterProps,\n}: PropsWithChildren<AvatarGroupsProps>) => {\n // always display counter with min +2 as +1 can require 1 more Avatar\n const minChildren = Children.count(children) - limit > 1 ? false : true;\n const _children = minChildren\n ? Children.toArray(children)\n : Children.toArray(children).slice(0, limit);\n\n const handleVariant = useMemo(() => {\n if (size >= 34) return \"Caption 1\";\n return \"Caption 2\";\n }, [size]);\n\n return (\n <AvatarGroupsStyles>\n {_children.map((child) => {\n const item = child as ReactElement<AvatarProps>;\n\n return cloneElement(item, {\n ...item.props,\n size: size,\n style: {\n marginInlineStart: \"-8px\",\n outline: \"1px solid var(--page-paper-main)\",\n },\n });\n })}\n\n {limit >= Children.count(children) || minChildren ? null : (\n <LengthCountStyles\n size={size}\n role=\"status\"\n aria-label=\"Rest of the users\"\n css={{ marginInlineStart: \"-8px\" }}\n {...counterProps}\n >\n <Typography variant={handleVariant} weight=\"medium\">\n +{Children.count(children) - limit}\n </Typography>\n </LengthCountStyles>\n )}\n </AvatarGroupsStyles>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,QAAQ,EACRC,YAAY,EAIZC,OAAO,QACF,OAAO;AAEd,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,kBAAkB,EAAEC,iBAAiB,QAAQ,UAAU;AAUhE,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAW,OAKoB;EAAA,IAJ1CC,KAAK,QAALA,KAAK;IAAA,iBACLC,IAAI;IAAJA,IAAI,0BAAG,EAAE;IACTC,QAAQ,QAARA,QAAQ;IACRC,YAAY,QAAZA,YAAY;EAEZ;EACA,IAAMC,WAAW,GAAGX,QAAQ,CAACY,KAAK,CAACH,QAAQ,CAAC,GAAGF,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,IAAI;EACvE,IAAMM,SAAS,GAAGF,WAAW,GACzBX,QAAQ,CAACc,OAAO,CAACL,QAAQ,CAAC,GAC1BT,QAAQ,CAACc,OAAO,CAACL,QAAQ,CAAC,CAACM,KAAK,CAAC,CAAC,EAAER,KAAK,CAAC;EAE9C,IAAMS,aAAa,GAAGd,OAAO,CAAC,YAAM;IAClC,IAAIM,IAAI,IAAI,EAAE,EAAE,OAAO,WAAW;IAClC,OAAO,WAAW;EACpB,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,oBACE,oBAAC,kBAAkB,QAChBK,SAAS,CAACI,GAAG,CAAC,UAACC,KAAK,EAAK;IACxB,IAAMC,IAAI,GAAGD,KAAkC;IAE/C,oBAAOjB,YAAY,CAACkB,IAAI,eACnBA,IAAI,CAACC,KAAK;MACbZ,IAAI,EAAEA,IAAI;MACVa,KAAK,EAAE;QACLC,iBAAiB,EAAE,MAAM;QACzBC,OAAO,EAAE;MACX;IAAC,GACD;EACJ,CAAC,CAAC,EAEDhB,KAAK,IAAIP,QAAQ,CAACY,KAAK,CAACH,QAAQ,CAAC,IAAIE,WAAW,GAAG,IAAI,gBACtD;IACE,IAAI,EAAEH,IAAK;IACX,IAAI,EAAC,QAAQ;IACb,cAAW;EAAmB,GAE1BE,YAAY,gBAEhB,oBAAC,UAAU;IAAC,OAAO,EAAEM,aAAc;IAAC,MAAM,EAAC;EAAQ,QAC/ChB,QAAQ,CAACY,KAAK,CAACH,QAAQ,CAAC,GAAGF,KAAK,CACvB,CAEhB,CACkB;AAEzB,CAAC;AAAC;EAAA;EAAA;AAAA,GAVa;EAAEe,iBAAiB,EAAE;AAAO,CAAC"}
1
+ {"version":3,"file":"AvatarGroup.js","names":["React","Children","cloneElement","useMemo","forwardRef","Tooltip","Typography","AvatarGroupsStyles","LengthCountStyles","AvatarGroup","ref","limit","size","children","hasTooltip","minChildren","count","gap","_children","toArray","slice","handleVariant","nameArr","map","item","props","alt","renderAvatars","tooltipText","style","marginLeft","outline","renderCounter","join","child","displayName","whiteSpace","lineHeight"],"sources":["../../../../src/components/AvatarGroup/AvatarGroup.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n PropsWithChildren,\n ReactElement,\n useMemo,\n forwardRef,\n} from \"react\";\nimport { AvatarProps } from \"../Avatar/Avatar\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Typography } from \"../Typography/Typography\";\nimport { AvatarGroupsStyles, LengthCountStyles } from \"./Styles\";\n\nexport interface AvatarGroupsProps {\n limit: number;\n size?: number;\n hasTooltip?: boolean;\n}\n\nexport const AvatarGroup = forwardRef<\n HTMLDivElement,\n PropsWithChildren<AvatarGroupsProps>\n>(({ limit, size = 34, children, hasTooltip = false }, ref) => {\n // always display counter with min +2 as +1 can takes space of an 1 more Avatar\n const minChildren = Children.count(children) - limit > 1 ? false : true;\n // gap between Avatars\n const gap = 8;\n\n const _children = minChildren\n ? Children.toArray(children)\n : Children.toArray(children).slice(0, limit);\n\n const handleVariant = useMemo(() => {\n if (size >= 34) return \"Caption 1\";\n return \"Caption 2\";\n }, [size]);\n\n // get all names indexed above limit number from alt tag on Avatar for counter tooltip\n const nameArr = Children.toArray(children)\n ?.slice(limit)\n .map((item) => {\n const { props } = item as ReactElement;\n return props.alt;\n });\n\n // render React Element with tooltip or without\n const renderAvatars = (item: ReactElement) => {\n const tooltipText = item.props.alt;\n const alt = `Image of ${tooltipText}`;\n\n if (hasTooltip) {\n return (\n <Tooltip title={tooltipText}>\n {cloneElement(item, {\n ...item.props,\n size: size,\n alt: alt,\n style: {\n marginLeft: `-${gap}px`,\n outline: \"1px solid var(--page-paper-main)\",\n },\n })}\n </Tooltip>\n );\n }\n return cloneElement(item, {\n ...item.props,\n size: size,\n alt: alt,\n style: {\n marginLeft: `-${gap}px`,\n outline: \"1px solid var(--page-paper-main)\",\n },\n });\n };\n\n // render Tooltip if hasTooltip is true\n const renderCounter = () => {\n if (hasTooltip) {\n return (\n <Tooltip\n title={nameArr.join(\"\\n\")}\n css={{\n whiteSpace: \"break-spaces\",\n lineHeight: \"18px\",\n }}\n >\n <LengthCountStyles\n size={size}\n role=\"status\"\n aria-label=\"Rest of the users\"\n css={{\n marginLeft: `-${gap}px`,\n }}\n >\n <Typography variant={handleVariant} weight=\"medium\">\n +{Children.count(children) - limit}\n </Typography>\n </LengthCountStyles>\n </Tooltip>\n );\n }\n return (\n <LengthCountStyles\n size={size}\n role=\"status\"\n aria-label=\"Rest of the users\"\n css={{\n marginLeft: `-${gap}px`,\n }}\n >\n <Typography variant={handleVariant} weight=\"medium\">\n +{Children.count(children) - limit}\n </Typography>\n </LengthCountStyles>\n );\n };\n\n return (\n <AvatarGroupsStyles hasTooltip={hasTooltip} gap={gap} ref={ref}>\n {_children.map((child) => {\n const item = child as ReactElement<AvatarProps>;\n\n return renderAvatars(item);\n })}\n\n {limit >= Children.count(children) || minChildren\n ? null\n : renderCounter()}\n </AvatarGroupsStyles>\n );\n});\n\nAvatarGroup.displayName = \"AvatarGroup\";\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IACVC,QAAQ,EACRC,YAAY,EAGZC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AAEG,GAAI;IAAC,GAAG,EAAEP;EAAI,GAC5DQ,SAAS,CAACK,GAAG,CAAC,UAACW,KAAK,EAAK;IACxB,IAAMV,IAAI,GAAGU,KAAkC;IAE/C,OAAOP,aAAa,CAACH,IAAI,CAAC;EAC5B,CAAC,CAAC,EAEDb,KAAK,IAAIV,QAAQ,CAACe,KAAK,CAACH,QAAQ,CAAC,IAAIE,WAAW,GAC7C,IAAI,GACJiB,aAAa,EAAE,CACA;AAEzB,CAAC,CAAC;AAEFvB,WAAW,CAAC0B,WAAW,GAAG,aAAa;AAAC;EAAA;EAAA;AAAA,GAnDzB;EACHC,UAAU,EAAE,cAAc;EAC1BC,UAAU,EAAE;AACd,CAAC;AAAA;EAAA;EAAA;AAAA;EAAA,OAMM;IACHP,UAAU;EACZ,CAAC;AAAA;AAAA;EAAA;EAAA;AAAA;EAAA,OAcA;IACHA,UAAU;EACZ,CAAC;AAAA"}
@@ -1,4 +1,7 @@
1
- export declare const AvatarGroupsStyles: import("styled-components").StyledComponent<"div", any, {}, never>;
1
+ export declare const AvatarGroupsStyles: import("styled-components").StyledComponent<"div", any, {
2
+ hasTooltip: boolean;
3
+ gap: number;
4
+ }, never>;
2
5
  interface LengthCountStylesProps {
3
6
  size: number;
4
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/AvatarGroup/Styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,oEAK9B,CAAC;AAEF,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,iBAAiB,wFAU7B,CAAC"}
1
+ {"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/AvatarGroup/Styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;gBACjB,OAAO;SACd,MAAM;SA6BZ,CAAC;AAEF,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,iBAAiB,wFAU7B,CAAC"}
@@ -3,7 +3,15 @@ import { FontStyle } from "../FontStyle";
3
3
  export var AvatarGroupsStyles = styled.div.withConfig({
4
4
  displayName: "Styles__AvatarGroupsStyles",
5
5
  componentId: "sc-1padv46-0"
6
- })(["display:flex;cursor:pointer;width:fit-content;", ""], FontStyle);
6
+ })(["", " align-items:center;cursor:pointer;display:flex;justify-content:center;position:relative;user-select:none;width:fit-content;&::before{border-radius:5px;background-color:", ";content:\"\";height:100%;margin-left:", "px;opacity:0;padding:5px 0;position:absolute;transition:opacity 0.2s ease-in-out;width:", ";}&:hover::before{opacity:1;}"], FontStyle, function (props) {
7
+ return !props.hasTooltip && "var(--color-theme-300)";
8
+ }, function (_ref) {
9
+ var gap = _ref.gap;
10
+ return -gap;
11
+ }, function (_ref2) {
12
+ var gap = _ref2.gap;
13
+ return "calc(100% + " + gap * 2 + "px + 5px)";
14
+ });
7
15
  export var LengthCountStyles = styled.div.withConfig({
8
16
  displayName: "Styles__LengthCountStyles",
9
17
  componentId: "sc-1padv46-1"
@@ -1 +1 @@
1
- {"version":3,"file":"Styles.js","names":["styled","FontStyle","AvatarGroupsStyles","div","LengthCountStyles","props","size"],"sources":["../../../../src/components/AvatarGroup/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const AvatarGroupsStyles = styled.div`\n display: flex;\n cursor: pointer;\n width: fit-content;\n ${FontStyle}\n`;\n\ninterface LengthCountStylesProps {\n size: number;\n}\n\nexport const LengthCountStyles = styled.div<LengthCountStylesProps>`\n align-items: center;\n background-color: var(--color-theme-400);\n block-size: ${(props) => props.size + \"px\"};\n border-radius: var(--ac-br-rounded);\n display: flex;\n inline-size: ${(props) => props.size + \"px\"};\n justify-content: center;\n outline: 1px solid var(--page-paper-main);\n z-index: 99;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AACtC,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,IAAMC,kBAAkB,GAAGF,MAAM,CAACG,GAAG;EAAA;EAAA;AAAA,2DAIxCF,SAAS,CACZ;AAMD,OAAO,IAAMG,iBAAiB,GAAGJ,MAAM,CAACG,GAAG;EAAA;EAAA;AAAA,gOAG3B,UAACE,KAAK;EAAA,OAAKA,KAAK,CAACC,IAAI,GAAG,IAAI;AAAA,GAG3B,UAACD,KAAK;EAAA,OAAKA,KAAK,CAACC,IAAI,GAAG,IAAI;AAAA,EAI5C"}
1
+ {"version":3,"file":"Styles.js","names":["styled","FontStyle","AvatarGroupsStyles","div","props","hasTooltip","gap","LengthCountStyles","size"],"sources":["../../../../src/components/AvatarGroup/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const AvatarGroupsStyles = styled.div<{\n hasTooltip: boolean;\n gap: number;\n}>`\n ${FontStyle}\n align-items: center;\n cursor: pointer;\n display: flex;\n justify-content: center;\n position: relative;\n user-select: none;\n width: fit-content;\n\n &::before {\n border-radius: 5px;\n background-color: ${(props) =>\n !props.hasTooltip && \"var(--color-theme-300)\"};\n content: \"\";\n height: 100%;\n margin-left: ${({ gap }) => -gap}px;\n opacity: 0;\n padding: 5px 0;\n position: absolute;\n transition: opacity 0.2s ease-in-out;\n // 5px represents padding px\n width: ${({ gap }) => `calc(100% + ${gap * 2}px + 5px)`};\n }\n\n &:hover::before {\n opacity: 1;\n }\n`;\n\ninterface LengthCountStylesProps {\n size: number;\n}\n\nexport const LengthCountStyles = styled.div<LengthCountStylesProps>`\n align-items: center;\n background-color: var(--color-theme-400);\n block-size: ${(props) => props.size + \"px\"};\n border-radius: var(--ac-br-rounded);\n display: flex;\n inline-size: ${(props) => props.size + \"px\"};\n justify-content: center;\n outline: 1px solid var(--page-paper-main);\n z-index: 99;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AACtC,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,IAAMC,kBAAkB,GAAGF,MAAM,CAACG,GAAG;EAAA;EAAA;AAAA,4VAIxCF,SAAS,EAWW,UAACG,KAAK;EAAA,OACxB,CAACA,KAAK,CAACC,UAAU,IAAI,wBAAwB;AAAA,GAGhC;EAAA,IAAGC,GAAG,QAAHA,GAAG;EAAA,OAAO,CAACA,GAAG;AAAA,GAMvB;EAAA,IAAGA,GAAG,SAAHA,GAAG;EAAA,wBAAsBA,GAAG,GAAG,CAAC;AAAA,CAAW,CAM1D;AAMD,OAAO,IAAMC,iBAAiB,GAAGP,MAAM,CAACG,GAAG;EAAA;EAAA;AAAA,gOAG3B,UAACC,KAAK;EAAA,OAAKA,KAAK,CAACI,IAAI,GAAG,IAAI;AAAA,GAG3B,UAACJ,KAAK;EAAA,OAAKA,KAAK,CAACI,IAAI,GAAG,IAAI;AAAA,EAI5C"}
package/dist/index.js CHANGED
@@ -15997,7 +15997,15 @@
15997
15997
  var AvatarGroupsStyles = styled__default["default"].div.withConfig({
15998
15998
  displayName: "Styles__AvatarGroupsStyles",
15999
15999
  componentId: "sc-1padv46-0"
16000
- })(["display:flex;cursor:pointer;width:fit-content;", ""], FontStyle);
16000
+ })(["", " align-items:center;cursor:pointer;display:flex;justify-content:center;position:relative;user-select:none;width:fit-content;&::before{border-radius:5px;background-color:", ";content:\"\";height:100%;margin-left:", "px;opacity:0;padding:5px 0;position:absolute;transition:opacity 0.2s ease-in-out;width:", ";}&:hover::before{opacity:1;}"], FontStyle, function (props) {
16001
+ return !props.hasTooltip && "var(--color-theme-300)";
16002
+ }, function (_ref) {
16003
+ var gap = _ref.gap;
16004
+ return -gap;
16005
+ }, function (_ref2) {
16006
+ var gap = _ref2.gap;
16007
+ return "calc(100% + ".concat(gap * 2, "px + 5px)");
16008
+ });
16001
16009
  var LengthCountStyles = styled__default["default"].div.withConfig({
16002
16010
  displayName: "Styles__LengthCountStyles",
16003
16011
  componentId: "sc-1padv46-1"
@@ -16007,42 +16015,114 @@
16007
16015
  return props.size + "px";
16008
16016
  });
16009
16017
 
16010
- var AvatarGroup = function AvatarGroup(_ref) {
16018
+ var AvatarGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
16019
+ var _Children$toArray;
16011
16020
  var limit = _ref.limit,
16012
16021
  _ref$size = _ref.size,
16013
16022
  size = _ref$size === void 0 ? 34 : _ref$size,
16014
16023
  children = _ref.children,
16015
- counterProps = _ref.counterProps;
16016
- // always display counter with min +2 as +1 can require 1 more Avatar
16024
+ _ref$hasTooltip = _ref.hasTooltip,
16025
+ hasTooltip = _ref$hasTooltip === void 0 ? false : _ref$hasTooltip;
16026
+ // always display counter with min +2 as +1 can takes space of an 1 more Avatar
16017
16027
  var minChildren = React.Children.count(children) - limit > 1 ? false : true;
16028
+ // gap between Avatars
16029
+ var gap = 8;
16018
16030
  var _children = minChildren ? React.Children.toArray(children) : React.Children.toArray(children).slice(0, limit);
16019
16031
  var handleVariant = React.useMemo(function () {
16020
16032
  if (size >= 34) return "Caption 1";
16021
16033
  return "Caption 2";
16022
16034
  }, [size]);
16023
- return /*#__PURE__*/React__default["default"].createElement(AvatarGroupsStyles, null, _children.map(function (child) {
16024
- var item = child;
16035
+
16036
+ // get all names indexed above limit number from alt tag on Avatar for counter tooltip
16037
+ var nameArr = (_Children$toArray = React.Children.toArray(children)) === null || _Children$toArray === void 0 ? void 0 : _Children$toArray.slice(limit).map(function (item) {
16038
+ var _ref2 = item,
16039
+ props = _ref2.props;
16040
+ return props.alt;
16041
+ });
16042
+
16043
+ // render React Element with tooltip or without
16044
+ var renderAvatars = function renderAvatars(item) {
16045
+ var tooltipText = item.props.alt;
16046
+ var alt = "Image of ".concat(tooltipText);
16047
+ if (hasTooltip) {
16048
+ return /*#__PURE__*/React__default["default"].createElement(Tooltip, {
16049
+ title: tooltipText
16050
+ }, /*#__PURE__*/React.cloneElement(item, _objectSpread2(_objectSpread2({}, item.props), {}, {
16051
+ size: size,
16052
+ alt: alt,
16053
+ style: {
16054
+ marginLeft: "-".concat(gap, "px"),
16055
+ outline: "1px solid var(--page-paper-main)"
16056
+ }
16057
+ })));
16058
+ }
16025
16059
  return /*#__PURE__*/React.cloneElement(item, _objectSpread2(_objectSpread2({}, item.props), {}, {
16026
16060
  size: size,
16061
+ alt: alt,
16027
16062
  style: {
16028
- marginInlineStart: "-8px",
16063
+ marginLeft: "-".concat(gap, "px"),
16029
16064
  outline: "1px solid var(--page-paper-main)"
16030
16065
  }
16031
16066
  }));
16032
- }), limit >= React.Children.count(children) || minChildren ? null : /*#__PURE__*/React__default["default"].createElement(_StyledLengthCountStyles, _extends({
16033
- size: size,
16034
- role: "status",
16035
- "aria-label": "Rest of the users"
16036
- }, counterProps), /*#__PURE__*/React__default["default"].createElement(Typography, {
16037
- variant: handleVariant,
16038
- weight: "medium"
16039
- }, "+", React.Children.count(children) - limit)));
16040
- };
16041
- var _StyledLengthCountStyles = styled__default["default"](LengthCountStyles).withConfig({
16042
- displayName: "AvatarGroup___StyledLengthCountStyles",
16067
+ };
16068
+
16069
+ // render Tooltip if hasTooltip is true
16070
+ var renderCounter = function renderCounter() {
16071
+ if (hasTooltip) {
16072
+ return /*#__PURE__*/React__default["default"].createElement(_StyledTooltip, {
16073
+ title: nameArr.join("\n")
16074
+ }, /*#__PURE__*/React__default["default"].createElement(_StyledLengthCountStyles, {
16075
+ size: size,
16076
+ role: "status",
16077
+ "aria-label": "Rest of the users",
16078
+ $_css: "-".concat(gap, "px")
16079
+ }, /*#__PURE__*/React__default["default"].createElement(Typography, {
16080
+ variant: handleVariant,
16081
+ weight: "medium"
16082
+ }, "+", React.Children.count(children) - limit)));
16083
+ }
16084
+ return /*#__PURE__*/React__default["default"].createElement(_StyledLengthCountStyles2, {
16085
+ size: size,
16086
+ role: "status",
16087
+ "aria-label": "Rest of the users",
16088
+ $_css2: "-".concat(gap, "px")
16089
+ }, /*#__PURE__*/React__default["default"].createElement(Typography, {
16090
+ variant: handleVariant,
16091
+ weight: "medium"
16092
+ }, "+", React.Children.count(children) - limit));
16093
+ };
16094
+ return /*#__PURE__*/React__default["default"].createElement(AvatarGroupsStyles, {
16095
+ hasTooltip: hasTooltip,
16096
+ gap: gap,
16097
+ ref: ref
16098
+ }, _children.map(function (child) {
16099
+ var item = child;
16100
+ return renderAvatars(item);
16101
+ }), limit >= React.Children.count(children) || minChildren ? null : renderCounter());
16102
+ });
16103
+ AvatarGroup.displayName = "AvatarGroup";
16104
+ var _StyledTooltip = styled__default["default"](Tooltip).withConfig({
16105
+ displayName: "AvatarGroup___StyledTooltip",
16043
16106
  componentId: "sc-1rsx1j5-0"
16044
16107
  })({
16045
- marginInlineStart: "-8px"
16108
+ whiteSpace: "break-spaces",
16109
+ lineHeight: "18px"
16110
+ });
16111
+ var _StyledLengthCountStyles = styled__default["default"](LengthCountStyles).withConfig({
16112
+ displayName: "AvatarGroup___StyledLengthCountStyles",
16113
+ componentId: "sc-1rsx1j5-1"
16114
+ })(function (p) {
16115
+ return {
16116
+ marginLeft: p.$_css
16117
+ };
16118
+ });
16119
+ var _StyledLengthCountStyles2 = styled__default["default"](LengthCountStyles).withConfig({
16120
+ displayName: "AvatarGroup___StyledLengthCountStyles2",
16121
+ componentId: "sc-1rsx1j5-2"
16122
+ })(function (p) {
16123
+ return {
16124
+ marginLeft: p.$_css2
16125
+ };
16046
16126
  });
16047
16127
 
16048
16128
  var StyledCommandPalette = styled__default["default"].div.withConfig({