Merge pull request #1275 from ant-design/deps-object-assign

deps: remove object-assign
This commit is contained in:
yiminghe 2016-03-25 18:30:53 +08:00
commit 771bbaa044
14 changed files with 53 additions and 55 deletions

View File

@ -1,5 +1,4 @@
import React, { createElement } from 'react';
import assign from 'object-assign';
import { isCssAnimationSupported } from 'css-animation';
function getNumberArray(num) {
@ -94,9 +93,10 @@ export default class ScrollNumber extends React.Component {
}
render() {
const props = assign({}, this.props, {
const props = {
...this.props,
className: `${this.props.prefixCls} ${this.props.className}`
});
};
const isBrowser = (typeof document !== 'undefined' && typeof window !== 'undefined');
if (isBrowser && isCssAnimationSupported) {
return createElement(

View File

@ -15,11 +15,10 @@ if (typeof window !== 'undefined') {
import SlickCarousel from 'react-slick';
import React from 'react';
import assign from 'object-assign';
export default class Carousel extends React.Component {
render() {
let props = assign({}, this.props);
let props = { ...this.props };
if (props.effect === 'fade') {
props.fade = true;

View File

@ -1,5 +1,4 @@
import React from 'react';
import objectAssign from 'object-assign';
import defaultLocale from './locale/zh_CN';
import DateTimeFormat from 'gregorian-calendar-format';
import GregorianCalendar from 'gregorian-calendar';
@ -15,8 +14,8 @@ export default {
locale = this.context.antLocale.DatePicker;
}
// Locale
const result = objectAssign({}, locale, this.props.locale);
result.lang = objectAssign({}, locale.lang, this.props.locale.lang);
const result = { ...locale, ...this.props.locale };
result.lang = { ...locale.lang, ...this.props.locale.lang };
return result;
},

View File

@ -1,13 +1,13 @@
import objectAssign from 'object-assign';
import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US';
import CalendarLocale from 'rc-calendar/lib/locale/en_US';
// 统一合并为完整的 Locale
let locale = objectAssign({}, GregorianCalendarLocale);
locale.lang = objectAssign({
let locale = { ...GregorianCalendarLocale };
locale.lang = {
placeholder: 'Select date',
timePlaceholder: 'Select time',
}, CalendarLocale);
...CalendarLocale,
};
// All settings at:
// https://github.com/ant-design/ant-design/issues/424

View File

@ -1,13 +1,13 @@
import objectAssign from 'object-assign';
import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/zh_CN';
import CalendarLocale from 'rc-calendar/lib/locale/zh_CN';
// 统一合并为完整的 Locale
let locale = objectAssign({}, GregorianCalendarLocale);
locale.lang = objectAssign({
let locale = { ...GregorianCalendarLocale };
locale.lang = {
placeholder: '请选择日期',
timePlaceholder: '请选择时间',
}, CalendarLocale);
...CalendarLocale,
};
// should add whitespace between char in Button
locale.lang.ok = '确 定';

View File

@ -1,5 +1,4 @@
import React from 'react';
import assign from 'object-assign';
import classNames from 'classnames';
function ieGT9() {
@ -67,7 +66,7 @@ class Input extends React.Component {
}
renderInput() {
const props = assign({}, this.props);
const props = { ...this.props };
const prefixCls = props.prefixCls;
if (!props.type) {
return props.children;

View File

@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
import Dialog from './Modal';
import Icon from '../icon';
import Button from '../button';
import objectAssign from 'object-assign';
const defaultLocale = {
okText: '确定',
@ -15,14 +14,14 @@ let runtimeLocale = { ...defaultLocale };
export function changeConfirmLocale(newLocale) {
if (newLocale) {
objectAssign(runtimeLocale, newLocale);
runtimeLocale = { ...runtimeLocale, ...newLocale };
} else {
runtimeLocale = { ...defaultLocale };
}
}
export default function confirm(config) {
const props = objectAssign({}, config);
const props = { ...config };
let div = document.createElement('div');
document.body.appendChild(div);

View File

@ -1,35 +1,38 @@
import Modal from './Modal';
import confirm from './confirm';
import objectAssign from 'object-assign';
Modal.info = function (props) {
const config = objectAssign({}, props, {
const config = {
...props,
iconClassName: 'info-circle',
okCancel: false,
});
};
return confirm(config);
};
Modal.success = function (props) {
const config = objectAssign({}, props, {
const config = {
...props,
iconClassName: 'check-circle',
okCancel: false,
});
};
return confirm(config);
};
Modal.error = function (props) {
const config = objectAssign({}, props, {
const config = {
...props,
iconClassName: 'exclamation-circle',
okCancel: false,
});
};
return confirm(config);
};
Modal.confirm = function (props) {
const config = objectAssign({}, props, {
const config = {
...props,
okCancel: true,
});
};
return confirm(config);
};

View File

@ -1,6 +1,5 @@
import React from 'react';
import Notification from 'rc-notification';
import assign from 'object-assign';
import Icon from '../icon';
let defaultTop = 24;
@ -124,9 +123,10 @@ const api = {
['success', 'info', 'warn', 'error'].forEach((type) => {
api[type] = (args) => {
let newArgs = assign({}, args, {
let newArgs = {
...args,
icon: type
});
};
return api.open(newArgs);
};
});

View File

@ -1,6 +1,5 @@
import { Circle as Progresscircle } from 'rc-progress';
import React from 'react';
import assign from 'object-assign';
import warning from 'warning';
import Icon from '../icon';
@ -35,7 +34,7 @@ let Line = React.createClass({
};
},
render() {
let props = assign({}, this.props);
let props = { ...this.props };
if (parseInt(props.percent, 10) === 100) {
props.status = 'success';
@ -119,7 +118,7 @@ let Circle = React.createClass({
};
},
render() {
let props = assign({}, this.props);
let props = { ...this.props };
if (parseInt(props.percent, 10) === 100) {
props.status = 'success';

View File

@ -5,7 +5,6 @@ import Radio from '../radio';
import FilterDropdown from './filterDropdown';
import Pagination from '../pagination';
import Icon from '../icon';
import objectAssign from 'object-assign';
import Spin from '../spin';
import classNames from 'classnames';
import { flatArray } from './util';
@ -39,10 +38,11 @@ let Table = React.createClass({
sorter: null,
radioIndex: null,
pagination: this.hasPagination() ?
objectAssign({
size: this.props.size,
}, defaultPagination, this.props.pagination) :
{},
{
size: this.props.size,
...defaultPagination,
...this.props.pagination,
} : {},
};
},
@ -93,13 +93,13 @@ let Table = React.createClass({
if (this.context.antLocale && this.context.antLocale.Table) {
locale = this.context.antLocale.Table;
}
return objectAssign({}, defaultLocale, locale, this.props.locale);
return { ...defaultLocale, ...locale, ...this.props.locale };
},
componentWillReceiveProps(nextProps) {
if (('pagination' in nextProps) && nextProps.pagination !== false) {
this.setState({
pagination: objectAssign({}, defaultPagination, this.state.pagination, nextProps.pagination)
pagination: { ...defaultPagination, ...this.state.pagination, ...nextProps.pagination },
});
}
// dataSource
@ -171,9 +171,10 @@ let Table = React.createClass({
},
handleFilter(column, nextFilters) {
const filters = objectAssign({}, this.state.filters, {
const filters = {
...this.state.filters,
[this.getColumnKey(column)]: nextFilters
});
};
// Remove filters not in current columns
const currentColumnKeys = this.props.columns.map(c => this.getColumnKey(c));
Object.keys(filters).forEach((columnKey) => {
@ -276,7 +277,7 @@ let Table = React.createClass({
},
handlePageChange(current) {
let pagination = objectAssign({}, this.state.pagination);
let pagination = { ...this.state.pagination };
if (current) {
pagination.current = current;
} else {
@ -416,7 +417,7 @@ let Table = React.createClass({
renderColumnsDropdown(columns) {
const locale = this.getLocale();
return columns.map((originColumn, i) => {
let column = objectAssign({}, originColumn);
let column = { ...originColumn };
let key = this.getColumnKey(column, i);
let filterDropdown;
let sortButton;
@ -587,7 +588,7 @@ let Table = React.createClass({
columns = this.renderColumnsDropdown(columns);
columns = columns.map((column, i) => {
const newColumn = objectAssign({}, column);
const newColumn = { ...column };
newColumn.key = newColumn.key || newColumn.dataIndex || i;
return newColumn;
});

View File

@ -1,7 +1,6 @@
import React from 'react';
import DateTimeFormat from 'gregorian-calendar-format';
import RcTimePicker from 'rc-time-picker/lib/TimePicker';
import objectAssign from 'object-assign';
import defaultLocale from './locale/zh_CN';
import classNames from 'classnames';
import GregorianCalendar from 'gregorian-calendar';
@ -77,12 +76,12 @@ const TimePicker = React.createClass({
locale = this.context.antLocale.TimePicker;
}
// Locale
return objectAssign({}, locale, this.props.locale);
return { ...locale, ...this.props.locale };
},
render() {
const locale = this.getLocale();
const props = objectAssign({}, this.props);
const props = { ...this.props };
props.placeholder = ('placeholder' in this.props)
? props.placeholder : locale.placeholder;
if (props.defaultValue) {

View File

@ -1,6 +1,5 @@
import React from 'react';
import RcUpload from 'rc-upload';
import assign from 'object-assign';
import UploadList from './uploadList';
import getFileItem from './getFileItem';
import classNames from 'classnames';
@ -218,13 +217,14 @@ const Upload = React.createClass({
render() {
let type = this.props.type || 'select';
let props = assign({}, this.props, {
let props = {
...this.props,
onStart: this.onStart,
onError: this.onError,
onProgress: this.onProgress,
onSuccess: this.onSuccess,
beforeUpload: this.beforeUpload,
});
};
let uploadList;
if (this.props.showUploadList) {
uploadList = (

View File

@ -37,7 +37,6 @@
"css-animation": "~1.1.0",
"gregorian-calendar": "~4.1.0",
"gregorian-calendar-format": "~4.1.0",
"object-assign": "~4.0.1",
"rc-animate": "~2.0.2",
"rc-calendar": "~5.4.0",
"rc-cascader": "~0.9.0",
@ -115,6 +114,7 @@
"mark-twain": "^0.2.0-beta.4",
"mkdirp": "~0.5.1",
"nico-jsx": "~0.9.0",
"object-assign": "~4.0.1",
"postcss-loader": "^0.8.0",
"pre-commit": "1.x",
"querystring": "^0.2.0",