superdesk-ui-framework 3.0.23 → 3.0.27

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.
@@ -59,6 +59,8 @@ var avatar_1 = require("./avatar");
59
59
  var avatar_wrapper_1 = require("./avatar-wrapper");
60
60
  var avatar_number_1 = require("./avatar-number");
61
61
  var avatar_placeholder_1 = require("./avatar-placeholder");
62
+ var Spacer_1 = require("../Spacer");
63
+ var WithPopover_1 = require("../WithPopover");
62
64
  function isAvatar(item) {
63
65
  return item['kind'] == null;
64
66
  }
@@ -69,7 +71,8 @@ var AvatarGroup = /** @class */ (function (_super) {
69
71
  }
70
72
  AvatarGroup.prototype.render = function () {
71
73
  var _this = this;
72
- var _a = this.props, size = _a.size, items = _a.items;
74
+ var _a;
75
+ var _b = this.props, size = _b.size, items = _b.items;
73
76
  var someIconsHaveExtraElements = items.filter(isAvatar).some(function (_a) {
74
77
  var icon = _a.icon, administratorIndicator = _a.administratorIndicator;
75
78
  return icon != null || administratorIndicator != null;
@@ -87,7 +90,31 @@ var AvatarGroup = /** @class */ (function (_super) {
87
90
  }
88
91
  })();
89
92
  var itemsOverLimit = items.length - max;
90
- return (React.createElement("div", { className: (0, classnames_1.default)('sd-avatar-group', 'sd-avatar-group--stacked', "sd-avatar-group--stacked--gap-".concat(gap)), role: 'group' },
93
+ var PlusButtonWrapper = function (_a) {
94
+ var children = _a.children, onToggle = _a.onToggle;
95
+ if (_this.props.onClick == null) {
96
+ return (React.createElement("button", { style: { padding: 0 }, onClick: function (event) {
97
+ if (_this.props.onClick == null) {
98
+ onToggle(event.target);
99
+ }
100
+ } }, children));
101
+ }
102
+ else {
103
+ return React.createElement(React.Fragment, null, children);
104
+ }
105
+ };
106
+ var someHaveDisplayName = this.props.items.some(function (item) { return isAvatar(item) && item.displayName.length > 0; });
107
+ return (React.createElement(WithPopover_1.WithPopover, { zIndex: (_a = this.props.zIndex) !== null && _a !== void 0 ? _a : 101, placement: 'bottom-end', component: function () { return (React.createElement("div", { className: "avatar-popup" }, _this.props.items.map(function (item, index) {
108
+ return (someHaveDisplayName
109
+ ? React.createElement(Spacer_1.Spacer, { h: true, alignItems: 'center', gap: '16', noGrow: true, key: index },
110
+ isAvatar(item)
111
+ && item.displayName,
112
+ isAvatar(item)
113
+ ? (React.createElement(avatar_1.Avatar, { size: 'small', imageUrl: item.imageUrl, initials: item.initials, displayName: item.displayName, icon: item.icon }))
114
+ : (React.createElement(avatar_placeholder_1.AvatarPlaceholder, { kind: 'plus-button', size: 'small', icon: item.icon, onClick: item.onClick })))
115
+ : React.createElement("div", null,
116
+ React.createElement(avatar_placeholder_1.AvatarPlaceholder, { kind: 'plus-button', size: 'small', icon: item.icon, onClick: isAvatar(item) ? undefined : item.onClick, key: index })));
117
+ }))); } }, function (onToggle) { return (React.createElement("div", { className: (0, classnames_1.default)('sd-avatar-group', 'sd-avatar-group--stacked', "sd-avatar-group--stacked--gap-".concat(gap)), role: 'group', onClick: _this.props.onClick },
91
118
  items.slice(0, max).map(function (item, index) {
92
119
  if (isAvatar(item)) {
93
120
  return (React.createElement(avatar_1.Avatar, __assign({}, item, { key: index, size: size })));
@@ -96,8 +123,9 @@ var AvatarGroup = /** @class */ (function (_super) {
96
123
  return (React.createElement(avatar_placeholder_1.AvatarPlaceholder, __assign({}, item, { key: index, size: _this.props.size })));
97
124
  }
98
125
  }),
99
- itemsOverLimit > 0 && (React.createElement(avatar_wrapper_1.AvatarWrapper, { size: size, isEmpty: false },
100
- React.createElement(avatar_number_1.AvatarContentNumber, { number: "".concat(itemsOverLimit) })))));
126
+ itemsOverLimit > 0 && (React.createElement(PlusButtonWrapper, { onToggle: onToggle },
127
+ React.createElement(avatar_wrapper_1.AvatarWrapper, { size: size, isEmpty: false },
128
+ React.createElement(avatar_number_1.AvatarContentNumber, { number: "".concat(itemsOverLimit) })))))); }));
101
129
  };
102
130
  return AvatarGroup;
103
131
  }(React.PureComponent));
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface IPropsAvatar {
3
3
  imageUrl: string | null;
4
- tooltip: string | null;
4
+ displayName: string;
5
5
  /** 3 letters max */
6
6
  initials: string | null;
7
7
  size: 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | 'xx-large';
@@ -49,10 +49,10 @@ var Avatar = /** @class */ (function (_super) {
49
49
  return _super !== null && _super.apply(this, arguments) || this;
50
50
  }
51
51
  Avatar.prototype.render = function () {
52
- var _a = this.props, imageUrl = _a.imageUrl, initials = _a.initials, size = _a.size, statusIndicator = _a.statusIndicator, administratorIndicator = _a.administratorIndicator, icon = _a.icon, tooltip = _a.tooltip;
52
+ var _a = this.props, imageUrl = _a.imageUrl, initials = _a.initials, size = _a.size, statusIndicator = _a.statusIndicator, administratorIndicator = _a.administratorIndicator, icon = _a.icon, displayName = _a.displayName;
53
53
  return (React.createElement(avatar_wrapper_1.AvatarWrapper, { size: size, statusIndicator: statusIndicator ? { status: statusIndicator, tooltipText: '' } : undefined, administratorIndicator: administratorIndicator ? { enabled: true, tooltipText: '' } : undefined, icon: icon, isEmpty: false }, imageUrl != null || initials == null
54
- ? (React.createElement(avatar_image_1.AvatarContentImage, { imageUrl: imageUrl, tooltipText: tooltip !== null && tooltip !== void 0 ? tooltip : undefined }))
55
- : (React.createElement(avatar_text_1.AvatarContentText, { text: initials, tooltipText: tooltip !== null && tooltip !== void 0 ? tooltip : undefined }))));
54
+ ? (React.createElement(avatar_image_1.AvatarContentImage, { imageUrl: imageUrl, tooltipText: displayName }))
55
+ : (React.createElement(avatar_text_1.AvatarContentText, { text: initials, tooltipText: displayName }))));
56
56
  };
57
57
  return Avatar;
58
58
  }(React.PureComponent));