superdesk-ui-framework 3.0.17 → 3.0.19

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.
Files changed (59) hide show
  1. package/app/styles/_avatar.scss +175 -25
  2. package/app/styles/design-tokens/_new-colors.scss +35 -2
  3. package/app-typescript/components/Icon.tsx +7 -1
  4. package/app-typescript/components/ShowPopup.tsx +173 -0
  5. package/app-typescript/components/Spacer.tsx +0 -8
  6. package/app-typescript/components/WithPagination.tsx +4 -4
  7. package/app-typescript/components/WithPopover.tsx +43 -0
  8. package/app-typescript/components/avatar/avatar-action-add.tsx +27 -0
  9. package/app-typescript/components/avatar/avatar-group.tsx +86 -0
  10. package/app-typescript/components/avatar/avatar-image.tsx +26 -0
  11. package/app-typescript/components/avatar/avatar-number.tsx +16 -0
  12. package/app-typescript/components/avatar/avatar-placeholder.tsx +35 -0
  13. package/app-typescript/components/avatar/avatar-text.tsx +19 -0
  14. package/app-typescript/components/avatar/avatar-wrapper.tsx +72 -0
  15. package/app-typescript/components/avatar/avatar.tsx +48 -0
  16. package/app-typescript/components/avatar/interfaces.ts +3 -0
  17. package/app-typescript/index.ts +8 -4
  18. package/dist/avatar_dummy.svg +4 -0
  19. package/dist/examples.bundle.js +3271 -2470
  20. package/dist/react/Avatar.tsx +628 -307
  21. package/dist/superdesk-ui.bundle.css +139 -27
  22. package/dist/superdesk-ui.bundle.js +2689 -1846
  23. package/dist/vendor.bundle.js +22 -22
  24. package/examples/pages/react/Avatar.tsx +628 -307
  25. package/images/avatar_dummy.svg +4 -0
  26. package/package.json +2 -1
  27. package/react/components/Icon.d.ts +1 -0
  28. package/react/components/Icon.js +1 -1
  29. package/react/components/ShowPopup.d.ts +10 -0
  30. package/react/components/ShowPopup.js +158 -0
  31. package/react/components/Spacer.d.ts +30 -0
  32. package/react/components/Spacer.js +86 -0
  33. package/react/components/WithPagination.d.ts +1 -1
  34. package/react/components/WithPagination.js +3 -3
  35. package/react/components/WithPopover.d.ts +18 -0
  36. package/react/components/WithPopover.js +65 -0
  37. package/react/components/avatar/avatar-action-add.d.ts +9 -0
  38. package/react/components/avatar/avatar-action-add.js +59 -0
  39. package/react/components/avatar/avatar-group.d.ts +18 -0
  40. package/react/components/avatar/avatar-group.js +104 -0
  41. package/react/components/avatar/avatar-image.d.ts +9 -0
  42. package/react/components/avatar/avatar-image.js +62 -0
  43. package/react/components/avatar/avatar-number.d.ts +9 -0
  44. package/react/components/avatar/avatar-number.js +56 -0
  45. package/react/components/avatar/avatar-placeholder.d.ts +14 -0
  46. package/react/components/avatar/avatar-placeholder.js +57 -0
  47. package/react/components/avatar/avatar-text.d.ts +9 -0
  48. package/react/components/avatar/avatar-text.js +54 -0
  49. package/react/components/avatar/avatar-wrapper.d.ts +26 -0
  50. package/react/components/{Avatar.js → avatar/avatar-wrapper.js} +16 -57
  51. package/react/components/avatar/avatar.d.ts +17 -0
  52. package/react/components/avatar/avatar.js +59 -0
  53. package/react/components/avatar/interfaces.d.ts +3 -0
  54. package/react/components/avatar/interfaces.js +2 -0
  55. package/react/index.d.ts +8 -4
  56. package/react/index.js +20 -11
  57. package/app-typescript/components/Avatar.tsx +0 -122
  58. package/dist/avatar_64.png +0 -0
  59. package/react/components/Avatar.d.ts +0 -42
@@ -0,0 +1,4 @@
1
+ <svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="100" cy="100" r="100" fill="white" fill-opacity="0.01"/>
3
+ <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-interactive)" fill-opacity="0.6"/>
4
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "3.0.17",
3
+ "version": "3.0.19",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -102,6 +102,7 @@
102
102
  "enzyme": "^3.11.0",
103
103
  "enzyme-adapter-react-16": "^1.15.7",
104
104
  "moment": "^2.29.3",
105
+ "popper-max-size-modifier": "^0.2.0",
105
106
  "popper.js": "1.14.4",
106
107
  "primeicons": "2.0.0",
107
108
  "react-beautiful-dnd": "^13.0.0",
@@ -6,6 +6,7 @@ interface IProps {
6
6
  className?: string;
7
7
  scale?: '2x' | '3x' | '4x';
8
8
  ariaHidden?: boolean;
9
+ color?: string;
9
10
  }
10
11
  export declare class Icon extends React.PureComponent<IProps> {
11
12
  render(): JSX.Element;
@@ -57,7 +57,7 @@ var Icon = /** @class */ (function (_super) {
57
57
  _a["color--".concat(this.props.type)] = this.props.type,
58
58
  _a["scale--".concat(this.props.scale)] = this.props.scale,
59
59
  _a));
60
- return (React.createElement("i", { className: classes, "aria-label": this.props.name, "aria-hidden": this.props.ariaHidden }));
60
+ return (React.createElement("i", { className: classes, "aria-label": this.props.name, "aria-hidden": this.props.ariaHidden, style: { color: this.props.color } }));
61
61
  };
62
62
  return Icon;
63
63
  }(React.PureComponent));
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { Placement } from '@popperjs/core';
3
+ /**
4
+ * The popup will remove itself if click/scroll events are detected outside the popup.
5
+ */
6
+ export declare function showPopup(referenceElement: HTMLElement, placement: Placement, Component: React.ComponentType<{
7
+ closePopup(): void;
8
+ }>, zIndex?: number, closeOnHoverEnd?: boolean, onClose?: () => void): {
9
+ close: () => void;
10
+ };
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.showPopup = void 0;
45
+ var React = __importStar(require("react"));
46
+ var react_dom_1 = __importDefault(require("react-dom"));
47
+ var core_1 = require("@popperjs/core");
48
+ var lodash_1 = require("lodash");
49
+ var popper_max_size_modifier_1 = __importDefault(require("popper-max-size-modifier"));
50
+ var PopupPositioner = /** @class */ (function (_super) {
51
+ __extends(PopupPositioner, _super);
52
+ function PopupPositioner(props) {
53
+ var _this = _super.call(this, props) || this;
54
+ _this.closeOnClick = _this.closeOnClick.bind(_this);
55
+ _this.closeOnScroll = (0, lodash_1.throttle)(_this.closeOnScroll.bind(_this), 200);
56
+ _this.closeOnMouseLeave = _this.closeOnMouseLeave.bind(_this);
57
+ _this.wrapperEl = null;
58
+ _this.popper = null;
59
+ return _this;
60
+ }
61
+ PopupPositioner.prototype.closeOnClick = function (event) {
62
+ if (this.wrapperEl == null) {
63
+ return;
64
+ }
65
+ if (this.props.referenceElement.contains(event.target) !== true
66
+ && this.wrapperEl.contains(event.target) !== true) {
67
+ this.props.onClose();
68
+ }
69
+ };
70
+ PopupPositioner.prototype.closeOnScroll = function (event) {
71
+ if (this.wrapperEl == null) {
72
+ return;
73
+ }
74
+ if (this.wrapperEl.contains(event.target) !== true) {
75
+ this.props.onClose();
76
+ }
77
+ };
78
+ PopupPositioner.prototype.closeOnMouseLeave = function (event) {
79
+ if (this.wrapperEl == null) {
80
+ return;
81
+ }
82
+ if (this.wrapperEl.contains(event.target) !== true) {
83
+ this.props.onClose();
84
+ }
85
+ };
86
+ PopupPositioner.prototype.componentDidMount = function () {
87
+ var _this = this;
88
+ window.addEventListener('click', this.closeOnClick, { capture: true });
89
+ window.addEventListener('scroll', this.closeOnScroll, true);
90
+ if (this.props.closeOnHoverEnd && this.wrapperEl != null) {
91
+ this.props.referenceElement.addEventListener('mouseleave', this.closeOnMouseLeave);
92
+ this.wrapperEl.addEventListener('mouseleave', this.closeOnMouseLeave);
93
+ }
94
+ var applyMaxSize = {
95
+ name: 'applyMaxSize',
96
+ enabled: true,
97
+ phase: 'beforeWrite',
98
+ requires: ['maxSize'],
99
+ fn: function (_a) {
100
+ var state = _a.state;
101
+ var height = state.modifiersData.maxSize.height;
102
+ // subtracting 10 in order to make a gap between the edge of the viewport
103
+ state.styles.popper.maxHeight = "".concat(height - 10, "px");
104
+ },
105
+ };
106
+ if (this.wrapperEl != null) {
107
+ /**
108
+ * Wait until referenceElement renders so createPopper
109
+ * can take its dimensions into account.
110
+ */
111
+ setTimeout(function () {
112
+ if (_this.wrapperEl != null) {
113
+ _this.popper = (0, core_1.createPopper)(_this.props.referenceElement, _this.wrapperEl, {
114
+ placement: _this.props.placement,
115
+ modifiers: [
116
+ popper_max_size_modifier_1.default,
117
+ applyMaxSize,
118
+ ],
119
+ });
120
+ }
121
+ }, 50);
122
+ }
123
+ };
124
+ PopupPositioner.prototype.componentWillUnmount = function () {
125
+ var _a, _b;
126
+ window.removeEventListener('click', this.closeOnClick);
127
+ window.removeEventListener('scroll', this.closeOnScroll, true);
128
+ if (this.props.closeOnHoverEnd && this.wrapperEl != null) {
129
+ this.props.referenceElement.removeEventListener('mouseleave', this.closeOnMouseLeave);
130
+ this.wrapperEl.removeEventListener('mouseleave', this.closeOnMouseLeave);
131
+ }
132
+ (_b = (_a = this.popper) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
133
+ };
134
+ PopupPositioner.prototype.render = function () {
135
+ var _this = this;
136
+ var _a;
137
+ return (React.createElement("div", { ref: function (el) {
138
+ _this.wrapperEl = el;
139
+ }, style: { zIndex: (_a = this.props.zIndex) !== null && _a !== void 0 ? _a : 1, position: 'absolute', left: '-100vw' } }, this.props.children));
140
+ };
141
+ return PopupPositioner;
142
+ }(React.PureComponent));
143
+ /**
144
+ * The popup will remove itself if click/scroll events are detected outside the popup.
145
+ */
146
+ function showPopup(referenceElement, placement, Component, zIndex, closeOnHoverEnd, onClose) {
147
+ var el = document.createElement('div');
148
+ document.body.appendChild(el);
149
+ var closeFn = function () {
150
+ react_dom_1.default.unmountComponentAtNode(el);
151
+ el.remove();
152
+ onClose === null || onClose === void 0 ? void 0 : onClose();
153
+ };
154
+ react_dom_1.default.render((React.createElement(PopupPositioner, { referenceElement: referenceElement, placement: placement, onClose: closeFn, zIndex: zIndex, closeOnHoverEnd: closeOnHoverEnd || false },
155
+ React.createElement(Component, { closePopup: closeFn }))), el);
156
+ return { close: closeFn };
157
+ }
158
+ exports.showPopup = showPopup;
@@ -0,0 +1,30 @@
1
+ import * as React from 'react';
2
+ export interface IPropsSpacer {
3
+ h?: boolean;
4
+ v?: boolean;
5
+ gap: '0' | '4' | '8' | '16' | '32' | '64';
6
+ justifyContent?: 'start' | 'end' | 'center' | 'space-around' | 'space-between' | 'space-evenly' | 'stretch';
7
+ alignItems?: 'start' | 'end' | 'center' | 'stretch';
8
+ noGrow?: boolean;
9
+ /**
10
+ * Will not wrap children in div elements.
11
+ * `noGrow` prop would then not be relevant.
12
+ */
13
+ noWrap?: boolean;
14
+ style?: React.CSSProperties;
15
+ children: Array<React.ReactNode>;
16
+ }
17
+ export declare class Spacer extends React.PureComponent<IPropsSpacer> {
18
+ render(): JSX.Element;
19
+ }
20
+ /**
21
+ * Renders a standalone spacing block - similar to <br />
22
+ */
23
+ export interface ISpacerBlock {
24
+ h?: boolean;
25
+ v?: boolean;
26
+ gap: '4' | '8' | '16' | '32' | '64';
27
+ }
28
+ export declare class SpacerBlock extends React.PureComponent<ISpacerBlock> {
29
+ render(): JSX.Element;
30
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
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
+ };
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
41
+ }) : function(o, v) {
42
+ o["default"] = v;
43
+ });
44
+ var __importStar = (this && this.__importStar) || function (mod) {
45
+ if (mod && mod.__esModule) return mod;
46
+ var result = {};
47
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
48
+ __setModuleDefault(result, mod);
49
+ return result;
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.SpacerBlock = exports.Spacer = void 0;
53
+ var React = __importStar(require("react"));
54
+ var Spacer = /** @class */ (function (_super) {
55
+ __extends(Spacer, _super);
56
+ function Spacer() {
57
+ return _super !== null && _super.apply(this, arguments) || this;
58
+ }
59
+ Spacer.prototype.render = function () {
60
+ var _a;
61
+ var _b = this.props, h = _b.h, v = _b.v, gap = _b.gap, justifyContent = _b.justifyContent, alignItems = _b.alignItems, noGrow = _b.noGrow, noWrap = _b.noWrap;
62
+ var justifyContentDefault = h ? 'space-between' : 'start';
63
+ var alignItemsDefault = h ? 'center' : 'start';
64
+ return (React.createElement("div", { style: __assign({ display: 'flex', flexDirection: v ? 'column' : 'row', gap: "".concat(gap, "px"), justifyContent: justifyContent !== null && justifyContent !== void 0 ? justifyContent : justifyContentDefault, alignItems: alignItems !== null && alignItems !== void 0 ? alignItems : alignItemsDefault, width: noGrow === true ? undefined : '100%' }, ((_a = this.props.style) !== null && _a !== void 0 ? _a : {})) }, this.props.children.map(function (el, i) { return noWrap ? el : (React.createElement("div", { key: i, style: {
65
+ width: noGrow === true ? undefined : '100%',
66
+ } }, el)); })));
67
+ };
68
+ return Spacer;
69
+ }(React.PureComponent));
70
+ exports.Spacer = Spacer;
71
+ var SpacerBlock = /** @class */ (function (_super) {
72
+ __extends(SpacerBlock, _super);
73
+ function SpacerBlock() {
74
+ return _super !== null && _super.apply(this, arguments) || this;
75
+ }
76
+ SpacerBlock.prototype.render = function () {
77
+ var _a = this.props, gap = _a.gap, h = _a.h, v = _a.v;
78
+ return (React.createElement("span", { style: {
79
+ display: h === true ? 'inline-block' : 'block',
80
+ width: h === true ? "".concat(gap, "px") : undefined,
81
+ height: v === true ? "".concat(gap, "px") : undefined,
82
+ } }));
83
+ };
84
+ return SpacerBlock;
85
+ }(React.PureComponent));
86
+ exports.SpacerBlock = SpacerBlock;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  interface IProps<T> {
3
- getItems(pageNo: number, signal: AbortSignal): Promise<{
3
+ getItems(pageNo: number, pageSize: number, signal: AbortSignal): Promise<{
4
4
  items: Array<T>;
5
5
  itemCount: number;
6
6
  }>;
@@ -115,7 +115,7 @@ var WithPagination = /** @class */ (function (_super) {
115
115
  }
116
116
  WithPagination.prototype.getPageSize = function () {
117
117
  var _a;
118
- return (_a = this.props.pageSize) !== null && _a !== void 0 ? _a : 20;
118
+ return (_a = this.props.pageSize) !== null && _a !== void 0 ? _a : 100;
119
119
  };
120
120
  WithPagination.prototype.switchPage = function (page) {
121
121
  var _this = this;
@@ -123,7 +123,7 @@ var WithPagination = /** @class */ (function (_super) {
123
123
  this.abortController.abort();
124
124
  }
125
125
  this.inProgress = true;
126
- this.props.getItems(page, this.abortController.signal).then(function (res) {
126
+ this.props.getItems(page, this.getPageSize(), this.abortController.signal).then(function (res) {
127
127
  _this.inProgress = false;
128
128
  _this.setState({ items: res.items, currentPage: page }, function () {
129
129
  var _a;
@@ -139,7 +139,7 @@ var WithPagination = /** @class */ (function (_super) {
139
139
  };
140
140
  WithPagination.prototype.componentDidMount = function () {
141
141
  var _this = this;
142
- this.props.getItems(1, this.abortController.signal).then(function (res) {
142
+ this.props.getItems(1, this.getPageSize(), this.abortController.signal).then(function (res) {
143
143
  _this.pageCount = Math.ceil(res.itemCount / _this.getPageSize());
144
144
  _this.setState({ items: res.items });
145
145
  });
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { Placement } from '@popperjs/core';
3
+ export interface IPropsWithPopover {
4
+ children(toggle: (referenceElement: HTMLElement) => void): React.ReactNode;
5
+ placement: Placement;
6
+ component: React.ComponentType<{
7
+ closePopup(): void;
8
+ }>;
9
+ zIndex?: number;
10
+ closeOnHoverEnd?: boolean;
11
+ onClose?: () => void;
12
+ }
13
+ export declare class WithPopover extends React.PureComponent<IPropsWithPopover> {
14
+ private closePopup?;
15
+ constructor(props: IPropsWithPopover);
16
+ togglePopup(referenceElement: HTMLElement): void;
17
+ render(): React.ReactNode;
18
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.WithPopover = void 0;
42
+ var React = __importStar(require("react"));
43
+ var ShowPopup_1 = require("./ShowPopup");
44
+ var WithPopover = /** @class */ (function (_super) {
45
+ __extends(WithPopover, _super);
46
+ function WithPopover(props) {
47
+ var _this = _super.call(this, props) || this;
48
+ _this.togglePopup = _this.togglePopup.bind(_this);
49
+ return _this;
50
+ }
51
+ WithPopover.prototype.togglePopup = function (referenceElement) {
52
+ if (this.closePopup != null) {
53
+ this.closePopup();
54
+ this.closePopup = undefined;
55
+ }
56
+ else {
57
+ this.closePopup = (0, ShowPopup_1.showPopup)(referenceElement, this.props.placement, this.props.component, this.props.zIndex, this.props.closeOnHoverEnd, this.props.onClose).close;
58
+ }
59
+ };
60
+ WithPopover.prototype.render = function () {
61
+ return this.props.children(this.togglePopup);
62
+ };
63
+ return WithPopover;
64
+ }(React.PureComponent));
65
+ exports.WithPopover = WithPopover;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { IPropsBase } from './interfaces';
3
+ interface IProps extends IPropsBase {
4
+ onClick?(): void;
5
+ }
6
+ export declare class AvatarContentAdd extends React.PureComponent<IProps> {
7
+ render(): JSX.Element;
8
+ }
9
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.AvatarContentAdd = void 0;
42
+ var React = __importStar(require("react"));
43
+ var AvatarContentAdd = /** @class */ (function (_super) {
44
+ __extends(AvatarContentAdd, _super);
45
+ function AvatarContentAdd() {
46
+ return _super !== null && _super.apply(this, arguments) || this;
47
+ }
48
+ AvatarContentAdd.prototype.render = function () {
49
+ var _this = this;
50
+ if (this.props.onClick == null) {
51
+ return (React.createElement("span", { className: "sd-avatar-content sd-avatar-content--add-item", title: this.props.tooltipText }));
52
+ }
53
+ else {
54
+ return (React.createElement("button", { className: "sd-avatar-content sd-avatar-content--add-item sd-avatar-content--add-item--clickable", title: this.props.tooltipText, onClick: function () { var _a, _b; return (_b = (_a = _this.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a); } }));
55
+ }
56
+ };
57
+ return AvatarContentAdd;
58
+ }(React.PureComponent));
59
+ exports.AvatarContentAdd = AvatarContentAdd;
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { IPropsAvatar } from './avatar';
3
+ import { IPropsAvatarPlaceholder } from './avatar-placeholder';
4
+ export type IAvatarInGroup = Omit<IPropsAvatar, 'size'>;
5
+ export type IAvatarPlaceholderInGroup = Omit<IPropsAvatarPlaceholder, 'size'>;
6
+ export type IAvatarGroupItem = IAvatarInGroup | IAvatarPlaceholderInGroup;
7
+ export interface IPropsAvatarGroup {
8
+ size: IPropsAvatar['size'];
9
+ items: Array<IAvatarGroupItem>;
10
+ /**
11
+ * maximum number of avatars to shown inline; defaults to 4
12
+ * if exceeded, "+1"/"+2"/"+n" button will be shown
13
+ */
14
+ max?: number | 'show-all';
15
+ }
16
+ export declare class AvatarGroup extends React.PureComponent<IPropsAvatarGroup> {
17
+ render(): JSX.Element;
18
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
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
+ };
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
41
+ }) : function(o, v) {
42
+ o["default"] = v;
43
+ });
44
+ var __importStar = (this && this.__importStar) || function (mod) {
45
+ if (mod && mod.__esModule) return mod;
46
+ var result = {};
47
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
48
+ __setModuleDefault(result, mod);
49
+ return result;
50
+ };
51
+ var __importDefault = (this && this.__importDefault) || function (mod) {
52
+ return (mod && mod.__esModule) ? mod : { "default": mod };
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.AvatarGroup = void 0;
56
+ var React = __importStar(require("react"));
57
+ var classnames_1 = __importDefault(require("classnames"));
58
+ var avatar_1 = require("./avatar");
59
+ var avatar_wrapper_1 = require("./avatar-wrapper");
60
+ var avatar_number_1 = require("./avatar-number");
61
+ var avatar_placeholder_1 = require("./avatar-placeholder");
62
+ function isAvatar(item) {
63
+ return item['kind'] == null;
64
+ }
65
+ var AvatarGroup = /** @class */ (function (_super) {
66
+ __extends(AvatarGroup, _super);
67
+ function AvatarGroup() {
68
+ return _super !== null && _super.apply(this, arguments) || this;
69
+ }
70
+ AvatarGroup.prototype.render = function () {
71
+ var _this = this;
72
+ var _a = this.props, size = _a.size, items = _a.items;
73
+ var someIconsHaveExtraElements = items.filter(isAvatar).some(function (_a) {
74
+ var icon = _a.icon, administratorIndicator = _a.administratorIndicator;
75
+ return icon != null || administratorIndicator != null;
76
+ });
77
+ var gap = someIconsHaveExtraElements ? 'medium' : 'none';
78
+ var max = (function () {
79
+ if (_this.props.max === 'show-all') {
80
+ return _this.props.items.length;
81
+ }
82
+ else if (_this.props.max == null) {
83
+ return 4;
84
+ }
85
+ else {
86
+ return _this.props.max;
87
+ }
88
+ })();
89
+ 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' },
91
+ items.slice(0, max).map(function (item, index) {
92
+ if (isAvatar(item)) {
93
+ return (React.createElement(avatar_1.Avatar, __assign({}, item, { key: index, size: size })));
94
+ }
95
+ else {
96
+ return (React.createElement(avatar_placeholder_1.AvatarPlaceholder, __assign({}, item, { key: index, size: _this.props.size })));
97
+ }
98
+ }),
99
+ itemsOverLimit > 0 && (React.createElement(avatar_wrapper_1.AvatarWrapper, { size: size, isEmpty: false },
100
+ React.createElement(avatar_number_1.AvatarContentNumber, { number: "".concat(itemsOverLimit) })))));
101
+ };
102
+ return AvatarGroup;
103
+ }(React.PureComponent));
104
+ exports.AvatarGroup = AvatarGroup;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { IPropsBase } from './interfaces';
3
+ interface IPropsImageAvatar extends IPropsBase {
4
+ imageUrl?: string | null;
5
+ }
6
+ export declare class AvatarContentImage extends React.PureComponent<IPropsImageAvatar> {
7
+ render(): JSX.Element;
8
+ }
9
+ export {};