Compare commits

...

6 Commits
theme ... 3.4.5

Author SHA1 Message Date
afc163
b229418e0f release 3.4.5 2018-05-03 14:14:35 +08:00
afc163
f7ef968540 fix fileToObject, close #10319 2018-05-03 14:11:43 +08:00
afc163
b6a617f2e9 Fix ts error temporarily, DefinitelyTyped/DefinitelyTyped#25342 2018-04-28 15:02:25 +08:00
afc163
1a790a5a9f 3.4.4 2018-04-28 14:32:20 +08:00
afc163
2a411130bc Fix upload onChange arg type when beforeUpload return false, close #10293 2018-04-28 14:17:29 +08:00
Wu Haotian
bf22853f41 add lib/**/style/* as sideEffects (#10217) 2018-04-28 14:17:01 +08:00
7 changed files with 51 additions and 8 deletions

View File

@@ -15,6 +15,19 @@ timeline: true
---
## 3.4.5
`2018-05-03`
- 🐞 Fix file object is empty and file name not showing in Upload. [#10319](https://github.com/ant-design/ant-design/issues/10319)
## 3.4.4
`2018-04-28`
- 🐞 Fix that Upload file in`onChange({ file })` is not a File instance introduced in `3.4.2`. [#10293](https://github.com/ant-design/ant-design/issues/10293)
- 🐞 Fix style lose bug when use tree shaking in webpack@4. [#10217](https://github.com/ant-design/ant-design/pull/10217) [@whtsky](https://github.com/whtsky)
## 3.4.3
`2018-04-23`

View File

@@ -15,6 +15,18 @@ timeline: true
---
## 3.4.5
`2018-05-03`
- 🐞 修复 Upload 上传文件名不展示file 对象属性为空)的问题。[#10319](https://github.com/ant-design/ant-design/issues/10319)
## 3.4.4
`2018-04-28`
- 🐞 修复 3.4.2 中引入的 Upload 中 onChange 参数 `{ file }` file 不是 File 实例的问题。[#10293](https://github.com/ant-design/ant-design/issues/10293)
- 🐞 修复 webpack@4 下使用 Tree Shaking 样式丢失的问题。[#10217](https://github.com/ant-design/ant-design/pull/10217) [@whtsky](https://github.com/whtsky)
## 3.4.3

View File

@@ -195,7 +195,7 @@ export default class Upload extends React.Component<UploadProps, UploadState> {
const result = this.props.beforeUpload(file, fileList);
if (result === false) {
this.onChange({
file: fileToObject(file),
file,
fileList: uniqBy(fileList.map(fileToObject).concat(this.state.fileList), (item: UploadFile) => item.uid),
});
return false;

View File

@@ -2,6 +2,7 @@
import React from 'react';
import { mount } from 'enzyme';
import Upload from '..';
import { fileToObject } from '../utils';
describe('Upload', () => {
// https://github.com/react-component/upload/issues/36
@@ -54,13 +55,17 @@ describe('Upload', () => {
});
});
it('should not stop upload when return value of beforeUpload is not false', (done) => {
it('should not stop upload when return value of beforeUpload is false', (done) => {
const mockFile = new File(['foo'], 'foo.png', {
type: 'image/png',
});
const data = jest.fn();
const props = {
action: 'http://upload.com',
beforeUpload: () => false,
data,
onChange: () => {
onChange: ({ file }) => {
expect(file instanceof File).toBe(true);
expect(data).not.toBeCalled();
done();
},
@@ -75,7 +80,7 @@ describe('Upload', () => {
wrapper.find('input').simulate('change', {
target: {
files: [
{ file: 'foo.png' },
mockFile,
],
},
});
@@ -107,4 +112,14 @@ describe('Upload', () => {
},
});
});
describe('util', () => {
it('should be able to copy file instance', () => {
const file = new File([], 'aaa.zip');
const copiedFile = fileToObject(file);
['uid', 'lastModified', 'lastModifiedDate', 'name', 'size', 'type'].forEach((key) => {
expect(key in copiedFile).toBe(true);
});
});
});
});

View File

@@ -16,7 +16,7 @@ export interface UploadFile {
name: string;
filename?: string;
lastModified?: number;
lastModifiedDate?: Date;
lastModrcFlieifiedDate?: Date;
url?: string;
status?: UploadFileStatus;
percent?: number;

View File

@@ -8,13 +8,14 @@ export function T() {
// via coping a new Object
export function fileToObject(file: RcFile): UploadFile {
return {
...file,
lastModified: file.lastModified,
lastModifiedDate: file.lastModifiedDate,
name: file.name,
size: file.size,
type: file.type,
percent: 0,
uid: file.uid,
percent: 0,
originFileObj: file,
} as UploadFile;
}

View File

@@ -1,6 +1,6 @@
{
"name": "antd",
"version": "3.4.3",
"version": "3.4.5",
"title": "Ant Design",
"description": "An enterprise-class UI design language and React-based implementation",
"homepage": "http://ant.design/",
@@ -84,6 +84,7 @@
},
"devDependencies": {
"@babel/types": "7.0.0-beta.44",
"@types/node": "^9.6.7",
"@types/react": "^16.0.0",
"@types/react-dom": "^16.0.0",
"ansi-styles": "^3.2.0",
@@ -213,6 +214,7 @@
"lint-staged"
],
"sideEffects": [
"es/**/style/*"
"es/**/style/*",
"lib/**/style/*"
]
}