@douyinfe/semi-ui 2.27.0-alpha.1 → 2.27.0-beta.0
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/dist/css/semi.css +19 -207
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +243 -297
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/input/index.d.ts +1 -1
- package/lib/cjs/input/inputGroup.d.ts +1 -1
- package/lib/cjs/rating/index.d.ts +1 -1
- package/lib/cjs/rating/item.d.ts +1 -1
- package/lib/cjs/switch/index.d.ts +1 -1
- package/lib/cjs/table/Table.d.ts +2 -2
- package/lib/cjs/table/index.d.ts +1 -1
- package/lib/cjs/tabs/TabBar.d.ts +2 -1
- package/lib/cjs/tabs/TabBar.js +48 -22
- package/lib/cjs/tabs/index.d.ts +1 -2
- package/lib/cjs/tabs/index.js +0 -3
- package/lib/cjs/tagInput/index.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +1 -1
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/input/index.d.ts +1 -1
- package/lib/es/input/inputGroup.d.ts +1 -1
- package/lib/es/rating/index.d.ts +1 -1
- package/lib/es/rating/item.d.ts +1 -1
- package/lib/es/switch/index.d.ts +1 -1
- package/lib/es/table/Table.d.ts +2 -2
- package/lib/es/table/index.d.ts +1 -1
- package/lib/es/tabs/TabBar.d.ts +2 -1
- package/lib/es/tabs/TabBar.js +49 -22
- package/lib/es/tabs/index.d.ts +1 -2
- package/lib/es/tabs/index.js +0 -2
- package/lib/es/tagInput/index.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +1 -1
- package/package.json +8 -8
- package/lib/cjs/tabs/TabItem.d.ts +0 -18
- package/lib/cjs/tabs/TabItem.js +0 -95
- package/lib/es/tabs/TabItem.d.ts +0 -18
- package/lib/es/tabs/TabItem.js +0 -78
package/lib/es/tabs/TabBar.js
CHANGED
|
@@ -19,9 +19,8 @@ import getDataAttr from '@douyinfe/semi-foundation/lib/es/utils/getDataAttr';
|
|
|
19
19
|
import OverflowList from '../overflowList';
|
|
20
20
|
import Dropdown from '../dropdown';
|
|
21
21
|
import Button from '../button';
|
|
22
|
-
import { IconChevronRight, IconChevronLeft } from '@douyinfe/semi-icons';
|
|
22
|
+
import { IconChevronRight, IconChevronLeft, IconClose } from '@douyinfe/semi-icons';
|
|
23
23
|
import { getUuidv4 } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
|
|
24
|
-
import TabItem from './TabItem';
|
|
25
24
|
|
|
26
25
|
class TabBar extends React.Component {
|
|
27
26
|
constructor(props) {
|
|
@@ -34,7 +33,7 @@ class TabBar extends React.Component {
|
|
|
34
33
|
const key = this._getItemKey(itemKey); // eslint-disable-next-line max-len
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
const tabItem = document.querySelector("[data-uuid=\"".concat(this.uuid, "\"] .").concat(cssClasses.TABS_TAB, "[data-scrollkey=\"").concat(key, "\"]"));
|
|
36
|
+
const tabItem = document.querySelector("[data-uuid=\"".concat(this.state.uuid, "\"] .").concat(cssClasses.TABS_TAB, "[data-scrollkey=\"").concat(key, "\"]"));
|
|
38
37
|
tabItem.scrollIntoView({
|
|
39
38
|
behavior: 'smooth',
|
|
40
39
|
block: 'nearest',
|
|
@@ -51,23 +50,45 @@ class TabBar extends React.Component {
|
|
|
51
50
|
const {
|
|
52
51
|
size,
|
|
53
52
|
type,
|
|
54
|
-
deleteTabItem
|
|
55
|
-
handleKeyDown,
|
|
56
|
-
tabPosition
|
|
53
|
+
deleteTabItem
|
|
57
54
|
} = this.props;
|
|
55
|
+
const panelIcon = panel.icon ? this.renderIcon(panel.icon) : null;
|
|
56
|
+
const closableIcon = type === 'card' && panel.closable ? /*#__PURE__*/React.createElement(IconClose, {
|
|
57
|
+
"aria-label": "Close",
|
|
58
|
+
role: "button",
|
|
59
|
+
className: "".concat(cssClasses.TABS_TAB, "-icon-close"),
|
|
60
|
+
onClick: e => deleteTabItem(panel.itemKey, e)
|
|
61
|
+
}) : null;
|
|
62
|
+
let events = {};
|
|
63
|
+
const key = panel.itemKey;
|
|
64
|
+
|
|
65
|
+
if (!panel.disabled) {
|
|
66
|
+
events = {
|
|
67
|
+
onClick: e => this.handleItemClick(key, e)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
58
70
|
|
|
59
|
-
const isSelected = this._isActive(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
const isSelected = this._isActive(key);
|
|
72
|
+
|
|
73
|
+
const className = cls(cssClasses.TABS_TAB, {
|
|
74
|
+
[cssClasses.TABS_TAB_ACTIVE]: isSelected,
|
|
75
|
+
[cssClasses.TABS_TAB_DISABLED]: panel.disabled,
|
|
76
|
+
["".concat(cssClasses.TABS_TAB, "-small")]: size === 'small',
|
|
77
|
+
["".concat(cssClasses.TABS_TAB, "-medium")]: size === 'medium'
|
|
78
|
+
});
|
|
79
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
80
|
+
role: "tab",
|
|
81
|
+
id: "semiTab".concat(key),
|
|
82
|
+
"data-tabkey": "semiTab".concat(key),
|
|
83
|
+
"aria-controls": "semiTabPanel".concat(key),
|
|
84
|
+
"aria-disabled": panel.disabled ? 'true' : 'false',
|
|
85
|
+
"aria-selected": isSelected ? 'true' : 'false',
|
|
86
|
+
tabIndex: isSelected ? 0 : -1,
|
|
87
|
+
onKeyDown: e => this.handleKeyDown(e, key, panel.closable)
|
|
88
|
+
}, events, {
|
|
89
|
+
className: className,
|
|
90
|
+
key: this._getItemKey(key)
|
|
91
|
+
}), panelIcon, panel.tab, closableIcon);
|
|
71
92
|
};
|
|
72
93
|
|
|
73
94
|
this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
|
|
@@ -82,7 +103,7 @@ class TabBar extends React.Component {
|
|
|
82
103
|
const key = this._getItemKey(lastItem.itemKey); // eslint-disable-next-line max-len
|
|
83
104
|
|
|
84
105
|
|
|
85
|
-
const tabItem = document.querySelector("[data-uuid=\"".concat(this.uuid, "\"] .").concat(cssClasses.TABS_TAB, "[data-scrollkey=\"").concat(key, "\"]"));
|
|
106
|
+
const tabItem = document.querySelector("[data-uuid=\"".concat(this.state.uuid, "\"] .").concat(cssClasses.TABS_TAB, "[data-scrollkey=\"").concat(key, "\"]"));
|
|
86
107
|
tabItem.scrollIntoView({
|
|
87
108
|
behavior: 'smooth',
|
|
88
109
|
block: 'nearest',
|
|
@@ -184,9 +205,15 @@ class TabBar extends React.Component {
|
|
|
184
205
|
this.state = {
|
|
185
206
|
endInd: props.list.length,
|
|
186
207
|
rePosKey: 0,
|
|
187
|
-
startInd: 0
|
|
208
|
+
startInd: 0,
|
|
209
|
+
uuid: ''
|
|
188
210
|
};
|
|
189
|
-
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
componentDidMount() {
|
|
214
|
+
this.setState({
|
|
215
|
+
uuid: getUuidv4()
|
|
216
|
+
});
|
|
190
217
|
}
|
|
191
218
|
|
|
192
219
|
renderIcon(icon) {
|
|
@@ -248,7 +275,7 @@ class TabBar extends React.Component {
|
|
|
248
275
|
className: classNames,
|
|
249
276
|
style: style
|
|
250
277
|
}, getDataAttr(restProps), {
|
|
251
|
-
"data-uuid": this.uuid
|
|
278
|
+
"data-uuid": this.state.uuid
|
|
252
279
|
}), contents, extra);
|
|
253
280
|
}
|
|
254
281
|
|
package/lib/es/tabs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MouseEvent, ReactElement, ReactNode, RefCallback, RefObject } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import TabsFoundation, { TabsAdapter } from '@douyinfe/semi-foundation/lib/es/tabs/foundation';
|
|
4
4
|
import BaseComponent from '../_base/baseComponent';
|
|
@@ -14,7 +14,6 @@ export interface TabsState {
|
|
|
14
14
|
}
|
|
15
15
|
declare class Tabs extends BaseComponent<TabsProps, TabsState> {
|
|
16
16
|
static TabPane: typeof TabPane;
|
|
17
|
-
static TabItem: React.ForwardRefExoticComponent<import("./TabItem").TabItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
17
|
static propTypes: {
|
|
19
18
|
activeKey: PropTypes.Requireable<string>;
|
|
20
19
|
className: PropTypes.Requireable<string>;
|
package/lib/es/tabs/index.js
CHANGED
|
@@ -23,7 +23,6 @@ import BaseComponent from '../_base/baseComponent';
|
|
|
23
23
|
import '@douyinfe/semi-foundation/lib/es/tabs/tabs.css';
|
|
24
24
|
import TabBar from './TabBar';
|
|
25
25
|
import TabPane from './TabPane';
|
|
26
|
-
import TabItem from './TabItem';
|
|
27
26
|
import TabsContext from './tabs-context';
|
|
28
27
|
const panePickKeys = ['className', 'style', 'disabled', 'itemKey', 'tab', 'icon'];
|
|
29
28
|
export * from './interface';
|
|
@@ -336,7 +335,6 @@ class Tabs extends BaseComponent {
|
|
|
336
335
|
}
|
|
337
336
|
|
|
338
337
|
Tabs.TabPane = TabPane;
|
|
339
|
-
Tabs.TabItem = TabItem;
|
|
340
338
|
Tabs.propTypes = {
|
|
341
339
|
activeKey: PropTypes.string,
|
|
342
340
|
className: PropTypes.string,
|
|
@@ -92,7 +92,7 @@ declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
92
92
|
onAdd: PropTypes.Requireable<(...args: any[]) => any>;
|
|
93
93
|
onRemove: PropTypes.Requireable<(...args: any[]) => any>;
|
|
94
94
|
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
95
|
-
size: PropTypes.Requireable<"
|
|
95
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
96
96
|
validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
|
|
97
97
|
prefix: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
98
98
|
suffix: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
@@ -130,7 +130,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
130
130
|
secondStep: PropTypes.Requireable<number>;
|
|
131
131
|
focusOnOpen: PropTypes.Requireable<boolean>;
|
|
132
132
|
autoFocus: PropTypes.Requireable<boolean>;
|
|
133
|
-
size: PropTypes.Requireable<"
|
|
133
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
134
134
|
panels: PropTypes.Requireable<PropTypes.InferProps<{
|
|
135
135
|
panelHeader: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
136
136
|
panelFooter: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
@@ -48,7 +48,7 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
|
|
|
48
48
|
secondStep: import("prop-types").Requireable<number>;
|
|
49
49
|
focusOnOpen: import("prop-types").Requireable<boolean>;
|
|
50
50
|
autoFocus: import("prop-types").Requireable<boolean>;
|
|
51
|
-
size: import("prop-types").Requireable<"
|
|
51
|
+
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
52
52
|
panels: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
53
53
|
panelHeader: import("prop-types").Requireable<NonNullable<import("prop-types").ReactNodeLike>>;
|
|
54
54
|
panelFooter: import("prop-types").Requireable<NonNullable<import("prop-types").ReactNodeLike>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.27.0-
|
|
3
|
+
"version": "2.27.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.27.0-
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.27.0-
|
|
22
|
-
"@douyinfe/semi-foundation": "2.27.0-
|
|
23
|
-
"@douyinfe/semi-icons": "2.27.0-
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.27.0-
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.27.0-
|
|
20
|
+
"@douyinfe/semi-animation": "2.27.0-beta.0",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.27.0-beta.0",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.27.0-beta.0",
|
|
23
|
+
"@douyinfe/semi-icons": "2.27.0-beta.0",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.27.0-beta.0",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.27.0-beta.0",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "fa59dd4e1bce1f81bb2d8cce4118a26354476c91",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, MouseEvent } from 'react';
|
|
2
|
-
import { TabType, TabSize, TabPosition } from './interface';
|
|
3
|
-
export interface TabItemProps {
|
|
4
|
-
tab?: ReactNode;
|
|
5
|
-
icon?: ReactNode;
|
|
6
|
-
size?: TabSize;
|
|
7
|
-
type?: TabType;
|
|
8
|
-
tabPosition?: TabPosition;
|
|
9
|
-
selected?: boolean;
|
|
10
|
-
closable?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
itemKey?: string;
|
|
13
|
-
handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
|
|
14
|
-
deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
|
|
15
|
-
onClick?: (itemKey: string, e: MouseEvent<Element>) => void;
|
|
16
|
-
}
|
|
17
|
-
declare const ForwardTabItem: React.ForwardRefExoticComponent<TabItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
-
export default ForwardTabItem;
|
package/lib/cjs/tabs/TabItem.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
|
|
12
|
-
var _constants = require("@douyinfe/semi-foundation/lib/cjs/tabs/constants");
|
|
13
|
-
|
|
14
|
-
var _semiIcons = require("@douyinfe/semi-icons");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
23
|
-
var t = {};
|
|
24
|
-
|
|
25
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
26
|
-
|
|
27
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
29
|
-
}
|
|
30
|
-
return t;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const TabItem = (props, ref) => {
|
|
34
|
-
const {
|
|
35
|
-
tab,
|
|
36
|
-
size,
|
|
37
|
-
type,
|
|
38
|
-
icon,
|
|
39
|
-
selected,
|
|
40
|
-
closable,
|
|
41
|
-
disabled,
|
|
42
|
-
itemKey,
|
|
43
|
-
deleteTabItem,
|
|
44
|
-
tabPosition,
|
|
45
|
-
handleKeyDown,
|
|
46
|
-
onClick
|
|
47
|
-
} = props,
|
|
48
|
-
resetProps = __rest(props, ["tab", "size", "type", "icon", "selected", "closable", "disabled", "itemKey", "deleteTabItem", "tabPosition", "handleKeyDown", "onClick"]);
|
|
49
|
-
|
|
50
|
-
const closableIcon = (0, _react.useMemo)(() => {
|
|
51
|
-
return type === 'card' && closable ? /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, {
|
|
52
|
-
"aria-label": "Close",
|
|
53
|
-
role: "button",
|
|
54
|
-
className: "".concat(_constants.cssClasses.TABS_TAB, "-icon-close"),
|
|
55
|
-
onClick: e => deleteTabItem(itemKey, e)
|
|
56
|
-
}) : null;
|
|
57
|
-
}, [type, closable, deleteTabItem, itemKey]);
|
|
58
|
-
const renderIcon = (0, _react.useCallback)(icon => /*#__PURE__*/_react.default.createElement("span", null, icon), []);
|
|
59
|
-
const handleKeyDownInItem = (0, _react.useCallback)(event => {
|
|
60
|
-
handleKeyDown && handleKeyDown(event, itemKey, closable);
|
|
61
|
-
}, [handleKeyDown, itemKey, closable]);
|
|
62
|
-
const handleItemClick = (0, _react.useCallback)(e => {
|
|
63
|
-
!disabled && onClick && onClick(itemKey, e);
|
|
64
|
-
}, [itemKey, disabled, onClick]);
|
|
65
|
-
const panelIcon = icon ? renderIcon(icon) : null;
|
|
66
|
-
const className = (0, _classnames.default)(_constants.cssClasses.TABS_TAB, "".concat(_constants.cssClasses.TABS_TAB, "-").concat(type), "".concat(_constants.cssClasses.TABS_TAB, "-").concat(tabPosition), "".concat(_constants.cssClasses.TABS_TAB, "-single"), {
|
|
67
|
-
[_constants.cssClasses.TABS_TAB_ACTIVE]: selected,
|
|
68
|
-
[_constants.cssClasses.TABS_TAB_DISABLED]: disabled,
|
|
69
|
-
["".concat(_constants.cssClasses.TABS_TAB, "-small")]: size === 'small',
|
|
70
|
-
["".concat(_constants.cssClasses.TABS_TAB, "-medium")]: size === 'medium'
|
|
71
|
-
});
|
|
72
|
-
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
73
|
-
role: "tab",
|
|
74
|
-
id: "semiTab".concat(itemKey),
|
|
75
|
-
"data-tabkey": "semiTab".concat(itemKey),
|
|
76
|
-
"aria-controls": "semiTabPanel".concat(itemKey),
|
|
77
|
-
"aria-disabled": disabled ? 'true' : 'false',
|
|
78
|
-
"aria-selected": selected ? 'true' : 'false',
|
|
79
|
-
tabIndex: selected ? 0 : -1,
|
|
80
|
-
onKeyDown: handleKeyDownInItem,
|
|
81
|
-
onClick: handleItemClick,
|
|
82
|
-
className: className
|
|
83
|
-
}, resetProps, {
|
|
84
|
-
ref: ref
|
|
85
|
-
}), panelIcon, tab, closableIcon);
|
|
86
|
-
}; // Why is forwardRef needed here?
|
|
87
|
-
// Because TabItem needs to be used in OverflowList (when tabs' type is collapsible),
|
|
88
|
-
// OverflowList will pass ref to the outermost div DOM node of TabItem
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const ForwardTabItem = /*#__PURE__*/(0, _react.forwardRef)(TabItem); // @ts-ignore
|
|
92
|
-
|
|
93
|
-
ForwardTabItem.elementType = 'TabItem';
|
|
94
|
-
var _default = ForwardTabItem;
|
|
95
|
-
exports.default = _default;
|
package/lib/es/tabs/TabItem.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, MouseEvent } from 'react';
|
|
2
|
-
import { TabType, TabSize, TabPosition } from './interface';
|
|
3
|
-
export interface TabItemProps {
|
|
4
|
-
tab?: ReactNode;
|
|
5
|
-
icon?: ReactNode;
|
|
6
|
-
size?: TabSize;
|
|
7
|
-
type?: TabType;
|
|
8
|
-
tabPosition?: TabPosition;
|
|
9
|
-
selected?: boolean;
|
|
10
|
-
closable?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
itemKey?: string;
|
|
13
|
-
handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
|
|
14
|
-
deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
|
|
15
|
-
onClick?: (itemKey: string, e: MouseEvent<Element>) => void;
|
|
16
|
-
}
|
|
17
|
-
declare const ForwardTabItem: React.ForwardRefExoticComponent<TabItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
-
export default ForwardTabItem;
|
package/lib/es/tabs/TabItem.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
5
|
-
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
13
|
-
import cls from 'classnames';
|
|
14
|
-
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/tabs/constants';
|
|
15
|
-
import { IconClose } from '@douyinfe/semi-icons';
|
|
16
|
-
|
|
17
|
-
const TabItem = (props, ref) => {
|
|
18
|
-
const {
|
|
19
|
-
tab,
|
|
20
|
-
size,
|
|
21
|
-
type,
|
|
22
|
-
icon,
|
|
23
|
-
selected,
|
|
24
|
-
closable,
|
|
25
|
-
disabled,
|
|
26
|
-
itemKey,
|
|
27
|
-
deleteTabItem,
|
|
28
|
-
tabPosition,
|
|
29
|
-
handleKeyDown,
|
|
30
|
-
onClick
|
|
31
|
-
} = props,
|
|
32
|
-
resetProps = __rest(props, ["tab", "size", "type", "icon", "selected", "closable", "disabled", "itemKey", "deleteTabItem", "tabPosition", "handleKeyDown", "onClick"]);
|
|
33
|
-
|
|
34
|
-
const closableIcon = useMemo(() => {
|
|
35
|
-
return type === 'card' && closable ? /*#__PURE__*/React.createElement(IconClose, {
|
|
36
|
-
"aria-label": "Close",
|
|
37
|
-
role: "button",
|
|
38
|
-
className: "".concat(cssClasses.TABS_TAB, "-icon-close"),
|
|
39
|
-
onClick: e => deleteTabItem(itemKey, e)
|
|
40
|
-
}) : null;
|
|
41
|
-
}, [type, closable, deleteTabItem, itemKey]);
|
|
42
|
-
const renderIcon = useCallback(icon => /*#__PURE__*/React.createElement("span", null, icon), []);
|
|
43
|
-
const handleKeyDownInItem = useCallback(event => {
|
|
44
|
-
handleKeyDown && handleKeyDown(event, itemKey, closable);
|
|
45
|
-
}, [handleKeyDown, itemKey, closable]);
|
|
46
|
-
const handleItemClick = useCallback(e => {
|
|
47
|
-
!disabled && onClick && onClick(itemKey, e);
|
|
48
|
-
}, [itemKey, disabled, onClick]);
|
|
49
|
-
const panelIcon = icon ? renderIcon(icon) : null;
|
|
50
|
-
const className = cls(cssClasses.TABS_TAB, "".concat(cssClasses.TABS_TAB, "-").concat(type), "".concat(cssClasses.TABS_TAB, "-").concat(tabPosition), "".concat(cssClasses.TABS_TAB, "-single"), {
|
|
51
|
-
[cssClasses.TABS_TAB_ACTIVE]: selected,
|
|
52
|
-
[cssClasses.TABS_TAB_DISABLED]: disabled,
|
|
53
|
-
["".concat(cssClasses.TABS_TAB, "-small")]: size === 'small',
|
|
54
|
-
["".concat(cssClasses.TABS_TAB, "-medium")]: size === 'medium'
|
|
55
|
-
});
|
|
56
|
-
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
57
|
-
role: "tab",
|
|
58
|
-
id: "semiTab".concat(itemKey),
|
|
59
|
-
"data-tabkey": "semiTab".concat(itemKey),
|
|
60
|
-
"aria-controls": "semiTabPanel".concat(itemKey),
|
|
61
|
-
"aria-disabled": disabled ? 'true' : 'false',
|
|
62
|
-
"aria-selected": selected ? 'true' : 'false',
|
|
63
|
-
tabIndex: selected ? 0 : -1,
|
|
64
|
-
onKeyDown: handleKeyDownInItem,
|
|
65
|
-
onClick: handleItemClick,
|
|
66
|
-
className: className
|
|
67
|
-
}, resetProps, {
|
|
68
|
-
ref: ref
|
|
69
|
-
}), panelIcon, tab, closableIcon);
|
|
70
|
-
}; // Why is forwardRef needed here?
|
|
71
|
-
// Because TabItem needs to be used in OverflowList (when tabs' type is collapsible),
|
|
72
|
-
// OverflowList will pass ref to the outermost div DOM node of TabItem
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const ForwardTabItem = /*#__PURE__*/forwardRef(TabItem); // @ts-ignore
|
|
76
|
-
|
|
77
|
-
ForwardTabItem.elementType = 'TabItem';
|
|
78
|
-
export default ForwardTabItem;
|