chore: remove deprecated code (#2920)

* chore: remove deprecated code

* chore: add warning for Breadcrumb
This commit is contained in:
Benjy Cui 2016-09-09 13:55:46 +08:00 committed by 偏右
parent 77a45f0b00
commit 14fb2c78ba
14 changed files with 39 additions and 100 deletions

View File

@ -2,7 +2,6 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import classNames from 'classnames';
import warning from 'warning';
import assign from 'object-assign';
import shallowequal from 'shallowequal';
@ -182,8 +181,6 @@ export default class Affix extends React.Component<AffixProps, any> {
}
componentDidMount() {
warning(!('offset' in this.props), '`offset` prop of Affix is deprecated, use `offsetTop` instead.');
const target = this.props.target;
this.setTargetEventListeners(target);
}

View File

@ -1,5 +1,6 @@
import * as React from 'react';
import { cloneElement } from 'react';
import warning from 'warning';
import BreadcrumbItem from './BreadcrumbItem';
export interface BreadcrumbProps {
@ -50,6 +51,15 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
nameRender: React.PropTypes.func,
};
constructor(props) {
super();
warning(
!('linkRender' in props || 'nameRender' in props),
'`linkRender` and `nameRender` is removed, please use `itemRender` instead.'
);
}
render() {
let crumbs;
const { separator, prefixCls, routes, params, children, itemRender } = this.props;

View File

@ -81,7 +81,7 @@ let Demo = React.createClass({
);
});
return (
<Form horizontal form={this.props.form}>
<Form horizontal>
{formItems}
<Form.Item wrapperCol={{ span: 18, offset: 6 }}>
<Button onClick={this.add} style={{ marginRight: 8 }}>add good friend</Button>

View File

@ -47,7 +47,7 @@ let Demo = React.createClass({
<div>
<Button type="primary" onClick={this.showModal}>点击有惊喜</Button>
<Modal title="login" visible={this.state.visible} onOk={this.handleSubmit} onCancel={this.hideModal}>
<Form horizontal form={this.props.form}>
<Form horizontal>
<FormItem
{...formItemLayout}
label="User name"

View File

@ -78,7 +78,7 @@ let BasicDemo = React.createClass({
wrapperCol: { span: 12 },
};
return (
<Form horizontal form={this.props.form}>
<Form horizontal>
<FormItem
{...formItemLayout}
label="User name"

View File

@ -125,7 +125,7 @@ let Demo = React.createClass({
const { getFieldDecorator } = this.props.form;
return (
<div>
<Form vertical style={{ maxWidth: 600 }} form={this.props.form}>
<Form vertical style={{ maxWidth: 600 }}>
<Row type="flex" align="middle">
<Col span={12}>
<FormItem label="Password">

View File

@ -77,7 +77,7 @@ let Demo = React.createClass({
wrapperCol: { span: 12 },
};
return (
<Form horizontal form={this.props.form}>
<Form horizontal>
<FormItem
{...formItemLayout}
label="Country"

View File

@ -47,26 +47,26 @@ let App = React.createClass({
}
},
render() {
const { getFieldProps, getFieldValue } = this.props.form;
const mentionProps = getFieldProps('mention', {
rules: [
{ validator: this.checkMention },
],
initialValue: this.state.initValue,
});
const { getFieldDecorator, getFieldValue } = this.props.form;
console.log('>> render', getFieldValue('mention') === this.state.initValue);
return (
<Form horizontal form={this.props.form}>
<Form horizontal>
<FormItem
id="control-mention"
label="最帅的码农"
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
>
<Mention
{...mentionProps}
suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
/>
{getFieldDecorator('mention', {
rules: [
{ validator: this.checkMention },
],
initialValue: this.state.initValue,
})(
<Mention
suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
/>
)}
</FormItem>
<FormItem wrapperCol={{ span: 14, offset: 6 }}>
<Button type="primary" onClick={this.handleSubmit}>确定</Button>

View File

@ -2,7 +2,7 @@
category: Components
type: Views
noinstant: true
english: -tification
title: Notification
---
To display a notification message globally.

View File

@ -1,9 +1,9 @@
---
category: Components
chinese: 通知提醒框
type: Views
noinstant: true
english: Notification
title: Notification
subtitle: 通知提醒框
---
全局展示通知提醒信息。

View File

@ -1,7 +1,6 @@
import * as React from 'react';
import Tooltip from '../tooltip';
import getPlacements from './placements';
import warning from 'warning';
const placements = getPlacements();
@ -29,8 +28,6 @@ export interface PopoverProps {
getTooltipContainer?: (triggerNode: React.ReactNode) => React.ReactNode;
/** content of popup-container */
content?: React.ReactNode;
/** keep overlay for compatibility */
overlay?: React.ReactNode;
style?: React.CSSProperties;
transitionName?: string;
}
@ -63,22 +60,14 @@ export default class Popover extends React.Component<PopoverProps, any> {
return (this.refs as any).tooltip.getPopupDomNode();
}
componentDidMount() {
if ('overlay' in this.props) {
warning(false, '`overlay` prop of Popover is deprecated, use `content` instead.');
}
}
getOverlay() {
// use content replace overlay
// keep overlay for compatibility
const { title, prefixCls, overlay, content } = this.props;
const { title, prefixCls, content } = this.props;
return (
<div>
{title && <div className={`${prefixCls}-title`}>{title}</div>}
<div className={`${prefixCls}-inner-content`}>
{content || overlay}
{content}
</div>
</div>
);

View File

@ -1,17 +1,3 @@
import * as React from 'react';
import Progress from './progress';
import warning from 'warning';
const AntProgress = Progress;
// For downward compatibility
AntProgress.Line = (props) => {
warning(false, '<Progress.Line /> is deprecated, use <Progress type="line" /> instead.');
return <Progress {...props} type="line" />;
};
AntProgress.Circle = (props) => {
warning(false, '<Progress.Circle /> is deprecated, use <Progress type="circle" /> instead.');
return <Progress {...props} type="circle" />;
};
export default AntProgress;
export default Progress;

View File

@ -1,7 +1,6 @@
import * as React from 'react';
import { PropTypes } from 'react';
import RcSlider from 'rc-slider';
import splitObject from '../_util/splitObject';
interface SliderMarks {
[key: number]: React.ReactNode | {
@ -23,8 +22,8 @@ export interface SliderProps {
defaultValue?: SliderValue;
included?: boolean;
disabled?: boolean;
onChange?: (value: SliderValue) => any;
onAfterChange?: (value: SliderValue) => any;
onChange?: (value: SliderValue) => void;
onAfterChange?: (value: SliderValue) => void;
tipFormatter?: void | ((value: number) => React.ReactNode);
}
@ -37,40 +36,9 @@ export default class Slider extends React.Component<SliderProps, any> {
static propTypes = {
prefixCls: PropTypes.string,
tipTransitionName: PropTypes.string,
included: PropTypes.bool,
marks: PropTypes.object,
};
render() {
const [{isIncluded, marks, index, defaultIndex}, others] = splitObject(this.props,
['isIncluded', 'marks', 'index', 'defaultIndex']);
if (isIncluded !== undefined) {
// 兼容 `isIncluded`
others.included = isIncluded;
}
if (Array.isArray(marks)) {
// 兼容当 marks 为数组的情况
others.min = 0;
others.max = marks.length - 1;
others.step = 1;
if (index !== undefined) {
others.value = index;
}
if (defaultIndex !== undefined) {
others.defaultValue = defaultIndex;
}
others.marks = {};
marks.forEach((val, idx) => {
others.marks[idx] = val;
});
} else {
others.marks = marks;
}
return <RcSlider {...others} />;
return <RcSlider {...this.props} />;
}
}

View File

@ -3,7 +3,6 @@ import { PropTypes } from 'react';
import { findDOMNode } from 'react-dom';
import classNames from 'classnames';
import isCssAnimationSupported from '../_util/isCssAnimationSupported';
import warning from 'warning';
import splitObject from '../_util/splitObject';
import omit from 'object.omit';
@ -33,7 +32,7 @@ export default class Spin extends React.Component<SpinProps, any> {
constructor(props) {
super(props);
const spinning = this.getSpinning(props);
const spinning = props.spinning;
this.state = {
spinning,
};
@ -44,7 +43,6 @@ export default class Spin extends React.Component<SpinProps, any> {
}
componentDidMount() {
warning(!('spining' in this.props), '`spining` property of Popover is a spell mistake, use `spinning` instead.');
if (!isCssAnimationSupported()) {
// Show text in IE8/9
findDOMNode(this).className += ` ${this.props.prefixCls}-show-text`;
@ -57,18 +55,9 @@ export default class Spin extends React.Component<SpinProps, any> {
}
}
getSpinning(props) {
// Backwards support
if ('spining' in props) {
warning(false, '`spining` property of Spin is a spell mistake, use `spinning` instead.');
return props.spining;
}
return props.spinning;
}
componentWillReceiveProps(nextProps) {
const currentSpinning = this.getSpinning(this.props);
const spinning = this.getSpinning(nextProps);
const currentSpinning = this.props.spinning;
const spinning = nextProps.spinning;
if (this.debounceTimeout) {
clearTimeout(this.debounceTimeout);
}