superdesk-ui-framework 3.0.52 → 3.0.54

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "3.0.52",
3
+ "version": "3.0.54",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,6 +10,9 @@ interface IProps<T> extends IInputWrapper {
10
10
  itemTemplate: React.ComponentType<{
11
11
  option: T | null;
12
12
  }>;
13
+ valueTemplate?: React.ComponentType<{
14
+ option: T | null;
15
+ }>;
13
16
  noResultsFoundMessage: string;
14
17
  filterPlaceholder?: string;
15
18
  autoFocus?: boolean;
@@ -75,6 +75,7 @@ var SelectWithTemplate = /** @class */ (function (_super) {
75
75
  var _this = this;
76
76
  var _a;
77
77
  var ItemTemplate = this.props.itemTemplate;
78
+ var ValueTemplate = this.props.valueTemplate;
78
79
  var _b = this.state, loading = _b.loading, options = _b.options;
79
80
  var _c = this.props, value = _c.value, onChange = _c.onChange, getLabel = _c.getLabel, disabled = _c.disabled, required = _c.required, zIndex = _c.zIndex, autoFocus = _c.autoFocus, areEqual = _c.areEqual, getItems = _c.getItems, emptyFilterMessage = _c.noResultsFoundMessage, filterPlaceholder = _c.filterPlaceholder, width = _c.width;
80
81
  // Using another data structure so it is possible to have getLabel function
@@ -98,7 +99,12 @@ var SelectWithTemplate = /** @class */ (function (_super) {
98
99
  return (React.createElement(Form_1.InputWrapper, { label: this.props.label, error: this.props.error, required: this.props.required, disabled: this.props.disabled, invalid: this.state.invalid, info: this.props.info, inlineLabel: this.props.inlineLabel, labelHidden: this.props.labelHidden, fullWidth: this.props.fullWidth, htmlId: this.htmlId, tabindex: this.props.tabindex },
99
100
  React.createElement(dropdown_1.Dropdown, { inputId: this.htmlId, ariaLabelledBy: this.htmlId + 'label', value: valueInternal, options: optionsInternal, onChange: function (e) {
100
101
  onChange(e.value == null ? null : e.value.original);
101
- }, placeholder: fakePlaceholderWithNonBreakingSpace, filterPlaceholder: filterPlaceholder, filter: true, filterBy: labelKey, showClear: !required, emptyFilterMessage: emptyFilterMessage, valueTemplate: function (option) { return React.createElement(ItemTemplate, { option: option == null ? null : option.original }); }, itemTemplate: function (option) { return React.createElement(ItemTemplate, { option: option.original }); }, disabled: disabled, required: required, autoFocus: autoFocus, appendTo: document.body, loading: loading, onFilterInputChange: function (searchString) {
102
+ }, placeholder: fakePlaceholderWithNonBreakingSpace, filterPlaceholder: filterPlaceholder, filter: true, filterBy: labelKey, showClear: !required, emptyFilterMessage: emptyFilterMessage, itemTemplate: function (option) { var _a; return React.createElement(ItemTemplate, { option: (_a = option === null || option === void 0 ? void 0 : option.original) !== null && _a !== void 0 ? _a : null }); }, valueTemplate: function (option) {
103
+ var _a, _b;
104
+ return ValueTemplate != null
105
+ ? (React.createElement(ValueTemplate, { option: (_a = option === null || option === void 0 ? void 0 : option.original) !== null && _a !== void 0 ? _a : null }))
106
+ : (React.createElement(ItemTemplate, { option: (_b = option === null || option === void 0 ? void 0 : option.original) !== null && _b !== void 0 ? _b : null }));
107
+ }, disabled: disabled, required: required, autoFocus: autoFocus, appendTo: document.body, loading: loading, onFilterInputChange: function (searchString) {
102
108
  _this.setState({ loading: true });
103
109
  getItems(searchString).then(function (_options) {
104
110
  _this.setState({ options: _options, loading: false });
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { IPropsBase } from './interfaces';
3
3
  interface IPropsImageAvatar extends IPropsBase {
4
4
  imageUrl?: string | null;
5
+ onClick?(): void;
5
6
  }
6
7
  export declare class AvatarContentImage extends React.PureComponent<IPropsImageAvatar> {
7
8
  render(): JSX.Element;
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
17
28
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
29
  if (k2 === undefined) k2 = k;
19
30
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -46,15 +57,20 @@ var AvatarContentImage = /** @class */ (function (_super) {
46
57
  return _super !== null && _super.apply(this, arguments) || this;
47
58
  }
48
59
  AvatarContentImage.prototype.render = function () {
49
- if (this.props.imageUrl == null) {
50
- return (React.createElement("span", { className: "sd-avatar-content sd-avatar-content--dummy-img", title: this.props.tooltipText },
60
+ var _a = this.props, imageUrl = _a.imageUrl, tooltipText = _a.tooltipText, onClick = _a.onClick;
61
+ var maybeButtonProps = onClick == null ? {} : {
62
+ role: 'button',
63
+ onClick: function () { return onClick(); },
64
+ };
65
+ if (imageUrl == null) {
66
+ return (React.createElement("span", __assign({}, maybeButtonProps, { className: "sd-avatar-content sd-avatar-content--dummy-img", title: tooltipText }),
51
67
  React.createElement("svg", { width: "200", height: "200", viewBox: "0 0 200 200", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
52
- React.createElement("circle", { cx: "100", cy: "100", r: "100", fill: "white", "fill-opacity": "0.01" }),
53
- React.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M40 153V145.384C40 141.557 41.16 137.981 43.16 135C49.14 126.057 66.24 119.711 77.14 118C82.74 117.115 90.16 116.538 100 116.538C109.84 116.538 117.26 117.115 122.86 118C133.76 119.711 150.86 126.057 156.84 135C158.84 137.981 160 141.557 160 145.384V153C150 165 130 180 100 180C70 180 50 165 40 153ZM100 30C122.08 30 140 47.2307 140 68.4614C140 89.6922 122.08 106.923 100 106.923C77.92 106.923 60 89.6922 60 68.4614C60 47.2307 77.92 30 100 30Z", fill: "var(--sd-colour-avatar-dummy)", "fill-opacity": "1" }))));
68
+ React.createElement("circle", { cx: "100", cy: "100", r: "100", fill: "white", fillOpacity: "0.01" }),
69
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M40 153V145.384C40 141.557 41.16 137.981 43.16 135C49.14 126.057 66.24 119.711 77.14 118C82.74 117.115 90.16 116.538 100 116.538C109.84 116.538 117.26 117.115 122.86 118C133.76 119.711 150.86 126.057 156.84 135C158.84 137.981 160 141.557 160 145.384V153C150 165 130 180 100 180C70 180 50 165 40 153ZM100 30C122.08 30 140 47.2307 140 68.4614C140 89.6922 122.08 106.923 100 106.923C77.92 106.923 60 89.6922 60 68.4614C60 47.2307 77.92 30 100 30Z", fill: "var(--sd-colour-avatar-dummy)", fillOpacity: "1" }))));
54
70
  }
55
71
  else {
56
- return (React.createElement("span", { className: "sd-avatar-content", title: this.props.tooltipText },
57
- React.createElement("img", { src: this.props.imageUrl })));
72
+ return (React.createElement("span", __assign({}, maybeButtonProps, { className: "sd-avatar-content", title: tooltipText }),
73
+ React.createElement("img", { src: imageUrl })));
58
74
  }
59
75
  };
60
76
  return AvatarContentImage;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  export interface IPropsAvatarPlaceholder {
3
- kind: 'plus-button';
3
+ kind: 'plus-button' | 'user-icon';
4
4
  tooltip?: string | null;
5
5
  size: 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | 'xx-large';
6
6
  icon?: {
@@ -42,15 +42,25 @@ exports.AvatarPlaceholder = void 0;
42
42
  var React = __importStar(require("react"));
43
43
  var avatar_wrapper_1 = require("./avatar-wrapper");
44
44
  var avatar_action_add_1 = require("./avatar-action-add");
45
+ var avatar_image_1 = require("./avatar-image");
45
46
  var AvatarPlaceholder = /** @class */ (function (_super) {
46
47
  __extends(AvatarPlaceholder, _super);
47
48
  function AvatarPlaceholder() {
48
49
  return _super !== null && _super.apply(this, arguments) || this;
49
50
  }
50
51
  AvatarPlaceholder.prototype.render = function () {
51
- var _a = this.props, size = _a.size, tooltip = _a.tooltip, icon = _a.icon;
52
- return (React.createElement(avatar_wrapper_1.AvatarWrapper, { size: size, isEmpty: false, icon: icon },
53
- React.createElement(avatar_action_add_1.AvatarContentAdd, { tooltipText: tooltip !== null && tooltip !== void 0 ? tooltip : undefined, onClick: this.props.onClick })));
52
+ var _a = this.props, size = _a.size, tooltip = _a.tooltip, icon = _a.icon, kind = _a.kind, onClick = _a.onClick;
53
+ return (React.createElement(avatar_wrapper_1.AvatarWrapper, { size: size, isEmpty: false, icon: icon }, (function () {
54
+ if (kind === 'plus-button') {
55
+ return (React.createElement(avatar_action_add_1.AvatarContentAdd, { tooltipText: tooltip !== null && tooltip !== void 0 ? tooltip : undefined, onClick: onClick }));
56
+ }
57
+ else if (kind === 'user-icon') {
58
+ return (React.createElement(avatar_image_1.AvatarContentImage, { imageUrl: null, tooltipText: tooltip !== null && tooltip !== void 0 ? tooltip : undefined, onClick: onClick }));
59
+ }
60
+ else {
61
+ return null;
62
+ }
63
+ })()));
54
64
  };
55
65
  return AvatarPlaceholder;
56
66
  }(React.PureComponent));
@@ -11,6 +11,17 @@ export interface IPropsAvatar {
11
11
  name: string;
12
12
  color?: string;
13
13
  };
14
+ /**
15
+ * displayName is shown as tooltip by default
16
+ * use this if you need to add additional information (it will be added on a new line)
17
+ */
18
+ tooltip?: string;
19
+ /**
20
+ * JSX resulting from rendering of one of the following components:
21
+ * AvatarContentText
22
+ * AvatarContentImage
23
+ */
24
+ customContent?: JSX.Element;
14
25
  }
15
26
  export declare class Avatar extends React.PureComponent<IPropsAvatar> {
16
27
  render(): JSX.Element;
@@ -49,10 +49,19 @@ 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, displayName = _a.displayName;
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: displayName }))
55
- : (React.createElement(avatar_text_1.AvatarContentText, { text: initials, tooltipText: displayName }))));
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, customContent = _a.customContent;
53
+ var tooltipCombined = [displayName, this.props.tooltip].filter(function (str) { return (str !== null && str !== void 0 ? str : '').trim().length > 0; }).join('\n');
54
+ 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 }, (function () {
55
+ if (customContent != null) {
56
+ return customContent;
57
+ }
58
+ else if (imageUrl != null || initials == null) {
59
+ return (React.createElement(avatar_image_1.AvatarContentImage, { imageUrl: imageUrl, tooltipText: tooltipCombined }));
60
+ }
61
+ else {
62
+ return (React.createElement(avatar_text_1.AvatarContentText, { text: initials, tooltipText: tooltipCombined }));
63
+ }
64
+ })()));
56
65
  };
57
66
  return Avatar;
58
67
  }(React.PureComponent));