@king-design/intact 2.0.12 → 2.0.13
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/code/index.md +2 -2
- package/components/code/index.ts +2 -2
- package/components/code/useEditor.ts +1 -1
- package/components/drawer/index.spec.ts +20 -0
- package/components/dropdown/demos/trigger.md +13 -2
- package/components/dropdown/dropdown.ts +29 -13
- package/components/dropdown/index.md +1 -1
- package/components/dropdown/index.spec.ts +34 -0
- package/components/portal.ts +8 -2
- package/components/select/demos/format.md +3 -2
- package/components/select/styles.ts +10 -5
- package/components/table/demos/animation.md +7 -0
- package/components/table/index.md +1 -0
- package/components/table/row.ts +1 -0
- package/components/table/row.vdt +5 -3
- package/components/table/table.ts +3 -0
- package/components/table/table.vdt +97 -89
- package/components/timepicker/index.ts +1 -0
- package/components/tooltip/demos/trigger.md +5 -2
- package/components/tooltip/index.md +1 -1
- package/components/tooltip/index.ts +1 -1
- package/es/components/code/index.d.ts +2 -2
- package/es/components/code/useEditor.js +1 -1
- package/es/components/drawer/index.spec.js +48 -0
- package/es/components/dropdown/dropdown.d.ts +2 -1
- package/es/components/dropdown/dropdown.js +31 -14
- package/es/components/dropdown/index.spec.js +58 -0
- package/es/components/portal.js +9 -2
- package/es/components/select/styles.js +2 -2
- package/es/components/table/row.d.ts +1 -0
- package/es/components/table/row.vdt.js +5 -6
- package/es/components/table/table.d.ts +1 -0
- package/es/components/table/table.js +4 -2
- package/es/components/table/table.vdt.js +111 -104
- package/es/components/timepicker/index.d.ts +1 -0
- package/es/components/timepicker/index.js +1 -0
- package/es/components/tooltip/index.d.ts +1 -1
- package/es/hooks/useDocumentClick.js +29 -2
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/dropdown/demos/trigger/react.js +6 -2
- package/es/site/data/components/select/demos/format/react.js +1 -1
- package/es/site/data/components/table/demos/animation/react.js +16 -0
- package/es/site/data/components/tooltip/demos/trigger/react.js +7 -2
- package/hooks/useDocumentClick.ts +29 -1
- package/index.ts +2 -2
- package/package.json +1 -1
package/components/code/index.md
CHANGED
|
@@ -17,7 +17,7 @@ sidebar: doc
|
|
|
17
17
|
| readOnly | 是否只读 | `boolean` | `false` |
|
|
18
18
|
| width | 指定宽度,需要带单位 | `string` | `100%` |
|
|
19
19
|
| height | 指定高度,需要带单位 | `string` | `100%` |
|
|
20
|
-
| options | 其它可选的配置,会传给`monaco.editor.create()`方法,可选值参考[options](https://microsoft.github.io/monaco-editor/
|
|
20
|
+
| options | 其它可选的配置,会传给`monaco.editor.create()`方法,可选值参考[options](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html) | [`editor.IStandaloneEditorConstructionOptions`](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html) | `{}` |
|
|
21
21
|
|
|
22
22
|
> 例如:通过`options`可以隐藏右侧代码的缩影(minimap): `options = {minimap: {enabled: false}}`
|
|
23
23
|
|
|
@@ -25,4 +25,4 @@ sidebar: doc
|
|
|
25
25
|
|
|
26
26
|
| 事件名 | 说明 | 参数 |
|
|
27
27
|
| --- | --- | --- |
|
|
28
|
-
| ready | 组件加载并实例化完成触发 | (editor: [editor.IStandaloneCodeEditor](https://microsoft.github.io/monaco-editor/
|
|
28
|
+
| ready | 组件加载并实例化完成触发 | (editor: [editor.IStandaloneCodeEditor](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneCodeEditor.html), Editor: typeof [editor](https://microsoft.github.io/monaco-editor/docs.html#modules/editor.html), Monaco: typeof [monaco](https://microsoft.github.io/monaco-editor/docs.html)) => void |
|
package/components/code/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Component, TypeDefs, createRef} from 'intact';
|
|
2
2
|
import template from './index.vdt';
|
|
3
|
-
import type {editor} from 'monaco-editor';
|
|
3
|
+
import type {editor, default as monaco} from 'monaco-editor';
|
|
4
4
|
import {useEditor} from './useEditor';
|
|
5
5
|
import type {Events} from '../types';
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ export interface CodeProps {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface CodeEvents {
|
|
18
|
-
ready: [editor.IStandaloneCodeEditor, typeof editor]
|
|
18
|
+
ready: [editor.IStandaloneCodeEditor, typeof editor, typeof monaco]
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const typeDefs: Required<TypeDefs<CodeProps>> = {
|
|
@@ -2,6 +2,9 @@ import BasicDemo from '~/components/drawer/demos/basic';
|
|
|
2
2
|
import PlacementDemo from '~/components/drawer/demos/placement';
|
|
3
3
|
import overlayDemo from '~/components/drawer/demos/overlay';
|
|
4
4
|
import {mount, unmount, dispatchEvent, getElement, wait} from '../../test/utils';
|
|
5
|
+
import {Component} from 'intact';
|
|
6
|
+
import {Drawer} from '.';
|
|
7
|
+
import {Dialog} from '../dialog';
|
|
5
8
|
|
|
6
9
|
describe('Drawer', () => {
|
|
7
10
|
afterEach((done) => {
|
|
@@ -67,4 +70,21 @@ describe('Drawer', () => {
|
|
|
67
70
|
await wait(500);
|
|
68
71
|
expect(getElement('.k-drawer')).to.be.undefined;
|
|
69
72
|
});
|
|
73
|
+
|
|
74
|
+
it('nested dialog', async () => {
|
|
75
|
+
class Demo extends Component {
|
|
76
|
+
static template = `
|
|
77
|
+
const {Dialog, Drawer} = this;
|
|
78
|
+
<Drawer value={true}>
|
|
79
|
+
<Dialog value={true} ref="dialog">Dialog</Dialog>
|
|
80
|
+
</Drawer>
|
|
81
|
+
`;
|
|
82
|
+
private Dialog = Dialog;
|
|
83
|
+
private Drawer = Drawer;
|
|
84
|
+
}
|
|
85
|
+
const [instance, element] = mount(Demo);
|
|
86
|
+
|
|
87
|
+
await wait();
|
|
88
|
+
expect(instance.refs.dialog.dialogRef.value.parentElement.parentElement).to.eql(document.body);
|
|
89
|
+
});
|
|
70
90
|
});
|
|
@@ -3,11 +3,13 @@ title: 触发方式
|
|
|
3
3
|
order: 0
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`Dropdown`提供了两种触发方式来弹窗菜单,`hover`悬停触发(默认),`click
|
|
6
|
+
`Dropdown`提供了两种触发方式来弹窗菜单,`hover`悬停触发(默认),`click`点击触发,当使用`Input`组件时,还可以
|
|
7
|
+
指定为`foucs`来触发。
|
|
8
|
+
|
|
7
9
|
通过`trigger`属性来指定它们。
|
|
8
10
|
|
|
9
11
|
```vdt
|
|
10
|
-
import {Dropdown, DropdownMenu, DropdownItem, Button, Icon} from 'kpc';
|
|
12
|
+
import {Dropdown, DropdownMenu, DropdownItem, Button, Icon, Input} from 'kpc';
|
|
11
13
|
|
|
12
14
|
<div>
|
|
13
15
|
<Dropdown>
|
|
@@ -31,6 +33,15 @@ import {Dropdown, DropdownMenu, DropdownItem, Button, Icon} from 'kpc';
|
|
|
31
33
|
<DropdownItem>item 3</DropdownItem>
|
|
32
34
|
</DropdownMenu>
|
|
33
35
|
</Dropdown>
|
|
36
|
+
|
|
37
|
+
<Dropdown trigger="focus">
|
|
38
|
+
<Input placeholder="focus" />
|
|
39
|
+
<DropdownMenu>
|
|
40
|
+
<DropdownItem>item 1</DropdownItem>
|
|
41
|
+
<DropdownItem>item 2</DropdownItem>
|
|
42
|
+
<DropdownItem>item 3</DropdownItem>
|
|
43
|
+
</DropdownMenu>
|
|
44
|
+
</Dropdown>
|
|
34
45
|
</div>
|
|
35
46
|
```
|
|
36
47
|
|
|
@@ -31,7 +31,7 @@ export const DROPDOWN = 'Dropdown';
|
|
|
31
31
|
export const ROOT_DROPDOWN = 'RootDropdown';
|
|
32
32
|
|
|
33
33
|
export interface DropdownProps {
|
|
34
|
-
trigger?: 'hover' | 'click' | 'contextmenu'
|
|
34
|
+
trigger?: 'hover' | 'click' | 'contextmenu' | 'focus'
|
|
35
35
|
disabled?: boolean
|
|
36
36
|
value?: boolean
|
|
37
37
|
position?: Position | 'left' | 'bottom' | 'right' | 'top'
|
|
@@ -51,7 +51,7 @@ export interface DropdownEvents {
|
|
|
51
51
|
export interface DropdownBlocks { }
|
|
52
52
|
|
|
53
53
|
const typeDefs: Required<TypeDefs<DropdownProps>> = {
|
|
54
|
-
trigger: ['hover', 'click', 'contextmenu'],
|
|
54
|
+
trigger: ['hover', 'click', 'contextmenu', 'focus'],
|
|
55
55
|
disabled: Boolean,
|
|
56
56
|
value: Boolean,
|
|
57
57
|
position: [Object, 'left', 'bottom', 'right', 'top'],
|
|
@@ -106,17 +106,7 @@ export class Dropdown<
|
|
|
106
106
|
|
|
107
107
|
const [trigger, menu] = children as DropdownChildren;
|
|
108
108
|
const triggerType = this.get('trigger');
|
|
109
|
-
const props
|
|
110
|
-
|
|
111
|
-
if (triggerType !== 'contextmenu') {
|
|
112
|
-
props['ev-click'] = this.onEnter;
|
|
113
|
-
if (triggerType === 'hover') {
|
|
114
|
-
props['ev-mouseenter'] = this.onEnter;
|
|
115
|
-
props['ev-mouseleave'] = this.onLeave;
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
props['ev-contextmenu'] = this.onContextMenu;
|
|
119
|
-
}
|
|
109
|
+
const props = this.initEventCallbacks(triggerType);
|
|
120
110
|
|
|
121
111
|
const clonedTrigger = isTextChildren(trigger) ?
|
|
122
112
|
createVNode('span', null, trigger) :
|
|
@@ -235,6 +225,29 @@ export class Dropdown<
|
|
|
235
225
|
this.hide();
|
|
236
226
|
}
|
|
237
227
|
|
|
228
|
+
private initEventCallbacks(trigger: DropdownProps['trigger']) {
|
|
229
|
+
const props: Record<string, Function> = {};
|
|
230
|
+
|
|
231
|
+
switch (trigger) {
|
|
232
|
+
case 'focus':
|
|
233
|
+
props['ev-focusin'] = this.onEnter;
|
|
234
|
+
props['ev-focusout'] = this.onLeave;
|
|
235
|
+
break;
|
|
236
|
+
case 'contextmenu':
|
|
237
|
+
props['ev-contextmenu'] = this.onContextMenu;
|
|
238
|
+
break;
|
|
239
|
+
default:
|
|
240
|
+
props['ev-click'] = this.onEnter;
|
|
241
|
+
if (trigger === 'hover') {
|
|
242
|
+
props['ev-mouseenter'] = this.onEnter;
|
|
243
|
+
props['ev-mouseleave'] = this.onLeave;
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return props;
|
|
249
|
+
}
|
|
250
|
+
|
|
238
251
|
private callOriginalCallback(name: string, e: MouseEvent) {
|
|
239
252
|
const callback = this.triggerProps[name];
|
|
240
253
|
const callbackOnDropdown = this.get<Function>(name);
|
|
@@ -283,7 +296,10 @@ function useDocumentClickForDropdown(dropdown: Dropdown) {
|
|
|
283
296
|
const [addDocumentClick, removeDocumentClick] = useDocumentClick(elementRef, (e) => {
|
|
284
297
|
// case 1: if click an trigger and the trigger type is hover, ignore it
|
|
285
298
|
// case 2: if right click on trigger and the trigger type is contextmenu, ignore it
|
|
299
|
+
// case 3: if click on trigger and the trigger type is focus, do nothing
|
|
286
300
|
const trigger = dropdown.get('trigger');
|
|
301
|
+
if (trigger === 'focus') return;
|
|
302
|
+
|
|
287
303
|
const isHover = trigger === 'hover';
|
|
288
304
|
if (isHover || trigger === 'contextmenu') {
|
|
289
305
|
const triggerDom = findDomFromVNode(dropdown.$lastInput!, true) as Element;
|
|
@@ -11,7 +11,7 @@ sidebar: doc
|
|
|
11
11
|
|
|
12
12
|
| 属性 | 说明 | 类型 | 默认值 |
|
|
13
13
|
| --- | --- | --- | --- |
|
|
14
|
-
| trigger | 触发方式,`hover`为悬停触发,`click`为点击触发 | `"hover"` | `"click"` | `"hover"` |
|
|
14
|
+
| trigger | 触发方式,`hover`为悬停触发,`click`为点击触发 | `"hover"` | `"click"` | `"contextmenu"` | `"focus"` | `"hover"` |
|
|
15
15
|
| disabled | 是否禁用整个菜单 | `boolean` | `false` |
|
|
16
16
|
| value | 是否将弹出菜单展示出来,可通过`v-model`双向绑定 | `boolean` | `false` |
|
|
17
17
|
| position | 菜单弹出的位置,默认与触发器左侧对齐向下偏移`8px`的地方 | `Position` | `"left"` | `"bottom"` | `"right"` | `"top"` | `{my: 'left top+8', 'left bottom'}` |
|
|
@@ -280,4 +280,38 @@ describe('Dropdown', () => {
|
|
|
280
280
|
await wait();
|
|
281
281
|
expect(parent.scrollTop).to.eql(item.offsetHeight * 2 - 40);
|
|
282
282
|
});
|
|
283
|
+
|
|
284
|
+
it('trigger: focus', async() => {
|
|
285
|
+
class Demo extends Component {
|
|
286
|
+
static template = `
|
|
287
|
+
const {Dropdown, DropdownMenu, DropdownItem} = this;
|
|
288
|
+
<div>
|
|
289
|
+
<Dropdown trigger="focus">
|
|
290
|
+
<input ref="trigger" />
|
|
291
|
+
<DropdownMenu>
|
|
292
|
+
<DropdownItem>test1</DropdownItem>
|
|
293
|
+
<DropdownItem>test2</DropdownItem>
|
|
294
|
+
</DropdownMenu>
|
|
295
|
+
</Dropdown>
|
|
296
|
+
</div>
|
|
297
|
+
`;
|
|
298
|
+
private Dropdown = Dropdown;
|
|
299
|
+
private DropdownItem = DropdownItem;
|
|
300
|
+
private DropdownMenu = DropdownMenu;
|
|
301
|
+
}
|
|
302
|
+
const [instance] = mount(Demo);
|
|
303
|
+
|
|
304
|
+
dispatchEvent(instance.refs.trigger, 'focusin');
|
|
305
|
+
await wait(500);
|
|
306
|
+
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
307
|
+
|
|
308
|
+
// clicking anywhere should not hide menu
|
|
309
|
+
dispatchEvent(document, 'click');
|
|
310
|
+
await wait(500);
|
|
311
|
+
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
312
|
+
|
|
313
|
+
dispatchEvent(instance.refs.trigger, 'focusout');
|
|
314
|
+
await wait(700);
|
|
315
|
+
expect(getElement('.k-dropdown-menu')).to.not.be.exist;
|
|
316
|
+
});
|
|
283
317
|
});
|
package/components/portal.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import {isString} from 'intact-shared';
|
|
15
15
|
import {DIALOG} from './dialog/constants';
|
|
16
16
|
import type {Dialog} from './dialog';
|
|
17
|
+
import {BaseDialog} from './dialog/base';
|
|
17
18
|
|
|
18
19
|
export interface PortalProps {
|
|
19
20
|
container?: Container
|
|
@@ -131,8 +132,13 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
if (!this.container) {
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
if (this.$senior instanceof BaseDialog) {
|
|
136
|
+
// Dialog and Drawer must be inserted into document.body
|
|
137
|
+
this.container = document.body;
|
|
138
|
+
} else {
|
|
139
|
+
// find the closest dialog if exists
|
|
140
|
+
this.container = parentDom.closest('.k-dialog') || document.body;
|
|
141
|
+
}
|
|
136
142
|
|
|
137
143
|
/**
|
|
138
144
|
* @FIXME: We cannot get parent ref from sub component in Vue
|
|
@@ -34,7 +34,7 @@ import {Select, Option, Icon} from 'kpc';
|
|
|
34
34
|
</Option>
|
|
35
35
|
<b:value args="[value, label]">
|
|
36
36
|
<Icon class={value} style="vertical-align: middle;" />
|
|
37
|
-
<span class="
|
|
37
|
+
<span class="middle">{value}</span>
|
|
38
38
|
</b:value>
|
|
39
39
|
</Select>
|
|
40
40
|
</div>
|
|
@@ -67,8 +67,9 @@ import {Select, Option, Icon} from 'kpc';
|
|
|
67
67
|
height 60px
|
|
68
68
|
line-height 60px
|
|
69
69
|
text-align center
|
|
70
|
-
.
|
|
70
|
+
.middle
|
|
71
71
|
margin-left 6px
|
|
72
|
+
vertical-align middle
|
|
72
73
|
.label
|
|
73
74
|
display inline-block
|
|
74
75
|
width 100px
|
|
@@ -58,7 +58,7 @@ const defaults = deepDefaults(
|
|
|
58
58
|
},
|
|
59
59
|
tag: {
|
|
60
60
|
margin: `3px 8px 3px 0`,
|
|
61
|
-
padding: `
|
|
61
|
+
padding: `3px 8px`,
|
|
62
62
|
get borderRadius() { return theme.borderRadius },
|
|
63
63
|
get bgColor() { return theme.color.bg },
|
|
64
64
|
disabledBgColor: '#eee',
|
|
@@ -225,6 +225,7 @@ export default function makeStyles() {
|
|
|
225
225
|
.k-select-values {
|
|
226
226
|
display: inline-block;
|
|
227
227
|
margin-right: -${getRight(select.tag.margin)};
|
|
228
|
+
width: 100%;
|
|
228
229
|
&.k-with-values {
|
|
229
230
|
margin: 0;
|
|
230
231
|
}
|
|
@@ -236,16 +237,20 @@ export default function makeStyles() {
|
|
|
236
237
|
background: ${select.tag.bgColor};
|
|
237
238
|
border-radius: ${select.tag.borderRadius};
|
|
238
239
|
margin: ${select.tag.margin};
|
|
239
|
-
|
|
240
|
+
max-width: calc(100% - ${getRight(select.tag.margin)} - 1px);
|
|
241
|
+
}
|
|
242
|
+
.k-select-text {
|
|
243
|
+
max-width: calc(100% - 18px);
|
|
244
|
+
word-break: break-word;
|
|
240
245
|
}
|
|
241
246
|
.k-select-close {
|
|
242
247
|
margin-left: ${select.tag.delete.gap};
|
|
243
248
|
font-size: ${select.tag.delete.fontSize};
|
|
244
249
|
color: ${select.tag.delete.color};
|
|
245
250
|
}
|
|
246
|
-
.k-select-input {
|
|
247
|
-
margin-right: ${getRight(select.tag.margin)};
|
|
248
|
-
}
|
|
251
|
+
// .k-select-input {
|
|
252
|
+
// margin-right: ${getRight(select.tag.margin)};
|
|
253
|
+
// }
|
|
249
254
|
|
|
250
255
|
// size
|
|
251
256
|
${sizes.map(size => {
|
|
@@ -5,6 +5,8 @@ order: 20
|
|
|
5
5
|
|
|
6
6
|
一个简单的`Table`,点击按钮,即可查看新增表格的动效。
|
|
7
7
|
|
|
8
|
+
通过`animation`可以禁用动效,取值为`false`时,禁用行和列动画;或者通过数组分别指定禁用行和列动画,如:`[false, true]`,只禁用列动画
|
|
9
|
+
|
|
8
10
|
```vdt
|
|
9
11
|
import {Table, TableColumn, Button} from 'kpc';
|
|
10
12
|
|
|
@@ -21,6 +23,11 @@ import {Table, TableColumn, Button} from 'kpc';
|
|
|
21
23
|
<TableColumn v-if={this.get('isShow')} key="b" title="Title 2"/>
|
|
22
24
|
<TableColumn key="c" title="Title 3" />
|
|
23
25
|
</Table>
|
|
26
|
+
<Table data={this.get('data')} resizable rowKey={row => row.a} animation={false}>
|
|
27
|
+
<TableColumn key="a" title="Title 1" />
|
|
28
|
+
<TableColumn v-if={this.get('isShow')} key="b" title="Title 2"/>
|
|
29
|
+
<TableColumn key="c" title="Title 3" />
|
|
30
|
+
</Table>
|
|
24
31
|
</div>
|
|
25
32
|
```
|
|
26
33
|
|
|
@@ -42,6 +42,7 @@ sidebar: doc
|
|
|
42
42
|
| minColWidth | 指定所有列拖动时的最小宽度 | `number` | `40` |
|
|
43
43
|
| widthStoreKey | 如果要保存表格拖动后的列宽信息,可以通过该属性设置保存到`localStorage`中的`key` | `string` | `undefined` |
|
|
44
44
|
| draggable | 表格行是否可拖动 | `boolean` | `false` |
|
|
45
|
+
| animation | 是否开启动效,默认开启。可以通过`true` `false`全部设置,或者通过数组单独设置行和列的动效 | `boolean` | `[boolean, boolean]` | `true` |
|
|
45
46
|
|
|
46
47
|
```ts
|
|
47
48
|
import {Props} from 'intact';
|
package/components/table/row.ts
CHANGED
package/components/table/row.vdt
CHANGED
|
@@ -3,7 +3,7 @@ import {getClassAndStyleForFixed} from './useFixedColumns';
|
|
|
3
3
|
import {Checkbox} from '../checkbox';
|
|
4
4
|
import {Radio} from '../radio';
|
|
5
5
|
import {TableCell} from './cell';
|
|
6
|
-
import {createElementVNode, className as cx} from 'intact';
|
|
6
|
+
import {createElementVNode, className as cx, createFragment} from 'intact';
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
cols, data, checkType, hasFixedLeft,
|
|
@@ -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,
|
|
14
|
+
draggable, draggingKey, animation,
|
|
15
15
|
} = this.get();
|
|
16
16
|
const classNameObj = {
|
|
17
17
|
'k-disabled': disabled,
|
|
@@ -89,7 +89,9 @@ cols.forEach((props, columnIndex) => {
|
|
|
89
89
|
);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
const rows =
|
|
92
|
+
const rows = animation ?
|
|
93
|
+
<TransitionGroup name="k-fade-expand" move={false}>{vNodes}</TransitionGroup> :
|
|
94
|
+
createFragment(vNodes, 8);
|
|
93
95
|
/* const rows = vNodes; */
|
|
94
96
|
|
|
95
97
|
// for performance, no normalize
|
|
@@ -59,6 +59,7 @@ export interface TableProps<
|
|
|
59
59
|
minColWidth?: number
|
|
60
60
|
widthStoreKey?: string
|
|
61
61
|
draggable?: boolean
|
|
62
|
+
animation?: boolean | [boolean, boolean]
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export interface TableEvents<T = any, K extends TableRowKey = number> {
|
|
@@ -116,6 +117,7 @@ const typeDefs: Required<TypeDefs<TableProps<unknown>>> = {
|
|
|
116
117
|
minColWidth: Number,
|
|
117
118
|
widthStoreKey: String,
|
|
118
119
|
draggable: Boolean,
|
|
120
|
+
animation: [Boolean, Array],
|
|
119
121
|
};
|
|
120
122
|
|
|
121
123
|
const defaults = (): Partial<TableProps> => ({
|
|
@@ -126,6 +128,7 @@ const defaults = (): Partial<TableProps> => ({
|
|
|
126
128
|
childrenKey: 'children',
|
|
127
129
|
indent: 32,
|
|
128
130
|
minColWidth: 40,
|
|
131
|
+
animation: true,
|
|
129
132
|
});
|
|
130
133
|
|
|
131
134
|
const events: Events<TableEvents> = {
|
|
@@ -23,8 +23,9 @@ const {
|
|
|
23
23
|
rowClassName, group, sort, loading,
|
|
24
24
|
merge, childrenKey, indent, tooltipPosition,
|
|
25
25
|
tooltipContainer, showIndeterminate, resizable,
|
|
26
|
-
draggable,
|
|
26
|
+
draggable, animation: _animation,
|
|
27
27
|
} = this.get();
|
|
28
|
+
const animation = !Array.isArray(_animation) ? [_animation, _animation] : _animation;
|
|
28
29
|
const {columns, cols, maxRows, maxCols} = this.columns.getData();
|
|
29
30
|
const {scrollPosition, hasFixed, getHasFixedLeft, getOffsetMap} = this.fixedColumns;
|
|
30
31
|
const {scrollRef} = this.scroll;
|
|
@@ -71,23 +72,29 @@ const thead = (
|
|
|
71
72
|
<FixedColumnsContext.Provider value={offsetMap}>
|
|
72
73
|
<thead>
|
|
73
74
|
<tr v-for={columns}>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
{(() => {
|
|
76
|
+
const ths = <template>
|
|
77
|
+
<th v-if={$key === 0 && checkType !== 'none'}
|
|
78
|
+
{...getClassAndStyleForFixed({
|
|
79
|
+
fixed: hasFixedLeft ? 'left' : false,
|
|
80
|
+
}, 0)}
|
|
81
|
+
rowspan={maxRows}
|
|
82
|
+
key="$checktype"
|
|
83
|
+
>
|
|
84
|
+
<Checkbox v-if={checkType === 'checkbox'}
|
|
85
|
+
value={allCheckedStatus === AllCheckedStatus.All}
|
|
86
|
+
indeterminate={showIndeterminate && allCheckedStatus == AllCheckedStatus.Indeterminate}
|
|
87
|
+
ev-$change:value={toggleCheckedAll}
|
|
88
|
+
disabled={!hasData}
|
|
89
|
+
/>
|
|
90
|
+
</th>
|
|
91
|
+
{$value}
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
return animation[1] ?
|
|
95
|
+
<TransitionGroup name="k-fade-expand" move={false}>{ths}</TransitionGroup> :
|
|
96
|
+
ths;
|
|
97
|
+
})()}
|
|
91
98
|
</tr>
|
|
92
99
|
</thead>
|
|
93
100
|
</FixedColumnsContext.Provider>
|
|
@@ -114,84 +121,85 @@ const tbody = (
|
|
|
114
121
|
<b:empty>{_$('/(ㄒoㄒ)/~~ 没有找到亲要的数据哦~')}</b:empty>
|
|
115
122
|
</td>
|
|
116
123
|
</tr> :
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (hidden) return hidden;
|
|
124
|
+
(() => {
|
|
125
|
+
const rows = [];
|
|
126
|
+
loopData((value, index, level, hidden) => {
|
|
127
|
+
// don't render if row is hidden
|
|
128
|
+
if (hidden) return hidden;
|
|
123
129
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
const status = allStatus[index];
|
|
131
|
+
const key = allKeys[index];
|
|
132
|
+
const spreaded = isSpreaded(key);
|
|
133
|
+
const hasChildren = !!childrenKey && Array.isArray(value[childrenKey]);
|
|
134
|
+
const indentSize = indent ? indent * level : 0;
|
|
129
135
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
136
|
+
let row = <TableRow
|
|
137
|
+
key={key}
|
|
138
|
+
cols={cols}
|
|
139
|
+
data={value}
|
|
140
|
+
checkType={checkType}
|
|
141
|
+
hasFixedLeft={hasFixedLeft}
|
|
142
|
+
onClick={this.clickRow}
|
|
143
|
+
checked={status.checked}
|
|
144
|
+
indeterminate={status.indeterminate}
|
|
145
|
+
index={index}
|
|
146
|
+
disabled={status.disabled}
|
|
147
|
+
allDisabled={status.allDisabled}
|
|
148
|
+
className={rowClassName && rowClassName(value, index, key)}
|
|
149
|
+
merge={merge}
|
|
150
|
+
grid={getGrid()}
|
|
151
|
+
onChangeChecked={onChangeChecked}
|
|
152
|
+
selected={isSelected(key)}
|
|
153
|
+
spreaded={spreaded}
|
|
154
|
+
hasChildren={hasChildren}
|
|
155
|
+
indent={indentSize}
|
|
156
|
+
onToggleSpreadRow={toggleSpreadRow}
|
|
157
|
+
onBeforeUnmount={this.resetRowStatus.onRowBeforeUnmount}
|
|
158
|
+
offsetMap={offsetMap}
|
|
159
|
+
animation={animation[1]}
|
|
153
160
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
draggable={draggable}
|
|
162
|
+
draggingKey={draggingKey.value}
|
|
163
|
+
onRowDragStart={onRowDragStart}
|
|
164
|
+
onRowDragEnd={onRowDragEnd}
|
|
165
|
+
onRowDragOver={onRowDragOver}
|
|
166
|
+
/>
|
|
160
167
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
if ($blocks.tooltip) {
|
|
169
|
+
const content = <b:tooltip params={[value, index]} />;
|
|
170
|
+
row = (
|
|
171
|
+
<Tooltip key={key} position={tooltipPosition} container={tooltipContainer}>
|
|
172
|
+
<template>{row}</template>
|
|
173
|
+
<b:content>{content}</b:content>
|
|
174
|
+
</Tooltip>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
170
177
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
178
|
+
rows.push(row);
|
|
179
|
+
if ($blocks.expand) {
|
|
180
|
+
const expanded = isExpanded(key);
|
|
181
|
+
rows.push(
|
|
182
|
+
<tr class={{"k-expand": true, 'k-expanded': expanded}}
|
|
183
|
+
key={`${key}.$expand`}
|
|
184
|
+
>
|
|
185
|
+
<td colspan={colCount}>
|
|
186
|
+
<Transition {...expandAnimationCallbacks}>
|
|
187
|
+
<div v-if={expanded} class="k-table-expand">
|
|
188
|
+
<b:expand params={[value, index]} />
|
|
189
|
+
</div>
|
|
190
|
+
</Transition>
|
|
191
|
+
</td>
|
|
192
|
+
</tr>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
188
195
|
|
|
189
|
-
|
|
190
|
-
|
|
196
|
+
return hidden || !spreaded;
|
|
197
|
+
});
|
|
191
198
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
199
|
+
return animation[0] ?
|
|
200
|
+
<TransitionGroup name="k-fade-in-left" move={!draggingKey.value}>{rows}</TransitionGroup> :
|
|
201
|
+
rows;
|
|
202
|
+
})()
|
|
195
203
|
}
|
|
196
204
|
</tbody>
|
|
197
205
|
);
|
|
@@ -9,6 +9,7 @@ export class Timepicker<
|
|
|
9
9
|
Multipe extends boolean = false,
|
|
10
10
|
Range extends boolean = false,
|
|
11
11
|
> extends Component<TimepickerProps<Multipe, Range>, TimepickerEvents, TimepickerBlocks<Range>> {
|
|
12
|
+
static $doubleVNodes = true;
|
|
12
13
|
static template(this: Timepicker) {
|
|
13
14
|
const props = this.get();
|
|
14
15
|
if (props.step && !props.range) {
|