@king-design/intact 2.0.14 → 2.0.16
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/colorpicker/index.md +1 -0
- package/components/colorpicker/index.ts +2 -0
- package/components/colorpicker/index.vdt +1 -0
- package/components/dialog/alert.vdt +5 -3
- package/components/dialog/index.md +3 -0
- package/components/dialog/index.spec.ts +35 -0
- package/components/dialog/staticMethods.ts +14 -1
- package/components/dialog/useFixBody.ts +3 -1
- package/components/icon/demos/icons.md +158 -0
- package/components/pagination/demos/disable.md +51 -0
- package/components/pagination/index.md +2 -0
- package/components/pagination/index.spec.ts +14 -0
- package/components/pagination/index.ts +8 -0
- package/components/pagination/index.vdt +13 -3
- package/components/pagination/styles.ts +3 -0
- package/components/portal.ts +38 -28
- package/components/select/demos/basic.md +1 -1
- package/components/table/column.vdt +26 -10
- package/components/table/demos/rowExpandable.md +1 -1
- package/components/table/demos/selectedKeys.md +1 -1
- package/components/table/index.md +3 -3
- package/components/table/index.spec.ts +2 -2
- package/components/table/styles.ts +6 -0
- package/components/table/useGroup.ts +18 -2
- package/components/table/useSortable.ts +4 -1
- package/es/components/colorpicker/index.d.ts +1 -0
- package/es/components/colorpicker/index.js +2 -1
- package/es/components/colorpicker/index.vdt.js +5 -1
- package/es/components/dialog/alert.vdt.js +6 -4
- package/es/components/dialog/index.spec.js +61 -1
- package/es/components/dialog/staticMethods.d.ts +4 -2
- package/es/components/dialog/staticMethods.js +16 -0
- package/es/components/dialog/useFixBody.js +3 -1
- package/es/components/pagination/index.d.ts +2 -0
- package/es/components/pagination/index.js +12 -1
- package/es/components/pagination/index.spec.js +28 -0
- package/es/components/pagination/index.vdt.js +18 -3
- package/es/components/pagination/styles.js +1 -1
- package/es/components/portal.js +23 -11
- package/es/components/table/column.vdt.js +43 -7
- package/es/components/table/index.spec.js +2 -2
- package/es/components/table/styles.js +7 -1
- package/es/components/table/useGroup.d.ts +3 -0
- package/es/components/table/useGroup.js +24 -1
- package/es/components/table/useSortable.d.ts +3 -1
- package/es/components/table/useSortable.js +4 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/packages/kpc-react/__tests__/components/dialog.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/dialog.spec.js +45 -0
- package/es/packages/kpc-react/__tests__/components/drawer.spec.js +42 -2
- package/es/site/data/components/icon/demos/icons/index.d.ts +9 -0
- package/es/site/data/components/icon/demos/icons/index.js +24 -0
- package/es/site/data/components/icon/demos/icons/react.d.ts +9 -0
- package/es/site/data/components/icon/demos/icons/react.js +63 -0
- package/es/site/data/components/menu/demos/collapse/react.d.ts +11 -0
- package/es/site/data/components/menu/demos/size/react.d.ts +7 -0
- package/es/site/data/components/pagination/demos/disable/index.d.ts +16 -0
- package/es/site/data/components/pagination/demos/disable/index.js +35 -0
- package/es/site/data/components/pagination/demos/disable/react.d.ts +16 -0
- package/es/site/data/components/pagination/demos/disable/react.js +65 -0
- package/es/site/data/components/select/demos/basic/react.js +1 -2
- package/index.ts +2 -2
- package/package.json +3 -3
- package/styles/fonts/demo.css +370 -0
- package/styles/fonts/demo.html +29 -0
- package/styles/fonts/iconfont.css +477 -0
|
@@ -13,3 +13,4 @@ sidebar: doc
|
|
|
13
13
|
| presets | 预选颜色 | `string[]` | `['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF']` |
|
|
14
14
|
| size | 组件尺寸 | `"large"` | `"default"` | `"small"` | `"mini"` | `"default"` |
|
|
15
15
|
| disabled | 是否禁用 | `boolean` | `false` |
|
|
16
|
+
| show | 是否展示颜色选择面板 | `boolean` | `false` |
|
|
@@ -9,6 +9,7 @@ export interface ColorpickerProps {
|
|
|
9
9
|
size?: Sizes
|
|
10
10
|
disabled?: boolean
|
|
11
11
|
container?: Container
|
|
12
|
+
show?: boolean
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export interface ColorpickerEvents { }
|
|
@@ -22,6 +23,7 @@ const typeDefs: Required<TypeDefs<ColorpickerProps>> = {
|
|
|
22
23
|
size: sizes,
|
|
23
24
|
disabled: Boolean,
|
|
24
25
|
container: [Function, String],
|
|
26
|
+
show: Boolean,
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
const defaults = (): Partial<ColorpickerProps> => ({
|
|
@@ -4,7 +4,8 @@ import {makeAlertStyles} from './styles';
|
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
type, content, hideIcon,
|
|
7
|
-
hideFooter, hideClose, title
|
|
7
|
+
hideFooter, hideClose, title,
|
|
8
|
+
iconClassName, icon
|
|
8
9
|
} = this.get();
|
|
9
10
|
|
|
10
11
|
const classNameObj = {
|
|
@@ -18,12 +19,13 @@ const classNameObj = {
|
|
|
18
19
|
<b:header />
|
|
19
20
|
<b:body>
|
|
20
21
|
<div class="k-dialog-tip-icon">
|
|
21
|
-
<Icon class={{
|
|
22
|
+
<Icon class={iconClassName || {
|
|
22
23
|
"ion-ios-checkmark": type === 'success',
|
|
23
24
|
"ion-ios-information": type === 'warning',
|
|
24
25
|
"ion-ios-close": type === 'error',
|
|
25
26
|
"ion-ios-help": type === 'confirm',
|
|
26
|
-
}} v-if={!hideIcon} />
|
|
27
|
+
}} v-if={!hideIcon && !icon} />
|
|
28
|
+
{icon}
|
|
27
29
|
</div>
|
|
28
30
|
<div class="k-alert-dialog-wrapper">
|
|
29
31
|
<div class="k-alert-dialog-title" v-if={title}>{title}</div>
|
|
@@ -103,6 +103,9 @@ export type Container = string | ((parentDom: Element, anchor: Node | null) => E
|
|
|
103
103
|
| hideIcon | 是否隐藏提示图标 | `boolean` | `false` |
|
|
104
104
|
| hideFooter | 是否隐藏底部按钮 | `boolean` | `false` |
|
|
105
105
|
| ref | 传入一个函数,组件会调用该函数,将当前`Dialog`实例传入 | `(i: Dialog) => void` | `undefined` |
|
|
106
|
+
| className | 样式类名 | `string` | `undefined` |
|
|
107
|
+
| iconClassName | 指定icon样式名 | `string` | `undefined` |
|
|
108
|
+
| icon | 自定义icon内容 | `VNode` | `undefined` |
|
|
106
109
|
|
|
107
110
|
其中`Promise`对象会在点击“确定”按钮时`resolve()`,在点击“取消”按钮时`reject()`,你可以在`then()`
|
|
108
111
|
中书写用户点击不同按钮的逻辑
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Component} from 'intact';
|
|
2
2
|
import {Dialog, BaseDialog, DialogProps} from './';
|
|
3
|
+
import {bind} from '../utils';
|
|
3
4
|
import {getElement, mount, unmount, dispatchEvent, wait} from '../../test/utils';
|
|
4
5
|
import BasicDemo from '~/components/dialog/demos/basic';
|
|
5
6
|
import AsyncCloseDemo from '~/components/dialog/demos/asyncClose';
|
|
@@ -263,6 +264,40 @@ describe('Dialog', () => {
|
|
|
263
264
|
expectDialog();
|
|
264
265
|
});
|
|
265
266
|
|
|
267
|
+
it('should remove body style when destroy', async () => {
|
|
268
|
+
class Demo extends Component<{content: string, show: boolean, onClose: Function}> {
|
|
269
|
+
static template = `
|
|
270
|
+
var Dialog = this.Dialog;
|
|
271
|
+
<div>
|
|
272
|
+
<Dialog v-if={this.get('show')}
|
|
273
|
+
value={this.get('show')}
|
|
274
|
+
ev-close={this.onClose}
|
|
275
|
+
ref="dialog"
|
|
276
|
+
>test</Dialog>
|
|
277
|
+
</div>
|
|
278
|
+
`;
|
|
279
|
+
|
|
280
|
+
private Dialog = Dialog;
|
|
281
|
+
|
|
282
|
+
static defaults() {
|
|
283
|
+
return {
|
|
284
|
+
show: true,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@bind
|
|
289
|
+
onClose() {
|
|
290
|
+
this.set('show', false);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const [instance, element] = mount(Demo);
|
|
295
|
+
instance.refs.dialog.close();
|
|
296
|
+
|
|
297
|
+
await wait();
|
|
298
|
+
expect(document.body.getAttribute('style')).to.be.null;
|
|
299
|
+
});
|
|
300
|
+
|
|
266
301
|
// it('should handle v-if and v-model at the same time correctly in Vue', async () => {
|
|
267
302
|
// const Test = {
|
|
268
303
|
// template: `<Dialog v-model="show" v-if="show" ref="dialog">test</Dialog>`,
|
|
@@ -3,11 +3,14 @@ import type {Dialog, DialogProps} from './';
|
|
|
3
3
|
import template from './alert.vdt';
|
|
4
4
|
|
|
5
5
|
export interface AlertDialogProps extends DialogProps {
|
|
6
|
-
content?: string |
|
|
6
|
+
content?: string | object
|
|
7
7
|
type?: 'success' | 'warning' | 'error' | 'confirm'
|
|
8
8
|
hideIcon?: boolean
|
|
9
9
|
hideFooter?: boolean
|
|
10
10
|
ref?: (i: Dialog) => void
|
|
11
|
+
className?: string
|
|
12
|
+
iconClassName?: string
|
|
13
|
+
icon?: object
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export type StaticMethod = (options?: AlertDialogProps) => Promise<void>
|
|
@@ -25,6 +28,16 @@ export function addStaticMethods(Component: typeof Dialog) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function show(options: AlertDialogProps = {}) {
|
|
31
|
+
const normalize = (Component as any).normalize;
|
|
32
|
+
if (normalize) {
|
|
33
|
+
if (options.content) {
|
|
34
|
+
options = {...options, content: normalize(options.content)};
|
|
35
|
+
}
|
|
36
|
+
if (options.icon) {
|
|
37
|
+
options = {...options, icon: normalize(options.icon)};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
const dialog = new AlertDialog(options);
|
|
29
42
|
dialog.show();
|
|
30
43
|
|
|
@@ -21,7 +21,9 @@ export function useFixBody(elementRef: RefObject<HTMLDivElement>) {
|
|
|
21
21
|
instance.on('afterClose', onAfterLeave);
|
|
22
22
|
|
|
23
23
|
onBeforeUnmount(() => {
|
|
24
|
-
|
|
24
|
+
// should also remove body style when dialog is removed, #805
|
|
25
|
+
// if (fixedBody && instance.get('value')) {
|
|
26
|
+
if (fixedBody) {
|
|
25
27
|
// maybe HIDE event has not triggered
|
|
26
28
|
onClosed(instance);
|
|
27
29
|
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: King-Design Icons
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Icon} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div class="icons">
|
|
12
|
+
<div class="icon" v-for={this.get('fonts')}>
|
|
13
|
+
<Icon
|
|
14
|
+
class={'k-icon-' + $value}
|
|
15
|
+
size="large"
|
|
16
|
+
/>
|
|
17
|
+
<div>{'k-icon-' + $value}</div>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```styl
|
|
23
|
+
.icons
|
|
24
|
+
display flex
|
|
25
|
+
flex-wrap wrap
|
|
26
|
+
gap 10px
|
|
27
|
+
text-align center
|
|
28
|
+
.icon
|
|
29
|
+
width 100px
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
export default class extends Component {
|
|
34
|
+
static template = template;
|
|
35
|
+
|
|
36
|
+
static defaults() {
|
|
37
|
+
return {
|
|
38
|
+
fonts: [
|
|
39
|
+
'alert',
|
|
40
|
+
'alarm',
|
|
41
|
+
'calendar',
|
|
42
|
+
'application',
|
|
43
|
+
'arrow-right',
|
|
44
|
+
'arrow-up',
|
|
45
|
+
'arrow-left',
|
|
46
|
+
'arrow-down',
|
|
47
|
+
'arrow-expand',
|
|
48
|
+
'arrow-left-circled',
|
|
49
|
+
'arrow-right-circled',
|
|
50
|
+
'close',
|
|
51
|
+
'bill',
|
|
52
|
+
'change',
|
|
53
|
+
'cloud-download',
|
|
54
|
+
'content-squared',
|
|
55
|
+
'cloud',
|
|
56
|
+
'arrow-move',
|
|
57
|
+
'code-download',
|
|
58
|
+
'cloud-server',
|
|
59
|
+
'arrow-shrink',
|
|
60
|
+
'clone',
|
|
61
|
+
'cloud-servers',
|
|
62
|
+
'cart',
|
|
63
|
+
'delete',
|
|
64
|
+
'fault-outline',
|
|
65
|
+
'calculate',
|
|
66
|
+
'arrow-swap',
|
|
67
|
+
'download',
|
|
68
|
+
'information',
|
|
69
|
+
'internet',
|
|
70
|
+
'edit',
|
|
71
|
+
'search',
|
|
72
|
+
'code-working',
|
|
73
|
+
'heart',
|
|
74
|
+
'content',
|
|
75
|
+
'cut',
|
|
76
|
+
'money-square',
|
|
77
|
+
'logout',
|
|
78
|
+
'cloud-upload',
|
|
79
|
+
'lock',
|
|
80
|
+
'corporate',
|
|
81
|
+
'truth-none',
|
|
82
|
+
'resize',
|
|
83
|
+
'protect',
|
|
84
|
+
'time',
|
|
85
|
+
'date',
|
|
86
|
+
'document-change',
|
|
87
|
+
'scanner',
|
|
88
|
+
'notification',
|
|
89
|
+
'notification-outline',
|
|
90
|
+
'silent',
|
|
91
|
+
'heart-outline',
|
|
92
|
+
'share',
|
|
93
|
+
'pay',
|
|
94
|
+
'picture',
|
|
95
|
+
'desktop',
|
|
96
|
+
'earphone',
|
|
97
|
+
'cube',
|
|
98
|
+
'user-verify',
|
|
99
|
+
'fault',
|
|
100
|
+
'location',
|
|
101
|
+
'down-squared',
|
|
102
|
+
'pay-dollar',
|
|
103
|
+
'paperclip',
|
|
104
|
+
'settings',
|
|
105
|
+
'home',
|
|
106
|
+
'more',
|
|
107
|
+
'phonecall',
|
|
108
|
+
'tag',
|
|
109
|
+
'truth-circled',
|
|
110
|
+
'refresh',
|
|
111
|
+
'watch',
|
|
112
|
+
'images',
|
|
113
|
+
'sort',
|
|
114
|
+
'money-circled',
|
|
115
|
+
'trade',
|
|
116
|
+
'star-outline',
|
|
117
|
+
'minus-circled',
|
|
118
|
+
'right',
|
|
119
|
+
'left',
|
|
120
|
+
'up',
|
|
121
|
+
'down',
|
|
122
|
+
'upward',
|
|
123
|
+
'up-circled',
|
|
124
|
+
'pin',
|
|
125
|
+
'hide',
|
|
126
|
+
'users',
|
|
127
|
+
'user',
|
|
128
|
+
'return-right',
|
|
129
|
+
'message',
|
|
130
|
+
'paper',
|
|
131
|
+
'phonecall-prohibit',
|
|
132
|
+
'speedometer',
|
|
133
|
+
'settings-horizontal',
|
|
134
|
+
'phone',
|
|
135
|
+
'star',
|
|
136
|
+
'play',
|
|
137
|
+
'refresh-lock',
|
|
138
|
+
'shield',
|
|
139
|
+
'panel',
|
|
140
|
+
'structure',
|
|
141
|
+
'settings-vertical',
|
|
142
|
+
'printer',
|
|
143
|
+
'stop',
|
|
144
|
+
'return-left',
|
|
145
|
+
'question',
|
|
146
|
+
'unlock',
|
|
147
|
+
'sound-off',
|
|
148
|
+
'up-squared',
|
|
149
|
+
'sound-on',
|
|
150
|
+
'upload',
|
|
151
|
+
'tool',
|
|
152
|
+
'visible',
|
|
153
|
+
'truth',
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 禁用某些按钮和页码
|
|
3
|
+
order: 7
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
禁用按钮和页码有两种方式
|
|
7
|
+
|
|
8
|
+
1. `disableBtn`只禁用页码按钮,“上一页”“下一页”按钮依然可点
|
|
9
|
+
2. `disablePage`同时禁用页码按钮和“上一页”“下一页”按钮
|
|
10
|
+
|
|
11
|
+
两个属性类型为:`(page: number, limit: number) => boolean`,返回`true`则禁用
|
|
12
|
+
|
|
13
|
+
```vdt
|
|
14
|
+
import {Pagination} from 'kpc';
|
|
15
|
+
|
|
16
|
+
<div>
|
|
17
|
+
<Pagination v-model="value1" total={200} disableBtn={this.disableBtn} />
|
|
18
|
+
<Pagination v-model="value2" total={200} showGoto disablePage={this.disablePage} />
|
|
19
|
+
</div>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```styl
|
|
23
|
+
.k-pagination
|
|
24
|
+
margin-bottom 20px
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
interface Props {
|
|
29
|
+
value1?: number
|
|
30
|
+
value2?: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default class extends Component<Props> {
|
|
34
|
+
static template = template;
|
|
35
|
+
|
|
36
|
+
static defaults() {
|
|
37
|
+
return {
|
|
38
|
+
value1: 10,
|
|
39
|
+
value2: 10,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
disableBtn(page: number, limit: number) {
|
|
44
|
+
return page > 10;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
disablePage(page: number, limit: number) {
|
|
48
|
+
return page > 10;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
@@ -20,6 +20,8 @@ sidebar: doc
|
|
|
20
20
|
| showTotal | 显示总条数 | `boolean` | `true` |
|
|
21
21
|
| showGoto | 显示快速跳转框 | `boolean` | `false` |
|
|
22
22
|
| showLimits | 是否显示每页条数选择框 | `boolean` | `true` |
|
|
23
|
+
| disableBtn | 只禁用页码按钮,“上一页”“下一页”按钮依然可点 | `(page: number, limit: number) => boolean` | `undefined` |
|
|
24
|
+
| disablePage | 同时禁用页码按钮和“上一页”“下一页”按钮 | `(page: number, limit: number) => boolean` | `undefined` |
|
|
23
25
|
|
|
24
26
|
# 事件
|
|
25
27
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BasicDemo from '~/components/pagination/demos/basic';
|
|
2
2
|
import GotoDemo from '~/components/pagination/demos/goto';
|
|
3
3
|
import CurrentDemo from '~/components/pagination/demos/current';
|
|
4
|
+
import DisableDemo from '~/components/pagination/demos/disable';
|
|
4
5
|
import {mount, unmount, dispatchEvent, wait} from '../../test/utils';
|
|
5
6
|
|
|
6
7
|
describe('Pagination', () => {
|
|
@@ -75,4 +76,17 @@ describe('Pagination', () => {
|
|
|
75
76
|
expect(fn.callCount).to.eql(2);
|
|
76
77
|
expect(fn.lastCall.lastArg).to.eql({value: 1, limit: 50});
|
|
77
78
|
});
|
|
79
|
+
|
|
80
|
+
it('should not goto disabled page', async () => {
|
|
81
|
+
const [instance, element] = mount(DisableDemo);
|
|
82
|
+
|
|
83
|
+
const input = element.querySelector('.k-input-inner') as HTMLInputElement;
|
|
84
|
+
dispatchEvent(input, 'focus');
|
|
85
|
+
input.value = '11';
|
|
86
|
+
dispatchEvent(input, 'change');
|
|
87
|
+
dispatchEvent(input, 'blur');
|
|
88
|
+
await wait();
|
|
89
|
+
expect(input.value).to.eql('10');
|
|
90
|
+
expect(instance.get('value2')).to.eql(10);
|
|
91
|
+
});
|
|
78
92
|
});
|
|
@@ -16,6 +16,8 @@ export interface PaginationProps {
|
|
|
16
16
|
showTotal?: boolean,
|
|
17
17
|
showGoto?: boolean,
|
|
18
18
|
showLimits?: boolean,
|
|
19
|
+
disableBtn?: (page: number, limit: number) => boolean,
|
|
20
|
+
disablePage?: (page: number, limit: number) => boolean,
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface PaginationEvents {
|
|
@@ -39,6 +41,8 @@ const typeDefs: Required<TypeDefs<PaginationProps>> = {
|
|
|
39
41
|
showTotal: Boolean,
|
|
40
42
|
showGoto: Boolean,
|
|
41
43
|
showLimits: Boolean,
|
|
44
|
+
disableBtn: Function,
|
|
45
|
+
disablePage: Function,
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
const defaults = (): Partial<PaginationProps> => ({
|
|
@@ -132,7 +136,11 @@ export class Pagination extends Component<PaginationProps, PaginationEvents> {
|
|
|
132
136
|
|
|
133
137
|
@bind
|
|
134
138
|
private goto(e: InputEvent) {
|
|
139
|
+
const {disablePage, limit} = this.get();
|
|
135
140
|
const value = parseInt((e.target as HTMLInputElement).value) || 1;
|
|
141
|
+
if (disablePage && disablePage(value, limit!)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
136
144
|
this.changePage(value);
|
|
137
145
|
}
|
|
138
146
|
}
|
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
total, size, noBorder, simple,
|
|
11
11
|
className, showTotal, showGoto,
|
|
12
12
|
counts, value, limit, limits,
|
|
13
|
-
showLimits
|
|
13
|
+
showLimits, disableBtn, disablePage
|
|
14
14
|
} = this.get();
|
|
15
15
|
|
|
16
16
|
if (!total) return <!-- pagination -->
|
|
@@ -32,11 +32,21 @@ if (noBorder || simple) {
|
|
|
32
32
|
const totalPages = (Math.ceil(total / limit)) || 0;
|
|
33
33
|
|
|
34
34
|
const paginationButton = function(page) {
|
|
35
|
+
let disabled = false;
|
|
36
|
+
if (page !== value) {
|
|
37
|
+
if (disablePage) {
|
|
38
|
+
disabled ||= !!disablePage(page, limit);
|
|
39
|
+
}
|
|
40
|
+
if (disableBtn) {
|
|
41
|
+
disabled ||= !!disableBtn(page, limit);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
35
44
|
return (
|
|
36
45
|
<Button type={type}
|
|
37
46
|
size={size}
|
|
38
47
|
icon
|
|
39
48
|
value={page}
|
|
49
|
+
disabled={disabled}
|
|
40
50
|
>{page}</Button>
|
|
41
51
|
);
|
|
42
52
|
};
|
|
@@ -108,13 +118,13 @@ let nextPage = value + 1;
|
|
|
108
118
|
<ButtonGroup checkType="radio" v-model="value">
|
|
109
119
|
<Button icon size={size}
|
|
110
120
|
type={type}
|
|
111
|
-
disabled={value <= 1}
|
|
121
|
+
disabled={value <= 1 || !!(disablePage && disablePage(value - 1, limit))}
|
|
112
122
|
ev-click={this.prev}
|
|
113
123
|
><Icon class="ion-ios-arrow-left" /></Button>
|
|
114
124
|
<template>{paginationItems}</template>
|
|
115
125
|
<Button icon size={size}
|
|
116
126
|
type={type}
|
|
117
|
-
disabled={value >= totalPages}
|
|
127
|
+
disabled={value >= totalPages || !!(disablePage && disablePage(value + 1, limit))}
|
|
118
128
|
ev-click={this.next}
|
|
119
129
|
><Icon class="ion-ios-arrow-right" /></Button>
|
|
120
130
|
</ButtonGroup>
|
package/components/portal.ts
CHANGED
|
@@ -85,36 +85,46 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
|
|
|
85
85
|
// update container if it has changed
|
|
86
86
|
const lastProps = lastVNode.props!;
|
|
87
87
|
const nextProps = nextVNode.props!;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
const update = () => {
|
|
89
|
+
const lastContainer = this.container!;
|
|
90
|
+
|
|
91
|
+
if (lastProps.container !== nextProps.container) {
|
|
92
|
+
this.initContainer(nextProps.container, parentDom, anchor);
|
|
93
|
+
}
|
|
94
|
+
const nextContainer = this.container!;
|
|
95
|
+
|
|
96
|
+
if (lastContainer === nextContainer) {
|
|
97
|
+
patch(
|
|
98
|
+
lastProps.children as VNode,
|
|
99
|
+
nextProps.children as VNode,
|
|
100
|
+
nextContainer,
|
|
101
|
+
this,
|
|
102
|
+
this.$SVG,
|
|
103
|
+
anchor,
|
|
104
|
+
mountedQueue,
|
|
105
|
+
false,
|
|
106
|
+
);
|
|
107
|
+
} else {
|
|
108
|
+
remove(lastProps.children as VNode, lastContainer, false);
|
|
109
|
+
mount(
|
|
110
|
+
nextProps.children as VNode,
|
|
111
|
+
nextContainer,
|
|
112
|
+
this,
|
|
113
|
+
this.$SVG,
|
|
114
|
+
anchor,
|
|
115
|
+
mountedQueue,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
super.$update(lastVNode, nextVNode, parentDom, anchor, mountedQueue, force);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (!this.container) {
|
|
123
|
+
// in react, sometimes $update will be called before mountedQueue in $render
|
|
124
|
+
mountedQueue.push(update);
|
|
105
125
|
} else {
|
|
106
|
-
|
|
107
|
-
mount(
|
|
108
|
-
nextProps.children as VNode,
|
|
109
|
-
nextContainer,
|
|
110
|
-
this,
|
|
111
|
-
this.$SVG,
|
|
112
|
-
anchor,
|
|
113
|
-
mountedQueue,
|
|
114
|
-
);
|
|
126
|
+
update();
|
|
115
127
|
}
|
|
116
|
-
|
|
117
|
-
super.$update(lastVNode, nextVNode, parentDom, anchor, mountedQueue, force);
|
|
118
128
|
}
|
|
119
129
|
|
|
120
130
|
$unmount(vNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this> | null) {
|
|
@@ -11,7 +11,7 @@ import {Select, Option} from 'kpc';
|
|
|
11
11
|
|
|
12
12
|
<div>
|
|
13
13
|
<div style="margin-bottom: 16px;">
|
|
14
|
-
<Select v-model="day"
|
|
14
|
+
<Select v-model="day">
|
|
15
15
|
<Option value="Monday">星期一</Option>
|
|
16
16
|
<Option value="Tuesday">星期二</Option>
|
|
17
17
|
<Option value="Wednesday">星期三</Option>
|
|
@@ -12,9 +12,11 @@ import {context as TableContext} from './useColumns';
|
|
|
12
12
|
import {context as ResizableContext} from './useResizable';
|
|
13
13
|
import {context as FixedColumnsContext} from './useFixedColumns';
|
|
14
14
|
import {stopPropagation} from '../utils';
|
|
15
|
+
import {Input} from '../input';
|
|
16
|
+
import {_$} from '../../i18n';
|
|
15
17
|
|
|
16
18
|
const {title, fixed, group, multiple, key, sortable, cols, rows} = this.get();
|
|
17
|
-
const {onSelect, isChecked, getGroupText} = this.group;
|
|
19
|
+
const {onSelect, isChecked, getGroupText, keywords, filteredGroup} = this.group;
|
|
18
20
|
|
|
19
21
|
<TableContext.Consumer>
|
|
20
22
|
{checkType => {
|
|
@@ -61,21 +63,35 @@ const {onSelect, isChecked, getGroupText} = this.group;
|
|
|
61
63
|
<Dropdown v-if={group}
|
|
62
64
|
position={{my: 'center top', at: 'center bottom+5', collision: 'flipfit'}}
|
|
63
65
|
key="dropdown"
|
|
66
|
+
trigger="click"
|
|
67
|
+
ev-show={() => keywords.set('')}
|
|
64
68
|
>
|
|
65
69
|
<Button icon size="mini" class="k-table-group"
|
|
66
|
-
ev-click={
|
|
70
|
+
ev-click={e => e._ignoreSortable = true}
|
|
67
71
|
>
|
|
68
72
|
<Icon class="ion-android-arrow-dropdown" />
|
|
69
73
|
</Button>
|
|
70
74
|
<DropdownMenu class={{"k-table-group-dropdown": true, [makeGroupMenuStyles()]: true}}>
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
<div class="k-table-group-header">
|
|
76
|
+
<Input size="small" fluid
|
|
77
|
+
placeholder={_$('请输入关键字')}
|
|
78
|
+
value={keywords.value}
|
|
79
|
+
ev-$change:value={keywords.set}
|
|
80
|
+
clearable
|
|
81
|
+
>
|
|
82
|
+
<b:suffix><Icon class="ion-ios-search" /></b:suffix>
|
|
83
|
+
</Input>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="k-table-group-body">
|
|
86
|
+
<DropdownItem v-for={filteredGroup.value}
|
|
87
|
+
ev-select={() => onSelect($value.value, groupValue, onChange)}
|
|
88
|
+
hideOnSelect={!multiple}
|
|
89
|
+
class={{'k-active': (checked = isChecked($value.value, groupValue))}}
|
|
90
|
+
>
|
|
91
|
+
<Checkbox v-if={multiple} value={checked}>{$value.label}</Checkbox>
|
|
92
|
+
<span v-else>{$value.label}</span>
|
|
93
|
+
</DropdownItem>
|
|
94
|
+
</div>
|
|
79
95
|
</DropdownMenu>
|
|
80
96
|
</Dropdown>
|
|
81
97
|
<div v-if={sortable}
|
|
@@ -5,7 +5,7 @@ order: 8
|
|
|
5
5
|
|
|
6
6
|
通过`expand`扩展点指定行展开后的模板内容。是否支持点击该行任何区域都展开内容,
|
|
7
7
|
是由`rowExpandable`控制的,默认情况下它为`true`。你也可以将它设为`false`,来自定义展开逻辑。例如:
|
|
8
|
-
点击某个`icon
|
|
8
|
+
点击某个`icon`后展开该行,而点击其它元素无效。自定义展开逻辑,修改`expandedKeys`属性值,来指定哪些`key`对应的行展开。
|
|
9
9
|
|
|
10
10
|
```vdt
|
|
11
11
|
import {Table, TableColumn} from 'kpc';
|
|
@@ -3,7 +3,7 @@ title: 行高亮
|
|
|
3
3
|
order: 5
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
给`Table`添加`rowSelectable
|
|
6
|
+
给`Table`添加`rowSelectable`属性,可以让表格点击行时高亮该行,你可以指定值为`multiple`来支持多行
|
|
7
7
|
高亮。类似`checkedKeys`,我们可以通过`selectedKeys`来绑定高亮行的`key`,当高亮的行改变时,组件也会
|
|
8
8
|
抛出`$change:selectedKeys`事件,我们可以通过`getSelectedData`来获取高亮行的数据
|
|
9
9
|
|