Skip to content

Commit

Permalink
chore: remove deprecated code (ant-design#2920)
Browse files Browse the repository at this point in the history
* chore: remove deprecated code

* chore: add warning for Breadcrumb
  • Loading branch information
benjycui authored and afc163 committed Sep 9, 2016
1 parent 77a45f0 commit 14fb2c7
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 100 deletions.
3 changes: 0 additions & 3 deletions components/affix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { cloneElement } from 'react';
import warning from 'warning';
import BreadcrumbItem from './BreadcrumbItem';

export interface BreadcrumbProps {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/form/demo/dynamic-form-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion components/form/demo/form-in-modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion components/form/demo/validate-basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion components/form/demo/validate-customized.md
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion components/form/demo/validate-other.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let Demo = React.createClass({
wrapperCol: { span: 12 },
};
return (
<Form horizontal form={this.props.form}>
<Form horizontal>
<FormItem
{...formItemLayout}
label="Country"
Expand Down
24 changes: 12 additions & 12 deletions components/mention/demo/controlled.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion components/notification/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
category: Components
type: Views
noinstant: true
english: -tification
title: Notification
---

To display a notification message globally.
Expand Down
4 changes: 2 additions & 2 deletions components/notification/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
category: Components
chinese: 通知提醒框
type: Views
noinstant: true
english: Notification
title: Notification
subtitle: 通知提醒框
---

全局展示通知提醒信息。
Expand Down
15 changes: 2 additions & 13 deletions components/popover/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import Tooltip from '../tooltip';
import getPlacements from './placements';
import warning from 'warning';

const placements = getPlacements();

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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>
);
Expand Down
16 changes: 1 addition & 15 deletions components/progress/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
38 changes: 3 additions & 35 deletions components/slider/index.tsx
Original file line number Diff line number Diff line change
@@ -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 | {
Expand All @@ -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);
}

Expand All @@ -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} />;
}
}
17 changes: 3 additions & 14 deletions components/spin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
};
Expand All @@ -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`;
Expand All @@ -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);
}
Expand Down

0 comments on commit 14fb2c7

Please sign in to comment.