superdesk-ui-framework 2.4.17 → 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.
- package/app/styles/_accessibility.scss +8 -3
- package/app/styles/_buttons.scss +52 -1
- package/app/styles/_spinner.scss +46 -0
- package/app-typescript/components/Button.tsx +7 -1
- package/app-typescript/components/Input.tsx +22 -7
- package/app-typescript/components/Select.tsx +13 -3
- package/app-typescript/components/Spinner.tsx +33 -0
- package/app-typescript/components/TabCustom.tsx +89 -40
- package/app-typescript/components/TabList.tsx +43 -18
- package/app-typescript/components/Tag.tsx +2 -2
- package/app-typescript/index.ts +1 -1
- package/dist/examples.bundle.css +36 -1
- package/dist/examples.bundle.js +901 -632
- package/dist/react/Buttons.tsx +25 -0
- package/dist/react/Inputs.tsx +24 -3
- package/dist/react/Selects.tsx +23 -1
- package/dist/react/Tabs.tsx +225 -72
- package/dist/superdesk-ui.bundle.css +75 -13
- package/dist/superdesk-ui.bundle.js +560 -400
- package/dist/vendor.bundle.js +13 -13
- package/examples/pages/react/Buttons.tsx +25 -0
- package/examples/pages/react/Inputs.tsx +24 -3
- package/examples/pages/react/Selects.tsx +23 -1
- package/examples/pages/react/Tabs.tsx +225 -72
- package/package.json +2 -2
- package/react/components/Button.d.ts +2 -0
- package/react/components/Button.js +4 -2
- package/react/components/Input.d.ts +4 -1
- package/react/components/Input.js +17 -5
- package/react/components/Select.d.ts +3 -1
- package/react/components/Select.js +11 -2
- package/react/components/Spinner.d.ts +12 -0
- package/react/components/Spinner.js +70 -0
- package/react/components/TabCustom.d.ts +22 -12
- package/react/components/TabCustom.js +52 -23
- package/react/components/TabList.d.ts +11 -2
- package/react/components/TabList.js +32 -11
- package/react/components/Tag.js +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
@@ -16,6 +16,8 @@ interface IPropsButton extends IButtonBase {
|
|
16
16
|
expand?: boolean;
|
17
17
|
style?: 'filled' | 'hollow' | 'text-only';
|
18
18
|
shape?: 'square' | 'round';
|
19
|
+
isLoading?: boolean;
|
20
|
+
loadingLabel?: string;
|
19
21
|
}
|
20
22
|
export declare class Button extends React.PureComponent<IPropsButton> {
|
21
23
|
render(): JSX.Element;
|
@@ -39,6 +39,7 @@ exports.Button = void 0;
|
|
39
39
|
var React = __importStar(require("react"));
|
40
40
|
var classnames_1 = __importDefault(require("classnames"));
|
41
41
|
var Icon_1 = require("./Icon");
|
42
|
+
var Spinner_1 = require("./Spinner");
|
42
43
|
var Button = /** @class */ (function (_super) {
|
43
44
|
__extends(Button, _super);
|
44
45
|
function Button() {
|
@@ -58,8 +59,9 @@ var Button = /** @class */ (function (_super) {
|
|
58
59
|
_a['btn--ui-dark'] = this.props.theme === 'dark',
|
59
60
|
_a['btn--icon-only-circle'] = this.props.shape === 'round' && this.props.iconOnly,
|
60
61
|
_a));
|
61
|
-
return (React.createElement("button", { id: this.props.id, className: classes, tabIndex: 0, onClick: this.props.disabled ? function () { return false; } : function (event) { return _this.props.onClick(event); }, "aria-label": this.props.iconOnly ? this.props.text : '', "data-test-id": this.props['data-test-id'] },
|
62
|
-
this.props.
|
62
|
+
return (React.createElement("button", { id: this.props.id, className: classes, tabIndex: 0, disabled: this.props.isLoading, "data-loading": this.props.isLoading, onClick: this.props.disabled ? function () { return false; } : function (event) { return _this.props.onClick(event); }, "aria-label": this.props.iconOnly ? this.props.text : '', "data-test-id": this.props['data-test-id'] },
|
63
|
+
this.props.isLoading ? React.createElement(Spinner_1.Spinner, { size: "mini" }) : null,
|
64
|
+
this.props.icon && !this.props.isLoading ? React.createElement(Icon_1.Icon, { name: this.props.icon }) : null,
|
63
65
|
this.props.iconOnly ? null : this.props.text));
|
64
66
|
};
|
65
67
|
return Button;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
interface IProps {
|
3
3
|
value?: string;
|
4
|
-
label
|
4
|
+
label: string;
|
5
5
|
maxLength?: number;
|
6
6
|
info?: string;
|
7
7
|
error?: string;
|
@@ -9,6 +9,7 @@ interface IProps {
|
|
9
9
|
disabled?: boolean;
|
10
10
|
invalid?: boolean;
|
11
11
|
inlineLabel?: boolean;
|
12
|
+
labelHidden?: boolean;
|
12
13
|
onChange(newValue: string): void;
|
13
14
|
}
|
14
15
|
interface IState {
|
@@ -18,7 +19,9 @@ interface IState {
|
|
18
19
|
export declare class Input extends React.Component<IProps, IState> {
|
19
20
|
constructor(props: IProps);
|
20
21
|
htmlId: string;
|
22
|
+
handleData(value: string): void;
|
21
23
|
handleChange(event: React.ChangeEvent<HTMLInputElement>): void;
|
24
|
+
componentDidUpdate(prevProps: IProps): void;
|
22
25
|
render(): JSX.Element;
|
23
26
|
}
|
24
27
|
export {};
|
@@ -52,11 +52,20 @@ var Input = /** @class */ (function (_super) {
|
|
52
52
|
_this.handleChange = _this.handleChange.bind(_this);
|
53
53
|
return _this;
|
54
54
|
}
|
55
|
-
Input.prototype.
|
56
|
-
this.setState({ value:
|
57
|
-
this.props.onChange(
|
55
|
+
Input.prototype.handleData = function (value) {
|
56
|
+
this.setState({ value: value !== null && value !== void 0 ? value : '' });
|
57
|
+
this.props.onChange(value !== null && value !== void 0 ? value : '');
|
58
58
|
if (this.props.maxLength && !this.props.invalid) {
|
59
|
-
this.setState({ invalid:
|
59
|
+
this.setState({ invalid: value.length > this.props.maxLength });
|
60
|
+
}
|
61
|
+
};
|
62
|
+
Input.prototype.handleChange = function (event) {
|
63
|
+
this.handleData(event.target.value);
|
64
|
+
};
|
65
|
+
Input.prototype.componentDidUpdate = function (prevProps) {
|
66
|
+
var _a;
|
67
|
+
if (this.props.value !== prevProps.value) {
|
68
|
+
this.handleData((_a = this.props.value) !== null && _a !== void 0 ? _a : '');
|
60
69
|
}
|
61
70
|
};
|
62
71
|
Input.prototype.render = function () {
|
@@ -66,8 +75,11 @@ var Input = /** @class */ (function (_super) {
|
|
66
75
|
'sd-input--disabled': this.props.disabled,
|
67
76
|
'sd-input--invalid': this.props.invalid || this.state.invalid,
|
68
77
|
});
|
78
|
+
var labelClasses = classnames_1.default('sd-input__label', {
|
79
|
+
'a11y-only': this.props.labelHidden,
|
80
|
+
});
|
69
81
|
return (React.createElement("div", { className: classes },
|
70
|
-
|
82
|
+
React.createElement("label", { className: labelClasses, htmlFor: this.htmlId, id: this.htmlId + 'label' }, this.props.label),
|
71
83
|
React.createElement("input", { className: 'sd-input__input', type: 'text', id: this.htmlId, value: this.state.value, "aria-label": this.props.label, "aria-describedby": this.htmlId + 'label', onChange: this.handleChange, disabled: this.props.disabled }),
|
72
84
|
this.props.maxLength ?
|
73
85
|
React.createElement("div", { className: 'sd-input__char-count' },
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
interface ISelect {
|
3
3
|
value?: string;
|
4
|
-
label
|
4
|
+
label: string;
|
5
5
|
info?: string;
|
6
6
|
error?: string;
|
7
7
|
required?: boolean;
|
8
8
|
disabled?: boolean;
|
9
9
|
invalid?: boolean;
|
10
10
|
inlineLabel?: boolean;
|
11
|
+
labelHidden?: boolean;
|
11
12
|
onChange(newValue: string): void;
|
12
13
|
}
|
13
14
|
interface IState {
|
@@ -18,6 +19,7 @@ declare class Select extends React.Component<ISelect, IState> {
|
|
18
19
|
constructor(props: ISelect);
|
19
20
|
htmlId: string;
|
20
21
|
handleChange(event: React.ChangeEvent<HTMLSelectElement>): void;
|
22
|
+
componentDidUpdate(prevProps: any): void;
|
21
23
|
render(): JSX.Element;
|
22
24
|
}
|
23
25
|
interface IOption {
|
@@ -56,6 +56,13 @@ var Select = /** @class */ (function (_super) {
|
|
56
56
|
this.setState({ value: event.target.value });
|
57
57
|
this.props.onChange(event.target.value);
|
58
58
|
};
|
59
|
+
Select.prototype.componentDidUpdate = function (prevProps) {
|
60
|
+
var _a, _b;
|
61
|
+
if (this.props.value !== prevProps.value) {
|
62
|
+
this.setState({ value: (_a = this.props.value) !== null && _a !== void 0 ? _a : '' });
|
63
|
+
this.props.onChange((_b = this.props.value) !== null && _b !== void 0 ? _b : '');
|
64
|
+
}
|
65
|
+
};
|
59
66
|
Select.prototype.render = function () {
|
60
67
|
var classes = classnames_1.default('sd-input sd-input--is-select', {
|
61
68
|
'sd-input--inline-label': this.props.inlineLabel,
|
@@ -63,9 +70,11 @@ var Select = /** @class */ (function (_super) {
|
|
63
70
|
'sd-input--disabled': this.props.disabled,
|
64
71
|
'sd-input--invalid': this.props.invalid || this.state.invalid,
|
65
72
|
});
|
73
|
+
var labelClasses = classnames_1.default('sd-input__label', {
|
74
|
+
'a11y-only': this.props.labelHidden,
|
75
|
+
});
|
66
76
|
return (React.createElement("div", { className: classes },
|
67
|
-
this.props.label
|
68
|
-
React.createElement("label", { className: 'sd-input__label', htmlFor: this.htmlId }, this.props.label) : null,
|
77
|
+
React.createElement("label", { className: labelClasses, htmlFor: this.htmlId }, this.props.label),
|
69
78
|
React.createElement("select", { className: 'sd-input__select', id: this.htmlId, value: this.state.value, "aria-label": this.props.label, "aria-describedby": this.htmlId, onChange: this.handleChange, disabled: this.props.disabled }, this.props.children),
|
70
79
|
React.createElement("div", { className: 'sd-input__message-box' },
|
71
80
|
this.props.info && !this.props.invalid && !this.state.invalid ?
|
@@ -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
|
-
|
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(
|
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
|
11
|
-
|
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:
|
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
|
-
|
20
|
-
children: any
|
29
|
+
id: string;
|
30
|
+
children: Array<any>;
|
21
31
|
}
|
22
|
-
export declare const
|
23
|
-
export declare const
|
24
|
-
export declare const
|
25
|
-
export declare const TabPanel: ({ children,
|
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.
|
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.
|
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
|
37
|
-
|
38
|
-
|
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' },
|
48
|
-
|
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' : '') },
|
55
|
-
|
56
|
-
|
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,
|
61
|
-
return (React.createElement(React.Fragment, { key:
|
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
|
-
|
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(
|
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 (
|
69
|
-
var
|
70
|
-
this.
|
71
|
-
|
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.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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/components/Tag.js
CHANGED
@@ -32,7 +32,7 @@ exports.Tag = function (_a) {
|
|
32
32
|
_b["tag-label--" + shade] = shade && shade !== 'light',
|
33
33
|
_b['tag-label--square'] = shape === 'square',
|
34
34
|
_b));
|
35
|
-
return (React.createElement("
|
35
|
+
return (React.createElement("span", { className: classes, key: keyValue },
|
36
36
|
text,
|
37
37
|
!readOnly ? React.createElement("button", { className: 'tag-label__remove', onClick: onClick },
|
38
38
|
React.createElement("i", { className: 'icon-close-small' })) : null));
|
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 {
|
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, "
|
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, "
|
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");
|