@king-design/intact 3.4.0-beta.1 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/descriptions/.DS_Store +0 -0
- package/components/descriptions/demos/basic.md +47 -0
- package/components/descriptions/demos/custom.md +51 -0
- package/components/descriptions/demos/vertical.md +25 -0
- package/components/descriptions/descriptions.ts +42 -0
- package/components/descriptions/descriptions.vdt +31 -0
- package/components/descriptions/index.md +50 -0
- package/components/descriptions/index.spec.ts +0 -0
- package/components/descriptions/index.ts +2 -0
- package/components/descriptions/item.ts +31 -0
- package/components/descriptions/item.vdt +34 -0
- package/components/descriptions/styles.ts +83 -0
- package/components/icon/demos/icons.md +3 -0
- package/components/menu/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/components/switch/demos/beforeChange.md +6 -6
- package/components/switch/index.md +1 -1
- package/components/switch/index.spec.ts +8 -1
- package/components/switch/index.ts +6 -4
- package/components/switch/useDraggable.ts +2 -1
- package/components/table/column.ts +2 -0
- package/components/table/column.vdt +3 -4
- package/components/table/index.md +1 -0
- package/es/components/descriptions/descriptions.d.ts +20 -0
- package/es/components/descriptions/descriptions.js +34 -0
- package/es/components/descriptions/descriptions.vdt.js +40 -0
- package/es/components/descriptions/index.d.ts +2 -0
- package/es/components/descriptions/index.js +2 -0
- package/es/components/descriptions/index.spec.d.ts +1 -0
- package/es/components/descriptions/index.spec.js +1 -0
- package/es/components/descriptions/item.d.ts +17 -0
- package/es/components/descriptions/item.js +26 -0
- package/es/components/descriptions/item.vdt.js +45 -0
- package/es/components/descriptions/styles.d.ts +5 -0
- package/es/components/descriptions/styles.js +31 -0
- package/es/components/switch/index.d.ts +1 -1
- package/es/components/switch/index.js +17 -14
- package/es/components/switch/index.spec.js +21 -3
- package/es/components/switch/useDraggable.js +7 -4
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +1 -0
- package/es/components/table/column.vdt.js +6 -6
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/site/data/components/descriptions/demos/basic/index.d.ts +17 -0
- package/es/site/data/components/descriptions/demos/basic/index.js +32 -0
- package/es/site/data/components/descriptions/demos/basic/react.d.ts +16 -0
- package/es/site/data/components/descriptions/demos/basic/react.js +55 -0
- package/es/site/data/components/descriptions/demos/custom/index.d.ts +6 -0
- package/es/site/data/components/descriptions/demos/custom/index.js +14 -0
- package/es/site/data/components/descriptions/demos/custom/react.d.ts +5 -0
- package/es/site/data/components/descriptions/demos/custom/react.js +45 -0
- package/es/site/data/components/descriptions/demos/vertical/index.d.ts +6 -0
- package/es/site/data/components/descriptions/demos/vertical/index.js +14 -0
- package/es/site/data/components/descriptions/demos/vertical/react.d.ts +5 -0
- package/es/site/data/components/descriptions/demos/vertical/react.js +29 -0
- package/es/site/data/components/descriptions/index.d.ts +57 -0
- package/es/site/data/components/descriptions/index.js +32 -0
- package/es/site/data/components/icon/demos/icons/index.js +1 -1
- package/es/site/data/components/switch/demos/beforeChange/index.d.ts +3 -3
- package/es/site/data/components/switch/demos/beforeChange/index.js +5 -5
- package/es/site/data/components/switch/demos/beforeChange/react.d.ts +3 -3
- package/es/site/data/components/switch/demos/beforeChange/react.js +7 -5
- package/es/styles/fonts/iconfont.eot +0 -0
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/fonts/iconfont.svg +6 -0
- package/es/styles/fonts/iconfont.ttf +0 -0
- package/es/styles/fonts/iconfont.woff +0 -0
- package/es/styles/fonts/iconfont.woff2 +0 -0
- package/es/styles/fonts/ionicons.woff2 +0 -0
- package/es/styles/theme.js +1 -1
- package/index.ts +3 -2
- package/package.json +1 -1
- package/styles/.DS_Store +0 -0
- package/styles/fonts/demo_index.html +75 -6
- package/styles/fonts/iconfont.css +18 -6
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.json +21 -0
- package/styles/fonts/iconfont.svg +6 -0
- package/styles/fonts/iconfont.ts +13 -1
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/theme.ts +1 -1
|
Binary file
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 基本用法
|
|
3
|
+
order: 0
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
常见于详情页的信息展示 默认自带超长省略, 可通过DescriptionItem形式渲染数据或者提供items属性。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Descriptions, DescriptionItem} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
|
|
13
|
+
<Descriptions title="基础信息" items={this.get('items')} columns={4}/>
|
|
14
|
+
|
|
15
|
+
<Descriptions title="基础信息">
|
|
16
|
+
<DescriptionItem label="测试1">测试1</DescriptionItem>
|
|
17
|
+
<DescriptionItem label="测试2">测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长测试超长</DescriptionItem>
|
|
18
|
+
<DescriptionItem label="测试3">测试3</DescriptionItem>
|
|
19
|
+
<DescriptionItem label="测试4">测试4</DescriptionItem>
|
|
20
|
+
<DescriptionItem label="测试5">测试5</DescriptionItem>
|
|
21
|
+
</Descriptions>
|
|
22
|
+
</div>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```styl
|
|
26
|
+
.k-descriptions
|
|
27
|
+
padding 10px
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default class extends Component {
|
|
32
|
+
static template = template;
|
|
33
|
+
static defaults() {
|
|
34
|
+
return {
|
|
35
|
+
items: [
|
|
36
|
+
{label:'label1', content:'测试1'},
|
|
37
|
+
{label:'label2', content:'测试测试'},
|
|
38
|
+
{label:'label3', content: '测试3'},
|
|
39
|
+
{label:'label4', content:'测试4', append: 'option'},
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义内容
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
两种使用方式均支持自定义内容。DescriptionItem提供了append插槽便于自定义内容, 若通过items形式传入则需要配置append字段作为自定义渲染内容。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Descriptions, DescriptionItem, Copy, Button, Tooltip, Icon} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Descriptions title="基础信息">
|
|
13
|
+
<b:title>
|
|
14
|
+
<span>自定义标题</span>
|
|
15
|
+
<Tooltip content="custom title">
|
|
16
|
+
<Icon class="k-icon-question" />
|
|
17
|
+
</Tooltip>
|
|
18
|
+
</b:title>
|
|
19
|
+
<DescriptionItem label="label1">
|
|
20
|
+
测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试
|
|
21
|
+
<b:append>
|
|
22
|
+
<Copy text="success" />
|
|
23
|
+
</b:append>
|
|
24
|
+
</DescriptionItem>
|
|
25
|
+
<DescriptionItem label="label2">
|
|
26
|
+
测试
|
|
27
|
+
</DescriptionItem>
|
|
28
|
+
<DescriptionItem label="label3">
|
|
29
|
+
<b:label>
|
|
30
|
+
<span>自定义label</span>
|
|
31
|
+
<Tooltip content="custom label">
|
|
32
|
+
<Icon class="k-icon-question" />
|
|
33
|
+
</Tooltip>
|
|
34
|
+
</b:label>
|
|
35
|
+
测试
|
|
36
|
+
</DescriptionItem>
|
|
37
|
+
<DescriptionItem label="label4">
|
|
38
|
+
<span>测试4</span>
|
|
39
|
+
<Button type="link">分配项目</Button>
|
|
40
|
+
</DescriptionItem>
|
|
41
|
+
<DescriptionItem label="label5">测试5</DescriptionItem>
|
|
42
|
+
<DescriptionItem label="label6">测试6</DescriptionItem>
|
|
43
|
+
</Descriptions>
|
|
44
|
+
</div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```styl
|
|
48
|
+
.k-descriptions
|
|
49
|
+
padding 10px
|
|
50
|
+
```
|
|
51
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 垂直展示
|
|
3
|
+
order: 2
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
通过vertical属性控制是否垂直展示
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Descriptions, DescriptionItem} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Descriptions title="基础信息" vertical>
|
|
13
|
+
<DescriptionItem label="测试1">测试1</DescriptionItem>
|
|
14
|
+
<DescriptionItem label="测试2">测试2</DescriptionItem>
|
|
15
|
+
<DescriptionItem label="测试3">测试3</DescriptionItem>
|
|
16
|
+
<DescriptionItem label="测试4">测试4</DescriptionItem>
|
|
17
|
+
<DescriptionItem label="测试5">测试5</DescriptionItem>
|
|
18
|
+
</Descriptions>
|
|
19
|
+
</div>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```styl
|
|
23
|
+
.k-descriptions
|
|
24
|
+
padding 10px
|
|
25
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {Component, TypeDefs} from 'intact';
|
|
2
|
+
import {DescriptionItemProps} from './item';
|
|
3
|
+
import template from './descriptions.vdt';
|
|
4
|
+
import { useConfigContext } from '../config';
|
|
5
|
+
import { VNode } from "intact";
|
|
6
|
+
|
|
7
|
+
export interface DescriptionsProps {
|
|
8
|
+
vertical?: boolean
|
|
9
|
+
columns?: number
|
|
10
|
+
items?: DescriptionItemProps[]
|
|
11
|
+
title?: string | number | VNode
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DescriptionsBlocks {
|
|
15
|
+
title: null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export interface DescriptionsEvents {}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const typeDefs: Required<TypeDefs<DescriptionsProps>> = {
|
|
23
|
+
vertical: Boolean,
|
|
24
|
+
columns: Number,
|
|
25
|
+
items: Array,
|
|
26
|
+
title: [String, Number, VNode],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const defaults = (): Partial<DescriptionsProps> => ({
|
|
33
|
+
columns: 3,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export class Descriptions extends Component<DescriptionsProps, DescriptionsEvents, DescriptionsBlocks> {
|
|
37
|
+
static template = template;
|
|
38
|
+
static typeDefs = typeDefs;
|
|
39
|
+
static defaults = defaults;
|
|
40
|
+
|
|
41
|
+
private config = useConfigContext();
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {DescriptionItem} from './item';
|
|
2
|
+
import {makeStyles} from './styles';
|
|
3
|
+
import {getRestProps} from '../utils';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const {children, className, columns, title, vertical, items} = this.get();
|
|
7
|
+
const { k } = this.config;
|
|
8
|
+
|
|
9
|
+
const classNameObj = {
|
|
10
|
+
[`${k}-descriptions`]: true,
|
|
11
|
+
[`${k}-vertical`]: vertical,
|
|
12
|
+
[className]: className,
|
|
13
|
+
[makeStyles(k, columns)]: true,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<div {...getRestProps(this)} class={classNameObj}>
|
|
18
|
+
<div v-if={$blocks.title || title} class={`${k}-descriptions-title`}>
|
|
19
|
+
<b:title>
|
|
20
|
+
<template v-if={title}>{title}</template>
|
|
21
|
+
</b:title>
|
|
22
|
+
</div>
|
|
23
|
+
<div class={`${k}-descriptions-content`}>
|
|
24
|
+
<template v-if={items}>
|
|
25
|
+
<DescriptionItem v-for={items} label={$value.label} content={$value.content} append={$value.append} />
|
|
26
|
+
</template>
|
|
27
|
+
<template v-else>
|
|
28
|
+
{children}
|
|
29
|
+
</template>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 描述列表
|
|
3
|
+
category: 组件
|
|
4
|
+
order: 30
|
|
5
|
+
sidebar: doc
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# 属性
|
|
9
|
+
|
|
10
|
+
## Descriptions
|
|
11
|
+
|
|
12
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| vertical | 垂直排列 | `boolean` | `false` |
|
|
15
|
+
| title | 描述列表的标题,显示在最顶部 | `string` | `number` | `VNode` | `undefined` |
|
|
16
|
+
| items | 描述列表项内容 | `DescriptionItemProps[]` | `[]` |
|
|
17
|
+
| columns | 一行的 DescriptionItem 数量 | `number` | `3` |
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import {VNode} from 'intact';
|
|
21
|
+
|
|
22
|
+
export interface DescriptionItemProps {
|
|
23
|
+
label?: string | number | VNode
|
|
24
|
+
content?: string | number | VNode
|
|
25
|
+
option?: string | number | VNode
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## DescriptionItem
|
|
30
|
+
|
|
31
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| label | 内容的标题 | `string` | `number` | `VNode` | `undefined` |
|
|
34
|
+
| content | 包含内容 | `string` | `number` | `VNode` | `undefined` |
|
|
35
|
+
| append | 自定义内容 | `string` | `number` | `VNode` | `undefined` |
|
|
36
|
+
|
|
37
|
+
# 拓展点
|
|
38
|
+
|
|
39
|
+
## Descriptions
|
|
40
|
+
|
|
41
|
+
| 名称 | 说明
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| title | 自定义title |
|
|
44
|
+
|
|
45
|
+
## DescriptionItem
|
|
46
|
+
|
|
47
|
+
| 名称 | 说明
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| append | 用于超长省略后的操作区自定义内容 |
|
|
50
|
+
| label | 自定义label |
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import { Component, TypeDefs, VNode } from "intact";
|
|
3
|
+
import template from './item.vdt';
|
|
4
|
+
import { useConfigContext } from '../config';
|
|
5
|
+
|
|
6
|
+
export interface DescriptionItemProps {
|
|
7
|
+
label?: string | number | VNode
|
|
8
|
+
content?: string | number | VNode
|
|
9
|
+
append?: string | number | VNode
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DescriptionItemBlocks {
|
|
13
|
+
append: null
|
|
14
|
+
label: null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface DescriptionItemEvents {}
|
|
18
|
+
|
|
19
|
+
const typeDefs: Required<TypeDefs<DescriptionItemProps>> = {
|
|
20
|
+
label: [String, Number, VNode],
|
|
21
|
+
content: [String, Number, VNode],
|
|
22
|
+
append: [String, Number, VNode]
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export class DescriptionItem extends Component<DescriptionItemProps, DescriptionItemEvents, DescriptionItemBlocks> {
|
|
27
|
+
static template = template;
|
|
28
|
+
static typeDefs = typeDefs;
|
|
29
|
+
|
|
30
|
+
private config = useConfigContext();
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {makeStyles} from './styles';
|
|
2
|
+
import {getRestProps, addStyle} from '../utils';
|
|
3
|
+
import {isFunction} from 'intact-shared';
|
|
4
|
+
import {Ellipsis} from 'kpc';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
children, className, span, label, content, append
|
|
8
|
+
} = this.get();
|
|
9
|
+
const { k } = this.config;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const classNameObj = {
|
|
13
|
+
[`${k}-description-item`]: true,
|
|
14
|
+
[className]: className,
|
|
15
|
+
[makeStyles(k)]: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
<div {...getRestProps(this)} class={classNameObj}>
|
|
19
|
+
<div class={`${k}-description-item-label`}>
|
|
20
|
+
<b:label>
|
|
21
|
+
<template v-if={label}>{label}</template>
|
|
22
|
+
</b:label>
|
|
23
|
+
</div>
|
|
24
|
+
<div class={`${k}-description-centent`}>
|
|
25
|
+
<Ellipsis>
|
|
26
|
+
{content || children}
|
|
27
|
+
</Ellipsis>
|
|
28
|
+
<div class={`${k}-description-option`} v-if={$blocks.append || append}>
|
|
29
|
+
<b:append>
|
|
30
|
+
<template v-if={append}>{append}</template>
|
|
31
|
+
</b:append>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {css} from '@emotion/css';
|
|
2
|
+
import {theme, setDefault} from '../../styles/theme';
|
|
3
|
+
import {deepDefaults} from '../../styles/utils';
|
|
4
|
+
import '../../styles/global';
|
|
5
|
+
import { cache } from '../utils';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const defaults = {
|
|
9
|
+
title: {
|
|
10
|
+
get color() { return theme.color.title },
|
|
11
|
+
weight: 500,
|
|
12
|
+
size: '14px',
|
|
13
|
+
},
|
|
14
|
+
label: {
|
|
15
|
+
get color() { return theme.color.lightBlack },
|
|
16
|
+
padding: '0 16px 0 0',
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let descriptions: typeof defaults;
|
|
22
|
+
setDefault(() => {
|
|
23
|
+
descriptions = deepDefaults(theme, {descriptions: defaults}).descriptions;
|
|
24
|
+
makeStyles?.clearCache();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const makeStyles = cache(function makeStyles(k: string, column: number) {
|
|
28
|
+
const itemWidth = `${100 / column}%`;
|
|
29
|
+
|
|
30
|
+
return css`
|
|
31
|
+
&.${k}-vertical {
|
|
32
|
+
.${k}-description-item {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: baseline;
|
|
36
|
+
|
|
37
|
+
.${k}-description-centent {
|
|
38
|
+
width: auto;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.${k}-descriptions-title {
|
|
44
|
+
color: ${descriptions.title.color};
|
|
45
|
+
font-weight: ${descriptions.title.weight};
|
|
46
|
+
font-size: ${descriptions.title.size};
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.${k}-descriptions-content {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: wrap;
|
|
54
|
+
padding-top: 16px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.${k}-description-item {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
padding-bottom: 16px;
|
|
61
|
+
flex: 0 0 ${itemWidth};
|
|
62
|
+
width: ${itemWidth};
|
|
63
|
+
}
|
|
64
|
+
.${k}-description-centent {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
max-width: 60%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.${k}-description-item-label {
|
|
71
|
+
color: ${descriptions.label.color};
|
|
72
|
+
padding: ${descriptions.label.padding};
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.${k}-description-option {
|
|
78
|
+
display: inline-block;
|
|
79
|
+
margin-left: 8px;
|
|
80
|
+
line-height: 0px;
|
|
81
|
+
}
|
|
82
|
+
`
|
|
83
|
+
});
|
|
Binary file
|
|
Binary file
|
|
@@ -11,7 +11,7 @@ order: 8
|
|
|
11
11
|
import {Switch} from 'kpc';
|
|
12
12
|
|
|
13
13
|
<div>
|
|
14
|
-
<Switch v-model="value1" beforeChange={this.beforeChange} />
|
|
14
|
+
<Switch v-model="value1" trueValue={1} falseValue={0} beforeChange={this.beforeChange} />
|
|
15
15
|
<Switch v-model="value2" beforeChange={this.beforeChangeFalse} />
|
|
16
16
|
</div>
|
|
17
17
|
```
|
|
@@ -27,21 +27,21 @@ export default class extends Component {
|
|
|
27
27
|
static template = template;
|
|
28
28
|
static defaults() {
|
|
29
29
|
return {
|
|
30
|
-
value1:
|
|
30
|
+
value1: 0,
|
|
31
31
|
value2: false,
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
beforeChange(
|
|
35
|
+
beforeChange(from: any, to: any) {
|
|
36
36
|
return new Promise<boolean>(resolve => {
|
|
37
|
-
Message.warning(`current value is ${value}`);
|
|
37
|
+
Message.warning(`current value is ${from}, to value is ${to}`);
|
|
38
38
|
setTimeout(() => {
|
|
39
39
|
resolve(true);
|
|
40
40
|
}, 1000);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
beforeChangeFalse(
|
|
44
|
-
Message.warning(`current value is ${value}`);
|
|
43
|
+
beforeChangeFalse(from: any, to: any) {
|
|
44
|
+
Message.warning(`current value is ${from}, to value is ${to}`);
|
|
45
45
|
return new Promise<boolean>(resolve => {
|
|
46
46
|
setTimeout(() => {
|
|
47
47
|
resolve(false);
|
|
@@ -23,7 +23,7 @@ sidebar: doc
|
|
|
23
23
|
| size | 尺寸 | `"large"` | `"default"` | `"small"` | `"mini"` | `"default"` |
|
|
24
24
|
| disabled | 控制禁用 | `boolean` | `false` |
|
|
25
25
|
| loading | 开关loading属性 | `boolean` | `false` |
|
|
26
|
-
| beforeChange | 切换`Switch`之前的拦截函数,如果该函数返回`false`则阻止本次切换,支持异步函数,
|
|
26
|
+
| beforeChange | 切换`Switch`之前的拦截函数,如果该函数返回`false`则阻止本次切换,支持异步函数, 参数为当前值from,期望切换值to | <code>(from: any, to: any) => boolean | Promise<boolean></code> | `undefined` |
|
|
27
27
|
|
|
28
28
|
# 扩展点
|
|
29
29
|
|
|
@@ -126,7 +126,14 @@ describe('Switch', () => {
|
|
|
126
126
|
el1.click();
|
|
127
127
|
el2.click();
|
|
128
128
|
await wait(1000);
|
|
129
|
-
expect(instance.get('value1')).
|
|
129
|
+
expect(instance.get('value1')).eql(1);
|
|
130
|
+
expect(instance.get('value2')).to.be.false;
|
|
131
|
+
await wait();
|
|
132
|
+
const [dragg1, dragg2] = element.querySelectorAll<HTMLElement>('.k-switch-handle');
|
|
133
|
+
dispatchEvent(dragg2, 'mousedown', {which: 1, clientX: 0});
|
|
134
|
+
dispatchEvent(document, 'mousemove', {clientX: 30});
|
|
135
|
+
dispatchEvent(document, 'mouseup', {clientX: 30});
|
|
136
|
+
await wait();
|
|
130
137
|
expect(instance.get('value2')).to.be.false;
|
|
131
138
|
});
|
|
132
139
|
});
|
|
@@ -18,7 +18,7 @@ export interface SwitchProps<True = any, False = any> {
|
|
|
18
18
|
size?: Sizes
|
|
19
19
|
disabled?: boolean
|
|
20
20
|
loading?: boolean
|
|
21
|
-
beforeChange?: (
|
|
21
|
+
beforeChange?: (from: True | False | undefined, to: True | False | undefined) => boolean | Promise<boolean>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface SwitchEvents {
|
|
@@ -84,7 +84,8 @@ export class Switch<True = true, False = false> extends Component<SwitchProps<Tr
|
|
|
84
84
|
@bind
|
|
85
85
|
private onClickOnHandle(e: MouseEventWithIgnore) {
|
|
86
86
|
// we can not stop propagation, otherwise the click can not be listen at outer
|
|
87
|
-
|
|
87
|
+
const {beforeChange} = this.get();
|
|
88
|
+
e._switchIgnore = !beforeChange;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
@bind
|
|
@@ -96,7 +97,7 @@ export class Switch<True = true, False = false> extends Component<SwitchProps<Tr
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
public async toggle(isKeypress: boolean) {
|
|
99
|
-
const {disabled, beforeChange, value} = this.get();
|
|
100
|
+
const {disabled, beforeChange, value, trueValue, falseValue} = this.get();
|
|
100
101
|
if (disabled) return;
|
|
101
102
|
|
|
102
103
|
// if is not keypress, we blur it to remove focus style
|
|
@@ -110,7 +111,8 @@ export class Switch<True = true, False = false> extends Component<SwitchProps<Tr
|
|
|
110
111
|
loading: true
|
|
111
112
|
});
|
|
112
113
|
try {
|
|
113
|
-
const
|
|
114
|
+
const toValue = this.isChecked() ? falseValue : trueValue;
|
|
115
|
+
const ret = await beforeChange(value, toValue);
|
|
114
116
|
if (!ret) return;
|
|
115
117
|
} finally {
|
|
116
118
|
this.set({
|
|
@@ -14,7 +14,8 @@ export function useDraggable(elementRef: RefObject<HTMLElement>) {
|
|
|
14
14
|
let maxWidth: number;
|
|
15
15
|
|
|
16
16
|
function onStart(e: MouseEvent) {
|
|
17
|
-
|
|
17
|
+
const {disabled, beforeChange} = instance.get();
|
|
18
|
+
if (disabled || beforeChange) return;
|
|
18
19
|
|
|
19
20
|
x = e.clientX;
|
|
20
21
|
height = barRef.value!.clientHeight;
|
|
@@ -9,6 +9,7 @@ export interface TableColumnProps {
|
|
|
9
9
|
sortable?: boolean
|
|
10
10
|
width?: string | number
|
|
11
11
|
group?: TableColumnGroupItem[]
|
|
12
|
+
hideGroupHeader?: boolean
|
|
12
13
|
multiple?: boolean
|
|
13
14
|
ignore?: boolean
|
|
14
15
|
fixed?: 'left' | 'right'
|
|
@@ -48,6 +49,7 @@ const typeDefs: Required<TypeDefs<TableColumnProps>> = {
|
|
|
48
49
|
sortable: Boolean,
|
|
49
50
|
width: [String, Number],
|
|
50
51
|
group: Array,
|
|
52
|
+
hideGroupHeader: Boolean,
|
|
51
53
|
multiple: Boolean,
|
|
52
54
|
ignore: Boolean,
|
|
53
55
|
fixed: ['left', 'right'],
|
|
@@ -16,7 +16,7 @@ import {Input} from '../input';
|
|
|
16
16
|
import {_$} from '../../i18n';
|
|
17
17
|
import {ignoreSortable} from './useSortable';
|
|
18
18
|
|
|
19
|
-
const {title, fixed, group, multiple, key, sortable, cols, rows, hidden} = this.get();
|
|
19
|
+
const {title, fixed, group, multiple, key, sortable, cols, rows, hidden, hideGroupHeader} = this.get();
|
|
20
20
|
const {
|
|
21
21
|
onSelect, isChecked, keywords, filteredGroup,
|
|
22
22
|
onShow, reset, confirm, dropdownRef,
|
|
@@ -66,7 +66,7 @@ const { k } = this.config;
|
|
|
66
66
|
<b:title>{title}</b:title>
|
|
67
67
|
</div>
|
|
68
68
|
<Dropdown v-if={group}
|
|
69
|
-
position={{my: '
|
|
69
|
+
position={{my: 'left top', at: 'left bottom+5', collision: 'flipfit'}}
|
|
70
70
|
key="dropdown"
|
|
71
71
|
trigger="click"
|
|
72
72
|
ev-show={() => onShow(groupValue)}
|
|
@@ -78,7 +78,7 @@ const { k } = this.config;
|
|
|
78
78
|
color={isEmptyValue(groupValue) ? null : 'primary'}
|
|
79
79
|
/>
|
|
80
80
|
<DropdownMenu class={{[`${k}-table-group-dropdown`]: true, [makeGroupMenuStyles(k)]: true}}>
|
|
81
|
-
<div class={`${k}-table-group-header`}>
|
|
81
|
+
<div class={`${k}-table-group-header`} v-if={!hideGroupHeader}>
|
|
82
82
|
<Input size="small" fluid
|
|
83
83
|
placeholder={_$('请输入关键字')}
|
|
84
84
|
value={keywords.value}
|
|
@@ -105,7 +105,6 @@ const { k } = this.config;
|
|
|
105
105
|
>{_$('全选')}</Button>
|
|
106
106
|
<Button size="small"
|
|
107
107
|
disabled={isEmptyValue(localGroupValue.value)}
|
|
108
|
-
type="secondary"
|
|
109
108
|
ev-click={() => reset(onChange)}
|
|
110
109
|
>{_$('重置')}</Button>
|
|
111
110
|
<Button type="primary" size="small"
|
|
@@ -103,6 +103,7 @@ export interface PaginationProps {
|
|
|
103
103
|
| sortable | 是否可排序 | `boolean` | `false` |
|
|
104
104
|
| width | 列宽,可以指定百分比或像素(像素不需要加单位) | `string` | `undefined` |
|
|
105
105
|
| group | 指定分组数组,每一项格式为`{value: '选中后的值', label: '展示的文案'}` | `TableColumnGroupItem[]` | `undefined` |
|
|
106
|
+
| hideGroupHeader | 是否隐藏group下拉菜单中header区域 | `boolean` | `false` |
|
|
106
107
|
| multiple | 分组是否支持多选 | `boolean` | `false` |
|
|
107
108
|
| ignore | 是否忽略当前列的导出 | `boolean` | `false` |
|
|
108
109
|
| fixed | 是否将列固定,`"left"`固定在左侧;`"right"`固定在右侧 | `"left"` | `"right"` | `undefined` |
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component, TypeDefs } from 'intact';
|
|
2
|
+
import { DescriptionItemProps } from './item';
|
|
3
|
+
import { VNode } from "intact";
|
|
4
|
+
export interface DescriptionsProps {
|
|
5
|
+
vertical?: boolean;
|
|
6
|
+
columns?: number;
|
|
7
|
+
items?: DescriptionItemProps[];
|
|
8
|
+
title?: string | number | VNode;
|
|
9
|
+
}
|
|
10
|
+
export interface DescriptionsBlocks {
|
|
11
|
+
title: null;
|
|
12
|
+
}
|
|
13
|
+
export interface DescriptionsEvents {
|
|
14
|
+
}
|
|
15
|
+
export declare class Descriptions extends Component<DescriptionsProps, DescriptionsEvents, DescriptionsBlocks> {
|
|
16
|
+
static template: string | import("intact").Template<any>;
|
|
17
|
+
static typeDefs: Required<TypeDefs<DescriptionsProps>>;
|
|
18
|
+
static defaults: () => Partial<DescriptionsProps>;
|
|
19
|
+
private config;
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { Component } from 'intact';
|
|
4
|
+
import template from './descriptions.vdt';
|
|
5
|
+
import { useConfigContext } from '../config';
|
|
6
|
+
import { VNode } from "intact";
|
|
7
|
+
var typeDefs = {
|
|
8
|
+
vertical: Boolean,
|
|
9
|
+
columns: Number,
|
|
10
|
+
items: Array,
|
|
11
|
+
title: [String, Number, VNode]
|
|
12
|
+
};
|
|
13
|
+
var defaults = function defaults() {
|
|
14
|
+
return {
|
|
15
|
+
columns: 3
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export var Descriptions = /*#__PURE__*/function (_Component) {
|
|
19
|
+
_inheritsLoose(Descriptions, _Component);
|
|
20
|
+
function Descriptions() {
|
|
21
|
+
var _context;
|
|
22
|
+
var _this;
|
|
23
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
+
args[_key] = arguments[_key];
|
|
25
|
+
}
|
|
26
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
27
|
+
_this.config = useConfigContext();
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
return Descriptions;
|
|
31
|
+
}(Component);
|
|
32
|
+
Descriptions.template = template;
|
|
33
|
+
Descriptions.typeDefs = typeDefs;
|
|
34
|
+
Descriptions.defaults = defaults;
|