@douyinfe/semi-ui 2.54.0 → 2.55.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/umd/semi-ui.js +69 -90
- 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/_sortable/index.d.ts +1 -1
- package/lib/cjs/_sortable/index.js +13 -19
- package/lib/cjs/navigation/index.d.ts +3 -2
- package/lib/cjs/navigation/index.js +17 -11
- package/lib/cjs/tabs/index.d.ts +1 -0
- package/lib/cjs/tabs/index.js +31 -54
- package/lib/es/_sortable/index.d.ts +1 -1
- package/lib/es/_sortable/index.js +13 -19
- package/lib/es/navigation/index.d.ts +3 -2
- package/lib/es/navigation/index.js +17 -11
- package/lib/es/tabs/index.d.ts +1 -0
- package/lib/es/tabs/index.js +31 -54
- package/package.json +8 -8
|
@@ -36,6 +36,6 @@ interface SortableItemProps {
|
|
|
36
36
|
prefix?: string;
|
|
37
37
|
transition?: SortableTransition | null;
|
|
38
38
|
}
|
|
39
|
-
export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition,
|
|
39
|
+
export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition, collisionDetection, strategy, useDragOverlay, dragOverlayCls, container: Container, prefix, }: SortableProps): JSX.Element;
|
|
40
40
|
export declare function SortableItem({ animateLayoutChanges, id, renderItem, prefix, transition: animation, }: SortableItemProps): JSX.Element;
|
|
41
41
|
export {};
|
|
@@ -16,10 +16,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
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; }
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
const defaultPrefix = 'semi-sortable';
|
|
19
|
-
const defaultConstraint = {
|
|
20
|
-
delay: 150,
|
|
21
|
-
tolerance: 5
|
|
22
|
-
};
|
|
23
19
|
function DefaultContainer(props) {
|
|
24
20
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
25
21
|
style: {
|
|
@@ -27,6 +23,9 @@ function DefaultContainer(props) {
|
|
|
27
23
|
}
|
|
28
24
|
}, props));
|
|
29
25
|
}
|
|
26
|
+
const defaultKeyBoardOptions = {
|
|
27
|
+
coordinateGetter: _sortable.sortableKeyboardCoordinates
|
|
28
|
+
};
|
|
30
29
|
function Sortable(_ref) {
|
|
31
30
|
let {
|
|
32
31
|
items,
|
|
@@ -34,7 +33,6 @@ function Sortable(_ref) {
|
|
|
34
33
|
adjustScale,
|
|
35
34
|
renderItem,
|
|
36
35
|
transition,
|
|
37
|
-
activationConstraint = defaultConstraint,
|
|
38
36
|
collisionDetection = _core.closestCenter,
|
|
39
37
|
strategy = _sortable.rectSortingStrategy,
|
|
40
38
|
useDragOverlay = true,
|
|
@@ -43,13 +41,7 @@ function Sortable(_ref) {
|
|
|
43
41
|
prefix = defaultPrefix
|
|
44
42
|
} = _ref;
|
|
45
43
|
const [activeId, setActiveId] = (0, _react.useState)(null);
|
|
46
|
-
const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor,
|
|
47
|
-
activationConstraint
|
|
48
|
-
}), (0, _core.useSensor)(_core.TouchSensor, {
|
|
49
|
-
activationConstraint
|
|
50
|
-
}), (0, _core.useSensor)(_core.KeyboardSensor, {
|
|
51
|
-
coordinateGetter: _sortable.sortableKeyboardCoordinates
|
|
52
|
-
}));
|
|
44
|
+
const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor), (0, _core.useSensor)(_core.TouchSensor), (0, _core.useSensor)(_core.KeyboardSensor, defaultKeyBoardOptions));
|
|
53
45
|
const getIndex = (0, _react.useCallback)(id => items.indexOf(id), [items]);
|
|
54
46
|
const activeIndex = (0, _react.useMemo)(() => activeId ? getIndex(activeId) : -1, [getIndex, activeId]);
|
|
55
47
|
const onDragStart = (0, _react.useCallback)(_ref2 => {
|
|
@@ -159,13 +151,15 @@ function SortableItem(_ref4) {
|
|
|
159
151
|
[`${prefix}-sortable-item-over`]: isOver,
|
|
160
152
|
[`${prefix}-sortable-item-active`]: (active === null || active === void 0 ? void 0 : active.id) === id
|
|
161
153
|
});
|
|
162
|
-
const wrapperStyle =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
154
|
+
const wrapperStyle = (0, _react.useMemo)(() => {
|
|
155
|
+
return !(0, _isNull2.default)(animation) ? {
|
|
156
|
+
transform: _utilities.CSS.Transform.toString(Object.assign(Object.assign({}, transform), {
|
|
157
|
+
scaleX: 1,
|
|
158
|
+
scaleY: 1
|
|
159
|
+
})),
|
|
160
|
+
transition: transition
|
|
161
|
+
} : undefined;
|
|
162
|
+
}, [animation, transform, transition]);
|
|
169
163
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
170
164
|
ref: setNodeRef,
|
|
171
165
|
style: wrapperStyle,
|
|
@@ -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/cjs/navigation/foundation';
|
|
4
|
+
import NavigationFoundation, { NavigationAdapter } from '@douyinfe/semi-foundation/lib/cjs/navigation/foundation';
|
|
5
5
|
import SubNav, { SubNavProps } from './SubNav';
|
|
6
6
|
import Item, { NavItemProps } from './Item';
|
|
7
7
|
import Footer, { NavFooterProps } from './Footer';
|
|
@@ -122,10 +122,11 @@ 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;
|
|
128
|
-
componentDidUpdate(prevProps: NavProps
|
|
129
|
+
componentDidUpdate(prevProps: NavProps): void;
|
|
129
130
|
get adapter(): NavigationAdapter<NavProps, NavState>;
|
|
130
131
|
/**
|
|
131
132
|
* Render navigation items recursively
|
|
@@ -97,24 +97,19 @@ class Nav extends _baseComponent.default {
|
|
|
97
97
|
componentDidMount() {
|
|
98
98
|
// override BaseComponent
|
|
99
99
|
}
|
|
100
|
-
componentDidUpdate(prevProps
|
|
100
|
+
componentDidUpdate(prevProps) {
|
|
101
101
|
if (prevProps.items !== this.props.items || prevProps.children !== this.props.children) {
|
|
102
102
|
this.foundation.init();
|
|
103
103
|
} else {
|
|
104
104
|
this.foundation.handleItemsChange(false);
|
|
105
|
-
const {
|
|
106
|
-
selectedKeys
|
|
107
|
-
} = this.state;
|
|
108
105
|
if (this.props.selectedKeys && !(0, _isEqual2.default)(prevProps.selectedKeys, this.props.selectedKeys)) {
|
|
109
106
|
this.adapter.updateSelectedKeys(this.props.selectedKeys);
|
|
107
|
+
const willOpenKeys = this.foundation.getWillOpenKeys(this.state.itemKeysMap);
|
|
108
|
+
this.adapter.updateOpenKeys(willOpenKeys);
|
|
110
109
|
}
|
|
111
110
|
if (this.props.openKeys && !(0, _isEqual2.default)(prevProps.openKeys, this.props.openKeys)) {
|
|
112
111
|
this.adapter.updateOpenKeys(this.props.openKeys);
|
|
113
112
|
}
|
|
114
|
-
if (!(0, _isEqual2.default)(selectedKeys, prevState.selectedKeys)) {
|
|
115
|
-
const parentSelectKeys = this.foundation.selectLevelZeroParentKeys(null, ...selectedKeys);
|
|
116
|
-
this.adapter.addSelectedKeys(...parentSelectKeys);
|
|
117
|
-
}
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
get adapter() {
|
|
@@ -140,9 +135,20 @@ class Nav extends _baseComponent.default {
|
|
|
140
135
|
}),
|
|
141
136
|
addSelectedKeys: createAddKeysFn(this, 'selectedKeys'),
|
|
142
137
|
removeSelectedKeys: createRemoveKeysFn(this, 'selectedKeys'),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
/**
|
|
139
|
+
* when `includeParentKeys` is `true`, select a nested nav item will select parent nav sub
|
|
140
|
+
*/
|
|
141
|
+
updateSelectedKeys: function (selectedKeys) {
|
|
142
|
+
let includeParentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
143
|
+
let willUpdateSelectedKeys = selectedKeys;
|
|
144
|
+
if (includeParentKeys) {
|
|
145
|
+
const parentSelectKeys = _this.foundation.selectLevelZeroParentKeys(null, selectedKeys);
|
|
146
|
+
willUpdateSelectedKeys = Array.from(new Set(selectedKeys.concat(parentSelectKeys)));
|
|
147
|
+
}
|
|
148
|
+
_this.setState({
|
|
149
|
+
selectedKeys: willUpdateSelectedKeys
|
|
150
|
+
});
|
|
151
|
+
},
|
|
146
152
|
updateOpenKeys: openKeys => this.setState({
|
|
147
153
|
openKeys: [...openKeys]
|
|
148
154
|
}),
|
package/lib/cjs/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/cjs/tabs/index.js
CHANGED
|
@@ -52,6 +52,34 @@ class Tabs extends _baseComponent.default {
|
|
|
52
52
|
current: ref
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
+
this.getPanes = () => {
|
|
56
|
+
const {
|
|
57
|
+
tabList,
|
|
58
|
+
children
|
|
59
|
+
} = this.props;
|
|
60
|
+
if (Array.isArray(tabList) && tabList.length) {
|
|
61
|
+
return tabList;
|
|
62
|
+
}
|
|
63
|
+
return _react.default.Children.map(children, child => {
|
|
64
|
+
if (child) {
|
|
65
|
+
const {
|
|
66
|
+
tab,
|
|
67
|
+
icon,
|
|
68
|
+
disabled,
|
|
69
|
+
itemKey,
|
|
70
|
+
closable
|
|
71
|
+
} = child.props;
|
|
72
|
+
return {
|
|
73
|
+
tab,
|
|
74
|
+
icon,
|
|
75
|
+
disabled,
|
|
76
|
+
itemKey,
|
|
77
|
+
closable
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
55
83
|
this.onTabClick = (activeKey, event) => {
|
|
56
84
|
this.foundation.handleTabClick(activeKey, event);
|
|
57
85
|
};
|
|
@@ -90,7 +118,7 @@ class Tabs extends _baseComponent.default {
|
|
|
90
118
|
this.foundation = new _foundation.default(this.adapter);
|
|
91
119
|
this.state = {
|
|
92
120
|
activeKey: this.foundation.getDefaultActiveKey(),
|
|
93
|
-
panes:
|
|
121
|
+
panes: this.getPanes(),
|
|
94
122
|
prevActiveKey: null,
|
|
95
123
|
forceDisableMotion: false
|
|
96
124
|
};
|
|
@@ -100,41 +128,12 @@ class Tabs extends _baseComponent.default {
|
|
|
100
128
|
get adapter() {
|
|
101
129
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
102
130
|
collectPane: () => {
|
|
103
|
-
const
|
|
104
|
-
tabList,
|
|
105
|
-
children
|
|
106
|
-
} = this.props;
|
|
107
|
-
if (Array.isArray(tabList) && tabList.length) {
|
|
108
|
-
this.setState({
|
|
109
|
-
panes: tabList
|
|
110
|
-
});
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const panes = _react.default.Children.map(children, child => {
|
|
114
|
-
if (child) {
|
|
115
|
-
const {
|
|
116
|
-
tab,
|
|
117
|
-
icon,
|
|
118
|
-
disabled,
|
|
119
|
-
itemKey,
|
|
120
|
-
closable
|
|
121
|
-
} = child.props;
|
|
122
|
-
return {
|
|
123
|
-
tab,
|
|
124
|
-
icon,
|
|
125
|
-
disabled,
|
|
126
|
-
itemKey,
|
|
127
|
-
closable
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
return undefined;
|
|
131
|
-
});
|
|
131
|
+
const panes = this.getPanes();
|
|
132
132
|
this.setState({
|
|
133
133
|
panes
|
|
134
134
|
});
|
|
135
135
|
},
|
|
136
136
|
collectActiveKey: () => {
|
|
137
|
-
let panes = [];
|
|
138
137
|
const {
|
|
139
138
|
tabList,
|
|
140
139
|
children,
|
|
@@ -146,29 +145,7 @@ class Tabs extends _baseComponent.default {
|
|
|
146
145
|
const {
|
|
147
146
|
activeKey
|
|
148
147
|
} = this.state;
|
|
149
|
-
|
|
150
|
-
panes = tabList;
|
|
151
|
-
} else {
|
|
152
|
-
panes = _react.default.Children.map(children, child => {
|
|
153
|
-
if (child) {
|
|
154
|
-
const {
|
|
155
|
-
tab,
|
|
156
|
-
icon,
|
|
157
|
-
disabled,
|
|
158
|
-
itemKey,
|
|
159
|
-
closable
|
|
160
|
-
} = child.props;
|
|
161
|
-
return {
|
|
162
|
-
tab,
|
|
163
|
-
icon,
|
|
164
|
-
disabled,
|
|
165
|
-
itemKey,
|
|
166
|
-
closable
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
return undefined;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
148
|
+
const panes = this.getPanes();
|
|
172
149
|
if (panes.findIndex(p => p.itemKey === activeKey) === -1) {
|
|
173
150
|
if (panes.length > 0) {
|
|
174
151
|
this.setState({
|
|
@@ -36,6 +36,6 @@ interface SortableItemProps {
|
|
|
36
36
|
prefix?: string;
|
|
37
37
|
transition?: SortableTransition | null;
|
|
38
38
|
}
|
|
39
|
-
export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition,
|
|
39
|
+
export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition, collisionDetection, strategy, useDragOverlay, dragOverlayCls, container: Container, prefix, }: SortableProps): JSX.Element;
|
|
40
40
|
export declare function SortableItem({ animateLayoutChanges, id, renderItem, prefix, transition: animation, }: SortableItemProps): JSX.Element;
|
|
41
41
|
export {};
|
|
@@ -6,10 +6,6 @@ import cls from 'classnames';
|
|
|
6
6
|
import { closestCenter, DragOverlay, DndContext, MouseSensor, TouchSensor, useSensor, useSensors, KeyboardSensor, TraversalOrder } from '@dnd-kit/core';
|
|
7
7
|
import { useSortable, SortableContext, rectSortingStrategy, sortableKeyboardCoordinates } from '@dnd-kit/sortable';
|
|
8
8
|
const defaultPrefix = 'semi-sortable';
|
|
9
|
-
const defaultConstraint = {
|
|
10
|
-
delay: 150,
|
|
11
|
-
tolerance: 5
|
|
12
|
-
};
|
|
13
9
|
function DefaultContainer(props) {
|
|
14
10
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
15
11
|
style: {
|
|
@@ -17,6 +13,9 @@ function DefaultContainer(props) {
|
|
|
17
13
|
}
|
|
18
14
|
}, props));
|
|
19
15
|
}
|
|
16
|
+
const defaultKeyBoardOptions = {
|
|
17
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
18
|
+
};
|
|
20
19
|
export function Sortable(_ref) {
|
|
21
20
|
let {
|
|
22
21
|
items,
|
|
@@ -24,7 +23,6 @@ export function Sortable(_ref) {
|
|
|
24
23
|
adjustScale,
|
|
25
24
|
renderItem,
|
|
26
25
|
transition,
|
|
27
|
-
activationConstraint = defaultConstraint,
|
|
28
26
|
collisionDetection = closestCenter,
|
|
29
27
|
strategy = rectSortingStrategy,
|
|
30
28
|
useDragOverlay = true,
|
|
@@ -33,13 +31,7 @@ export function Sortable(_ref) {
|
|
|
33
31
|
prefix = defaultPrefix
|
|
34
32
|
} = _ref;
|
|
35
33
|
const [activeId, setActiveId] = useState(null);
|
|
36
|
-
const sensors = useSensors(useSensor(MouseSensor,
|
|
37
|
-
activationConstraint
|
|
38
|
-
}), useSensor(TouchSensor, {
|
|
39
|
-
activationConstraint
|
|
40
|
-
}), useSensor(KeyboardSensor, {
|
|
41
|
-
coordinateGetter: sortableKeyboardCoordinates
|
|
42
|
-
}));
|
|
34
|
+
const sensors = useSensors(useSensor(MouseSensor), useSensor(TouchSensor), useSensor(KeyboardSensor, defaultKeyBoardOptions));
|
|
43
35
|
const getIndex = useCallback(id => items.indexOf(id), [items]);
|
|
44
36
|
const activeIndex = useMemo(() => activeId ? getIndex(activeId) : -1, [getIndex, activeId]);
|
|
45
37
|
const onDragStart = useCallback(_ref2 => {
|
|
@@ -149,13 +141,15 @@ export function SortableItem(_ref4) {
|
|
|
149
141
|
[`${prefix}-sortable-item-over`]: isOver,
|
|
150
142
|
[`${prefix}-sortable-item-active`]: (active === null || active === void 0 ? void 0 : active.id) === id
|
|
151
143
|
});
|
|
152
|
-
const wrapperStyle =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
144
|
+
const wrapperStyle = useMemo(() => {
|
|
145
|
+
return !_isNull(animation) ? {
|
|
146
|
+
transform: cssDndKit.Transform.toString(Object.assign(Object.assign({}, transform), {
|
|
147
|
+
scaleX: 1,
|
|
148
|
+
scaleY: 1
|
|
149
|
+
})),
|
|
150
|
+
transition: transition
|
|
151
|
+
} : undefined;
|
|
152
|
+
}, [animation, transform, transition]);
|
|
159
153
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
160
154
|
ref: setNodeRef,
|
|
161
155
|
style: wrapperStyle,
|
|
@@ -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,10 +122,11 @@ 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;
|
|
128
|
-
componentDidUpdate(prevProps: NavProps
|
|
129
|
+
componentDidUpdate(prevProps: NavProps): void;
|
|
129
130
|
get adapter(): NavigationAdapter<NavProps, NavState>;
|
|
130
131
|
/**
|
|
131
132
|
* Render navigation items recursively
|
|
@@ -88,24 +88,19 @@ class Nav extends BaseComponent {
|
|
|
88
88
|
componentDidMount() {
|
|
89
89
|
// override BaseComponent
|
|
90
90
|
}
|
|
91
|
-
componentDidUpdate(prevProps
|
|
91
|
+
componentDidUpdate(prevProps) {
|
|
92
92
|
if (prevProps.items !== this.props.items || prevProps.children !== this.props.children) {
|
|
93
93
|
this.foundation.init();
|
|
94
94
|
} else {
|
|
95
95
|
this.foundation.handleItemsChange(false);
|
|
96
|
-
const {
|
|
97
|
-
selectedKeys
|
|
98
|
-
} = this.state;
|
|
99
96
|
if (this.props.selectedKeys && !_isEqual(prevProps.selectedKeys, this.props.selectedKeys)) {
|
|
100
97
|
this.adapter.updateSelectedKeys(this.props.selectedKeys);
|
|
98
|
+
const willOpenKeys = this.foundation.getWillOpenKeys(this.state.itemKeysMap);
|
|
99
|
+
this.adapter.updateOpenKeys(willOpenKeys);
|
|
101
100
|
}
|
|
102
101
|
if (this.props.openKeys && !_isEqual(prevProps.openKeys, this.props.openKeys)) {
|
|
103
102
|
this.adapter.updateOpenKeys(this.props.openKeys);
|
|
104
103
|
}
|
|
105
|
-
if (!_isEqual(selectedKeys, prevState.selectedKeys)) {
|
|
106
|
-
const parentSelectKeys = this.foundation.selectLevelZeroParentKeys(null, ...selectedKeys);
|
|
107
|
-
this.adapter.addSelectedKeys(...parentSelectKeys);
|
|
108
|
-
}
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
106
|
get adapter() {
|
|
@@ -131,9 +126,20 @@ class Nav extends BaseComponent {
|
|
|
131
126
|
}),
|
|
132
127
|
addSelectedKeys: createAddKeysFn(this, 'selectedKeys'),
|
|
133
128
|
removeSelectedKeys: createRemoveKeysFn(this, 'selectedKeys'),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
/**
|
|
130
|
+
* when `includeParentKeys` is `true`, select a nested nav item will select parent nav sub
|
|
131
|
+
*/
|
|
132
|
+
updateSelectedKeys: function (selectedKeys) {
|
|
133
|
+
let includeParentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
134
|
+
let willUpdateSelectedKeys = selectedKeys;
|
|
135
|
+
if (includeParentKeys) {
|
|
136
|
+
const parentSelectKeys = _this.foundation.selectLevelZeroParentKeys(null, selectedKeys);
|
|
137
|
+
willUpdateSelectedKeys = Array.from(new Set(selectedKeys.concat(parentSelectKeys)));
|
|
138
|
+
}
|
|
139
|
+
_this.setState({
|
|
140
|
+
selectedKeys: willUpdateSelectedKeys
|
|
141
|
+
});
|
|
142
|
+
},
|
|
137
143
|
updateOpenKeys: openKeys => this.setState({
|
|
138
144
|
openKeys: [...openKeys]
|
|
139
145
|
}),
|
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-beta.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-beta.0",
|
|
24
|
+
"@douyinfe/semi-animation-react": "2.55.0-beta.0",
|
|
25
|
+
"@douyinfe/semi-foundation": "2.55.0-beta.0",
|
|
26
|
+
"@douyinfe/semi-icons": "2.55.0-beta.0",
|
|
27
|
+
"@douyinfe/semi-illustrations": "2.55.0-beta.0",
|
|
28
|
+
"@douyinfe/semi-theme-default": "2.55.0-beta.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": "1b20ba60f41785e247a71987235b5f3bbd577ff0",
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
81
81
|
"@babel/plugin-transform-runtime": "^7.15.8",
|