@king-design/intact 3.4.3-beta.2 → 3.4.3
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/components/button/demos/disabled.md +14 -3
- package/components/button/index.vdt +1 -1
- package/components/button/styles.ts +14 -1
- package/components/dialog/styles.ts +3 -3
- package/components/dropdown/item.ts +7 -2
- package/components/editable/demos/textarea.md +53 -0
- package/components/editable/index.md +7 -1
- package/components/editable/index.spec.ts +27 -0
- package/components/editable/index.ts +4 -1
- package/components/editable/index.vdt +13 -4
- package/components/editable/styles.ts +1 -1
- package/components/ellipsis/demos/hoverable.md +23 -0
- package/components/ellipsis/index.ts +4 -1
- package/components/ellipsis/index.vdt +3 -1
- package/components/input/demos/size.md +9 -1
- package/components/input/styles.ts +12 -2
- package/components/menu/styles.ts +0 -3
- package/components/select/demos/immutable.md +7 -6
- package/components/select/index.spec.ts +31 -0
- package/components/select/useImmutable.ts +1 -1
- package/components/switch/styles.ts +5 -0
- package/components/table/cell.ts +1 -0
- package/components/table/cell.vdt +9 -2
- package/components/table/column.ts +2 -0
- package/components/table/demos/asyncTree.md +70 -0
- package/components/table/demos/ellipsis.md +29 -0
- package/components/table/demos/fixFooter.md +52 -0
- package/components/table/demos/footer.md +38 -0
- package/components/table/index.md +4 -0
- package/components/table/row.ts +26 -17
- package/components/table/row.vdt +2 -2
- package/components/table/styles.ts +24 -3
- package/components/table/table.ts +5 -0
- package/components/table/table.vdt +15 -2
- package/components/table/useTree.ts +9 -2
- package/components/tooltip/demos/content.md +17 -2
- package/components/tooltip/index.spec.ts +21 -2
- package/components/tooltip/tooltip.ts +2 -0
- package/components/treeSelect/demos/basic.md +1 -0
- package/components/treeSelect/index.vdt +1 -0
- package/es/components/button/index.vdt.js +1 -1
- package/es/components/button/styles.js +3 -3
- package/es/components/diagram/shapes/callout.d.ts +1 -1
- package/es/components/diagram/shapes/circle.d.ts +1 -1
- package/es/components/diagram/shapes/document.d.ts +1 -1
- package/es/components/diagram/shapes/ellipse.d.ts +1 -1
- package/es/components/diagram/shapes/hexagon.d.ts +1 -1
- package/es/components/diagram/shapes/image.d.ts +1 -1
- package/es/components/diagram/shapes/parallelogram.d.ts +1 -1
- package/es/components/diagram/shapes/rectangle.d.ts +1 -1
- package/es/components/diagram/shapes/square.d.ts +1 -1
- package/es/components/diagram/shapes/text.d.ts +1 -1
- package/es/components/dialog/styles.js +3 -3
- package/es/components/dropdown/item.js +5 -2
- package/es/components/editable/index.d.ts +2 -0
- package/es/components/editable/index.js +4 -2
- package/es/components/editable/index.spec.js +39 -0
- package/es/components/editable/index.vdt.js +17 -6
- package/es/components/editable/styles.d.ts +1 -0
- package/es/components/editable/styles.js +3 -0
- package/es/components/ellipsis/index.d.ts +1 -0
- package/es/components/ellipsis/index.js +4 -2
- package/es/components/ellipsis/index.vdt.js +3 -1
- package/es/components/input/styles.js +11 -1
- package/es/components/menu/styles.js +1 -1
- package/es/components/select/index.spec.js +47 -0
- package/es/components/switch/styles.js +1 -1
- package/es/components/table/cell.d.ts +1 -0
- package/es/components/table/cell.vdt.js +14 -3
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +1 -0
- package/es/components/table/row.d.ts +2 -1
- package/es/components/table/row.js +24 -15
- package/es/components/table/row.vdt.js +3 -1
- package/es/components/table/styles.js +2 -2
- package/es/components/table/table.d.ts +3 -0
- package/es/components/table/table.js +3 -1
- package/es/components/table/table.vdt.js +19 -3
- package/es/components/table/useTree.d.ts +1 -1
- package/es/components/table/useTree.js +30 -2
- package/es/components/tooltip/index.spec.js +99 -67
- package/es/components/tooltip/tooltip.d.ts +1 -0
- package/es/components/tooltip/tooltip.js +9 -1
- package/es/components/treeSelect/index.vdt.js +1 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/button/demos/disabled/index.d.ts +1 -0
- package/es/site/data/components/button/demos/disabled/index.js +1 -0
- package/es/site/data/components/button/demos/disabled/react.d.ts +1 -0
- package/es/site/data/components/button/demos/disabled/react.js +27 -8
- package/es/site/data/components/editable/demos/textarea/index.d.ts +16 -0
- package/es/site/data/components/editable/demos/textarea/index.js +21 -0
- package/es/site/data/components/editable/demos/textarea/react.d.ts +17 -0
- package/es/site/data/components/editable/demos/textarea/react.js +72 -0
- package/es/site/data/components/ellipsis/demos/hoverable/index.d.ts +6 -0
- package/es/site/data/components/ellipsis/demos/hoverable/index.js +14 -0
- package/es/site/data/components/ellipsis/demos/hoverable/react.d.ts +5 -0
- package/es/site/data/components/ellipsis/demos/hoverable/react.js +21 -0
- package/es/site/data/components/input/demos/size/react.js +20 -0
- package/es/site/data/components/select/demos/immutable/index.d.ts +2 -2
- package/es/site/data/components/select/demos/immutable/index.js +1 -1
- package/es/site/data/components/select/demos/immutable/react.d.ts +1 -1
- package/es/site/data/components/select/demos/immutable/react.js +5 -5
- package/es/site/data/components/table/demos/asyncTree/index.d.ts +20 -0
- package/es/site/data/components/table/demos/asyncTree/index.js +53 -0
- package/es/site/data/components/table/demos/asyncTree/react.d.ts +20 -0
- package/es/site/data/components/table/demos/asyncTree/react.js +76 -0
- package/es/site/data/components/table/demos/ellipsis/index.d.ts +11 -0
- package/es/site/data/components/table/demos/ellipsis/index.js +24 -0
- package/es/site/data/components/table/demos/ellipsis/react.d.ts +10 -0
- package/es/site/data/components/table/demos/ellipsis/react.js +43 -0
- package/es/site/data/components/table/demos/fixFooter/index.d.ts +6 -0
- package/es/site/data/components/table/demos/fixFooter/index.js +14 -0
- package/es/site/data/components/table/demos/fixFooter/react.d.ts +5 -0
- package/es/site/data/components/table/demos/fixFooter/react.js +69 -0
- package/es/site/data/components/table/demos/footer/index.d.ts +12 -0
- package/es/site/data/components/table/demos/footer/index.js +25 -0
- package/es/site/data/components/table/demos/footer/react.d.ts +11 -0
- package/es/site/data/components/table/demos/footer/react.js +46 -0
- package/es/site/data/components/tooltip/demos/content/index.d.ts +2 -0
- package/es/site/data/components/tooltip/demos/content/index.js +3 -1
- package/es/site/data/components/tooltip/demos/content/react.d.ts +2 -0
- package/es/site/data/components/tooltip/demos/content/react.js +21 -3
- package/es/site/data/components/treeSelect/demos/basic/react.js +2 -1
- package/index.ts +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 树形表格异步加载
|
|
3
|
+
order: 33
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
添加`load`数据加载函数即可实现异步加载子节点功能,组件会传入当前节点对象作为参数,函数可以返回
|
|
7
|
+
数组或者异步返回数组作为当前异步加载的子节点。如果子节点还可以进一步展开,可以将`children`属性
|
|
8
|
+
设为空数组`[]`,否则不指定`children`则表示该节点为叶子节点。
|
|
9
|
+
|
|
10
|
+
组件默认遇到`children`为`[]`空数组的情况就会去进行异步加载,你可以通过`loaded`属性设为`true`来
|
|
11
|
+
标识该子节点已经加载完成,无需再次加载
|
|
12
|
+
|
|
13
|
+
```vdt
|
|
14
|
+
import {Table, TableColumn} from 'kpc';
|
|
15
|
+
|
|
16
|
+
<Table data={this.get('data')} rowKey={data => data.name} load={this.loadData}>
|
|
17
|
+
<TableColumn key="name" title="Name" />
|
|
18
|
+
<TableColumn key="size" title="Size">
|
|
19
|
+
<b:template args="[data]">
|
|
20
|
+
{data.size}MB
|
|
21
|
+
</b:template>
|
|
22
|
+
</TableColumn>
|
|
23
|
+
</Table>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import {bind} from 'kpc';
|
|
28
|
+
interface Props {
|
|
29
|
+
data: NonNullable<any>
|
|
30
|
+
}
|
|
31
|
+
export default class extends Component<Props> {
|
|
32
|
+
static template = template;
|
|
33
|
+
|
|
34
|
+
static defaults() {
|
|
35
|
+
return {
|
|
36
|
+
data: [
|
|
37
|
+
{
|
|
38
|
+
name: 'Audios',
|
|
39
|
+
size: 12,
|
|
40
|
+
children: []
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Images',
|
|
44
|
+
size: 14,
|
|
45
|
+
children: []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'doc.pdf',
|
|
49
|
+
size: 18,
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@bind
|
|
56
|
+
loadData(node: any) {
|
|
57
|
+
return new Promise<void>(resolve => {
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
node.children = [
|
|
60
|
+
{name: 'child1', size: 17},
|
|
61
|
+
{name: 'child2', size: 15, loaded: true},
|
|
62
|
+
];
|
|
63
|
+
this.set('data', [...this.get('data')]);
|
|
64
|
+
|
|
65
|
+
resolve();
|
|
66
|
+
}, 2000);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 超长省略
|
|
3
|
+
order: 34
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
通过设置`TableColumn`的`ellipsis`属性,可以指定列超长省略
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Table, TableColumn} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<Table data={this.get('data')} resizable>
|
|
12
|
+
<TableColumn key="a" title="Title 1" minWidth={200} ellipsis/>
|
|
13
|
+
<TableColumn key="b" title="Title 2" minWidth={300} />
|
|
14
|
+
</Table>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
export default class extends Component {
|
|
19
|
+
static template = template;
|
|
20
|
+
static defaults() {
|
|
21
|
+
return {
|
|
22
|
+
data: [
|
|
23
|
+
{a: '测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长', b: 'Cell 1-2'},
|
|
24
|
+
{a: 'Cell 2-1', b: 'Cell 2-2'}
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: footer固定
|
|
3
|
+
order: 35
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`fixFooter`:设置自定义footer固定,类型`boolean`,默认:`false`;
|
|
7
|
+
设置为`true`时表示固定高度,`tbody`的高度自适应,但需要自己定义表格高度
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
```vdt
|
|
11
|
+
import {Table, TableColumn} from 'kpc';
|
|
12
|
+
|
|
13
|
+
<div class="wrapper">
|
|
14
|
+
<Table
|
|
15
|
+
data={[{a: 'footer不固定'}, {a: '下拉'}, {a: 'yeah!'}, {a: '你好'}, {a: '我很好'}]}
|
|
16
|
+
>
|
|
17
|
+
<TableColumn key="a" title="footer不固定" />
|
|
18
|
+
<b:footer>
|
|
19
|
+
<span>自定义footer</span>
|
|
20
|
+
</b:footer>
|
|
21
|
+
</Table>
|
|
22
|
+
<Table
|
|
23
|
+
data={[{a: 'footer固定啦'}, {a: '下拉'}, {a: 'yeah!'}, {a: '你好'}, {a: '我很好'}]}
|
|
24
|
+
fixFooter
|
|
25
|
+
>
|
|
26
|
+
<TableColumn key="a" title="footer固定" />
|
|
27
|
+
<b:footer>
|
|
28
|
+
<span>自定义footer</span>
|
|
29
|
+
</b:footer>
|
|
30
|
+
</Table>
|
|
31
|
+
<Table
|
|
32
|
+
data={[{a: 'footer固定啦'}, {a: '下拉'}, {a: 'yeah!'}, {a: '你好'}, {a: '我很好'}]}
|
|
33
|
+
fixFooter
|
|
34
|
+
fixHeader
|
|
35
|
+
>
|
|
36
|
+
<TableColumn key="a" title="footer,header同时固定" />
|
|
37
|
+
<b:footer>
|
|
38
|
+
<span>自定义footer</span>
|
|
39
|
+
</b:footer>
|
|
40
|
+
</Table>
|
|
41
|
+
</div>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```styl
|
|
45
|
+
.wrapper
|
|
46
|
+
display flex
|
|
47
|
+
.k-table
|
|
48
|
+
margin-left: 20px
|
|
49
|
+
flex: 1
|
|
50
|
+
.k-table-wrapper
|
|
51
|
+
height: 200px
|
|
52
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义footer
|
|
3
|
+
order: 32
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
```vdt
|
|
8
|
+
import {Table, TableColumn} from 'kpc';
|
|
9
|
+
|
|
10
|
+
<div>
|
|
11
|
+
<Table data={this.get('data')} resizable>
|
|
12
|
+
<TableColumn key="a" title="Title 1" minWidth={200}/>
|
|
13
|
+
<TableColumn key="b" title="Title 2" minWidth={300}/>
|
|
14
|
+
<b:footer>
|
|
15
|
+
<div class="footer">自定义底部</div>
|
|
16
|
+
</b:footer>
|
|
17
|
+
</Table>
|
|
18
|
+
</div>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```styl
|
|
22
|
+
.k-table
|
|
23
|
+
margin-bottom 20px
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export default class extends Component {
|
|
28
|
+
static template = template;
|
|
29
|
+
static defaults() {
|
|
30
|
+
return {
|
|
31
|
+
data: [
|
|
32
|
+
{a: 'Cell 1-1', b: 'Cell 1-2'},
|
|
33
|
+
{a: 'Cell 2-1', b: 'Cell 2-2'}
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
@@ -45,6 +45,8 @@ sidebar: doc
|
|
|
45
45
|
| animation | 是否开启动效,默认开启。可以通过`true` `false`全部设置,或者通过数组单独设置行和列的动效 | `boolean` | `[boolean, boolean]` | `true` |
|
|
46
46
|
| hideHeader | 是否隐藏表头 | `boolean` | `false` |
|
|
47
47
|
| pagination | 是否支持分页 | `boolean` | `PaginationProps` | `false` |
|
|
48
|
+
| fixFooter | `table`给定需要固定高度时,自定义footer固定 | `boolean` | `false` |
|
|
49
|
+
| load | 指定异步加载节点数据的函数,该函数通过`Promise`返回数组来添加子节点数据 | <code>(node: any) => Promise<void> | void</code> | `undefined` |
|
|
48
50
|
|
|
49
51
|
```ts
|
|
50
52
|
import {Props} from 'intact';
|
|
@@ -113,6 +115,7 @@ export interface PaginationProps {
|
|
|
113
115
|
| minWidth | 指定当前列拖动时的最小宽度,优先级高于`Table`的`minColWidth` | `number` | `undefined` |
|
|
114
116
|
| className | 给当前列添加className | `string` | `Record<string, any>` | `undefined` |
|
|
115
117
|
| hidden | 是否隐藏当前列,仅为不可见,不影响`exportTable`导出表格 | `boolean` | `false` |
|
|
118
|
+
| ellipsis | 是否开启超长省略 | `boolean` | `false` |
|
|
116
119
|
|
|
117
120
|
```ts
|
|
118
121
|
import {VNode} from 'intact';
|
|
@@ -132,6 +135,7 @@ export type TableColumnGroupItem = {
|
|
|
132
135
|
| empty | 自定义无数据展示模板 | - |
|
|
133
136
|
| expand | 指定行展开后要展示的模板内容 | `([data: T, index: number]) => Children` |
|
|
134
137
|
| tooltip | 行提示内容 | `([data: T, index: number]) => Children` |
|
|
138
|
+
| footer | 自定义`Table`底部 | - |
|
|
135
139
|
|
|
136
140
|
## TableColumn
|
|
137
141
|
|
package/components/table/row.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {bind} from '../utils';
|
|
|
14
14
|
import type {TableGrid} from './useMerge';
|
|
15
15
|
import { isEqualObject } from '../utils';
|
|
16
16
|
import { useConfigContext } from '../config';
|
|
17
|
+
import { hasOwn } from 'intact-shared';
|
|
17
18
|
|
|
18
19
|
export interface TableRowProps {
|
|
19
20
|
key: TableRowKey
|
|
@@ -34,10 +35,11 @@ export interface TableRowProps {
|
|
|
34
35
|
spreaded: boolean
|
|
35
36
|
hasChildren: boolean
|
|
36
37
|
indent: number
|
|
37
|
-
onToggleSpreadRow: (key: TableRowKey) => void
|
|
38
|
+
onToggleSpreadRow: (key: TableRowKey, rowData?: any) => void
|
|
38
39
|
onBeforeUnmount: (key: TableRowKey) => void
|
|
39
40
|
offsetMap: Record<Key, number>
|
|
40
41
|
animation: boolean
|
|
42
|
+
loaded: boolean
|
|
41
43
|
|
|
42
44
|
draggable: boolean
|
|
43
45
|
draggingKey: TableRowKey | null
|
|
@@ -65,20 +67,27 @@ export class TableRow extends Component<TableRowProps> {
|
|
|
65
67
|
const nextProps = nextVNode.props as TableRowProps;
|
|
66
68
|
|
|
67
69
|
let isSame = true;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
if (hasOwn.call(this, 'vueInstance')) {
|
|
71
|
+
// In Vue, we may change value by modifing the same reference,
|
|
72
|
+
// and the new row may be expanded by click tree arrow
|
|
73
|
+
// so we can not compare in this case, #1030
|
|
74
|
+
isSame = false;
|
|
75
|
+
} else {
|
|
76
|
+
let key: keyof TableRowProps;
|
|
77
|
+
for (key in lastProps) {
|
|
78
|
+
// ignore index
|
|
79
|
+
if (key === 'index') continue;
|
|
80
|
+
const lastValue = lastProps[key];
|
|
81
|
+
const nextValue = nextProps[key];
|
|
82
|
+
// deeply compare for offsetMap
|
|
83
|
+
if (key === 'offsetMap' && isEqualObject(lastValue, nextValue)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (lastValue !== nextValue) {
|
|
88
|
+
isSame = false;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
82
91
|
}
|
|
83
92
|
}
|
|
84
93
|
|
|
@@ -109,8 +118,8 @@ export class TableRow extends Component<TableRowProps> {
|
|
|
109
118
|
@bind
|
|
110
119
|
onClickArrow(e: MouseEvent) {
|
|
111
120
|
e.stopPropagation();
|
|
112
|
-
const {onToggleSpreadRow, key} = this.get();
|
|
113
|
-
onToggleSpreadRow(key);
|
|
121
|
+
const {onToggleSpreadRow, key, data} = this.get();
|
|
122
|
+
onToggleSpreadRow(key, data);
|
|
114
123
|
}
|
|
115
124
|
|
|
116
125
|
@bind
|
package/components/table/row.vdt
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
grid, index: rowIndex, indeterminate,
|
|
12
12
|
allDisabled, selected, /* hidden, */spreaded,
|
|
13
13
|
hasChildren, indent, key, offsetMap,
|
|
14
|
-
draggable, draggingKey, animation,
|
|
14
|
+
draggable, draggingKey, animation, loaded,
|
|
15
15
|
} = this.get();
|
|
16
16
|
const { k } = this.config;
|
|
17
17
|
|
|
@@ -71,13 +71,13 @@ cols.forEach((props, columnIndex) => {
|
|
|
71
71
|
if (!render) return;
|
|
72
72
|
|
|
73
73
|
const columnKey = props.key;
|
|
74
|
-
|
|
75
74
|
vNodes.push(
|
|
76
75
|
<TableCell
|
|
77
76
|
props={props}
|
|
78
77
|
columnIndex={columnIndex}
|
|
79
78
|
rowIndex={rowIndex}
|
|
80
79
|
data={data}
|
|
80
|
+
loaded={loaded}
|
|
81
81
|
offset={offsetMap[columnKey]}
|
|
82
82
|
checkType={checkType}
|
|
83
83
|
indent={indent}
|
|
@@ -90,7 +90,7 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
90
90
|
}
|
|
91
91
|
table {
|
|
92
92
|
width: 100%;
|
|
93
|
-
|
|
93
|
+
border-collapse: separate;
|
|
94
94
|
border-spacing: 0;
|
|
95
95
|
table-layout: fixed;
|
|
96
96
|
// td,
|
|
@@ -104,8 +104,6 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
104
104
|
text-align: ${table.thead.textAlign};
|
|
105
105
|
font-size: ${table.thead.fontSize};
|
|
106
106
|
font-weight: ${table.thead.fontWeight};
|
|
107
|
-
position: sticky;
|
|
108
|
-
top: 0;
|
|
109
107
|
z-index: 2;
|
|
110
108
|
tr {
|
|
111
109
|
height: ${table.thead.height};
|
|
@@ -114,6 +112,14 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
}
|
|
115
|
+
tfoot {
|
|
116
|
+
z-index: 2;
|
|
117
|
+
tr {
|
|
118
|
+
td {
|
|
119
|
+
border-top: ${table.border};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
117
123
|
th {
|
|
118
124
|
padding: ${table.thead.padding};
|
|
119
125
|
position: relative;
|
|
@@ -376,6 +382,21 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
376
382
|
.${k}-table-wrapper {
|
|
377
383
|
height: 100%;
|
|
378
384
|
}
|
|
385
|
+
thead {
|
|
386
|
+
position: sticky;
|
|
387
|
+
top: 0;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
// fixFooter
|
|
391
|
+
&.${k}-fix-footer {
|
|
392
|
+
min-height: 0;
|
|
393
|
+
.${k}-table-wrapper {
|
|
394
|
+
height: 100%;
|
|
395
|
+
}
|
|
396
|
+
tfoot {
|
|
397
|
+
position: sticky;
|
|
398
|
+
bottom: 0;
|
|
399
|
+
}
|
|
379
400
|
}
|
|
380
401
|
`;
|
|
381
402
|
});
|
|
@@ -65,6 +65,8 @@ export interface TableProps<
|
|
|
65
65
|
animation?: boolean | [boolean, boolean]
|
|
66
66
|
hideHeader?: boolean
|
|
67
67
|
pagination?: boolean | PaginationProps
|
|
68
|
+
fixFooter?: boolean
|
|
69
|
+
load?: (value: T) => Promise<void> | void
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
export interface TableEvents<T = any, K extends TableRowKey = number> {
|
|
@@ -82,6 +84,7 @@ export interface TableBlocks<T = unknown> {
|
|
|
82
84
|
empty: null
|
|
83
85
|
tooltip: [T, number]
|
|
84
86
|
expand: [T, number]
|
|
87
|
+
footer: null
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
type CheckType = 'checkbox' | 'radio' | 'none'
|
|
@@ -130,6 +133,8 @@ const typeDefs: Required<TypeDefs<TableProps<unknown>>> = {
|
|
|
130
133
|
animation: [Boolean, Array],
|
|
131
134
|
hideHeader: Boolean,
|
|
132
135
|
pagination: [Boolean, Object],
|
|
136
|
+
fixFooter: Boolean,
|
|
137
|
+
load: Function,
|
|
133
138
|
};
|
|
134
139
|
|
|
135
140
|
const defaults = (): Partial<TableProps> => ({
|
|
@@ -25,7 +25,7 @@ const {
|
|
|
25
25
|
merge, childrenKey, indent, tooltipPosition,
|
|
26
26
|
tooltipContainer, showIndeterminate, resizable,
|
|
27
27
|
draggable, animation: _animation, hideHeader,
|
|
28
|
-
pagination,
|
|
28
|
+
pagination, fixFooter,
|
|
29
29
|
} = this.get();
|
|
30
30
|
const animation = !Array.isArray(_animation) ? [_animation, _animation] : _animation;
|
|
31
31
|
const {columns, cols, maxRows, maxCols} = this.columns.getData();
|
|
@@ -36,6 +36,7 @@ const { k } = this.config;
|
|
|
36
36
|
const classNameObj = {
|
|
37
37
|
[`${k}-table`]: true,
|
|
38
38
|
[`${k}-fix-header`]: fixHeader,
|
|
39
|
+
[`${k}-fix-footer`]: fixFooter,
|
|
39
40
|
[`${k}-scroll-${scrollPosition.value}`]: scrollPosition.value,
|
|
40
41
|
[`${k}-fix-columns`]: hasFixed.value,
|
|
41
42
|
[`${k}-${type}`]: type && type !== 'default',
|
|
@@ -137,11 +138,11 @@ const tbody = (
|
|
|
137
138
|
const spreaded = isSpreaded(key);
|
|
138
139
|
const hasChildren = !!childrenKey && Array.isArray(value[childrenKey]);
|
|
139
140
|
const indentSize = indent ? indent * level : 0;
|
|
140
|
-
|
|
141
141
|
let row = <TableRow
|
|
142
142
|
key={key}
|
|
143
143
|
cols={cols}
|
|
144
144
|
data={value}
|
|
145
|
+
loaded={value.loaded}
|
|
145
146
|
checkType={checkType}
|
|
146
147
|
hasFixedLeft={hasFixedLeft}
|
|
147
148
|
onClick={this.clickRow}
|
|
@@ -208,6 +209,17 @@ const tbody = (
|
|
|
208
209
|
</tbody>
|
|
209
210
|
);
|
|
210
211
|
|
|
212
|
+
let tfooter = null;
|
|
213
|
+
if ($blocks.footer) {
|
|
214
|
+
tfooter = <tfoot>
|
|
215
|
+
<tr key="table-footer">
|
|
216
|
+
<td colspan={colCount} class={`${k}-table-footer`}>
|
|
217
|
+
<b:footer />
|
|
218
|
+
</td>
|
|
219
|
+
</tr>
|
|
220
|
+
</tfoot>
|
|
221
|
+
}
|
|
222
|
+
|
|
211
223
|
const tableWidthPx = tableWidth.value ? `${tableWidth.value}px` : null;
|
|
212
224
|
const {
|
|
213
225
|
shouldStickScrollbar,
|
|
@@ -240,6 +252,7 @@ const {
|
|
|
240
252
|
<template>{colgroup}</template>
|
|
241
253
|
<template v-if={isNull(stickHeader.value)}>{thead}</template>
|
|
242
254
|
<template>{tbody}</template>
|
|
255
|
+
<template v-if={$blocks.footer}>{tfooter}</template>
|
|
243
256
|
</table>
|
|
244
257
|
</div>
|
|
245
258
|
<Pagination v-if={pagination}
|
|
@@ -11,8 +11,15 @@ export function useTree(data: State<any[] | undefined>) {
|
|
|
11
11
|
return inArray(instance.get('spreadKeys'), key);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function toggleSpreadRow(key: TableRowKey) {
|
|
15
|
-
|
|
14
|
+
async function toggleSpreadRow(key: TableRowKey, rowData?: any) {
|
|
15
|
+
const {spreadKeys, load} = instance.get();
|
|
16
|
+
instance.set('spreadKeys', toggleArray(spreadKeys, key));
|
|
17
|
+
if (load && data.value && !rowData.loaded) {
|
|
18
|
+
rowData.loaded = false;
|
|
19
|
+
await load(rowData);
|
|
20
|
+
rowData.loaded = true;
|
|
21
|
+
instance.forceUpdate();
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
function loopData<T>(
|
|
@@ -6,7 +6,7 @@ order: 3
|
|
|
6
6
|
使用`content`扩展点,可以自定义复杂的提示内容
|
|
7
7
|
|
|
8
8
|
```vdt
|
|
9
|
-
import {Tooltip, Slider, Button} from 'kpc';
|
|
9
|
+
import {Tooltip, Slider, Button, Select, Option} from 'kpc';
|
|
10
10
|
|
|
11
11
|
<div>
|
|
12
12
|
<Tooltip trigger="click">
|
|
@@ -19,15 +19,30 @@ import {Tooltip, Slider, Button} from 'kpc';
|
|
|
19
19
|
/>
|
|
20
20
|
</b:content>
|
|
21
21
|
</Tooltip>
|
|
22
|
+
<Tooltip trigger="click" theme="light">
|
|
23
|
+
<Button>Test Dropdown</Button>
|
|
24
|
+
<b:content>
|
|
25
|
+
<Select v-model="day" width={200}>
|
|
26
|
+
<Option value="Monday">星期一</Option>
|
|
27
|
+
<Option value="Tuesday">星期二</Option>
|
|
28
|
+
</Select>
|
|
29
|
+
</b:content>
|
|
30
|
+
</Tooltip>
|
|
22
31
|
</div>
|
|
23
32
|
```
|
|
24
33
|
|
|
34
|
+
```styl
|
|
35
|
+
.k-btn
|
|
36
|
+
margin-right 8px
|
|
37
|
+
```
|
|
38
|
+
|
|
25
39
|
```ts
|
|
26
40
|
export default class extends Component {
|
|
27
41
|
static template = template;
|
|
28
42
|
static defaults() {
|
|
29
43
|
return {
|
|
30
|
-
volume: 0
|
|
44
|
+
volume: 0,
|
|
45
|
+
day: 'Monday'
|
|
31
46
|
};
|
|
32
47
|
};
|
|
33
48
|
}
|
|
@@ -148,14 +148,33 @@ describe('Tooltip', () => {
|
|
|
148
148
|
it('should custom content correctly', async () => {
|
|
149
149
|
const [, element] = mount(ContentDemo);
|
|
150
150
|
|
|
151
|
-
const [
|
|
152
|
-
|
|
151
|
+
const [btn1] = Array.from<HTMLElement>(element.querySelectorAll('.k-btn'));
|
|
152
|
+
btn1.click();
|
|
153
153
|
await wait(500);
|
|
154
154
|
const content = getElement('.k-tooltip-content') as HTMLElement;
|
|
155
155
|
// ignore the arrow, because it may change className to adapt to the direction
|
|
156
156
|
expect(content.querySelector<HTMLElement>('.k-slider')!.outerHTML).to.matchSnapshot();
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
+
it('Internal dropdown closing should not affect tooltip', async () => {
|
|
160
|
+
const [, element] = mount(ContentDemo);
|
|
161
|
+
|
|
162
|
+
const [, btn2] = Array.from<HTMLElement>(element.querySelectorAll('.k-btn'));
|
|
163
|
+
btn2.click();
|
|
164
|
+
await wait(500);
|
|
165
|
+
const content = getElement('.k-tooltip-content') as HTMLElement;
|
|
166
|
+
const trigger = content.querySelector('.k-select') as HTMLElement;
|
|
167
|
+
trigger.click();
|
|
168
|
+
await wait();
|
|
169
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
170
|
+
const dropdown = getElement('.k-select-menu')!;
|
|
171
|
+
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
172
|
+
const item = dropdown.querySelector('.k-dropdown-item') as HTMLElement;
|
|
173
|
+
item.click();
|
|
174
|
+
await wait(500);
|
|
175
|
+
expect(content.style.display).to.eql('')
|
|
176
|
+
});
|
|
177
|
+
|
|
159
178
|
|
|
160
179
|
it('should always show tooltip', async () => {
|
|
161
180
|
const [, element] = mount(AlwaysDemo);
|
|
@@ -55,7 +55,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
var classNameObj = (_classNameObj = {}, _classNameObj[cls('btn')] = true, _classNameObj[cls(size)] = size !== 'default', _classNameObj[cls(type)] = !color, _classNameObj[cls("btn-icon")] = icon, _classNameObj[className] = className, _classNameObj[cls('circle')] = circle, _classNameObj[cls('loading')] = loading, _classNameObj[cls('fluid')] = fluid, _classNameObj[cls('active')] = checked, _classNameObj[cls('
|
|
58
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[cls('btn')] = true, _classNameObj[cls(size)] = size !== 'default', _classNameObj[cls(type)] = !color, _classNameObj[cls("btn-icon")] = icon, _classNameObj[className] = className, _classNameObj[cls('circle')] = circle, _classNameObj[cls('loading')] = loading, _classNameObj[cls('fluid')] = fluid, _classNameObj[cls('active')] = checked, _classNameObj[cls('custom')] = color, _classNameObj[cls('disabled')] = disabled || loading, _classNameObj[cls('ghost')] = ghost, _classNameObj[makeButtonStyles(k, iconSide, color)] = true, _classNameObj);
|
|
59
59
|
var loadingIcon = _$cc(Icon, {
|
|
60
60
|
'className': _$cn("ion-load-c " + k + "-icon-loading"),
|
|
61
61
|
'size': size /*loadingSizeMap[size]*/,
|
|
@@ -11,7 +11,7 @@ var btnStyles = {
|
|
|
11
11
|
return theme.color.text;
|
|
12
12
|
},
|
|
13
13
|
bgColor: '#fff',
|
|
14
|
-
lineHeight: '1
|
|
14
|
+
lineHeight: '1',
|
|
15
15
|
get padding() {
|
|
16
16
|
return "0 16px";
|
|
17
17
|
},
|
|
@@ -199,8 +199,8 @@ export var makeButtonStyles = cache(function makeButtonStyles(k, iconSide, color
|
|
|
199
199
|
// extract static styles to individual css method for performance
|
|
200
200
|
css("display:inline-flex;align-items:center;justify-content:center;cursor:pointer;height:", button.height, ";padding:", button.padding, ";outline:none;vertical-align:middle;color:", button.color, ";background:", button.bgColor, ";border-radius:", button.borderRadius, ";border:1px solid ", button.borderColor, ";font-size:", button.fontSize, ";white-space:nowrap;transition:all ", button.transition, ";line-height:", button.lineHeight, ";.", k, "-icon{color:inherit;}&.", k, "-default,&.", k, "-none,&.", k, "-flat{.", k, "-icon{color:", theme.color.lightBlack, ";}&:hover{.", k, "-icon{color:inherit;}}}&:hover,&:focus{border-color:", button.hoverBorderColor, ";color:", button.hoverColor, ";}&:active{background:", palette(theme.color.primary, -4), ";}.", k, "-button-input{position:absolute;opacity:0;width:0;height:0;}", _mapInstanceProperty(types).call(types, function (type) {
|
|
201
201
|
var typeStyles = button[type];
|
|
202
|
-
return /*#__PURE__*/css("&.", k, "-", type, "{background:", typeStyles.bgColor, ";color:", typeStyles.color, ";border-color:", typeStyles.borderColor, ";&:hover,&:focus{background:", palette(typeStyles.bgColor, -1), ";border-color:", typeStyles.hoverBorderColor, ";color:", typeStyles.color, ";}&:active{background:", palette(typeStyles.bgColor, 1), ";border-color:", palette(typeStyles.borderColor, 1), ";}}");
|
|
203
|
-
}), "&.", k, "-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}}", color && /*#__PURE__*/css("&.", k, "-custom{color:", color, ";border-color:", color, ";&:hover,&:focus{background:", palette(color, -4), ";}&:active{background:", palette(color, -3), ";}}"), " &.", k, "-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.", k, "-none,&.", k, "-link,&.", k, "-flat{background:transparent;&,&:hover{border:none;}&.", k, "-active{color:", theme.color.primary, ";}}&.", k, "-none:hover{background:", button.none.hoverBgColor, ";}&.", k, "-flat{background:", button.none.hoverBgColor, ";}&.", k, "-disabled{.", k, "-icon{color:inherit;}&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.", k, "-none.", k, "-disabled,&.", k, "-link.", k, "-disabled{&,&:hover{background:transparent;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
202
|
+
return /*#__PURE__*/css("&.", k, "-", type, "{background:", typeStyles.bgColor, ";color:", typeStyles.color, ";border-color:", typeStyles.borderColor, ";&:hover,&:focus{background:", palette(typeStyles.bgColor, -1), ";border-color:", typeStyles.hoverBorderColor, ";color:", typeStyles.color, ";}&:active{background:", palette(typeStyles.bgColor, 1), ";border-color:", palette(typeStyles.borderColor, 1), ";}&.", k, "-disabled{&,&:hover{background:", palette(typeStyles.bgColor, -2), ";color:", palette(typeStyles.color, -2), ";border-color:", palette(typeStyles.borderColor, -2), ";}}}");
|
|
203
|
+
}), "&.", k, "-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}&.", k, "-disabled{border:none;}}", color && /*#__PURE__*/css("&.", k, "-custom{color:", color, ";border-color:", color, ";&:hover,&:focus{background:", palette(color, -4), ";}&:active{background:", palette(color, -3), ";}&.", k, "-disabled{border:none;}}"), " &.", k, "-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.", k, "-none,&.", k, "-link,&.", k, "-flat{background:transparent;&,&:hover{border:none;}&.", k, "-active{color:", theme.color.primary, ";}}&.", k, "-none:hover{background:", button.none.hoverBgColor, ";}&.", k, "-flat{background:", button.none.hoverBgColor, ";}&.", k, "-disabled{.", k, "-icon{color:inherit;}&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.", k, "-none.", k, "-disabled,&.", k, "-link.", k, "-disabled{&,&:hover{background:transparent;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
204
204
|
var styles = button[size];
|
|
205
205
|
return /*#__PURE__*/css("&.", k, "-", size, "{font-size:", styles.fontSize, ";height:", styles.height, ";padding:", styles.padding, ";&.", k, "-btn-icon{width:", styles.height, ";}}");
|
|
206
206
|
}), "&.", k, "-btn-icon{width:", button.height, ";padding:0;.", k, "-icon{margin:0;}}&.", k, "-fluid{width:100%;padding:0;}&.", k, "-circle{border-radius:calc(", button.large.height, " / 2);}&.", k, "-loading{", _mapInstanceProperty(types).call(types, function (type) {
|
|
@@ -12,7 +12,7 @@ export declare class DCallout extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DCircle extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DDocument extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DEllipse extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|