Skip to content

Commit 8df58d8

Browse files
committed
fix doc
1 parent c9736a4 commit 8df58d8

File tree

8 files changed

+53
-61
lines changed

8 files changed

+53
-61
lines changed

components/input-number/demo/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const md = {
1313
## 何时使用
1414
当需要获取标准数值时。
1515
## 代码演示`,
16-
us: `# Data Entry
16+
us: `# InputNumber
1717
Enter a number within certain range with the mouse or keyboard.
1818
## When To Use
1919
When a numeric value needs to be provided.

components/transfer/demo/basic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<cn>
22
#### 基本用法
3-
最基本的用法,展示了 `dataSource``targetKeys`、每行的渲染函数 `render` 以及回调函数 `onChange` `onSelectChange` `onScroll` 的用法。
3+
最基本的用法,展示了 `dataSource``targetKeys`、每行的渲染函数 `render` 以及回调函数 `change` `selectChange` `scroll` 的用法。
44
</cn>
55

66
<us>
@@ -41,7 +41,7 @@ export default {
4141
return {
4242
mockData,
4343
targetKeys,
44-
selectedKeys: [],
44+
selectedKeys: ['1', '4'],
4545
}
4646
},
4747
methods: {

components/transfer/index.en-US.md

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,36 @@
1-
---
2-
category: Components
3-
type: Data Entry
4-
cols: 1
5-
title: Transfer
6-
---
7-
8-
Double column transfer choice box.
9-
10-
## When To Use
11-
12-
Transfer the elements between two columns in an intuitive and efficient way.
13-
14-
One or more elements can be selected from either column, one click on the proper 'direction' button, and the transfer is done. The left column is considered the 'source' and the right column is considered the 'target'. As you can see in the API description, these names are reflected in.
15-
161
## API
172

183
| Property | Description | Type | Default |
194
| -------- | ----------- | ---- | ------- |
20-
| className | A custom CSS class. | string | ['', ''] |
21-
| dataSource | Used for setting the source data. The elements that are part of this array will be present the left column. Except the elements whose keys are included in `targetKeys` prop. | [TransferItem](https://git.io/vMM64)\[] | \[] |
5+
| dataSource | Used for setting the source data. The elements that are part of this array will be present the left column. Except the elements whose keys are included in `targetKeys` prop. | \[{key: string.isRequired,title: string.isRequired,description: string,disabled: bool}\] | \[] |
226
| filterOption | A function to determine whether an item should show in search result list | (inputValue, option): boolean | |
23-
| footer | A function used for rendering the footer. | (props): ReactNode | |
24-
| lazy | property of [react-lazy-load](https://github.com/loktar00/react-lazy-load) for lazy rendering items. Turn off it by set to `false`. | object\|boolean | `{ height: 32, offset: 32 }` |
7+
| footer | customize the progress dot by setting a scoped slot | slot="footer" slot-scope="props" | |
8+
| lazy | property of vc-lazy-load for lazy rendering items. Turn off it by set to `false`. | object\|boolean | `{ height: 32, offset: 32 }` |
259
| listStyle | A custom CSS style used for rendering the transfer columns. | object | |
26-
| notFoundContent | Text to display when a column is empty. | string\|ReactNode | 'The list is empty' |
10+
| notFoundContent | Text to display when a column is empty. | string\|slot | 'The list is empty' |
2711
| operations | A set of operations that are sorted from bottom to top. | string\[] | ['>', '<'] |
28-
| render | The function to generate the item shown on a column. Based on an record (element of the dataSource array), this function should return a React element which is generated from that record. Also, it can return a plain object with `value` and `label`, `label` is a React element and `value` is for title | Function(record) | |
12+
| render | The function to generate the item shown on a column. Based on an record (element of the dataSource array), this function should return a element which is generated from that record. Also, it can return a plain object with `value` and `label`, `label` is a element and `value` is for title | Function(record) | |
2913
| searchPlaceholder | The hint text of the search box. | string | 'Search here' |
3014
| selectedKeys | A set of keys of selected items. | string\[] | \[] |
3115
| showSearch | If included, a search box is shown on each column. | boolean | false |
3216
| targetKeys | A set of keys of elements that are listed on the right column. | string\[] | \[] |
3317
| titles | A set of titles that are sorted from left to right. | string\[] | - |
34-
| onChange | A callback function that is executed when the transfer between columns is complete. | (targetKeys, direction, moveKeys): void | |
35-
| onScroll | A callback function which is executed when scroll options list | (direction, event): void | |
36-
| onSearchChange | A callback function which is executed when search field are changed | (direction: 'left'\|'right', event: Event): void | - |
37-
| onSelectChange | A callback function which is executed when selected items are changed. | (sourceSelectedKeys, targetSelectedKeys): void | |
18+
19+
### events
20+
| Events Name | Description | Arguments |
21+
| --- | --- | --- |
22+
| change | A callback function that is executed when the transfer between columns is complete. | (targetKeys, direction, moveKeys): void | |
23+
| scroll | A callback function which is executed when scroll options list | (direction, event): void | |
24+
| searchChange | A callback function which is executed when search field are changed | (direction: 'left'\|'right', event: Event): void | - |
25+
| selectChange | A callback function which is executed when selected items are changed. | (sourceSelectedKeys, targetSelectedKeys): void | |
3826

3927
## Warning
4028

41-
According the [standard](http://facebook.github.io/react/docs/lists-and-keys.html#keys) of React, the key should always be supplied directly to the elements in the array. In Transfer, the keys should be set on the elements included in `dataSource` array. By default, `key` property is used as an unique identifier.
29+
According the standard of Vue, the key should always be supplied directly to the elements in the array. In Transfer, the keys should be set on the elements included in `dataSource` array. By default, `key` property is used as an unique identifier.
4230

4331
If there's no `key` in your data, you should use `rowKey` to specify the key that will be used for uniquely identify each element.
4432

4533
```jsx
4634
// eg. your primary key is `uid`
47-
return <Transfer rowKey={record => record.uid} />;
35+
return <Transfer :rowKey="record => record.uid" />;
4836
```

components/transfer/index.jsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import defaultLocale from '../locale-provider/default'
1313

1414
export const TransferDirection = 'left' | 'right'
1515

16-
export const TransferItem = PropTypes.shape({
17-
key: PropTypes.string,
18-
title: PropTypes.string,
16+
export const TransferItem = {
17+
key: PropTypes.string.isRequired,
18+
title: PropTypes.string.isRequired,
1919
description: PropTypes.string,
2020
disabled: PropTypes.bool,
21-
}).loose
21+
}
2222

2323
export const TransferProps = {
2424
prefixCls: PropTypes.string,
@@ -27,8 +27,8 @@ export const TransferProps = {
2727
selectedKeys: PropTypes.arrayOf(PropTypes.string),
2828
render: PropTypes.func,
2929
listStyle: PropTypes.object,
30-
titles: PropTypes.arrayOf(TransferItem),
31-
operations: PropTypes.arrayOf(TransferItem),
30+
titles: PropTypes.arrayOf(PropTypes.string),
31+
operations: PropTypes.arrayOf(PropTypes.string),
3232
showSearch: PropTypes.bool,
3333
filterOption: PropTypes.func,
3434
searchPlaceholder: PropTypes.string,
@@ -50,12 +50,13 @@ export const TransferLocale = {
5050

5151
const tranferProps = {
5252
prefixCls: PropTypes.string,
53-
dataSource: PropTypes.arrayOf(TransferItem),
54-
targetKeys: PropTypes.array,
53+
dataSource: PropTypes.arrayOf(PropTypes.shape(TransferItem).loose),
54+
targetKeys: PropTypes.arrayOf(PropTypes.string),
55+
selectedKeys: PropTypes.arrayOf(PropTypes.string),
5556
listStyle: PropTypes.object,
5657
render: PropTypes.func,
57-
titles: PropTypes.array,
58-
operations: PropTypes.array,
58+
titles: PropTypes.arrayOf(PropTypes.string),
59+
operations: PropTypes.arrayOf(PropTypes.string),
5960
showSearch: PropTypes.bool,
6061
filterOption: PropTypes.func,
6162
searchPlaceholder: PropTypes.string,

components/transfer/index.zh-CN.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,35 @@
22

33
| 参数 | 说明 | 类型 | 默认值 |
44
| --- | --- | --- | --- |
5-
| className | 自定义类 | string | |
6-
| dataSource | 数据源,其中的数据将会被渲染到左边一栏中,`targetKeys` 中指定的除外。 | [TransferItem](https://git.io/vMM64)\[] | \[] |
5+
| dataSource | 数据源,其中的数据将会被渲染到左边一栏中,`targetKeys` 中指定的除外。 | \[{key: string.isRequired,title: string.isRequired,description: string,disabled: bool}\]\[] | \[] |
76
| filterOption | 接收 `inputValue` `option` 两个参数,当 `option` 符合筛选条件时,应返回 `true`,反之则返回 `false`| (inputValue, option): boolean | |
8-
| footer | 底部渲染函数 | (props): ReactNode | |
9-
| lazy | Transfer 使用了 [react-lazy-load](https://github.com/loktar00/react-lazy-load) 优化性能,这里可以设置相关参数。设为 `false` 可以关闭懒加载。 | object\|boolean | `{ height: 32, offset: 32 }` |
7+
| footer | 可以设置为一个 作用域插槽 | slot="footer" slot-scope="props" | |
8+
| lazy | Transfer 使用了 [vc-lazy-load]优化性能,这里可以设置相关参数。设为 `false` 可以关闭懒加载。 | object\|boolean | `{ height: 32, offset: 32 }` |
109
| listStyle | 两个穿梭框的自定义样式 | object | |
11-
| notFoundContent | 当列表为空时显示的内容 | string\|ReactNode | '列表为空' |
10+
| notFoundContent | 当列表为空时显示的内容 | string\|slot | '列表为空' |
1211
| operations | 操作文案集合,顺序从下至上 | string\[] | ['>', '<'] |
13-
| render | 每行数据渲染函数,该函数的入参为 `dataSource` 中的项,返回值为 ReactElement。或者返回一个普通对象,其中 `label` 字段为 ReactElement`value` 字段为 title | Function(record) | |
12+
| render | 每行数据渲染函数,该函数的入参为 `dataSource` 中的项,返回值为 element。或者返回一个普通对象,其中 `label` 字段为 element`value` 字段为 title | Function(record) | |
1413
| searchPlaceholder | 搜索框的默认值 | string | '请输入搜索内容' |
1514
| selectedKeys | 设置哪些项应该被选中 | string\[] | \[] |
1615
| showSearch | 是否显示搜索框 | boolean | false |
1716
| targetKeys | 显示在右侧框数据的key集合 | string\[] | \[] |
1817
| titles | 标题集合,顺序从左至右 | string\[] | ['', ''] |
19-
| onChange | 选项在两栏之间转移时的回调函数 | (targetKeys, direction, moveKeys): void | |
20-
| onScroll | 选项列表滚动时的回调函数 | (direction, event): void | |
21-
| onSearchChange | 搜索框内容时改变时的回调函数 | (direction: 'left'\|'right', event: Event): void | - |
22-
| onSelectChange | 选中项发生改变时的回调函数 | (sourceSelectedKeys, targetSelectedKeys): void | |
18+
19+
### 事件
20+
| 事件名称 | 说明 | 回调参数 |
21+
| --- | --- | --- |
22+
| change | 选项在两栏之间转移时的回调函数 | (targetKeys, direction, moveKeys): void | |
23+
| scroll | 选项列表滚动时的回调函数 | (direction, event): void | |
24+
| searchChange | 搜索框内容时改变时的回调函数 | (direction: 'left'\|'right', event: Event): void | - |
25+
| selectChange | 选中项发生改变时的回调函数 | (sourceSelectedKeys, targetSelectedKeys): void | |
2326

2427
## 注意
2528

26-
按照 React 的[规范](http://facebook.github.io/react/docs/lists-and-keys.html#keys),所有的组件数组必须绑定 key。在 Transfer 中,`dataSource`里的数据值需要指定 `key` 值。对于 `dataSource` 默认将每列数据的 `key` 属性作为唯一的标识。
29+
按照Vue最新的规范,所有的组件数组最好绑定 key。在 Transfer 中,`dataSource`里的数据值需要指定 `key` 值。对于 `dataSource` 默认将每列数据的 `key` 属性作为唯一的标识。
2730

2831
如果你的数据没有这个属性,务必使用 `rowKey` 来指定数据列的主键。
2932

3033
```jsx
3134
// 比如你的数据主键是 uid
32-
return <Transfer rowKey={record => record.uid} />;
35+
return <Transfer :rowKey="record => record.uid" />;
3336
```

components/transfer/list.jsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import Search from './search'
99
import Item from './item'
1010
import triggerEvent from '../_util/triggerEvent'
1111

12-
const TransferItem = PropTypes.shape({
13-
key: PropTypes.string,
14-
title: PropTypes.string,
12+
function noop () {
13+
}
14+
15+
const TransferItem = {
16+
key: PropTypes.string.isRequired,
17+
title: PropTypes.string.isRequired,
1518
description: PropTypes.string,
1619
disabled: PropTypes.bool,
17-
}).loose
18-
19-
function noop () {
2020
}
2121

2222
function isRenderResultPlainObject (result) {
@@ -27,8 +27,7 @@ function isRenderResultPlainObject (result) {
2727
export const TransferListProps = {
2828
prefixCls: PropTypes.string,
2929
titleText: PropTypes.string,
30-
dataSource: PropTypes.arrayOf(TransferItem),
31-
// dataSource: PropTypes.any,
30+
dataSource: PropTypes.arrayOf(PropTypes.shape(TransferItem).loose),
3231
filter: PropTypes.string,
3332
filterOption: PropTypes.func,
3433
checkedKeys: PropTypes.arrayOf(PropTypes.string),

site/demo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ export { default as progress } from 'antd/progress/demo/index.vue'
4040
export { default as timeline } from 'antd/timeline/demo/index.vue'
4141
export { default as table } from 'antd/table/demo/index.vue'
4242
export { default as inputNumber } from 'antd/input-number/demo/index.vue'
43+
export { default as transfer } from 'antd/transfer/demo/index.vue'

site/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Demo from './components/demo.vue'
22
const AsyncComp = () => {
33
const d = window.location.hash.replace('#', '')
44
return {
5-
component: import(`../components/input-number/demo/${d}`),
5+
component: import(`../components/transfer/demo/${d}`),
66
}
77
}
88
export default [

0 commit comments

Comments
 (0)