@douyinfe/semi-foundation 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/descriptions/foundation.ts +17 -12
- package/lib/cjs/descriptions/foundation.d.ts +1 -0
- package/lib/cjs/descriptions/foundation.js +14 -9
- package/lib/cjs/navigation/foundation.d.ts +3 -3
- package/lib/cjs/navigation/foundation.js +6 -5
- package/lib/cjs/table/foundation.js +1 -1
- package/lib/es/descriptions/foundation.d.ts +1 -0
- package/lib/es/descriptions/foundation.js +14 -9
- package/lib/es/navigation/foundation.d.ts +3 -3
- package/lib/es/navigation/foundation.js +6 -5
- package/lib/es/table/foundation.js +1 -1
- package/navigation/foundation.ts +6 -4
- package/package.json +3 -3
- package/table/foundation.ts +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
2
|
|
|
3
|
-
export interface DescriptionsAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
3
|
+
export interface DescriptionsAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
|
+
getColumns: () => any[]
|
|
5
|
+
}
|
|
4
6
|
|
|
5
7
|
export default class DescriptionsFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<DescriptionsAdapter<P, S>, P, S> {
|
|
6
8
|
constructor(adapter: DescriptionsAdapter<P, S>) {
|
|
@@ -9,16 +11,7 @@ export default class DescriptionsFoundation<P = Record<string, any>, S = Record<
|
|
|
9
11
|
|
|
10
12
|
getHorizontalList() {
|
|
11
13
|
const { column, data, children } = this.getProps();
|
|
12
|
-
|
|
13
|
-
if (data?.length) {
|
|
14
|
-
columns = data || [];
|
|
15
|
-
} else {
|
|
16
|
-
columns =
|
|
17
|
-
children?.map(item => ({
|
|
18
|
-
value: item.props.children,
|
|
19
|
-
...item.props,
|
|
20
|
-
})) || [];
|
|
21
|
-
}
|
|
14
|
+
const columns = this._adapter.getColumns();
|
|
22
15
|
const horizontalList = [];
|
|
23
16
|
const curSpan = { totalSpan: 0, itemList: [] };
|
|
24
17
|
for (const item of columns) {
|
|
@@ -30,7 +23,19 @@ export default class DescriptionsFoundation<P = Record<string, any>, S = Record<
|
|
|
30
23
|
curSpan.totalSpan = 0;
|
|
31
24
|
}
|
|
32
25
|
}
|
|
33
|
-
if (curSpan.itemList.length != 0)
|
|
26
|
+
if (curSpan.itemList.length != 0) {
|
|
27
|
+
const lastSpan = curSpan.itemList[curSpan.itemList.length - 1];
|
|
28
|
+
if (isNaN(lastSpan.span)) {
|
|
29
|
+
let total = 0;
|
|
30
|
+
curSpan.itemList.forEach(item=>{
|
|
31
|
+
return total += !isNaN(item.span)?item.span:1;
|
|
32
|
+
});
|
|
33
|
+
if (total < column) {
|
|
34
|
+
lastSpan.span = column - total + 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
horizontalList.push(curSpan.itemList);
|
|
38
|
+
}
|
|
34
39
|
return horizontalList;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
2
|
export interface DescriptionsAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
3
|
+
getColumns: () => any[];
|
|
3
4
|
}
|
|
4
5
|
export default class DescriptionsFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<DescriptionsAdapter<P, S>, P, S> {
|
|
5
6
|
constructor(adapter: DescriptionsAdapter<P, S>);
|
|
@@ -16,14 +16,7 @@ class DescriptionsFoundation extends _foundation.default {
|
|
|
16
16
|
data,
|
|
17
17
|
children
|
|
18
18
|
} = this.getProps();
|
|
19
|
-
|
|
20
|
-
if (data === null || data === void 0 ? void 0 : data.length) {
|
|
21
|
-
columns = data || [];
|
|
22
|
-
} else {
|
|
23
|
-
columns = (children === null || children === void 0 ? void 0 : children.map(item => Object.assign({
|
|
24
|
-
value: item.props.children
|
|
25
|
-
}, item.props))) || [];
|
|
26
|
-
}
|
|
19
|
+
const columns = this._adapter.getColumns();
|
|
27
20
|
const horizontalList = [];
|
|
28
21
|
const curSpan = {
|
|
29
22
|
totalSpan: 0,
|
|
@@ -38,7 +31,19 @@ class DescriptionsFoundation extends _foundation.default {
|
|
|
38
31
|
curSpan.totalSpan = 0;
|
|
39
32
|
}
|
|
40
33
|
}
|
|
41
|
-
if (curSpan.itemList.length != 0)
|
|
34
|
+
if (curSpan.itemList.length != 0) {
|
|
35
|
+
const lastSpan = curSpan.itemList[curSpan.itemList.length - 1];
|
|
36
|
+
if (isNaN(lastSpan.span)) {
|
|
37
|
+
let total = 0;
|
|
38
|
+
curSpan.itemList.forEach(item => {
|
|
39
|
+
return total += !isNaN(item.span) ? item.span : 1;
|
|
40
|
+
});
|
|
41
|
+
if (total < column) {
|
|
42
|
+
lastSpan.span = column - total + 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
horizontalList.push(curSpan.itemList);
|
|
46
|
+
}
|
|
42
47
|
return horizontalList;
|
|
43
48
|
}
|
|
44
49
|
}
|
|
@@ -48,7 +48,7 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
48
48
|
* @param {*} lifecycle
|
|
49
49
|
* @returns
|
|
50
50
|
*/
|
|
51
|
-
init(lifecycle
|
|
51
|
+
init(lifecycle?: string): {
|
|
52
52
|
selectedKeys: any;
|
|
53
53
|
itemKeysMap: {};
|
|
54
54
|
openKeys: any[];
|
|
@@ -74,9 +74,9 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
74
74
|
* @param {*} itemKeysMap
|
|
75
75
|
*/
|
|
76
76
|
getWillOpenKeys(itemKeysMap: ItemKey2ParentKeysMap): any[];
|
|
77
|
-
getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?: string | number[]): unknown[];
|
|
77
|
+
getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?: (string | number)[]): unknown[];
|
|
78
78
|
destroy(): void;
|
|
79
|
-
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap,
|
|
79
|
+
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap, itemKeys: (string | number)[]): any[];
|
|
80
80
|
formatItems(items?: ItemProps[]): any[];
|
|
81
81
|
handleSelect(data: OnSelectData): void;
|
|
82
82
|
judgeIfOpen(openKeys: (string | number)[], items: NavItemType[]): boolean;
|
|
@@ -141,10 +141,14 @@ class NavigationFoundation extends _foundation.default {
|
|
|
141
141
|
selectedKeys,
|
|
142
142
|
mode
|
|
143
143
|
} = this.getProps();
|
|
144
|
+
const {
|
|
145
|
+
openKeys: stateOpenKeys = []
|
|
146
|
+
} = this.getStates();
|
|
144
147
|
let willOpenKeys = openKeys || defaultOpenKeys || [];
|
|
145
148
|
if (!(Array.isArray(defaultOpenKeys) || Array.isArray(openKeys)) && mode === _constants.strings.MODE_VERTICAL && (Array.isArray(defaultSelectedKeys) || Array.isArray(selectedKeys))) {
|
|
146
149
|
const currentSelectedKeys = Array.isArray(selectedKeys) ? selectedKeys : defaultSelectedKeys;
|
|
147
|
-
willOpenKeys = this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys);
|
|
150
|
+
willOpenKeys = stateOpenKeys.concat(this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys));
|
|
151
|
+
willOpenKeys = Array.from(new Set(willOpenKeys));
|
|
148
152
|
}
|
|
149
153
|
return [...willOpenKeys];
|
|
150
154
|
}
|
|
@@ -165,13 +169,10 @@ class NavigationFoundation extends _foundation.default {
|
|
|
165
169
|
return [...willOpenKeySet];
|
|
166
170
|
}
|
|
167
171
|
destroy() {}
|
|
168
|
-
selectLevelZeroParentKeys(itemKeysMap) {
|
|
172
|
+
selectLevelZeroParentKeys(itemKeysMap, itemKeys) {
|
|
169
173
|
const _itemKeysMap = (0, _isNullOrUndefined.default)(itemKeysMap) ? this.getState('itemKeysMap') : itemKeysMap;
|
|
170
174
|
// console.log(itemKeysMap);
|
|
171
175
|
const willAddKeys = [];
|
|
172
|
-
for (var _len2 = arguments.length, itemKeys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
173
|
-
itemKeys[_key2 - 1] = arguments[_key2];
|
|
174
|
-
}
|
|
175
176
|
if (itemKeys.length) {
|
|
176
177
|
for (const itemKey of itemKeys) {
|
|
177
178
|
if (Array.isArray(_itemKeysMap[itemKey]) && _itemKeysMap[itemKey].length) {
|
|
@@ -790,7 +790,7 @@ class TableFoundation extends _foundation.default {
|
|
|
790
790
|
}
|
|
791
791
|
return true;
|
|
792
792
|
} else {
|
|
793
|
-
const isAllSelected = allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
793
|
+
const isAllSelected = allKeys.length && allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
794
794
|
return isAllSelected || false;
|
|
795
795
|
}
|
|
796
796
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
2
|
export interface DescriptionsAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
3
|
+
getColumns: () => any[];
|
|
3
4
|
}
|
|
4
5
|
export default class DescriptionsFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<DescriptionsAdapter<P, S>, P, S> {
|
|
5
6
|
constructor(adapter: DescriptionsAdapter<P, S>);
|
|
@@ -9,14 +9,7 @@ export default class DescriptionsFoundation extends BaseFoundation {
|
|
|
9
9
|
data,
|
|
10
10
|
children
|
|
11
11
|
} = this.getProps();
|
|
12
|
-
|
|
13
|
-
if (data === null || data === void 0 ? void 0 : data.length) {
|
|
14
|
-
columns = data || [];
|
|
15
|
-
} else {
|
|
16
|
-
columns = (children === null || children === void 0 ? void 0 : children.map(item => Object.assign({
|
|
17
|
-
value: item.props.children
|
|
18
|
-
}, item.props))) || [];
|
|
19
|
-
}
|
|
12
|
+
const columns = this._adapter.getColumns();
|
|
20
13
|
const horizontalList = [];
|
|
21
14
|
const curSpan = {
|
|
22
15
|
totalSpan: 0,
|
|
@@ -31,7 +24,19 @@ export default class DescriptionsFoundation extends BaseFoundation {
|
|
|
31
24
|
curSpan.totalSpan = 0;
|
|
32
25
|
}
|
|
33
26
|
}
|
|
34
|
-
if (curSpan.itemList.length != 0)
|
|
27
|
+
if (curSpan.itemList.length != 0) {
|
|
28
|
+
const lastSpan = curSpan.itemList[curSpan.itemList.length - 1];
|
|
29
|
+
if (isNaN(lastSpan.span)) {
|
|
30
|
+
let total = 0;
|
|
31
|
+
curSpan.itemList.forEach(item => {
|
|
32
|
+
return total += !isNaN(item.span) ? item.span : 1;
|
|
33
|
+
});
|
|
34
|
+
if (total < column) {
|
|
35
|
+
lastSpan.span = column - total + 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
horizontalList.push(curSpan.itemList);
|
|
39
|
+
}
|
|
35
40
|
return horizontalList;
|
|
36
41
|
}
|
|
37
42
|
}
|
|
@@ -48,7 +48,7 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
48
48
|
* @param {*} lifecycle
|
|
49
49
|
* @returns
|
|
50
50
|
*/
|
|
51
|
-
init(lifecycle
|
|
51
|
+
init(lifecycle?: string): {
|
|
52
52
|
selectedKeys: any;
|
|
53
53
|
itemKeysMap: {};
|
|
54
54
|
openKeys: any[];
|
|
@@ -74,9 +74,9 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
74
74
|
* @param {*} itemKeysMap
|
|
75
75
|
*/
|
|
76
76
|
getWillOpenKeys(itemKeysMap: ItemKey2ParentKeysMap): any[];
|
|
77
|
-
getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?: string | number[]): unknown[];
|
|
77
|
+
getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?: (string | number)[]): unknown[];
|
|
78
78
|
destroy(): void;
|
|
79
|
-
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap,
|
|
79
|
+
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap, itemKeys: (string | number)[]): any[];
|
|
80
80
|
formatItems(items?: ItemProps[]): any[];
|
|
81
81
|
handleSelect(data: OnSelectData): void;
|
|
82
82
|
judgeIfOpen(openKeys: (string | number)[], items: NavItemType[]): boolean;
|
|
@@ -134,10 +134,14 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
134
134
|
selectedKeys,
|
|
135
135
|
mode
|
|
136
136
|
} = this.getProps();
|
|
137
|
+
const {
|
|
138
|
+
openKeys: stateOpenKeys = []
|
|
139
|
+
} = this.getStates();
|
|
137
140
|
let willOpenKeys = openKeys || defaultOpenKeys || [];
|
|
138
141
|
if (!(Array.isArray(defaultOpenKeys) || Array.isArray(openKeys)) && mode === strings.MODE_VERTICAL && (Array.isArray(defaultSelectedKeys) || Array.isArray(selectedKeys))) {
|
|
139
142
|
const currentSelectedKeys = Array.isArray(selectedKeys) ? selectedKeys : defaultSelectedKeys;
|
|
140
|
-
willOpenKeys = this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys);
|
|
143
|
+
willOpenKeys = stateOpenKeys.concat(this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys));
|
|
144
|
+
willOpenKeys = Array.from(new Set(willOpenKeys));
|
|
141
145
|
}
|
|
142
146
|
return [...willOpenKeys];
|
|
143
147
|
}
|
|
@@ -158,13 +162,10 @@ export default class NavigationFoundation extends BaseFoundation {
|
|
|
158
162
|
return [...willOpenKeySet];
|
|
159
163
|
}
|
|
160
164
|
destroy() {}
|
|
161
|
-
selectLevelZeroParentKeys(itemKeysMap) {
|
|
165
|
+
selectLevelZeroParentKeys(itemKeysMap, itemKeys) {
|
|
162
166
|
const _itemKeysMap = isNullOrUndefined(itemKeysMap) ? this.getState('itemKeysMap') : itemKeysMap;
|
|
163
167
|
// console.log(itemKeysMap);
|
|
164
168
|
const willAddKeys = [];
|
|
165
|
-
for (var _len2 = arguments.length, itemKeys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
166
|
-
itemKeys[_key2 - 1] = arguments[_key2];
|
|
167
|
-
}
|
|
168
169
|
if (itemKeys.length) {
|
|
169
170
|
for (const itemKey of itemKeys) {
|
|
170
171
|
if (Array.isArray(_itemKeysMap[itemKey]) && _itemKeysMap[itemKey].length) {
|
|
@@ -783,7 +783,7 @@ class TableFoundation extends BaseFoundation {
|
|
|
783
783
|
}
|
|
784
784
|
return true;
|
|
785
785
|
} else {
|
|
786
|
-
const isAllSelected = allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
786
|
+
const isAllSelected = allKeys.length && allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
787
787
|
return isAllSelected || false;
|
|
788
788
|
}
|
|
789
789
|
}
|
package/navigation/foundation.ts
CHANGED
|
@@ -114,7 +114,7 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
114
114
|
* @param {*} lifecycle
|
|
115
115
|
* @returns
|
|
116
116
|
*/
|
|
117
|
-
init(lifecycle
|
|
117
|
+
init(lifecycle?: string) {
|
|
118
118
|
const { defaultSelectedKeys, selectedKeys } = this.getProps();
|
|
119
119
|
let willSelectedKeys = selectedKeys || defaultSelectedKeys || [];
|
|
120
120
|
const { itemKeysMap, willOpenKeys, formattedItems } = this.getCalcState();
|
|
@@ -168,6 +168,7 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
168
168
|
*/
|
|
169
169
|
getWillOpenKeys(itemKeysMap: ItemKey2ParentKeysMap) {
|
|
170
170
|
const { defaultOpenKeys, openKeys, defaultSelectedKeys, selectedKeys, mode } = this.getProps();
|
|
171
|
+
const { openKeys: stateOpenKeys = [] } = this.getStates();
|
|
171
172
|
|
|
172
173
|
let willOpenKeys = openKeys || defaultOpenKeys || [];
|
|
173
174
|
if (
|
|
@@ -175,12 +176,13 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
175
176
|
Array.isArray(openKeys)) && mode === strings.MODE_VERTICAL && (Array.isArray(defaultSelectedKeys) || Array.isArray(selectedKeys))
|
|
176
177
|
) {
|
|
177
178
|
const currentSelectedKeys = Array.isArray(selectedKeys) ? selectedKeys : defaultSelectedKeys;
|
|
178
|
-
willOpenKeys = this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys);
|
|
179
|
+
willOpenKeys = stateOpenKeys.concat(this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys));
|
|
180
|
+
willOpenKeys = Array.from(new Set(willOpenKeys));
|
|
179
181
|
}
|
|
180
182
|
return [...willOpenKeys];
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
getShouldOpenKeys(itemKeysMap: ItemKey2ParentKeysMap = {}, selectedKeys: string | number[]= []) {
|
|
185
|
+
getShouldOpenKeys(itemKeysMap: ItemKey2ParentKeysMap = {}, selectedKeys: (string | number)[] = []) {
|
|
184
186
|
const willOpenKeySet = new Set();
|
|
185
187
|
|
|
186
188
|
if (Array.isArray(selectedKeys) && selectedKeys.length) {
|
|
@@ -200,7 +202,7 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
200
202
|
|
|
201
203
|
destroy() {}
|
|
202
204
|
|
|
203
|
-
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap,
|
|
205
|
+
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap, itemKeys: (string | number)[]) {
|
|
204
206
|
const _itemKeysMap = isNullOrUndefined(itemKeysMap) ? this.getState('itemKeysMap') : itemKeysMap;
|
|
205
207
|
// console.log(itemKeysMap);
|
|
206
208
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.55.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
7
7
|
"prepublishOnly": "npm run build:lib"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@douyinfe/semi-animation": "2.
|
|
10
|
+
"@douyinfe/semi-animation": "2.55.0",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"*.scss",
|
|
25
25
|
"*.css"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "21f02cad422b2d15d9f5d9b7b1ca96b0d21bb545",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
30
30
|
"@babel/preset-env": "^7.15.8",
|
package/table/foundation.ts
CHANGED
|
@@ -988,7 +988,7 @@ class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<RecordType
|
|
|
988
988
|
}
|
|
989
989
|
return true;
|
|
990
990
|
} else {
|
|
991
|
-
const isAllSelected = allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
991
|
+
const isAllSelected = allKeys.length && allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
992
992
|
return isAllSelected || false;
|
|
993
993
|
}
|
|
994
994
|
}
|