@douyinfe/semi-ui 2.26.0 → 2.27.0-alpha.1
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 +207 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +292 -232
- 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.js +17 -37
- package/lib/cjs/tabs/TabItem.d.ts +18 -0
- package/lib/cjs/tabs/TabItem.js +95 -0
- package/lib/cjs/tabs/index.d.ts +2 -1
- package/lib/cjs/tabs/index.js +3 -0
- 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.js +17 -38
- package/lib/es/tabs/TabItem.d.ts +18 -0
- package/lib/es/tabs/TabItem.js +78 -0
- package/lib/es/tabs/index.d.ts +2 -1
- package/lib/es/tabs/index.js +2 -0
- 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/es/tabs/TabBar.js
CHANGED
|
@@ -19,8 +19,9 @@ 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
|
|
22
|
+
import { IconChevronRight, IconChevronLeft } from '@douyinfe/semi-icons';
|
|
23
23
|
import { getUuidv4 } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
|
|
24
|
+
import TabItem from './TabItem';
|
|
24
25
|
|
|
25
26
|
class TabBar extends React.Component {
|
|
26
27
|
constructor(props) {
|
|
@@ -50,45 +51,23 @@ class TabBar extends React.Component {
|
|
|
50
51
|
const {
|
|
51
52
|
size,
|
|
52
53
|
type,
|
|
53
|
-
deleteTabItem
|
|
54
|
+
deleteTabItem,
|
|
55
|
+
handleKeyDown,
|
|
56
|
+
tabPosition
|
|
54
57
|
} = 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
|
-
}
|
|
70
|
-
|
|
71
|
-
const isSelected = this._isActive(key);
|
|
72
58
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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);
|
|
59
|
+
const isSelected = this._isActive(panel.itemKey);
|
|
60
|
+
|
|
61
|
+
return /*#__PURE__*/React.createElement(TabItem, Object.assign({}, panel, {
|
|
62
|
+
key: this._getItemKey(panel.itemKey),
|
|
63
|
+
selected: isSelected,
|
|
64
|
+
size: size,
|
|
65
|
+
type: type,
|
|
66
|
+
tabPosition: tabPosition,
|
|
67
|
+
handleKeyDown: handleKeyDown,
|
|
68
|
+
deleteTabItem: deleteTabItem,
|
|
69
|
+
onClick: this.handleItemClick
|
|
70
|
+
}));
|
|
92
71
|
};
|
|
93
72
|
|
|
94
73
|
this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,78 @@
|
|
|
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;
|
package/lib/es/tabs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MouseEvent, ReactElement, ReactNode, RefCallback, RefObject } from 'react';
|
|
1
|
+
import React, { 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,6 +14,7 @@ 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>>;
|
|
17
18
|
static propTypes: {
|
|
18
19
|
activeKey: PropTypes.Requireable<string>;
|
|
19
20
|
className: PropTypes.Requireable<string>;
|
package/lib/es/tabs/index.js
CHANGED
|
@@ -23,6 +23,7 @@ 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';
|
|
26
27
|
import TabsContext from './tabs-context';
|
|
27
28
|
const panePickKeys = ['className', 'style', 'disabled', 'itemKey', 'tab', 'icon'];
|
|
28
29
|
export * from './interface';
|
|
@@ -335,6 +336,7 @@ class Tabs extends BaseComponent {
|
|
|
335
336
|
}
|
|
336
337
|
|
|
337
338
|
Tabs.TabPane = TabPane;
|
|
339
|
+
Tabs.TabItem = TabItem;
|
|
338
340
|
Tabs.propTypes = {
|
|
339
341
|
activeKey: PropTypes.string,
|
|
340
342
|
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<"small" | "default" | "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<"small" | "default" | "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<"small" | "default" | "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.
|
|
3
|
+
"version": "2.27.0-alpha.1",
|
|
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.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.
|
|
23
|
-
"@douyinfe/semi-icons": "2.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.
|
|
20
|
+
"@douyinfe/semi-animation": "2.27.0-alpha.1",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.27.0-alpha.1",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.27.0-alpha.1",
|
|
23
|
+
"@douyinfe/semi-icons": "2.27.0-alpha.1",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.27.0-alpha.1",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.27.0-alpha.1",
|
|
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": "45aa538331cc89a4e1e75f9c8ac9e4dcf59eeb3a",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|