@douyinfe/semi-ui 2.58.0 → 2.58.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 +23 -20
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +23 -15
- 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/tabs/TabBar.d.ts +3 -0
- package/lib/cjs/tabs/TabBar.js +23 -15
- package/lib/es/tabs/TabBar.d.ts +3 -0
- package/lib/es/tabs/TabBar.js +23 -15
- package/package.json +8 -8
package/lib/cjs/tabs/TabBar.d.ts
CHANGED
|
@@ -30,11 +30,14 @@ declare class TabBar extends React.Component<TabBarProps, TabBarState> {
|
|
|
30
30
|
};
|
|
31
31
|
constructor(props: TabBarProps);
|
|
32
32
|
componentDidMount(): void;
|
|
33
|
+
componentDidUpdate(prevProps: any): void;
|
|
33
34
|
renderIcon(icon: ReactNode): ReactNode;
|
|
34
35
|
renderExtra(): ReactNode;
|
|
35
36
|
handleItemClick: (itemKey: string, e: MouseEvent<Element>) => void;
|
|
36
37
|
handleKeyDown: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
|
|
37
38
|
renderTabItem: (panel: PlainTab) => ReactNode;
|
|
39
|
+
scrollTabItemIntoViewByKey: (key: string, logicalPosition?: ScrollLogicalPosition) => void;
|
|
40
|
+
scrollActiveTabItemIntoView: (logicalPosition?: ScrollLogicalPosition) => void;
|
|
38
41
|
renderTabComponents: (list: Array<PlainTab>) => Array<ReactNode>;
|
|
39
42
|
handleArrowClick: (items: Array<OverflowItem>, pos: 'start' | 'end') => void;
|
|
40
43
|
renderCollapse: (items: Array<OverflowItem>, icon: ReactNode, pos: 'start' | 'end') => ReactNode;
|
package/lib/cjs/tabs/TabBar.js
CHANGED
|
@@ -29,18 +29,11 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
29
29
|
};
|
|
30
30
|
class TabBar extends _react.default.Component {
|
|
31
31
|
constructor(props) {
|
|
32
|
+
var _this;
|
|
32
33
|
super(props);
|
|
34
|
+
_this = this;
|
|
33
35
|
this.handleItemClick = (itemKey, e) => {
|
|
34
36
|
this.props.onTabClick(itemKey, e);
|
|
35
|
-
if (this.props.collapsible) {
|
|
36
|
-
const key = this._getItemKey(itemKey);
|
|
37
|
-
const tabItem = document.querySelector(`[data-uuid="${this.state.uuid}"] .${_constants.cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
|
|
38
|
-
tabItem.scrollIntoView({
|
|
39
|
-
behavior: 'smooth',
|
|
40
|
-
block: 'nearest',
|
|
41
|
-
inline: 'nearest'
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
37
|
};
|
|
45
38
|
this.handleKeyDown = (event, itemKey, closable) => {
|
|
46
39
|
this.props.handleKeyDown(event, itemKey, closable);
|
|
@@ -65,6 +58,19 @@ class TabBar extends _react.default.Component {
|
|
|
65
58
|
onClick: this.handleItemClick
|
|
66
59
|
}));
|
|
67
60
|
};
|
|
61
|
+
this.scrollTabItemIntoViewByKey = function (key) {
|
|
62
|
+
let logicalPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'nearest';
|
|
63
|
+
const tabItem = document.querySelector(`[data-uuid="${_this.state.uuid}"] .${_constants.cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
|
|
64
|
+
tabItem === null || tabItem === void 0 ? void 0 : tabItem.scrollIntoView({
|
|
65
|
+
behavior: 'smooth',
|
|
66
|
+
block: logicalPosition,
|
|
67
|
+
inline: logicalPosition
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
this.scrollActiveTabItemIntoView = logicalPosition => {
|
|
71
|
+
const key = this._getItemKey(this.props.activeKey);
|
|
72
|
+
this.scrollTabItemIntoViewByKey(key, logicalPosition);
|
|
73
|
+
};
|
|
68
74
|
this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
|
|
69
75
|
this.handleArrowClick = (items, pos) => {
|
|
70
76
|
const lastItem = pos === 'start' ? items.pop() : items.shift();
|
|
@@ -72,12 +78,7 @@ class TabBar extends _react.default.Component {
|
|
|
72
78
|
return;
|
|
73
79
|
}
|
|
74
80
|
const key = this._getItemKey(lastItem.itemKey);
|
|
75
|
-
|
|
76
|
-
tabItem.scrollIntoView({
|
|
77
|
-
behavior: 'smooth',
|
|
78
|
-
block: 'nearest',
|
|
79
|
-
inline: 'nearest'
|
|
80
|
-
});
|
|
81
|
+
this.scrollTabItemIntoViewByKey(key);
|
|
81
82
|
};
|
|
82
83
|
this.renderCollapse = (items, icon, pos) => {
|
|
83
84
|
if ((0, _isEmpty2.default)(items)) {
|
|
@@ -227,6 +228,13 @@ class TabBar extends _react.default.Component {
|
|
|
227
228
|
uuid: (0, _uuid.getUuidv4)()
|
|
228
229
|
});
|
|
229
230
|
}
|
|
231
|
+
componentDidUpdate(prevProps) {
|
|
232
|
+
if (prevProps.activeKey !== this.props.activeKey) {
|
|
233
|
+
if (this.props.collapsible) {
|
|
234
|
+
this.scrollActiveTabItemIntoView();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
230
238
|
renderIcon(icon) {
|
|
231
239
|
return /*#__PURE__*/_react.default.createElement("span", null, icon);
|
|
232
240
|
}
|
package/lib/es/tabs/TabBar.d.ts
CHANGED
|
@@ -30,11 +30,14 @@ declare class TabBar extends React.Component<TabBarProps, TabBarState> {
|
|
|
30
30
|
};
|
|
31
31
|
constructor(props: TabBarProps);
|
|
32
32
|
componentDidMount(): void;
|
|
33
|
+
componentDidUpdate(prevProps: any): void;
|
|
33
34
|
renderIcon(icon: ReactNode): ReactNode;
|
|
34
35
|
renderExtra(): ReactNode;
|
|
35
36
|
handleItemClick: (itemKey: string, e: MouseEvent<Element>) => void;
|
|
36
37
|
handleKeyDown: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
|
|
37
38
|
renderTabItem: (panel: PlainTab) => ReactNode;
|
|
39
|
+
scrollTabItemIntoViewByKey: (key: string, logicalPosition?: ScrollLogicalPosition) => void;
|
|
40
|
+
scrollActiveTabItemIntoView: (logicalPosition?: ScrollLogicalPosition) => void;
|
|
38
41
|
renderTabComponents: (list: Array<PlainTab>) => Array<ReactNode>;
|
|
39
42
|
handleArrowClick: (items: Array<OverflowItem>, pos: 'start' | 'end') => void;
|
|
40
43
|
renderCollapse: (items: Array<OverflowItem>, icon: ReactNode, pos: 'start' | 'end') => ReactNode;
|
package/lib/es/tabs/TabBar.js
CHANGED
|
@@ -22,18 +22,11 @@ import TabItem from './TabItem';
|
|
|
22
22
|
import LocaleConsumer from "../locale/localeConsumer";
|
|
23
23
|
class TabBar extends React.Component {
|
|
24
24
|
constructor(props) {
|
|
25
|
+
var _this;
|
|
25
26
|
super(props);
|
|
27
|
+
_this = this;
|
|
26
28
|
this.handleItemClick = (itemKey, e) => {
|
|
27
29
|
this.props.onTabClick(itemKey, e);
|
|
28
|
-
if (this.props.collapsible) {
|
|
29
|
-
const key = this._getItemKey(itemKey);
|
|
30
|
-
const tabItem = document.querySelector(`[data-uuid="${this.state.uuid}"] .${cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
|
|
31
|
-
tabItem.scrollIntoView({
|
|
32
|
-
behavior: 'smooth',
|
|
33
|
-
block: 'nearest',
|
|
34
|
-
inline: 'nearest'
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
30
|
};
|
|
38
31
|
this.handleKeyDown = (event, itemKey, closable) => {
|
|
39
32
|
this.props.handleKeyDown(event, itemKey, closable);
|
|
@@ -58,6 +51,19 @@ class TabBar extends React.Component {
|
|
|
58
51
|
onClick: this.handleItemClick
|
|
59
52
|
}));
|
|
60
53
|
};
|
|
54
|
+
this.scrollTabItemIntoViewByKey = function (key) {
|
|
55
|
+
let logicalPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'nearest';
|
|
56
|
+
const tabItem = document.querySelector(`[data-uuid="${_this.state.uuid}"] .${cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
|
|
57
|
+
tabItem === null || tabItem === void 0 ? void 0 : tabItem.scrollIntoView({
|
|
58
|
+
behavior: 'smooth',
|
|
59
|
+
block: logicalPosition,
|
|
60
|
+
inline: logicalPosition
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
this.scrollActiveTabItemIntoView = logicalPosition => {
|
|
64
|
+
const key = this._getItemKey(this.props.activeKey);
|
|
65
|
+
this.scrollTabItemIntoViewByKey(key, logicalPosition);
|
|
66
|
+
};
|
|
61
67
|
this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
|
|
62
68
|
this.handleArrowClick = (items, pos) => {
|
|
63
69
|
const lastItem = pos === 'start' ? items.pop() : items.shift();
|
|
@@ -65,12 +71,7 @@ class TabBar extends React.Component {
|
|
|
65
71
|
return;
|
|
66
72
|
}
|
|
67
73
|
const key = this._getItemKey(lastItem.itemKey);
|
|
68
|
-
|
|
69
|
-
tabItem.scrollIntoView({
|
|
70
|
-
behavior: 'smooth',
|
|
71
|
-
block: 'nearest',
|
|
72
|
-
inline: 'nearest'
|
|
73
|
-
});
|
|
74
|
+
this.scrollTabItemIntoViewByKey(key);
|
|
74
75
|
};
|
|
75
76
|
this.renderCollapse = (items, icon, pos) => {
|
|
76
77
|
if (_isEmpty(items)) {
|
|
@@ -220,6 +221,13 @@ class TabBar extends React.Component {
|
|
|
220
221
|
uuid: getUuidv4()
|
|
221
222
|
});
|
|
222
223
|
}
|
|
224
|
+
componentDidUpdate(prevProps) {
|
|
225
|
+
if (prevProps.activeKey !== this.props.activeKey) {
|
|
226
|
+
if (this.props.collapsible) {
|
|
227
|
+
this.scrollActiveTabItemIntoView();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
223
231
|
renderIcon(icon) {
|
|
224
232
|
return /*#__PURE__*/React.createElement("span", null, icon);
|
|
225
233
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.58.
|
|
3
|
+
"version": "2.58.1",
|
|
4
4
|
"description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"@dnd-kit/core": "^6.0.8",
|
|
21
21
|
"@dnd-kit/sortable": "^7.0.2",
|
|
22
22
|
"@dnd-kit/utilities": "^3.2.1",
|
|
23
|
-
"@douyinfe/semi-animation": "2.58.
|
|
24
|
-
"@douyinfe/semi-animation-react": "2.58.
|
|
25
|
-
"@douyinfe/semi-foundation": "2.58.
|
|
26
|
-
"@douyinfe/semi-icons": "2.58.
|
|
27
|
-
"@douyinfe/semi-illustrations": "2.58.
|
|
28
|
-
"@douyinfe/semi-theme-default": "2.58.
|
|
23
|
+
"@douyinfe/semi-animation": "2.58.1",
|
|
24
|
+
"@douyinfe/semi-animation-react": "2.58.1",
|
|
25
|
+
"@douyinfe/semi-foundation": "2.58.1",
|
|
26
|
+
"@douyinfe/semi-icons": "2.58.1",
|
|
27
|
+
"@douyinfe/semi-illustrations": "2.58.1",
|
|
28
|
+
"@douyinfe/semi-theme-default": "2.58.1",
|
|
29
29
|
"async-validator": "^3.5.0",
|
|
30
30
|
"classnames": "^2.2.6",
|
|
31
31
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
],
|
|
76
76
|
"author": "",
|
|
77
77
|
"license": "MIT",
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "1e48bf7b71e78f49b188ff82c5ab61884a6ec0ab",
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
81
81
|
"@babel/plugin-transform-runtime": "^7.15.8",
|