Skip to content

Commit

Permalink
refactor(comp:upload): fix review about name
Browse files Browse the repository at this point in the history
  • Loading branch information
typistZxd committed Jan 18, 2022
1 parent e3e211c commit 53a52ac
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 85 deletions.
6 changes: 3 additions & 3 deletions packages/components/config/src/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import type {
TreeConfig,
TreeSelectConfig,
UploadConfig,
UploadListConfig,
UploadFilesConfig,
} from './types'

import { numFormatter } from './numFormatter'
Expand Down Expand Up @@ -211,7 +211,7 @@ const upload: UploadConfig = {
requestMethod: 'post',
}

const uploadList: UploadListConfig = {
const uploadFiles: UploadFilesConfig = {
type: 'text',
icon: {
file: 'paper-clip',
Expand Down Expand Up @@ -431,7 +431,7 @@ export const defaultConfig: GlobalConfig = {
timeRangePicker,
treeSelect,
upload,
uploadList,
uploadFiles,
// Data Display
avatar,
badge,
Expand Down
8 changes: 4 additions & 4 deletions packages/components/config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type { StepperSize } from '@idux/components/stepper'
import type { TableColumnAlign, TableColumnSortOrder, TablePaginationPosition, TableSize } from '@idux/components/table'
import type { TagShape } from '@idux/components/tag'
import type { TextareaAutoRows, TextareaResize } from '@idux/components/textarea'
import type { UploadIconType, UploadListType, UploadRequestMethod, UploadRequestOption } from '@idux/components/upload'
import type { UploadFilesType, UploadIconType, UploadRequestMethod, UploadRequestOption } from '@idux/components/upload'
import type { VNode } from 'vue'

// Common
Expand Down Expand Up @@ -199,8 +199,8 @@ export interface UploadConfig {
customRequest?: (option: UploadRequestOption) => { abort: () => void }
}

export interface UploadListConfig {
type: UploadListType
export interface UploadFilesConfig {
type: UploadFilesType
icon: Partial<Record<UploadIconType, string | VNode>>
}

Expand Down Expand Up @@ -454,7 +454,7 @@ export interface GlobalConfig {
timePicker: TimePickerConfig
timeRangePicker: TimeRangePickerConfig
upload: UploadConfig
uploadList: UploadListConfig
uploadFiles: UploadFilesConfig
// Data Display
avatar: AvatarConfig
badge: BadgeConfig
Expand Down
4 changes: 2 additions & 2 deletions packages/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { IxTooltip } from '@idux/components/tooltip'
import { IxTree } from '@idux/components/tree'
import { IxTreeSelect } from '@idux/components/tree-select'
import { IxTypography } from '@idux/components/typography'
import { IxUpload, IxUploadList } from '@idux/components/upload'
import { IxUpload, IxUploadFiles } from '@idux/components/upload'
import { version } from '@idux/components/version'

const components = [
Expand Down Expand Up @@ -152,7 +152,7 @@ const components = [
IxTree,
IxTreeSelect,
IxUpload,
IxUploadList,
IxUploadFiles,
]

const directives: Record<string, Directive> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import type { TimePickerComponent } from '@idux/components/time-picker'
import type { TimelineComponent, TimelineItemComponent } from '@idux/components/timeline'
import type { TooltipComponent } from '@idux/components/tooltip'
import type { TreeComponent } from '@idux/components/tree'
import type { UploadComponent, UploadListComponent } from '@idux/components/upload'
import type { UploadComponent, UploadFilesComponent } from '@idux/components/upload'

declare module 'vue' {
export interface GlobalComponents {
Expand Down Expand Up @@ -156,7 +156,7 @@ declare module 'vue' {
IxTooltip: TooltipComponent
IxTree: TreeComponent
IxUpload: UploadComponent
IxUploadList: UploadListComponent
IxUploadFiles: UploadFilesComponent
}
}

Expand Down
36 changes: 18 additions & 18 deletions packages/components/upload/__tests__/list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UploadListProps } from '../src/types'
import type { UploadFilesProps } from '../src/types'
import type { MountingOptions } from '@vue/test-utils'

import { flushPromises, mount } from '@vue/test-utils'
Expand All @@ -8,14 +8,14 @@ import { renderWork } from '@tests'

import { IxIcon } from '@idux/components/icon'

import UploadFilesListCpm from '../src/List'
import UploadFilesCpm from '../src/List'
import { uploadToken } from '../src/token'

const uploadListMount = (options?: MountingOptions<Partial<UploadListProps>>) => {
const uploadFilesMount = (options?: MountingOptions<Partial<UploadFilesProps>>) => {
const { global: { provide: { [uploadToken as unknown as string]: provideObj } = {}, ...restGlobal } = {}, ...rest } =
options as MountingOptions<UploadListProps>
options as MountingOptions<UploadFilesProps>

return mount(UploadFilesListCpm, {
return mount(UploadFilesCpm, {
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -32,12 +32,12 @@ const uploadListMount = (options?: MountingOptions<Partial<UploadListProps>>) =>
}

describe('Upload list render', () => {
renderWork<UploadListProps>(UploadFilesListCpm, {
renderWork<UploadFilesProps>(UploadFilesCpm, {
global: { provide: { [uploadToken as symbol]: { props: {}, files: { value: [] }, setSelectorVisible: () => {} } } },
})

test('type work', async () => {
const wrapper = uploadListMount({
const wrapper = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('Upload list render', () => {
})

test('icon work', async () => {
const wrapper = uploadListMount({
const wrapper = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -88,7 +88,7 @@ describe('Upload list render', () => {
expect(wrapper.find('.ix-icon-delete').exists()).toBeTruthy()
expect(wrapper.find('.ix-icon-edit').exists()).toBeTruthy()

const wrapperFileSuccess = uploadListMount({
const wrapperFileSuccess = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -109,7 +109,7 @@ describe('Upload list render', () => {
file: 'left',
},
},
} as MountingOptions<Partial<UploadListProps>>)
} as MountingOptions<Partial<UploadFilesProps>>)
await flushPromises()

expect(wrapperFileSuccess.find('.ix-icon-download').exists()).toBeTruthy()
Expand All @@ -127,7 +127,7 @@ describe('Upload list render', () => {
},
]

const wrapper = uploadListMount({
const wrapper = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -141,7 +141,7 @@ describe('Upload list render', () => {
},
onDownload,
},
} as MountingOptions<Partial<UploadListProps>>)
} as MountingOptions<Partial<UploadFilesProps>>)

await wrapper.find('.ix-upload-icon-download').trigger('click')

Expand All @@ -158,7 +158,7 @@ describe('Upload list render', () => {
},
]

const wrapper = uploadListMount({
const wrapper = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -172,7 +172,7 @@ describe('Upload list render', () => {
},
onPreview,
},
} as MountingOptions<Partial<UploadListProps>>)
} as MountingOptions<Partial<UploadFilesProps>>)

await wrapper.find('.ix-upload-name').trigger('click')

Expand All @@ -195,7 +195,7 @@ describe('Upload list render', () => {
},
]

const wrapper = uploadListMount({
const wrapper = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -210,7 +210,7 @@ describe('Upload list render', () => {
},
onRetry,
},
} as MountingOptions<Partial<UploadListProps>>)
} as MountingOptions<Partial<UploadFilesProps>>)
await wrapper.find('.ix-upload-icon-retry').trigger('click')

expect(upload).toBeCalled()
Expand All @@ -230,7 +230,7 @@ describe('Upload list render', () => {
},
]

const wrapper = uploadListMount({
const wrapper = uploadFilesMount({
global: {
provide: {
[uploadToken as symbol]: {
Expand All @@ -243,7 +243,7 @@ describe('Upload list render', () => {
props: {
onRemove,
},
} as MountingOptions<Partial<UploadListProps>>)
} as MountingOptions<Partial<UploadFilesProps>>)
await wrapper.find('.ix-upload-icon-remove').trigger('click')

expect(onRemove).toBeCalledWith(expect.objectContaining(defaultFiles[0]))
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Action.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<IxUpload v-model:files="files" :action="action">
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354">
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/ButtonDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354">
<a>Click here</a>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Check.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
>
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/CustomRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
>
<IxButton>Custom upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Dragable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p>Drag and drop files or click to select files to upload.</p>
</div>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354">
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList />
<IxUploadFiles />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Hooks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<IxButton>Hook</IxButton>
<template #list>
<IxUploadList type="imageCard" />
<IxUploadFiles type="imageCard" />
</template>
</IxUpload>
<IxTimeline>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/upload/demo/Icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ order: 10

## zh

`IxUploadList`使用`icon`配置对应的图标,支持 `string``VNode`
`IxUploadFiles`使用`icon`配置对应的图标,支持 `string``VNode`

## en

`IxUploadList` uses `icon` to configure the corresponding icon, and supports `string` and `VNode`
`IxUploadFiles` uses `icon` to configure the corresponding icon, and supports `string` and `VNode`
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354">
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList type="text" :icon="icon" />
<IxUploadFiles type="text" :icon="icon" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/ListDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354">
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList :type="curType" />
<IxUploadFiles :type="curType" />
</template>
</IxUpload>
</IxSpace>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Manual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>
<IxButton>Manual upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/MaxCount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
>
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/Operation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354">
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList
<IxUploadFiles
:icon="icon"
type="imageCard"
@retry="onRetry"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/upload/demo/StrokeColor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<IxButton>Upload</IxButton>
<template #list>
<IxUploadList type="text" />
<IxUploadFiles type="text" />
</template>
</IxUpload>
</template>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/upload/docs/Index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ order: 0
| `requestData` | 上传附加的参数 | `Record<string, unknown> \| ((file: UploadFile) => Record<string, unknown> \| Promise<Record<string, unknown>>)` | - | - | - |
| `requestHeaders` | 设置上传请求的请求头 | `UploadRequestHeader` | - | - | - |
| `requestMethod` | 上传请求的http method | `UploadRequestMethod` | `post` || - |
| `onSelect` | 选中文件时钩子 | `(file: File[]) => boolean \| File[] \| Promise<boolean \| File[]>` | `() => true` | - | - |
| `onSelect` | 选中文件时钩子 | `(file: File[]) => boolean \| File[] \| Promise<boolean \| File[]>` | - | - | - |
| `onFileStatusChange` | 上传文件改变时的状态 | `(file: UploadFile) => void` | - | - | - |
| `onBeforeUpload` | 文件上传前的钩子,根据返回结果是否上传<br />返回`false`阻止上传<br />返回`Promise`对象`reject`时停止上传<br />返回`Promise`对象`resolve`时开始上传 | `(file: UploadFile) => boolean \| UploadFile \| Promise<boolean \| UploadFile>` | `() => true` | - | - |
| `onBeforeUpload` | 文件上传前的钩子,根据返回结果是否上传<br />返回`false`阻止上传<br />返回`Promise`对象`reject`时停止上传<br />返回`Promise`对象`resolve`时开始上传 | `(file: UploadFile) => boolean \| UploadFile \| Promise<boolean \| UploadFile>` | - | - | - |
| `onRequestChange` | 请求状态改变的钩子 | `(option: UploadRequestChangeOption) => void` | - | - | - |

### IxUploadFiles
Expand Down
Loading

0 comments on commit 53a52ac

Please sign in to comment.