@king-design/intact 3.4.3-beta.2 → 3.4.4
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/demos/group.md +3 -3
- package/components/button/group.ts +5 -0
- package/components/button/group.vdt +2 -2
- package/components/button/index.md +2 -1
- package/components/button/index.vdt +1 -1
- package/components/button/styles.ts +18 -5
- 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 +3 -2
- package/components/table/cell.vdt +13 -4
- package/components/table/column.ts +2 -0
- package/components/table/column.vdt +4 -3
- package/components/table/demos/asyncTree.md +73 -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/demos/tree.md +22 -10
- package/components/table/index.md +5 -0
- package/components/table/row.ts +27 -17
- package/components/table/row.vdt +4 -2
- package/components/table/styles.ts +27 -3
- package/components/table/table.ts +8 -2
- package/components/table/table.vdt +18 -3
- package/components/table/useColumns.ts +24 -1
- package/components/table/useTree.ts +9 -2
- package/components/tip/demos/icon.md +53 -0
- package/components/tip/demos/size.md +39 -0
- package/components/tip/index.md +2 -0
- package/components/tip/index.ts +17 -1
- package/components/tip/index.vdt +38 -5
- package/components/tip/styles.ts +84 -3
- package/components/tooltip/demos/always.md +6 -0
- package/components/tooltip/demos/content.md +17 -2
- package/components/tooltip/index.spec.ts +21 -2
- package/components/tooltip/tooltip.ts +4 -1
- package/components/transfer/index.vdt +2 -4
- package/components/tree/demos/loading.md +3 -0
- package/components/treeSelect/demos/basic.md +1 -0
- package/components/treeSelect/index.vdt +1 -0
- package/components/upload/demos/files.md +1 -0
- package/components/upload/index.vdt +4 -1
- package/components/upload/styles.ts +1 -0
- package/es/components/button/group.d.ts +1 -0
- package/es/components/button/group.js +4 -0
- package/es/components/button/group.vdt.js +3 -2
- package/es/components/button/index.vdt.js +1 -1
- package/es/components/button/styles.js +6 -6
- 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 +2 -0
- package/es/components/table/cell.vdt.js +18 -5
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +1 -0
- package/es/components/table/column.vdt.js +16 -12
- package/es/components/table/row.d.ts +3 -1
- package/es/components/table/row.js +24 -15
- package/es/components/table/row.vdt.js +6 -2
- package/es/components/table/styles.d.ts +49 -0
- package/es/components/table/styles.js +3 -2
- package/es/components/table/table.d.ts +4 -0
- package/es/components/table/table.js +4 -1
- package/es/components/table/table.vdt.js +29 -4
- package/es/components/table/useColumns.d.ts +9 -0
- package/es/components/table/useColumns.js +29 -1
- package/es/components/table/useTree.d.ts +1 -1
- package/es/components/table/useTree.js +30 -2
- package/es/components/tip/index.d.ts +6 -1
- package/es/components/tip/index.js +12 -1
- package/es/components/tip/index.vdt.js +25 -5
- package/es/components/tip/styles.js +44 -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 +14 -2
- package/es/components/transfer/index.vdt.js +2 -4
- package/es/components/treeSelect/index.vdt.js +1 -0
- package/es/components/upload/index.vdt.js +4 -1
- package/es/components/upload/styles.js +1 -1
- 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/button/demos/group/react.js +2 -2
- 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/table/demos/tree/react.js +18 -2
- package/es/site/data/components/tip/demos/icon/index.d.ts +9 -0
- package/es/site/data/components/tip/demos/icon/index.js +19 -0
- package/es/site/data/components/tip/demos/icon/react.d.ts +8 -0
- package/es/site/data/components/tip/demos/icon/react.js +54 -0
- package/es/site/data/components/tip/demos/size/index.d.ts +9 -0
- package/es/site/data/components/tip/demos/size/index.js +19 -0
- package/es/site/data/components/tip/demos/size/react.d.ts +8 -0
- package/es/site/data/components/tip/demos/size/react.js +39 -0
- package/es/site/data/components/tooltip/demos/always/react.js +5 -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/es/site/data/components/upload/demos/files/index.js +3 -0
- package/es/site/data/components/upload/demos/files/react.js +3 -0
- package/es/site/src/pages/font/index.js +1 -1
- package/es/site/src/pages/font/styles.js +1 -1
- package/index.ts +2 -2
- package/package.json +2 -2
|
@@ -25,10 +25,11 @@ const {
|
|
|
25
25
|
merge, childrenKey, indent, tooltipPosition,
|
|
26
26
|
tooltipContainer, showIndeterminate, resizable,
|
|
27
27
|
draggable, animation: _animation, hideHeader,
|
|
28
|
-
pagination,
|
|
28
|
+
pagination, fixFooter, spreadArrowIndex
|
|
29
29
|
} = this.get();
|
|
30
30
|
const animation = !Array.isArray(_animation) ? [_animation, _animation] : _animation;
|
|
31
31
|
const {columns, cols, maxRows, maxCols} = this.columns.getData();
|
|
32
|
+
const {lastCellKey, lastCellStyle} = this.columns.getStyleForLastColumn();
|
|
32
33
|
const {scrollPosition, hasFixed, getHasFixedLeft, offsetMap} = this.fixedColumns;
|
|
33
34
|
const {scrollRef} = this.scroll;
|
|
34
35
|
const {stickHeader, excludeStickHeader, elementRef, headRef} = this.stickyHeader;
|
|
@@ -36,6 +37,7 @@ const { k } = this.config;
|
|
|
36
37
|
const classNameObj = {
|
|
37
38
|
[`${k}-table`]: true,
|
|
38
39
|
[`${k}-fix-header`]: fixHeader,
|
|
40
|
+
[`${k}-fix-footer`]: fixFooter,
|
|
39
41
|
[`${k}-scroll-${scrollPosition.value}`]: scrollPosition.value,
|
|
40
42
|
[`${k}-fix-columns`]: hasFixed.value,
|
|
41
43
|
[`${k}-${type}`]: type && type !== 'default',
|
|
@@ -70,7 +72,7 @@ const hasFixedLeft = getHasFixedLeft();
|
|
|
70
72
|
const {getAllCheckedStatus, toggleCheckedAll, getAllStatus, onChangeChecked} = this.checked;
|
|
71
73
|
const allCheckedStatus = getAllCheckedStatus();
|
|
72
74
|
const thead = hideHeader ? null : (
|
|
73
|
-
<TableContext.Provider value={checkType}>
|
|
75
|
+
<TableContext.Provider value={{checkType, lastCellKey, lastCellStyle}}>
|
|
74
76
|
<GroupContext.Provider value={{group, onChange: this.onChangeGroup}}>
|
|
75
77
|
<SortableContext.Provider value={{sort, onChange: this.sortable.onChange}}>
|
|
76
78
|
<ResizableContext.Provider value={{resizable, onStart}}>
|
|
@@ -137,11 +139,11 @@ const tbody = (
|
|
|
137
139
|
const spreaded = isSpreaded(key);
|
|
138
140
|
const hasChildren = !!childrenKey && Array.isArray(value[childrenKey]);
|
|
139
141
|
const indentSize = indent ? indent * level : 0;
|
|
140
|
-
|
|
141
142
|
let row = <TableRow
|
|
142
143
|
key={key}
|
|
143
144
|
cols={cols}
|
|
144
145
|
data={value}
|
|
146
|
+
loaded={value.loaded}
|
|
145
147
|
checkType={checkType}
|
|
146
148
|
hasFixedLeft={hasFixedLeft}
|
|
147
149
|
onClick={this.clickRow}
|
|
@@ -162,6 +164,7 @@ const tbody = (
|
|
|
162
164
|
onBeforeUnmount={this.resetRowStatus.onRowBeforeUnmount}
|
|
163
165
|
offsetMap={offsetMap.value}
|
|
164
166
|
animation={animation[1]}
|
|
167
|
+
spreadArrowIndex={spreadArrowIndex}
|
|
165
168
|
|
|
166
169
|
draggable={draggable}
|
|
167
170
|
draggingKey={draggingKey.value}
|
|
@@ -208,6 +211,17 @@ const tbody = (
|
|
|
208
211
|
</tbody>
|
|
209
212
|
);
|
|
210
213
|
|
|
214
|
+
let tfooter = null;
|
|
215
|
+
if ($blocks.footer) {
|
|
216
|
+
tfooter = <tfoot>
|
|
217
|
+
<tr key="table-footer">
|
|
218
|
+
<td colspan={colCount} class={`${k}-table-footer`}>
|
|
219
|
+
<b:footer />
|
|
220
|
+
</td>
|
|
221
|
+
</tr>
|
|
222
|
+
</tfoot>
|
|
223
|
+
}
|
|
224
|
+
|
|
211
225
|
const tableWidthPx = tableWidth.value ? `${tableWidth.value}px` : null;
|
|
212
226
|
const {
|
|
213
227
|
shouldStickScrollbar,
|
|
@@ -240,6 +254,7 @@ const {
|
|
|
240
254
|
<template>{colgroup}</template>
|
|
241
255
|
<template v-if={isNull(stickHeader.value)}>{thead}</template>
|
|
242
256
|
<template>{tbody}</template>
|
|
257
|
+
<template v-if={$blocks.footer}>{tfooter}</template>
|
|
243
258
|
</table>
|
|
244
259
|
</div>
|
|
245
260
|
<Pagination v-if={pagination}
|
|
@@ -4,6 +4,7 @@ import {TableColumn, TableColumnProps} from './column';
|
|
|
4
4
|
import {useState} from '../../hooks/useState';
|
|
5
5
|
import type {Table, TableProps} from './table';
|
|
6
6
|
import {createContext} from '../context';
|
|
7
|
+
import {table as theme} from './styles';
|
|
7
8
|
|
|
8
9
|
export const context = createContext<TableProps['checkType']>();
|
|
9
10
|
|
|
@@ -118,5 +119,27 @@ export function useColumns() {
|
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
|
|
123
|
+
function getStyleForLastColumn() {
|
|
124
|
+
if (instance.get('type') !== 'grid' || !columns.length || !cols.length) {
|
|
125
|
+
return {lastCellKey: null, lastCellStyle: null};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const lastRow = columns[columns.length - 1];
|
|
129
|
+
const lastTrItem = lastRow[lastRow.length - 1];
|
|
130
|
+
const lastCol = cols[cols.length - 1];
|
|
131
|
+
|
|
132
|
+
if (!lastTrItem || !lastCol) {
|
|
133
|
+
return {lastCellKey: null, lastCellStyle: null};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return lastCol.key === lastTrItem.key
|
|
137
|
+
? {lastCellKey: null, lastCellStyle: null}
|
|
138
|
+
: {
|
|
139
|
+
lastCellKey: lastTrItem.key,
|
|
140
|
+
lastCellStyle: {'border-right': `${theme.border}`}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {getColumns, getCols, getData, getStyleForLastColumn}
|
|
122
145
|
}
|
|
@@ -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>(
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 支持Icon
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
标签类型:`default`, `primary`, `success`, `warning` `danger`
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tip, Icon} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Tip v-for={this.get('types')}
|
|
13
|
+
type={$value}
|
|
14
|
+
showIcon
|
|
15
|
+
closable
|
|
16
|
+
>{$value}</Tip>
|
|
17
|
+
<Tip type="success" showIcon closable>
|
|
18
|
+
这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容,这是一条测试内容。
|
|
19
|
+
</Tip>
|
|
20
|
+
<h3>自定义Icon</h3>
|
|
21
|
+
<Tip>
|
|
22
|
+
<b:icon><Icon class="k-icon-internet" /></b:icon>
|
|
23
|
+
custom Icon
|
|
24
|
+
</Tip>
|
|
25
|
+
<h3>标题带Icon</h3>
|
|
26
|
+
<Tip type="primary" showIcon>
|
|
27
|
+
<b:title>这是标题</b:title>
|
|
28
|
+
This is a tip.
|
|
29
|
+
</Tip>
|
|
30
|
+
<h3>标题自定义Icon</h3>
|
|
31
|
+
<Tip type="primary" showIcon closable>
|
|
32
|
+
<b:icon><Icon class="k-icon-internet" /></b:icon>
|
|
33
|
+
<b:title>这是标题</b:title>
|
|
34
|
+
This is a tip.
|
|
35
|
+
</Tip>
|
|
36
|
+
</div>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```styl
|
|
40
|
+
.k-tip
|
|
41
|
+
margin-bottom 8px
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
export default class extends Component {
|
|
46
|
+
static template = template;
|
|
47
|
+
static defaults() {
|
|
48
|
+
return {
|
|
49
|
+
types: ['default', 'primary', 'success', 'warning', 'danger'] as const
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 尺寸
|
|
3
|
+
order: 4
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
尺寸大小:`large`, `default`, `small`, `mini`
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tip} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Tip v-for={this.get('sizes')}
|
|
13
|
+
type="primary"
|
|
14
|
+
size={$value}
|
|
15
|
+
>{$value}</Tip>
|
|
16
|
+
<h3>带关闭按钮</h3>
|
|
17
|
+
<Tip v-for={this.get('sizes')}
|
|
18
|
+
type="primary"
|
|
19
|
+
size={$value}
|
|
20
|
+
closable
|
|
21
|
+
>{$value}</Tip>
|
|
22
|
+
</div>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```styl
|
|
26
|
+
.k-tip
|
|
27
|
+
margin-bottom 8px
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default class extends Component {
|
|
32
|
+
static template = template;
|
|
33
|
+
static defaults() {
|
|
34
|
+
return {
|
|
35
|
+
sizes: ['large', 'default', 'small', 'mini'] as const
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
package/components/tip/index.md
CHANGED
|
@@ -17,6 +17,7 @@ sidebar: doc
|
|
|
17
17
|
| disabled | 是否展示禁用状态 | `boolean` | `false` |
|
|
18
18
|
| size | 组件尺寸 | `"large"` | `"default"` | `"small"` | `"mini"` | `"default"` |
|
|
19
19
|
| border | 定义边框样式 | `"solid"` | `"dashed"` | `"none"` | `"solid"` |
|
|
20
|
+
| showIcon | 展示Icon | `boolean` | `false` |
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
# 扩展点
|
|
@@ -25,6 +26,7 @@ sidebar: doc
|
|
|
25
26
|
| --- | --- |
|
|
26
27
|
| title | 自定义标题内容 |
|
|
27
28
|
| close | 自定义关闭按钮内容 |
|
|
29
|
+
| icon | 自定义Icon内容 |
|
|
28
30
|
|
|
29
31
|
# 事件
|
|
30
32
|
|
package/components/tip/index.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
|
+
import {TypeDefs} from 'intact';
|
|
1
2
|
import template from './index.vdt';
|
|
2
3
|
import {Tag, TagProps, TagEvents, TagBlocks} from '../tag/base';
|
|
3
4
|
|
|
4
|
-
export interface TipProps extends TagProps {
|
|
5
|
+
export interface TipProps extends TagProps {
|
|
6
|
+
showIcon?: boolean
|
|
7
|
+
}
|
|
5
8
|
|
|
6
9
|
export interface TipEvents extends TagEvents { }
|
|
7
10
|
|
|
8
11
|
export interface TipBlocks extends TagBlocks {
|
|
9
12
|
title: null
|
|
10
13
|
close: null
|
|
14
|
+
icon: null
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
const typeDefs: Required<TypeDefs<TipProps>> = {
|
|
18
|
+
...Tag.typeDefs,
|
|
19
|
+
showIcon: Boolean,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const defaults = (): Partial<TipProps> => ({
|
|
23
|
+
...Tag.defaults(),
|
|
24
|
+
showIcon: false,
|
|
25
|
+
});
|
|
26
|
+
|
|
13
27
|
export class Tip extends Tag<TipProps, TipEvents, TipBlocks> {
|
|
14
28
|
static template = template;
|
|
29
|
+
static typeDefs = typeDefs;
|
|
30
|
+
static defaults = defaults;
|
|
15
31
|
}
|
package/components/tip/index.vdt
CHANGED
|
@@ -2,20 +2,53 @@ import {Button} from '../button';
|
|
|
2
2
|
import {Icon} from '../icon';
|
|
3
3
|
import {makeStyles} from './styles';
|
|
4
4
|
|
|
5
|
-
const {children, closable, type, disabled} = this.get();
|
|
5
|
+
const {children, closable, type, disabled, showIcon} = this.get();
|
|
6
6
|
const { k } = this.config;
|
|
7
|
+
|
|
8
|
+
const iconMap = {
|
|
9
|
+
default: 'information-fill',
|
|
10
|
+
info: 'information-fill',
|
|
11
|
+
warning: 'warning-fill',
|
|
12
|
+
success: 'success-fill',
|
|
13
|
+
error: 'error-fill',
|
|
14
|
+
};
|
|
15
|
+
|
|
7
16
|
const classNameObj = {
|
|
8
17
|
[`${k}-tip`]: true,
|
|
9
18
|
[makeStyles(k)]: true,
|
|
10
19
|
};
|
|
11
20
|
|
|
21
|
+
const iconWrapper = <template>
|
|
22
|
+
<template v-if={!$blocks.icon}>
|
|
23
|
+
<Icon class={{
|
|
24
|
+
[`${k}-icon-${iconMap[type] || iconMap.info}`]: true,
|
|
25
|
+
[`${k}-tip-icon`]: true,
|
|
26
|
+
}} />
|
|
27
|
+
</template>
|
|
28
|
+
<b:icon v-else />
|
|
29
|
+
</template>
|
|
30
|
+
|
|
12
31
|
<t:super class={classNameObj} name="k-fade">
|
|
13
32
|
<b:body>
|
|
14
|
-
<div class={
|
|
15
|
-
|
|
16
|
-
|
|
33
|
+
<div class={{
|
|
34
|
+
[`${k}-tip-wrapper`]: true,
|
|
35
|
+
[`${k}-with-icon`]: !$blocks.title && (showIcon || $blocks.icon)
|
|
36
|
+
}}>
|
|
37
|
+
<template v-if={!$blocks.title && (showIcon || $blocks.icon)}>
|
|
38
|
+
{iconWrapper}
|
|
39
|
+
</template>
|
|
40
|
+
<div v-if={$blocks.title} class={{
|
|
41
|
+
[`${k}-tip-title`]: true,
|
|
42
|
+
[`${k}-with-icon`]: showIcon
|
|
43
|
+
}}>
|
|
44
|
+
<template v-if={showIcon}>
|
|
45
|
+
{iconWrapper}
|
|
46
|
+
</template>
|
|
47
|
+
<span class={`${k}-title-content`}><b:title /></span>
|
|
48
|
+
</div>
|
|
49
|
+
<div class={`${k}-tip-content`}>
|
|
50
|
+
{children}
|
|
17
51
|
</div>
|
|
18
|
-
{children}
|
|
19
52
|
</div>
|
|
20
53
|
</b:body>
|
|
21
54
|
<b:_close>
|
package/components/tip/styles.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {theme, setDefault} from '../../styles/theme';
|
|
2
2
|
import {css} from '@emotion/css';
|
|
3
3
|
import '../../styles/global';
|
|
4
|
-
import {deepDefaults} from '../../styles/utils';
|
|
4
|
+
import {deepDefaults, sizes} from '../../styles/utils';
|
|
5
5
|
import { cache } from '../utils';
|
|
6
6
|
|
|
7
7
|
const defaults = {
|
|
@@ -12,6 +12,35 @@ const defaults = {
|
|
|
12
12
|
},
|
|
13
13
|
get color() { return theme.color.text },
|
|
14
14
|
get padding() { return `6px ${theme.default.padding}` },
|
|
15
|
+
content: {
|
|
16
|
+
padding: '7px 33px 8px 8px',
|
|
17
|
+
},
|
|
18
|
+
icon: {
|
|
19
|
+
fontSize: `18px`,
|
|
20
|
+
left: `16px`,
|
|
21
|
+
top: `6px`,
|
|
22
|
+
},
|
|
23
|
+
large: {
|
|
24
|
+
padding: `12px`,
|
|
25
|
+
get fontSize() { return theme.default.fontSize },
|
|
26
|
+
close: {
|
|
27
|
+
height: '42px',
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
small: {
|
|
31
|
+
padding: `4px 12px`,
|
|
32
|
+
get fontSize() { return theme.small.fontSize },
|
|
33
|
+
close: {
|
|
34
|
+
height: '26px',
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
mini: {
|
|
38
|
+
padding: `2px 12px`,
|
|
39
|
+
fontSize: '11px',
|
|
40
|
+
close: {
|
|
41
|
+
height: '20px',
|
|
42
|
+
}
|
|
43
|
+
},
|
|
15
44
|
};
|
|
16
45
|
|
|
17
46
|
let tip: typeof defaults;
|
|
@@ -29,6 +58,23 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
29
58
|
padding: 0;
|
|
30
59
|
color: ${tip.color} !important;
|
|
31
60
|
align-items: flex-start;
|
|
61
|
+
${sizes.map(s => {
|
|
62
|
+
if (s === 'default') return;
|
|
63
|
+
const styles = tip[s];
|
|
64
|
+
return css `
|
|
65
|
+
&.${k}-${s} {
|
|
66
|
+
padding: 0;
|
|
67
|
+
height: auto;
|
|
68
|
+
font-size: ${styles.fontSize};
|
|
69
|
+
.${k}-tip-wrapper {
|
|
70
|
+
padding: ${styles.padding};
|
|
71
|
+
}
|
|
72
|
+
.${k}-tip-close {
|
|
73
|
+
height: ${styles.close.height};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
})}
|
|
32
78
|
}
|
|
33
79
|
.${k}-tip-wrapper {
|
|
34
80
|
flex: 1;
|
|
@@ -39,14 +85,49 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
39
85
|
font-size: ${tip.title.fontSize};
|
|
40
86
|
margin-bottom: ${tip.title.gap};
|
|
41
87
|
font-weight: ${tip.title.fontWeight}
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
42
90
|
}
|
|
43
91
|
|
|
44
92
|
&.${k}-fade-leave-active {
|
|
45
93
|
position: relative;
|
|
46
94
|
}
|
|
47
95
|
|
|
48
|
-
.${k}-tip-close
|
|
49
|
-
|
|
96
|
+
.${k}-tip-close {
|
|
97
|
+
height: 30px;
|
|
98
|
+
&:hover {
|
|
99
|
+
background: none;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.${k}-with-icon {
|
|
104
|
+
display: flex;
|
|
105
|
+
.${k}-tip-icon {
|
|
106
|
+
font-size: 18px;
|
|
107
|
+
vertical-align: middle;
|
|
108
|
+
}
|
|
109
|
+
.${k}-title-content {
|
|
110
|
+
display: inline-block;
|
|
111
|
+
padding-left: 8px;
|
|
112
|
+
}
|
|
113
|
+
.${k}-tip-content {
|
|
114
|
+
display: inline-block;
|
|
115
|
+
padding-left: 8px;
|
|
116
|
+
vertical-align: middle;
|
|
117
|
+
word-break: break-word;
|
|
118
|
+
overflow-wrap: break-word;
|
|
119
|
+
}
|
|
50
120
|
}
|
|
121
|
+
|
|
122
|
+
${(['primary', 'danger', 'success', 'warning'] as const).map(type => {
|
|
123
|
+
const color = theme.color[type];
|
|
124
|
+
return css`
|
|
125
|
+
&.${k}-${type} {
|
|
126
|
+
.${k}-tip-icon {
|
|
127
|
+
color: ${color};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
`
|
|
131
|
+
})}
|
|
51
132
|
`;
|
|
52
133
|
});
|
|
@@ -18,6 +18,12 @@ import {Tooltip} from 'kpc';
|
|
|
18
18
|
always show this tootip
|
|
19
19
|
</Tooltip>
|
|
20
20
|
<br /><br />
|
|
21
|
+
<Tooltip content="hide" always value={false}
|
|
22
|
+
container={this.container}
|
|
23
|
+
>
|
|
24
|
+
always hide this tootip
|
|
25
|
+
</Tooltip>
|
|
26
|
+
<br /><br />
|
|
21
27
|
<Tooltip content="" always value={true}>
|
|
22
28
|
don't show if content is empty
|
|
23
29
|
</Tooltip>
|
|
@@ -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);
|
|
@@ -73,8 +73,11 @@ export class Tooltip<
|
|
|
73
73
|
static defaults = defaults;
|
|
74
74
|
static events = events;
|
|
75
75
|
|
|
76
|
+
public $isTooltip = true;
|
|
77
|
+
|
|
76
78
|
show(shouldFocus: boolean = false) {
|
|
77
|
-
|
|
79
|
+
const {disabled, always, value} = this.get();
|
|
80
|
+
if (disabled || (always && !value)) return;
|
|
78
81
|
|
|
79
82
|
clearTimeout(this.timer);
|
|
80
83
|
this.set('value', true);
|
|
@@ -82,16 +82,14 @@ const Panel = (model) => {
|
|
|
82
82
|
<Button circle icon
|
|
83
83
|
disabled={!enableRemove()}
|
|
84
84
|
ev-click={remove}
|
|
85
|
-
type="
|
|
86
|
-
size="large"
|
|
85
|
+
type="secondary"
|
|
87
86
|
>
|
|
88
87
|
<Icon class={`${k}-transfer-icon ${k}-icon-left`} />
|
|
89
88
|
</Button>
|
|
90
89
|
<Button circle icon
|
|
91
90
|
disabled={!enableAdd()}
|
|
92
91
|
ev-click={add}
|
|
93
|
-
type="
|
|
94
|
-
size="large"
|
|
92
|
+
type="secondary"
|
|
95
93
|
>
|
|
96
94
|
<Icon class={`${k}-transfer-icon ${k}-icon-right`} />
|
|
97
95
|
</Button>
|
|
@@ -10,6 +10,9 @@ order: 1.2
|
|
|
10
10
|
组件默认遇到`children`为`[]`空数组的情况就会去进行异步加载,你可以通过`loaded`属性设为`true`来
|
|
11
11
|
标识该子节点已经加载完成,无需再次加载
|
|
12
12
|
|
|
13
|
+
> 组件在该节点数据异步加载完成后,会往原始数据上自动添加`loaded=true`。你也可以手动指定该节点数据
|
|
14
|
+
> `loaded=true`,这样即使组件发现该节点数据`children`为空`[]`,也不会去加载了
|
|
15
|
+
|
|
13
16
|
```vdt
|
|
14
17
|
import {Tree} from 'kpc';
|
|
15
18
|
|
|
@@ -40,6 +40,7 @@ export default class extends Component<Props> {
|
|
|
40
40
|
{name: 'test1.jpg', url: 'http://www.example.com/test1.jpg'},
|
|
41
41
|
{name: 'test2.png', url: 'http://www.example.com/test2.png'},
|
|
42
42
|
{name: 'test3.png', status: UploadFileStatus.Error},
|
|
43
|
+
{name: 'test4-测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长.png', url: 'http://www.example.com/test4.png'},
|
|
43
44
|
]
|
|
44
45
|
} as Props;
|
|
45
46
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {Button} from '../button';
|
|
2
2
|
import {Progress} from '../progress';
|
|
3
3
|
import {Dialog} from '../dialog';
|
|
4
|
+
import {Ellipsis} from '../ellipsis';
|
|
4
5
|
import {expandAnimationCallbacks, getRestProps} from '../utils';
|
|
5
6
|
import {makeStyles, makeUploadDialogStyles} from './styles';
|
|
6
7
|
import {TransitionGroup, Transition, linkEvent} from 'intact';
|
|
@@ -131,7 +132,9 @@ const {show, close, image, isShow} = this.showImage;
|
|
|
131
132
|
<div class={`${k}-upload-file-main`}>
|
|
132
133
|
<div class={`${k}-upload-name c-ellipsis`}>
|
|
133
134
|
<Icon class={`${k}-upload-file-icon ion-document`} />
|
|
134
|
-
<span class={`${k}-upload-file-name`}>
|
|
135
|
+
<span class={`${k}-upload-file-name`}>
|
|
136
|
+
<Ellipsis>{$value.name}</Ellipsis>
|
|
137
|
+
</span>
|
|
135
138
|
<Icon class={`${k}-upload-status-icon ${k}-icon-success-fill`}
|
|
136
139
|
v-if={$value.status === UploadFileStatus.Done}
|
|
137
140
|
/>
|
|
@@ -11,6 +11,7 @@ var typeDefs = {
|
|
|
11
11
|
fluid: Boolean,
|
|
12
12
|
checkType: ['none', 'radio', 'checkbox'],
|
|
13
13
|
seperate: Boolean,
|
|
14
|
+
separate: Boolean,
|
|
14
15
|
btnWidth: [Number, String]
|
|
15
16
|
};
|
|
16
17
|
var defaults = function defaults() {
|
|
@@ -33,6 +34,9 @@ export var ButtonGroup = /*#__PURE__*/function (_Component) {
|
|
|
33
34
|
var _proto = ButtonGroup.prototype;
|
|
34
35
|
_proto.init = function init() {
|
|
35
36
|
provide(BUTTON_GROUP, this);
|
|
37
|
+
if (typeof this.get().seperate === 'boolean') {
|
|
38
|
+
console.warn("`seperate` is a typo which will be removed in next version, please using `separate` instead");
|
|
39
|
+
}
|
|
36
40
|
};
|
|
37
41
|
_proto.setValue = function setValue(v) {
|
|
38
42
|
var _this$get = this.get(),
|