@douyinfe/semi-ui 2.27.0-alpha.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/umd/semi-ui.js +67 -123
- 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/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/cascader/index.d.ts +1 -1
- package/lib/cjs/cascader/item.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/popover/index.d.ts +1 -1
- package/lib/cjs/tabs/TabBar.d.ts +0 -1
- package/lib/cjs/tabs/TabBar.js +3 -49
- package/lib/cjs/tabs/TabItem.d.ts +2 -22
- package/lib/cjs/tabs/TabItem.js +70 -79
- package/lib/cjs/tabs/index.d.ts +2 -3
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/cascader/index.d.ts +1 -1
- package/lib/es/cascader/item.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/popover/index.d.ts +1 -1
- package/lib/es/tabs/TabBar.d.ts +0 -1
- package/lib/es/tabs/TabBar.js +4 -50
- package/lib/es/tabs/TabItem.d.ts +2 -22
- package/lib/es/tabs/TabItem.js +67 -77
- package/lib/es/tabs/index.d.ts +2 -3
- package/lib/es/tooltip/index.d.ts +1 -1
- package/package.json +8 -8
package/lib/es/tabs/TabItem.js
CHANGED
|
@@ -1,88 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import cls from 'classnames';
|
|
4
|
-
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/tabs/constants';
|
|
5
|
-
import { IconClose } from '@douyinfe/semi-icons';
|
|
6
|
-
export default class TabItem extends React.Component {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
9
3
|
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
itemKey,
|
|
13
|
-
closable,
|
|
14
|
-
handleKeyDown
|
|
15
|
-
} = this.props;
|
|
16
|
-
handleKeyDown && handleKeyDown(event, itemKey, closable);
|
|
17
|
-
};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
18
5
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
itemKey,
|
|
22
|
-
onClick,
|
|
23
|
-
disabled
|
|
24
|
-
} = this.props;
|
|
25
|
-
!disabled && onClick && onClick(itemKey, e);
|
|
26
|
-
};
|
|
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]];
|
|
27
8
|
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
28
11
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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';
|
|
32
16
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
const closableIcon = type === 'card' && closable ? /*#__PURE__*/React.createElement(IconClose, {
|
|
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, {
|
|
54
36
|
"aria-label": "Close",
|
|
55
37
|
role: "button",
|
|
56
38
|
className: "".concat(cssClasses.TABS_TAB, "-icon-close"),
|
|
57
39
|
onClick: e => deleteTabItem(itemKey, e)
|
|
58
40
|
}) : null;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
type: PropTypes.oneOf(strings.TYPE_MAP),
|
|
79
|
-
tabPosition: PropTypes.oneOf(strings.POSITION_MAP),
|
|
80
|
-
selected: PropTypes.bool,
|
|
81
|
-
closable: PropTypes.bool,
|
|
82
|
-
disabled: PropTypes.bool,
|
|
83
|
-
itemKey: PropTypes.string,
|
|
84
|
-
handleKeyDown: PropTypes.func,
|
|
85
|
-
deleteTabItem: PropTypes.func,
|
|
86
|
-
onClick: PropTypes.func
|
|
87
|
-
};
|
|
88
|
-
TabItem.elementType = 'TabItem';
|
|
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,10 +1,9 @@
|
|
|
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';
|
|
5
5
|
import '@douyinfe/semi-foundation/lib/es/tabs/tabs.css';
|
|
6
6
|
import TabPane from './TabPane';
|
|
7
|
-
import TabItem from './TabItem';
|
|
8
7
|
import { PlainTab, TabsProps } from './interface';
|
|
9
8
|
export * from './interface';
|
|
10
9
|
export interface TabsState {
|
|
@@ -15,7 +14,7 @@ export interface TabsState {
|
|
|
15
14
|
}
|
|
16
15
|
declare class Tabs extends BaseComponent<TabsProps, TabsState> {
|
|
17
16
|
static TabPane: typeof TabPane;
|
|
18
|
-
static TabItem:
|
|
17
|
+
static TabItem: React.ForwardRefExoticComponent<import("./TabItem").TabItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
19
18
|
static propTypes: {
|
|
20
19
|
activeKey: PropTypes.Requireable<string>;
|
|
21
20
|
className: PropTypes.Requireable<string>;
|
|
@@ -90,7 +90,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
90
90
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
91
91
|
mouseEnterDelay: PropTypes.Requireable<number>;
|
|
92
92
|
mouseLeaveDelay: PropTypes.Requireable<number>;
|
|
93
|
-
trigger: PropTypes.Validator<NonNullable<"
|
|
93
|
+
trigger: PropTypes.Validator<NonNullable<"hover" | "focus" | "click" | "custom">>;
|
|
94
94
|
className: PropTypes.Requireable<string>;
|
|
95
95
|
wrapperClassName: PropTypes.Requireable<string>;
|
|
96
96
|
clickToHide: PropTypes.Requireable<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.27.0-alpha.
|
|
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.27.0-alpha.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.27.0-alpha.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.27.0-alpha.
|
|
23
|
-
"@douyinfe/semi-icons": "2.27.0-alpha.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.27.0-alpha.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.27.0-alpha.
|
|
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",
|