@douyinfe/semi-foundation 2.55.0-beta.0 → 2.55.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.
@@ -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
- let columns;
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) horizontalList.push(curSpan.itemList);
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
- let columns;
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) horizontalList.push(curSpan.itemList);
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
  }
@@ -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
- let columns;
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) horizontalList.push(curSpan.itemList);
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
  }
@@ -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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.55.0-beta.0",
3
+ "version": "2.55.1",
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.55.0-beta.0",
10
+ "@douyinfe/semi-animation": "2.55.1",
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": "1b20ba60f41785e247a71987235b5f3bbd577ff0",
27
+ "gitHead": "d74bd5368afc88bc49abc4ba432be9dd74fa707b",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-transform-runtime": "^7.15.8",
30
30
  "@babel/preset-env": "^7.15.8",
@@ -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
  }