@douyinfe/semi-ui 2.54.1 → 2.55.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 +40 -40
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +111 -93
- 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/_base/base.css +40 -40
- package/lib/cjs/_sortable/index.d.ts +1 -1
- package/lib/cjs/_sortable/index.js +13 -19
- package/lib/cjs/button/splitButtonGroup.d.ts +2 -0
- package/lib/cjs/button/splitButtonGroup.js +29 -3
- package/lib/cjs/descriptions/index.js +19 -2
- package/lib/cjs/descriptions/item.js +1 -1
- package/lib/cjs/navigation/index.d.ts +2 -1
- package/lib/cjs/tabs/index.d.ts +1 -0
- package/lib/cjs/tabs/index.js +31 -54
- package/lib/es/_base/base.css +40 -40
- package/lib/es/_sortable/index.d.ts +1 -1
- package/lib/es/_sortable/index.js +13 -19
- package/lib/es/button/splitButtonGroup.d.ts +2 -0
- package/lib/es/button/splitButtonGroup.js +29 -3
- package/lib/es/descriptions/index.js +17 -2
- package/lib/es/descriptions/item.js +1 -1
- package/lib/es/navigation/index.d.ts +2 -1
- package/lib/es/tabs/index.d.ts +1 -0
- package/lib/es/tabs/index.js +31 -54
- package/package.json +8 -8
|
@@ -9,16 +9,42 @@ export default class SplitButtonGroup extends BaseComponent {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
this.containerRef = /*#__PURE__*/React.createRef();
|
|
12
|
+
this.mutationObserver = null;
|
|
12
13
|
}
|
|
13
14
|
componentDidMount() {
|
|
14
|
-
|
|
15
|
+
const addClassName = () => {
|
|
15
16
|
const buttons = this.containerRef.current.querySelectorAll('button');
|
|
16
17
|
const firstButton = buttons[0];
|
|
17
18
|
const lastButton = buttons[buttons.length - 1];
|
|
18
|
-
firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.
|
|
19
|
-
|
|
19
|
+
if (!(firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.contains(`${prefixCls}-first`))) {
|
|
20
|
+
firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.add(`${prefixCls}-first`);
|
|
21
|
+
}
|
|
22
|
+
if (!(lastButton === null || lastButton === void 0 ? void 0 : lastButton.classList.contains(`${prefixCls}-last`))) {
|
|
23
|
+
lastButton === null || lastButton === void 0 ? void 0 : lastButton.classList.add(`${prefixCls}-last`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
if (this.containerRef.current) {
|
|
27
|
+
addClassName();
|
|
28
|
+
const mutationObserver = new MutationObserver((mutations, observer) => {
|
|
29
|
+
for (const mutation of mutations) {
|
|
30
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class' || mutation.type === 'childList' && Array.from(mutation.addedNodes).some(node => node.nodeName === 'BUTTON')) {
|
|
31
|
+
addClassName();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
mutationObserver.observe(this.containerRef.current, {
|
|
36
|
+
attributes: true,
|
|
37
|
+
childList: true,
|
|
38
|
+
subtree: true
|
|
39
|
+
});
|
|
40
|
+
this.mutationObserver = mutationObserver;
|
|
20
41
|
}
|
|
21
42
|
}
|
|
43
|
+
componentWillUnmount() {
|
|
44
|
+
var _a;
|
|
45
|
+
super.componentWillUnmount();
|
|
46
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
47
|
+
}
|
|
22
48
|
render() {
|
|
23
49
|
const {
|
|
24
50
|
children,
|
|
@@ -7,7 +7,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
7
7
|
}
|
|
8
8
|
return t;
|
|
9
9
|
};
|
|
10
|
-
import React from 'react';
|
|
10
|
+
import React, { isValidElement } from 'react';
|
|
11
11
|
import cls from 'classnames';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import { strings, cssClasses } from '@douyinfe/semi-foundation/lib/es/descriptions/constants';
|
|
@@ -50,7 +50,22 @@ class Descriptions extends BaseComponent {
|
|
|
50
50
|
this.foundation = new DescriptionsFoundation(this.adapter);
|
|
51
51
|
}
|
|
52
52
|
get adapter() {
|
|
53
|
-
return Object.assign({}, super.adapter)
|
|
53
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
54
|
+
getColumns: () => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if ((_a = this.props.data) === null || _a === void 0 ? void 0 : _a.length) {
|
|
57
|
+
return this.props.data;
|
|
58
|
+
}
|
|
59
|
+
if (this.props.children) {
|
|
60
|
+
return (_b = React.Children.toArray(this.props.children)) === null || _b === void 0 ? void 0 : _b.map(item => {
|
|
61
|
+
return /*#__PURE__*/isValidElement(item) ? Object.assign({
|
|
62
|
+
value: item.props.children
|
|
63
|
+
}, item.props) : [];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
54
69
|
}
|
|
55
70
|
render() {
|
|
56
71
|
const _a = this.props,
|
|
@@ -48,7 +48,7 @@ export default class Item extends PureComponent {
|
|
|
48
48
|
className: keyCls
|
|
49
49
|
}, itemKey)), /*#__PURE__*/React.createElement("td", {
|
|
50
50
|
className: `${prefixCls}-item ${prefixCls}-item-td`,
|
|
51
|
-
colSpan: span
|
|
51
|
+
colSpan: span ? span * 2 - 1 : 1
|
|
52
52
|
}, /*#__PURE__*/React.createElement("span", {
|
|
53
53
|
className: valCls
|
|
54
54
|
}, typeof children === 'function' ? children() : children)));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
2
2
|
import React, { ReactElement, ReactNode } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { NavigationAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/foundation';
|
|
4
|
+
import NavigationFoundation, { NavigationAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/foundation';
|
|
5
5
|
import SubNav, { SubNavProps } from './SubNav';
|
|
6
6
|
import Item, { NavItemProps } from './Item';
|
|
7
7
|
import Footer, { NavFooterProps } from './Footer';
|
|
@@ -122,6 +122,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
|
|
|
122
122
|
static __SemiComponentName__: string;
|
|
123
123
|
static defaultProps: any;
|
|
124
124
|
itemsChanged: boolean;
|
|
125
|
+
foundation: NavigationFoundation;
|
|
125
126
|
constructor(props: NavProps);
|
|
126
127
|
static getDerivedStateFromProps(props: NavProps, state: NavState): Partial<NavState>;
|
|
127
128
|
componentDidMount(): void;
|
package/lib/es/tabs/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ declare class Tabs extends BaseComponent<TabsProps, TabsState> {
|
|
|
48
48
|
static getDerivedStateFromProps(props: TabsProps, state: TabsState): Partial<TabsState>;
|
|
49
49
|
componentDidUpdate(prevProps: TabsProps, prevState: TabsState): void;
|
|
50
50
|
setContentRef: RefCallback<HTMLDivElement>;
|
|
51
|
+
getPanes: () => PlainTab[];
|
|
51
52
|
onTabClick: (activeKey: string, event: MouseEvent<HTMLDivElement>) => void;
|
|
52
53
|
rePosChildren: (children: ReactElement[], activeKey: string) => ReactElement[];
|
|
53
54
|
getActiveItem: () => ReactNode | ReactNode[];
|
package/lib/es/tabs/index.js
CHANGED
|
@@ -31,6 +31,34 @@ class Tabs extends BaseComponent {
|
|
|
31
31
|
current: ref
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
this.getPanes = () => {
|
|
35
|
+
const {
|
|
36
|
+
tabList,
|
|
37
|
+
children
|
|
38
|
+
} = this.props;
|
|
39
|
+
if (Array.isArray(tabList) && tabList.length) {
|
|
40
|
+
return tabList;
|
|
41
|
+
}
|
|
42
|
+
return React.Children.map(children, child => {
|
|
43
|
+
if (child) {
|
|
44
|
+
const {
|
|
45
|
+
tab,
|
|
46
|
+
icon,
|
|
47
|
+
disabled,
|
|
48
|
+
itemKey,
|
|
49
|
+
closable
|
|
50
|
+
} = child.props;
|
|
51
|
+
return {
|
|
52
|
+
tab,
|
|
53
|
+
icon,
|
|
54
|
+
disabled,
|
|
55
|
+
itemKey,
|
|
56
|
+
closable
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
34
62
|
this.onTabClick = (activeKey, event) => {
|
|
35
63
|
this.foundation.handleTabClick(activeKey, event);
|
|
36
64
|
};
|
|
@@ -69,7 +97,7 @@ class Tabs extends BaseComponent {
|
|
|
69
97
|
this.foundation = new TabsFoundation(this.adapter);
|
|
70
98
|
this.state = {
|
|
71
99
|
activeKey: this.foundation.getDefaultActiveKey(),
|
|
72
|
-
panes:
|
|
100
|
+
panes: this.getPanes(),
|
|
73
101
|
prevActiveKey: null,
|
|
74
102
|
forceDisableMotion: false
|
|
75
103
|
};
|
|
@@ -79,41 +107,12 @@ class Tabs extends BaseComponent {
|
|
|
79
107
|
get adapter() {
|
|
80
108
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
81
109
|
collectPane: () => {
|
|
82
|
-
const
|
|
83
|
-
tabList,
|
|
84
|
-
children
|
|
85
|
-
} = this.props;
|
|
86
|
-
if (Array.isArray(tabList) && tabList.length) {
|
|
87
|
-
this.setState({
|
|
88
|
-
panes: tabList
|
|
89
|
-
});
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const panes = React.Children.map(children, child => {
|
|
93
|
-
if (child) {
|
|
94
|
-
const {
|
|
95
|
-
tab,
|
|
96
|
-
icon,
|
|
97
|
-
disabled,
|
|
98
|
-
itemKey,
|
|
99
|
-
closable
|
|
100
|
-
} = child.props;
|
|
101
|
-
return {
|
|
102
|
-
tab,
|
|
103
|
-
icon,
|
|
104
|
-
disabled,
|
|
105
|
-
itemKey,
|
|
106
|
-
closable
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return undefined;
|
|
110
|
-
});
|
|
110
|
+
const panes = this.getPanes();
|
|
111
111
|
this.setState({
|
|
112
112
|
panes
|
|
113
113
|
});
|
|
114
114
|
},
|
|
115
115
|
collectActiveKey: () => {
|
|
116
|
-
let panes = [];
|
|
117
116
|
const {
|
|
118
117
|
tabList,
|
|
119
118
|
children,
|
|
@@ -125,29 +124,7 @@ class Tabs extends BaseComponent {
|
|
|
125
124
|
const {
|
|
126
125
|
activeKey
|
|
127
126
|
} = this.state;
|
|
128
|
-
|
|
129
|
-
panes = tabList;
|
|
130
|
-
} else {
|
|
131
|
-
panes = React.Children.map(children, child => {
|
|
132
|
-
if (child) {
|
|
133
|
-
const {
|
|
134
|
-
tab,
|
|
135
|
-
icon,
|
|
136
|
-
disabled,
|
|
137
|
-
itemKey,
|
|
138
|
-
closable
|
|
139
|
-
} = child.props;
|
|
140
|
-
return {
|
|
141
|
-
tab,
|
|
142
|
-
icon,
|
|
143
|
-
disabled,
|
|
144
|
-
itemKey,
|
|
145
|
-
closable
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
});
|
|
150
|
-
}
|
|
127
|
+
const panes = this.getPanes();
|
|
151
128
|
if (panes.findIndex(p => p.itemKey === activeKey) === -1) {
|
|
152
129
|
if (panes.length > 0) {
|
|
153
130
|
this.setState({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.55.0",
|
|
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.
|
|
24
|
-
"@douyinfe/semi-animation-react": "2.
|
|
25
|
-
"@douyinfe/semi-foundation": "2.
|
|
26
|
-
"@douyinfe/semi-icons": "2.
|
|
27
|
-
"@douyinfe/semi-illustrations": "2.
|
|
28
|
-
"@douyinfe/semi-theme-default": "2.
|
|
23
|
+
"@douyinfe/semi-animation": "2.55.0",
|
|
24
|
+
"@douyinfe/semi-animation-react": "2.55.0",
|
|
25
|
+
"@douyinfe/semi-foundation": "2.55.0",
|
|
26
|
+
"@douyinfe/semi-icons": "2.55.0",
|
|
27
|
+
"@douyinfe/semi-illustrations": "2.55.0",
|
|
28
|
+
"@douyinfe/semi-theme-default": "2.55.0",
|
|
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": "21f02cad422b2d15d9f5d9b7b1ca96b0d21bb545",
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
81
81
|
"@babel/plugin-transform-runtime": "^7.15.8",
|