Browse Source
chore: make bundle size smaller (#22693)
* update rc-resize-observer deps
* clean icons
* rm lodash/findIndex
* rm isPlainObject
* rm lodash uniqueBy
* rollback of icons
* clean up
pull/22712/head
二货机器人
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
12 additions and
10 deletions
-
components/carousel/index.tsx
-
components/upload/Upload.tsx
-
package.json
|
|
@ -1,5 +1,4 @@ |
|
|
|
import * as React from 'react'; |
|
|
|
import isPlainObject from 'lodash/isPlainObject'; |
|
|
|
import debounce from 'lodash/debounce'; |
|
|
|
import SlickCarousel, { Settings } from '@ant-design/react-slick'; |
|
|
|
import classNames from 'classnames'; |
|
|
@ -107,7 +106,7 @@ export default class Carousel extends React.Component<CarouselProps, {}> { |
|
|
|
const dotPosition = this.getDotPosition(); |
|
|
|
props.vertical = dotPosition === 'left' || dotPosition === 'right'; |
|
|
|
|
|
|
|
const enableDots = props.dots === true || isPlainObject(props.dots); |
|
|
|
const enableDots = !!props.dots; |
|
|
|
const dsClass = classNames( |
|
|
|
dotsClass, |
|
|
|
`${dotsClass}-${dotPosition || 'bottom'}`, |
|
|
|
|
|
@ -1,8 +1,6 @@ |
|
|
|
import * as React from 'react'; |
|
|
|
import RcUpload from 'rc-upload'; |
|
|
|
import classNames from 'classnames'; |
|
|
|
import uniqBy from 'lodash/uniqBy'; |
|
|
|
import findIndex from 'lodash/findIndex'; |
|
|
|
import Dragger from './Dragger'; |
|
|
|
import UploadList from './UploadList'; |
|
|
|
import { |
|
|
@ -85,7 +83,7 @@ class Upload extends React.Component<UploadProps, UploadState> { |
|
|
|
|
|
|
|
const nextFileList = fileList.concat(); |
|
|
|
|
|
|
|
const fileIndex = findIndex(nextFileList, ({ uid }: UploadFile) => uid === targetItem.uid); |
|
|
|
const fileIndex = nextFileList.findIndex(({ uid }: UploadFile) => uid === targetItem.uid); |
|
|
|
if (fileIndex === -1) { |
|
|
|
nextFileList.push(targetItem); |
|
|
|
} else { |
|
|
@ -209,12 +207,17 @@ class Upload extends React.Component<UploadProps, UploadState> { |
|
|
|
} |
|
|
|
const result = beforeUpload(file, fileList); |
|
|
|
if (result === false) { |
|
|
|
// Get unique file list
|
|
|
|
const uniqueList: UploadFile<any>[] = []; |
|
|
|
stateFileList.concat(fileList.map(fileToObject)).forEach(f => { |
|
|
|
if (uniqueList.every(uf => uf.uid !== f.uid)) { |
|
|
|
uniqueList.push(f); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
this.onChange({ |
|
|
|
file, |
|
|
|
fileList: uniqBy( |
|
|
|
stateFileList.concat(fileList.map(fileToObject)), |
|
|
|
(item: UploadFile) => item.uid, |
|
|
|
), |
|
|
|
fileList: uniqueList, |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
@ -122,7 +122,7 @@ |
|
|
|
"rc-picker": "~1.4.0", |
|
|
|
"rc-progress": "~2.5.0", |
|
|
|
"rc-rate": "~2.5.1", |
|
|
|
"rc-resize-observer": "^0.1.0", |
|
|
|
"rc-resize-observer": "^0.2.0", |
|
|
|
"rc-select": "~10.1.0", |
|
|
|
"rc-slider": "~9.2.3", |
|
|
|
"rc-steps": "~3.5.0", |
|
|
|