@activecollab/components 1.0.248 → 1.0.250

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.
@@ -1 +1 @@
1
- {"version":3,"file":"OptionContent.js","names":["React","Avatar","StyledOptionIndicator","StyledOptionText","StyledAdditionalInfo","StyledOptionContentWrapper","OptionContent","imageUrl","color","textColor","name","additionalInfo","displayName"],"sources":["../../../../../src/components/Select/OptionContent/OptionContent.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Avatar } from \"../../Avatar/Avatar\";\nimport {\n StyledOptionIndicator,\n StyledOptionText,\n StyledAdditionalInfo,\n StyledOptionContentWrapper,\n} from \"./Styles\";\n\ninterface OptionContentProps {\n imageUrl?: string;\n color?: string;\n textColor?: string;\n name: string;\n additionalInfo?: string;\n}\n\nexport const OptionContent: FC<OptionContentProps> = ({\n imageUrl,\n color,\n textColor,\n name,\n additionalInfo,\n}) => {\n return (\n <StyledOptionContentWrapper>\n {imageUrl || color ? (\n <StyledOptionIndicator\n className=\"c-option--label\"\n backgroundColor={color}\n >\n {imageUrl ? (\n <Avatar className=\"c-option--avatar\" url={imageUrl} />\n ) : null}\n </StyledOptionIndicator>\n ) : null}\n <StyledOptionText className=\"c-option--text\" textColor={textColor}>\n {name}\n </StyledOptionText>\n {additionalInfo ? (\n <StyledAdditionalInfo>{additionalInfo}</StyledAdditionalInfo>\n ) : null}\n </StyledOptionContentWrapper>\n );\n};\n\nOptionContent.displayName = \"OptionContent\";\n"],"mappings":"AAAA,OAAOA,KAAK,MAAc,OAAO;AACjC,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SACEC,qBAAqB,EACrBC,gBAAgB,EAChBC,oBAAoB,EACpBC,0BAA0B,QACrB,UAAU;AAUjB,OAAO,IAAMC,aAAqC,GAAG,SAAxCA,aAAqC,OAM5C;EAAA,IALJC,QAAQ,QAARA,QAAQ;IACRC,KAAK,QAALA,KAAK;IACLC,SAAS,QAATA,SAAS;IACTC,IAAI,QAAJA,IAAI;IACJC,cAAc,QAAdA,cAAc;EAEd,oBACE,oBAAC,0BAA0B,QACxBJ,QAAQ,IAAIC,KAAK,gBAChB,oBAAC,qBAAqB;IACpB,SAAS,EAAC,iBAAiB;IAC3B,eAAe,EAAEA;EAAM,GAEtBD,QAAQ,gBACP,oBAAC,MAAM;IAAC,SAAS,EAAC,kBAAkB;IAAC,GAAG,EAAEA;EAAS,EAAG,GACpD,IAAI,CACc,GACtB,IAAI,eACR,oBAAC,gBAAgB;IAAC,SAAS,EAAC,gBAAgB;IAAC,SAAS,EAAEE;EAAU,GAC/DC,IAAI,CACY,EAClBC,cAAc,gBACb,oBAAC,oBAAoB,QAAEA,cAAc,CAAwB,GAC3D,IAAI,CACmB;AAEjC,CAAC;AAEDL,aAAa,CAACM,WAAW,GAAG,eAAe"}
1
+ {"version":3,"file":"OptionContent.js","names":["React","Avatar","StyledOptionIndicator","StyledOptionText","StyledAdditionalInfo","StyledOptionContentWrapper","MultiAvatar","OptionContent","imageUrl","color","textColor","name","additionalInfo","Array","isArray","displayName"],"sources":["../../../../../src/components/Select/OptionContent/OptionContent.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Avatar } from \"../../Avatar/Avatar\";\nimport {\n StyledOptionIndicator,\n StyledOptionText,\n StyledAdditionalInfo,\n StyledOptionContentWrapper,\n} from \"./Styles\";\nimport { MultiAvatar } from \"../../MultiAvatar\";\n\ninterface OptionContentProps {\n imageUrl?: string | string[];\n color?: string;\n textColor?: string;\n name: string;\n additionalInfo?: string;\n}\n\nexport const OptionContent: FC<OptionContentProps> = ({\n imageUrl,\n color,\n textColor,\n name,\n additionalInfo,\n}) => {\n return (\n <StyledOptionContentWrapper>\n {imageUrl || color ? (\n <StyledOptionIndicator\n className=\"c-option--label\"\n backgroundColor={color}\n >\n {imageUrl ? (\n <>\n {Array.isArray(imageUrl) ? (\n <MultiAvatar\n className=\"c-option--multi-avatar\"\n url={imageUrl}\n />\n ) : (\n <Avatar className=\"c-option--avatar\" url={imageUrl} />\n )}\n </>\n ) : null}\n </StyledOptionIndicator>\n ) : null}\n <StyledOptionText className=\"c-option--text\" textColor={textColor}>\n {name}\n </StyledOptionText>\n {additionalInfo ? (\n <StyledAdditionalInfo>{additionalInfo}</StyledAdditionalInfo>\n ) : null}\n </StyledOptionContentWrapper>\n );\n};\n\nOptionContent.displayName = \"OptionContent\";\n"],"mappings":"AAAA,OAAOA,KAAK,MAAc,OAAO;AACjC,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SACEC,qBAAqB,EACrBC,gBAAgB,EAChBC,oBAAoB,EACpBC,0BAA0B,QACrB,UAAU;AACjB,SAASC,WAAW,QAAQ,mBAAmB;AAU/C,OAAO,IAAMC,aAAqC,GAAG,SAAxCA,aAAqC,OAM5C;EAAA,IALJC,QAAQ,QAARA,QAAQ;IACRC,KAAK,QAALA,KAAK;IACLC,SAAS,QAATA,SAAS;IACTC,IAAI,QAAJA,IAAI;IACJC,cAAc,QAAdA,cAAc;EAEd,oBACE,oBAAC,0BAA0B,QACxBJ,QAAQ,IAAIC,KAAK,gBAChB,oBAAC,qBAAqB;IACpB,SAAS,EAAC,iBAAiB;IAC3B,eAAe,EAAEA;EAAM,GAEtBD,QAAQ,gBACP,0CACGK,KAAK,CAACC,OAAO,CAACN,QAAQ,CAAC,gBACtB,oBAAC,WAAW;IACV,SAAS,EAAC,wBAAwB;IAClC,GAAG,EAAEA;EAAS,EACd,gBAEF,oBAAC,MAAM;IAAC,SAAS,EAAC,kBAAkB;IAAC,GAAG,EAAEA;EAAS,EACpD,CACA,GACD,IAAI,CACc,GACtB,IAAI,eACR,oBAAC,gBAAgB;IAAC,SAAS,EAAC,gBAAgB;IAAC,SAAS,EAAEE;EAAU,GAC/DC,IAAI,CACY,EAClBC,cAAc,gBACb,oBAAC,oBAAoB,QAAEA,cAAc,CAAwB,GAC3D,IAAI,CACmB;AAEjC,CAAC;AAEDL,aAAa,CAACQ,WAAW,GAAG,eAAe"}
package/dist/index.js CHANGED
@@ -9210,7 +9210,7 @@
9210
9210
  var StyledWrapper = styled__default["default"].span.withConfig({
9211
9211
  displayName: "Styles__StyledWrapper",
9212
9212
  componentId: "sc-5x2tyd-0"
9213
- })(["display:inline-flex;position:relative;"]);
9213
+ })(["display:inline-flex;position:relative;border-radius:100%;"]);
9214
9214
  var StyledAvatar = styled__default["default"].img.withConfig({
9215
9215
  displayName: "Styles__StyledAvatar",
9216
9216
  componentId: "sc-5x2tyd-1"
@@ -10378,6 +10378,119 @@
10378
10378
  })(["margin:0 0 0 5px;line-height:18px;flex-shrink:0;"]);
10379
10379
  StyledAdditionalInfo.displayName = "StyledAdditionalInfo";
10380
10380
 
10381
+ var StyledMultiAvatarImg = styled.css(["width:inherit;height:inherit;"]);
10382
+ var StyledMultiAvatarInner = styled__default["default"].div.withConfig({
10383
+ displayName: "Styles__StyledMultiAvatarInner",
10384
+ componentId: "sc-k6nldn-0"
10385
+ })(["overflow:hidden;position:absolute;"]);
10386
+ var StyledMultiAvatar = styled__default["default"].div.withConfig({
10387
+ displayName: "Styles__StyledMultiAvatar",
10388
+ componentId: "sc-k6nldn-1"
10389
+ })(["", " border-radius:100%;position:relative;overflow:hidden;", " ", " ", ""], BoxSizingStyle, function (props) {
10390
+ return props.$urlCount === 2 && styled.css(["", ":first-child{left:0;img{transform:translateX(-20%);}}", ":last-child{right:0;img{transform:translateX(-20%);}}"], StyledMultiAvatarInner, StyledMultiAvatarInner);
10391
+ }, function (props) {
10392
+ return props.$urlCount === 3 && styled.css(["", ":nth-child(1){left:0;img{transform:translateX(-20%);}}", ":nth-child(2){right:0;top:0;img{", "}}", ":nth-child(3){right:0;bottom:0;img{", "}}"], StyledMultiAvatarInner, StyledMultiAvatarInner, StyledMultiAvatarImg, StyledMultiAvatarInner, StyledMultiAvatarImg);
10393
+ }, function (props) {
10394
+ return props.$urlCount > 3 && styled.css(["img{", "}", ":nth-child(1){left:0;}", ":nth-child(2){left:0;bottom:0;}", ":nth-child(3){right:0;top:0;}", ":nth-child(4){right:0;bottom:0;}"], StyledMultiAvatarImg, StyledMultiAvatarInner, StyledMultiAvatarInner, StyledMultiAvatarInner, StyledMultiAvatarInner);
10395
+ });
10396
+ StyledMultiAvatar.displayName = "StyledMultiAvatar";
10397
+ StyledMultiAvatarInner.displayName = "StyledMultiAvatarInner";
10398
+
10399
+ /**
10400
+ * @component MultiAvatar
10401
+ * @description
10402
+ * The MultiAvatar component is used to represent user, and displays the profile picture, initials or fallback icon.
10403
+ *
10404
+ * @prop {url} - The image urls of the MultiAvatar.
10405
+ * @prop {size} - controls the size of an MultiAvatar (width and height) in pixels.
10406
+ * @prop {alt} - alt attributes of the imgs.
10407
+ *
10408
+ * @example
10409
+ * <MultiAvatar
10410
+ * url={["https://faces-img.xcdn.link/image-lorem-face-954.jpg", "https://faces-img.xcdn.link/image-lorem-face-953.jpg"]}
10411
+ * alt={["Profile picture of John", "Profile picture of Sarah"]} />
10412
+ *
10413
+ * @example
10414
+ * <MultiAvatar
10415
+ * url={["https://faces-img.xcdn.link/image-lorem-face-954.jpg", "https://faces-img.xcdn.link/image-lorem-face-953.jpg"]}
10416
+ * alt={["Profile picture of John", "Profile picture of Sarah"]}
10417
+ * >
10418
+ * <Badge />
10419
+ * </MultiAvatar>
10420
+ *
10421
+ * @see
10422
+ * https://system.activecollab.com/?path=/story/components-button-indicators-avatar--avatar
10423
+ * @see
10424
+ * https://design.activecollab.com/docs/components/avatar
10425
+ */
10426
+ var MultiAvatar = function MultiAvatar(_ref) {
10427
+ var url = _ref.url,
10428
+ alt = _ref.alt,
10429
+ _ref$size = _ref.size,
10430
+ size = _ref$size === void 0 ? 24 : _ref$size,
10431
+ className = _ref.className,
10432
+ children = _ref.children;
10433
+ var setSize = React.useCallback(function (i) {
10434
+ switch (url.length) {
10435
+ case 1:
10436
+ return {
10437
+ width: "".concat(size, "px"),
10438
+ height: "".concat(size, "px")
10439
+ };
10440
+ case 2:
10441
+ return {
10442
+ width: "".concat(size / 2, "px"),
10443
+ height: "".concat(size, "px")
10444
+ };
10445
+ case 3:
10446
+ if (i === 0) {
10447
+ return {
10448
+ width: "".concat(size / 2, "px"),
10449
+ height: "".concat(size, "px")
10450
+ };
10451
+ } else {
10452
+ return {
10453
+ width: "".concat(size / 2, "px"),
10454
+ height: "".concat(size / 2, "px")
10455
+ };
10456
+ }
10457
+ default:
10458
+ return {
10459
+ width: "".concat(size / 2, "px"),
10460
+ height: "".concat(size / 2, "px")
10461
+ };
10462
+ }
10463
+ }, [size, url.length]);
10464
+ var slicedUrl = React.useMemo(function () {
10465
+ if ((url === null || url === void 0 ? void 0 : url.length) > 4) {
10466
+ return url.slice(0, 4);
10467
+ }
10468
+ return url;
10469
+ }, [url]);
10470
+ return /*#__PURE__*/React__default["default"].createElement("span", {
10471
+ className: "tw-relative tw-inline-flex"
10472
+ }, /*#__PURE__*/React__default["default"].createElement(StyledMultiAvatar, {
10473
+ style: {
10474
+ width: "".concat(size, "px"),
10475
+ height: "".concat(size, "px")
10476
+ },
10477
+ className: className,
10478
+ $urlCount: url.length
10479
+ }, slicedUrl.map(function (v, i) {
10480
+ return /*#__PURE__*/React__default["default"].createElement(StyledMultiAvatarInner, {
10481
+ style: setSize(i),
10482
+ className: "c-multi-avatar__wrapper",
10483
+ key: "avatar_".concat(i)
10484
+ }, /*#__PURE__*/React__default["default"].createElement("img", {
10485
+ src: v,
10486
+ alt: alt && alt[i] ? alt[i] : "avatar_".concat(i),
10487
+ width: size,
10488
+ height: size
10489
+ }));
10490
+ })), children);
10491
+ };
10492
+ MultiAvatar.displayName = "MultiAvatar";
10493
+
10381
10494
  var OptionContent = function OptionContent(_ref) {
10382
10495
  var imageUrl = _ref.imageUrl,
10383
10496
  color = _ref.color,
@@ -10387,10 +10500,13 @@
10387
10500
  return /*#__PURE__*/React__default["default"].createElement(StyledOptionContentWrapper, null, imageUrl || color ? /*#__PURE__*/React__default["default"].createElement(StyledOptionIndicator, {
10388
10501
  className: "c-option--label",
10389
10502
  backgroundColor: color
10390
- }, imageUrl ? /*#__PURE__*/React__default["default"].createElement(Avatar, {
10503
+ }, imageUrl ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Array.isArray(imageUrl) ? /*#__PURE__*/React__default["default"].createElement(MultiAvatar, {
10504
+ className: "c-option--multi-avatar",
10505
+ url: imageUrl
10506
+ }) : /*#__PURE__*/React__default["default"].createElement(Avatar, {
10391
10507
  className: "c-option--avatar",
10392
10508
  url: imageUrl
10393
- }) : null) : null, /*#__PURE__*/React__default["default"].createElement(StyledOptionText, {
10509
+ })) : null) : null, /*#__PURE__*/React__default["default"].createElement(StyledOptionText, {
10394
10510
  className: "c-option--text",
10395
10511
  textColor: textColor
10396
10512
  }, name), additionalInfo ? /*#__PURE__*/React__default["default"].createElement(StyledAdditionalInfo, null, additionalInfo) : null);
@@ -11137,119 +11253,6 @@
11137
11253
  };
11138
11254
  MenuSelector.displayName = "MenuSelector";
11139
11255
 
11140
- var StyledMultiAvatarImg = styled.css(["width:inherit;height:inherit;"]);
11141
- var StyledMultiAvatarInner = styled__default["default"].div.withConfig({
11142
- displayName: "Styles__StyledMultiAvatarInner",
11143
- componentId: "sc-k6nldn-0"
11144
- })(["overflow:hidden;position:absolute;"]);
11145
- var StyledMultiAvatar = styled__default["default"].div.withConfig({
11146
- displayName: "Styles__StyledMultiAvatar",
11147
- componentId: "sc-k6nldn-1"
11148
- })(["", " border-radius:100%;position:relative;overflow:hidden;", " ", " ", ""], BoxSizingStyle, function (props) {
11149
- return props.$urlCount === 2 && styled.css(["", ":first-child{left:0;img{transform:translateX(-20%);}}", ":last-child{right:0;img{transform:translateX(-20%);}}"], StyledMultiAvatarInner, StyledMultiAvatarInner);
11150
- }, function (props) {
11151
- return props.$urlCount === 3 && styled.css(["", ":nth-child(1){left:0;img{transform:translateX(-20%);}}", ":nth-child(2){right:0;top:0;img{", "}}", ":nth-child(3){right:0;bottom:0;img{", "}}"], StyledMultiAvatarInner, StyledMultiAvatarInner, StyledMultiAvatarImg, StyledMultiAvatarInner, StyledMultiAvatarImg);
11152
- }, function (props) {
11153
- return props.$urlCount > 3 && styled.css(["img{", "}", ":nth-child(1){left:0;}", ":nth-child(2){left:0;bottom:0;}", ":nth-child(3){right:0;top:0;}", ":nth-child(4){right:0;bottom:0;}"], StyledMultiAvatarImg, StyledMultiAvatarInner, StyledMultiAvatarInner, StyledMultiAvatarInner, StyledMultiAvatarInner);
11154
- });
11155
- StyledMultiAvatar.displayName = "StyledMultiAvatar";
11156
- StyledMultiAvatarInner.displayName = "StyledMultiAvatarInner";
11157
-
11158
- /**
11159
- * @component MultiAvatar
11160
- * @description
11161
- * The MultiAvatar component is used to represent user, and displays the profile picture, initials or fallback icon.
11162
- *
11163
- * @prop {url} - The image urls of the MultiAvatar.
11164
- * @prop {size} - controls the size of an MultiAvatar (width and height) in pixels.
11165
- * @prop {alt} - alt attributes of the imgs.
11166
- *
11167
- * @example
11168
- * <MultiAvatar
11169
- * url={["https://faces-img.xcdn.link/image-lorem-face-954.jpg", "https://faces-img.xcdn.link/image-lorem-face-953.jpg"]}
11170
- * alt={["Profile picture of John", "Profile picture of Sarah"]} />
11171
- *
11172
- * @example
11173
- * <MultiAvatar
11174
- * url={["https://faces-img.xcdn.link/image-lorem-face-954.jpg", "https://faces-img.xcdn.link/image-lorem-face-953.jpg"]}
11175
- * alt={["Profile picture of John", "Profile picture of Sarah"]}
11176
- * >
11177
- * <Badge />
11178
- * </MultiAvatar>
11179
- *
11180
- * @see
11181
- * https://system.activecollab.com/?path=/story/components-button-indicators-avatar--avatar
11182
- * @see
11183
- * https://design.activecollab.com/docs/components/avatar
11184
- */
11185
- var MultiAvatar = function MultiAvatar(_ref) {
11186
- var url = _ref.url,
11187
- alt = _ref.alt,
11188
- _ref$size = _ref.size,
11189
- size = _ref$size === void 0 ? 24 : _ref$size,
11190
- className = _ref.className,
11191
- children = _ref.children;
11192
- var setSize = React.useCallback(function (i) {
11193
- switch (url.length) {
11194
- case 1:
11195
- return {
11196
- width: "".concat(size, "px"),
11197
- height: "".concat(size, "px")
11198
- };
11199
- case 2:
11200
- return {
11201
- width: "".concat(size / 2, "px"),
11202
- height: "".concat(size, "px")
11203
- };
11204
- case 3:
11205
- if (i === 0) {
11206
- return {
11207
- width: "".concat(size / 2, "px"),
11208
- height: "".concat(size, "px")
11209
- };
11210
- } else {
11211
- return {
11212
- width: "".concat(size / 2, "px"),
11213
- height: "".concat(size / 2, "px")
11214
- };
11215
- }
11216
- default:
11217
- return {
11218
- width: "".concat(size / 2, "px"),
11219
- height: "".concat(size / 2, "px")
11220
- };
11221
- }
11222
- }, [size, url.length]);
11223
- var slicedUrl = React.useMemo(function () {
11224
- if ((url === null || url === void 0 ? void 0 : url.length) > 4) {
11225
- return url.slice(0, 4);
11226
- }
11227
- return url;
11228
- }, [url]);
11229
- return /*#__PURE__*/React__default["default"].createElement("span", {
11230
- className: "tw-relative tw-inline-flex"
11231
- }, /*#__PURE__*/React__default["default"].createElement(StyledMultiAvatar, {
11232
- style: {
11233
- width: "".concat(size, "px"),
11234
- height: "".concat(size, "px")
11235
- },
11236
- className: className,
11237
- $urlCount: url.length
11238
- }, slicedUrl.map(function (v, i) {
11239
- return /*#__PURE__*/React__default["default"].createElement(StyledMultiAvatarInner, {
11240
- style: setSize(i),
11241
- className: "c-multi-avatar__wrapper",
11242
- key: "avatar_".concat(i)
11243
- }, /*#__PURE__*/React__default["default"].createElement("img", {
11244
- src: v,
11245
- alt: alt && alt[i] ? alt[i] : "avatar_".concat(i),
11246
- width: size,
11247
- height: size
11248
- }));
11249
- })), children);
11250
- };
11251
- MultiAvatar.displayName = "MultiAvatar";
11252
-
11253
11256
  var StyledTextarea = styled__default["default"].textarea.withConfig({
11254
11257
  displayName: "Styles__StyledTextarea",
11255
11258
  componentId: "sc-m6jqw8-0"
@@ -13853,6 +13856,31 @@
13853
13856
  variant: size === "small" ? "Caption 1" : size === "regular" ? "Body 2" : "Body 1"
13854
13857
  }, typeof hiddenNumberText === "function" ? hiddenNumberText(_hidden) : "+".concat(_hidden)));
13855
13858
  }
13859
+ if (type === "single" && selected) {
13860
+ var optionItem;
13861
+ options.forEach(function (option) {
13862
+ if (isOptionGroup(option)) {
13863
+ optionItem = option.options.find(function (child) {
13864
+ return child.id === selected;
13865
+ });
13866
+ } else if (!optionItem && option.id === selected) {
13867
+ optionItem = option;
13868
+ }
13869
+ });
13870
+ if (optionItem && optionItem.image) {
13871
+ var avatarSize = size === "big" ? 22 : size === "regular" ? 18 : 14;
13872
+ if (Array.isArray(optionItem.image)) {
13873
+ return /*#__PURE__*/React__default["default"].createElement(MultiAvatar, {
13874
+ url: optionItem.image,
13875
+ size: avatarSize
13876
+ });
13877
+ }
13878
+ return /*#__PURE__*/React__default["default"].createElement(Avatar, {
13879
+ url: optionItem.image,
13880
+ size: avatarSize
13881
+ });
13882
+ }
13883
+ }
13856
13884
  return undefined;
13857
13885
  }, [type, selected, options, open, limitChips, hiddenNumberText, renderChipAdornment, size]);
13858
13886
  var showXIcon = Array.isArray(selected) && type === "multiple" && selected.length > 0;