superdesk-ui-framework 2.4.19 → 2.4.20

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.
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import './../../app/styles/_spinner.scss';
3
+ declare class LoadingOverlay extends React.PureComponent {
4
+ render(): JSX.Element;
5
+ }
6
+ interface IProps {
7
+ size?: 'mini' | 'small' | 'medium' | 'large';
8
+ }
9
+ declare class Spinner extends React.PureComponent<IProps> {
10
+ render(): JSX.Element;
11
+ }
12
+ export { Spinner, LoadingOverlay };
@@ -0,0 +1,70 @@
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.LoadingOverlay = exports.Spinner = void 0;
39
+ var React = __importStar(require("react"));
40
+ var classnames_1 = __importDefault(require("classnames"));
41
+ require("./../../app/styles/_spinner.scss");
42
+ var LoadingOverlay = /** @class */ (function (_super) {
43
+ __extends(LoadingOverlay, _super);
44
+ function LoadingOverlay() {
45
+ return _super !== null && _super.apply(this, arguments) || this;
46
+ }
47
+ LoadingOverlay.prototype.render = function () {
48
+ return (React.createElement("div", { className: "sd-loading-overlay--plain" }, this.props.children));
49
+ };
50
+ return LoadingOverlay;
51
+ }(React.PureComponent));
52
+ exports.LoadingOverlay = LoadingOverlay;
53
+ var Spinner = /** @class */ (function (_super) {
54
+ __extends(Spinner, _super);
55
+ function Spinner() {
56
+ return _super !== null && _super.apply(this, arguments) || this;
57
+ }
58
+ Spinner.prototype.render = function () {
59
+ var _a;
60
+ var classes = classnames_1.default('sd-spinner', (_a = {
61
+ 'sd-spinner--small': this.props.size === undefined
62
+ },
63
+ _a["sd-spinner--" + this.props.size] = this.props.size || this.props.size !== undefined,
64
+ _a));
65
+ return (React.createElement("svg", { role: "progressbar", className: classes, viewBox: "0 0 50 50" },
66
+ React.createElement("circle", { className: "sd-spinner__path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" })));
67
+ };
68
+ return Spinner;
69
+ }(React.PureComponent));
70
+ exports.Spinner = Spinner;
@@ -1,26 +1,36 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  interface ITabs {
3
3
  size?: 'normal' | 'large' | 'small';
4
4
  theme?: 'light' | 'dark';
5
5
  ariaLabel?: string;
6
6
  children: Array<any>;
7
- onClick(i: number): void;
7
+ onClick(id: string): void;
8
+ tabs?: Array<{
9
+ label: string;
10
+ id: string;
11
+ }>;
12
+ activePanel: string;
8
13
  }
9
14
  interface ITabLabel {
10
- label: string;
11
- indexValue: number;
15
+ label?: string;
16
+ id: string;
17
+ children: Array<any>;
12
18
  }
13
19
  interface ITabContent {
14
20
  theme?: 'light' | 'dark';
15
- children: any;
16
- activePanel: number;
21
+ children: Array<any>;
22
+ activePanel: string;
23
+ tabs?: Array<{
24
+ content: React.ReactNode | string;
25
+ id: string;
26
+ }>;
17
27
  }
18
28
  interface ITabPanel {
19
- indexValue: number;
20
- children: any;
29
+ id: string;
30
+ children: Array<any>;
21
31
  }
22
- export declare const TabLabel: ({ label }: ITabLabel) => JSX.Element;
23
- export declare const Tabs: ({ size, theme, ariaLabel, children, onClick }: ITabs) => JSX.Element;
24
- export declare const TabContent: ({ theme, children, activePanel }: ITabContent) => JSX.Element;
25
- export declare const TabPanel: ({ children, indexValue }: ITabPanel) => JSX.Element;
32
+ export declare const TabNav: ({ size, theme, ariaLabel, children, onClick, tabs, activePanel }: ITabs) => JSX.Element;
33
+ export declare const TabContent: ({ theme, children, activePanel, tabs }: ITabContent) => JSX.Element;
34
+ export declare const TabItem: ({ children }: ITabLabel) => JSX.Element;
35
+ export declare const TabPanel: ({ children, id }: ITabPanel) => JSX.Element;
26
36
  export {};
@@ -22,41 +22,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.TabPanel = exports.TabContent = exports.Tabs = exports.TabLabel = void 0;
25
+ exports.TabPanel = exports.TabItem = exports.TabContent = exports.TabNav = void 0;
26
26
  var React = __importStar(require("react"));
27
27
  var classnames_1 = __importDefault(require("classnames"));
28
- exports.TabLabel = function (_a) {
29
- var label = _a.label;
30
- return (React.createElement("span", null, label));
31
- };
32
- exports.Tabs = function (_a) {
28
+ exports.TabNav = function (_a) {
33
29
  var _b;
34
- var size = _a.size, theme = _a.theme, ariaLabel = _a.ariaLabel, children = _a.children, onClick = _a.onClick;
30
+ var size = _a.size, theme = _a.theme, ariaLabel = _a.ariaLabel, children = _a.children, onClick = _a.onClick, tabs = _a.tabs, activePanel = _a.activePanel;
35
31
  var _c = React.useState(0), index = _c[0], setIndex = _c[1];
36
- function handleSelected(i) {
37
- setIndex(i);
38
- handleClick(i);
32
+ function goTo(id) {
33
+ if (tabs) {
34
+ var refLabel = tabs === null || tabs === void 0 ? void 0 : tabs.find(function (item) { return item.id === id; });
35
+ if (refLabel) {
36
+ setIndex(tabs.indexOf(refLabel));
37
+ }
38
+ }
39
+ else {
40
+ var refLabel = children.find(function (item) { return item.props.id === id; });
41
+ setIndex(children.indexOf(refLabel));
42
+ }
43
+ }
44
+ React.useEffect(function () {
45
+ goTo(activePanel ? activePanel : (tabs ? tabs[0].id : children[0].props.id));
46
+ }, []);
47
+ function handleSelected(id) {
48
+ goTo(id);
49
+ onClick(id);
39
50
  }
40
- var handleClick = function (i) {
41
- onClick(i);
42
- };
43
51
  var classes = classnames_1.default('sd-nav-tabs', (_b = {},
44
52
  _b["sd-nav-tabs--" + size] = size && size !== undefined,
45
53
  _b['sd-nav-tabs--ui-dark'] = theme === 'dark',
46
54
  _b));
47
- return (React.createElement("div", { className: classes, role: 'tablist', "aria-label": ariaLabel ? ariaLabel : 'tabs' }, children.map(function (item, i) {
48
- return React.createElement("button", { key: i, "aria-controls": 'tabpanel-' + i, className: 'sd-nav-tabs__tab' + (index === i ? ' sd-nav-tabs__tab--active' : ''), onClick: function () { return handleSelected(i); }, role: 'tab', "aria-selected": index === i ? 'true' : 'false' }, item);
49
- })));
55
+ return (React.createElement("div", { className: classes, role: 'tablist', "aria-label": ariaLabel ? ariaLabel : 'tabs' }, tabs ?
56
+ tabs.map(function (item, i) {
57
+ return React.createElement("button", { id: "tab-" + item.id, key: i, "aria-controls": 'tabpanel-' + item.id, className: 'sd-nav-tabs__tab' + (index === i ? ' sd-nav-tabs__tab--active' : ''), onClick: function () { return handleSelected(item.id); }, role: 'tab', "aria-selected": index === i ? 'true' : 'false' }, item.label);
58
+ })
59
+ :
60
+ children.map(function (item, i) {
61
+ return React.createElement("button", { id: "tab-" + item.props.id, key: i, "aria-controls": 'tabpanel-' + item.props.id, className: 'sd-nav-tabs__tab' + (index === i ? ' sd-nav-tabs__tab--active' : ''), onClick: function () { return handleSelected(item.props.id); }, role: 'tab', "aria-selected": index === i ? 'true' : 'false' }, item);
62
+ })));
50
63
  };
51
64
  exports.TabContent = function (_a) {
52
- var theme = _a.theme, children = _a.children, activePanel = _a.activePanel;
65
+ var theme = _a.theme, children = _a.children, activePanel = _a.activePanel, tabs = _a.tabs;
66
+ if (!activePanel && tabs) {
67
+ activePanel = tabs[0].id;
68
+ }
69
+ else if (!activePanel && children) {
70
+ activePanel = children[0].props.id;
71
+ }
53
72
  return (React.createElement("div", { className: 'sd-nav-tabs__content' +
54
- (theme === 'dark' ? ' sd-nav-tabs__content--ui-dark' : '') }, children.map(function (panel, i) {
55
- return panel.props.indexValue === activePanel ?
56
- React.createElement("div", { className: 'sd-nav-tabs__pane', role: 'tabpanel', "aria-labelledby": 'tab-' + activePanel, key: i }, panel) : null;
57
- })));
73
+ (theme === 'dark' ? ' sd-nav-tabs__content--ui-dark' : '') }, tabs ?
74
+ tabs.map(function (panel, i) {
75
+ return panel.id === activePanel ?
76
+ React.createElement("div", { className: 'sd-nav-tabs__pane', role: 'tabpanel', "aria-labelledby": "tab-" + panel.id, key: i }, panel.content) : null;
77
+ })
78
+ :
79
+ children.map(function (panel, i) {
80
+ return panel.props.id === activePanel ?
81
+ React.createElement("div", { className: 'sd-nav-tabs__pane', role: 'tabpanel', "aria-labelledby": "tab-" + panel.props.id, key: i }, panel) : null;
82
+ })));
83
+ };
84
+ exports.TabItem = function (_a) {
85
+ var children = _a.children;
86
+ return (React.createElement("span", null, children));
58
87
  };
59
88
  exports.TabPanel = function (_a) {
60
- var children = _a.children, indexValue = _a.indexValue;
61
- return (React.createElement(React.Fragment, { key: indexValue }, children));
89
+ var children = _a.children, id = _a.id;
90
+ return (React.createElement(React.Fragment, { key: id }, children));
62
91
  };
@@ -3,20 +3,29 @@ interface ITabList {
3
3
  size?: 'normal' | 'large' | 'small';
4
4
  theme?: 'light' | 'dark';
5
5
  children: Array<any>;
6
+ selected?: string;
7
+ tabs?: Array<{
8
+ label: string;
9
+ content: React.ReactNode | string;
10
+ id?: string;
11
+ }>;
6
12
  }
7
13
  interface IState {
8
14
  index: number;
9
15
  }
10
16
  interface ITab {
11
- label: string;
17
+ id?: string;
18
+ label?: string;
12
19
  }
13
20
  declare class Tab extends React.PureComponent<ITab> {
14
21
  render(): JSX.Element;
15
22
  }
16
23
  declare class TabList extends React.PureComponent<ITabList, IState> {
17
24
  constructor(props: ITabList);
25
+ componentDidMount(): void;
18
26
  private handleChange;
19
- goTo(label: string): void;
27
+ goTo(index: string): void;
28
+ private navBar;
20
29
  render(): JSX.Element;
21
30
  }
22
31
  export { Tab, TabList };
@@ -60,31 +60,52 @@ var TabList = /** @class */ (function (_super) {
60
60
  _this.goTo = _this.goTo.bind(_this);
61
61
  return _this;
62
62
  }
63
+ TabList.prototype.componentDidMount = function () {
64
+ var _a;
65
+ if (this.props.selected) {
66
+ this.goTo((_a = this.props.selected) !== null && _a !== void 0 ? _a : '');
67
+ }
68
+ };
63
69
  TabList.prototype.handleChange = function (index) {
64
70
  this.setState({
65
71
  index: index,
66
72
  });
67
73
  };
68
- TabList.prototype.goTo = function (label) {
69
- var refLabel = this.props.children.find(function (item) { return item.props.label === label; });
70
- this.setState({
71
- index: this.props.children.indexOf(refLabel),
74
+ TabList.prototype.goTo = function (index) {
75
+ var _a, _b;
76
+ if (this.props.tabs) {
77
+ var refLabel = (_a = this.props.tabs) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.id === index; });
78
+ this.setState({
79
+ index: refLabel ? (_b = this.props.tabs) === null || _b === void 0 ? void 0 : _b.indexOf(refLabel) : 0,
80
+ });
81
+ }
82
+ else {
83
+ var refLabel = this.props.children.find(function (item) { return item.props.id === index; });
84
+ this.setState({
85
+ index: this.props.children.indexOf(refLabel),
86
+ });
87
+ }
88
+ };
89
+ TabList.prototype.navBar = function (arr) {
90
+ var _this = this;
91
+ return arr.map(function (item, index) {
92
+ var label = _this.props.tabs ? item.label : item.props.label;
93
+ return React.createElement("button", { id: "TabList-" + index, key: index, onClick: function () { return _this.handleChange(index); }, role: 'tab', "aria-selected": _this.state.index === index ? 'true' : 'false', className: 'sd-nav-tabs__tab' + (_this.state.index === index ? ' sd-nav-tabs__tab--active' : '') },
94
+ React.createElement("span", null, label));
72
95
  });
73
96
  };
74
97
  TabList.prototype.render = function () {
75
98
  var _a;
76
- var _this = this;
77
99
  var classes = classnames_1.default('sd-nav-tabs', (_a = {},
78
100
  _a["sd-nav-tabs--" + this.props.size] = this.props.size && this.props.size !== undefined,
79
101
  _a['sd-nav-tabs--ui-dark'] = this.props.theme === 'dark',
80
102
  _a));
81
103
  return (React.createElement(React.Fragment, null,
82
- React.createElement("div", { className: classes, role: 'tablist' }, this.props.children.map(function (item, index) {
83
- return React.createElement("button", { key: index, onClick: function () { return _this.handleChange(index); }, role: 'tab', "aria-selected": _this.state.index === index ? 'true' : 'false', className: 'sd-nav-tabs__tab' + (_this.state.index === index ? ' sd-nav-tabs__tab--active' : '') },
84
- React.createElement("span", null, item.props.label));
85
- })),
86
- React.createElement("div", { className: 'sd-nav-tabs__content' +
87
- (this.props.theme === 'dark' ? ' sd-nav-tabs__content--ui-dark' : '') }, this.props.children[this.state.index])));
104
+ React.createElement("div", { className: classes, role: 'tablist' }, this.props.tabs ? this.navBar(this.props.tabs) : this.navBar(this.props.children)),
105
+ React.createElement("div", { "aria-labelledby": "TabList-" + this.state.index, role: 'tabpanel', className: 'sd-nav-tabs__content' +
106
+ (this.props.theme === 'dark' ? ' sd-nav-tabs__content--ui-dark' : '') }, this.props.tabs
107
+ ? React.createElement(Tab, { id: this.props.tabs[this.state.index].id }, this.props.tabs[this.state.index].content)
108
+ : this.props.children[this.state.index])));
88
109
  };
89
110
  return TabList;
90
111
  }(React.PureComponent));
package/react/index.d.ts CHANGED
@@ -44,7 +44,7 @@ export { DropdownLabel } from './components/DropdownFirst';
44
44
  export { DropdownDivider } from './components/DropdownFirst';
45
45
  export { Dropdown } from './components/Dropdown';
46
46
  export { Tag } from './components/Tag';
47
- export { TabLabel, TabPanel, TabContent, Tabs } from './components/TabCustom';
47
+ export { TabItem, TabPanel, TabContent, TabNav } from './components/TabCustom';
48
48
  export { EmptyState } from './components/EmptyState';
49
49
  export { Autocomplete } from './components/Autocomplete';
50
50
  export { DonutChart } from './components/DonutChart';
package/react/index.js CHANGED
@@ -96,10 +96,10 @@ Object.defineProperty(exports, "Dropdown", { enumerable: true, get: function ()
96
96
  var Tag_1 = require("./components/Tag");
97
97
  Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return Tag_1.Tag; } });
98
98
  var TabCustom_1 = require("./components/TabCustom");
99
- Object.defineProperty(exports, "TabLabel", { enumerable: true, get: function () { return TabCustom_1.TabLabel; } });
99
+ Object.defineProperty(exports, "TabItem", { enumerable: true, get: function () { return TabCustom_1.TabItem; } });
100
100
  Object.defineProperty(exports, "TabPanel", { enumerable: true, get: function () { return TabCustom_1.TabPanel; } });
101
101
  Object.defineProperty(exports, "TabContent", { enumerable: true, get: function () { return TabCustom_1.TabContent; } });
102
- Object.defineProperty(exports, "Tabs", { enumerable: true, get: function () { return TabCustom_1.Tabs; } });
102
+ Object.defineProperty(exports, "TabNav", { enumerable: true, get: function () { return TabCustom_1.TabNav; } });
103
103
  var EmptyState_1 = require("./components/EmptyState");
104
104
  Object.defineProperty(exports, "EmptyState", { enumerable: true, get: function () { return EmptyState_1.EmptyState; } });
105
105
  var Autocomplete_1 = require("./components/Autocomplete");