mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
Merge branch 'master' of github.com:ant-design/ant-design
This commit is contained in:
commit
b54020ea01
9
components/_util/warning.tsx
Normal file
9
components/_util/warning.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import warning from 'warning';
|
||||
|
||||
const warned: { [msg: string]: boolean} = {};
|
||||
export default (valid: boolean, message: string): void => {
|
||||
if (!valid && !warned[message]) {
|
||||
warning(false, message);
|
||||
warned[message] = true;
|
||||
}
|
||||
};
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import Animate from 'rc-animate';
|
||||
import ScrollNumber from './ScrollNumber';
|
||||
import classNames from 'classnames';
|
||||
import warning from 'warning';
|
||||
import warning from '../_util/warning';
|
||||
import splitObject from '../_util/splitObject';
|
||||
|
||||
export interface BadgeProps {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { cloneElement } from 'react';
|
||||
import warning from 'warning';
|
||||
import warning from '../_util/warning';
|
||||
import BreadcrumbItem from './BreadcrumbItem';
|
||||
|
||||
export interface BreadcrumbProps {
|
||||
@ -52,9 +52,8 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
|
||||
nameRender: React.PropTypes.func,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super();
|
||||
|
||||
componentDidMount() {
|
||||
const props = this.props;
|
||||
warning(
|
||||
!('linkRender' in props || 'nameRender' in props),
|
||||
'`linkRender` and `nameRender` are removed, please use `itemRender` instead.'
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { PropTypes } from 'react';
|
||||
import TimePickerPanel from 'rc-time-picker/lib/Panel';
|
||||
import classNames from 'classnames';
|
||||
import warning from 'warning';
|
||||
import warning from '../_util/warning';
|
||||
import getLocale from '../_util/getLocale';
|
||||
declare const require: Function;
|
||||
|
||||
|
@ -81,8 +81,6 @@ export interface ComponentDecorator {
|
||||
<T extends (typeof FormComponent)>(component: T): T;
|
||||
}
|
||||
|
||||
let warnedGetFieldProps = false;
|
||||
|
||||
export default class Form extends React.Component<FormProps, any> {
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-form',
|
||||
@ -123,24 +121,17 @@ export default class Form extends React.Component<FormProps, any> {
|
||||
};
|
||||
},
|
||||
componentWillMount() {
|
||||
if (!warnedGetFieldProps) {
|
||||
this.getFieldProps = this.props.form.getFieldProps;
|
||||
}
|
||||
this.getFieldProps = this.deprecatedGetFieldProps;
|
||||
},
|
||||
deprecatedGetFieldProps(name, option) {
|
||||
if (!warnedGetFieldProps) {
|
||||
warnedGetFieldProps = true;
|
||||
warning(
|
||||
false,
|
||||
'`getFieldProps` is not recommended, please use `getFieldDecorator` instead'
|
||||
);
|
||||
}
|
||||
warning(
|
||||
false,
|
||||
'`getFieldProps` is not recommended, please use `getFieldDecorator` instead'
|
||||
);
|
||||
return this.getFieldProps(name, option);
|
||||
},
|
||||
render() {
|
||||
if (!warnedGetFieldProps) {
|
||||
this.props.form.getFieldProps = this.deprecatedGetFieldProps;
|
||||
}
|
||||
this.props.form.getFieldProps = this.deprecatedGetFieldProps;
|
||||
|
||||
const withRef: any = {};
|
||||
if (options && options.withRef) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import warning from 'warning';
|
||||
import PureRenderMixin from 'rc-util/lib/PureRenderMixin';
|
||||
import Row from '../row';
|
||||
import Col from '../col';
|
||||
import { WrappedFormUtils } from './Form';
|
||||
import { FIELD_META_PROP } from './constants';
|
||||
import warning from '../_util/warning';
|
||||
|
||||
export interface FormItemLabelColOption {
|
||||
span: number;
|
||||
@ -32,7 +32,6 @@ export interface FormItemContext {
|
||||
form: WrappedFormUtils;
|
||||
}
|
||||
|
||||
let autoGenerateWarning = false;
|
||||
export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
static defaultProps = {
|
||||
hasFeedback: false,
|
||||
@ -61,14 +60,11 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
context: FormItemContext;
|
||||
|
||||
componentDidMount() {
|
||||
if (!autoGenerateWarning && (this.getControls(this.props.children, true).length > 1)) {
|
||||
autoGenerateWarning = true;
|
||||
warning(
|
||||
false,
|
||||
'`Form.Item` cannot generate `validateStatus` and `help` automatically, ' +
|
||||
'while there are more than one `getFieldDecorator` in it.'
|
||||
);
|
||||
}
|
||||
warning(
|
||||
this.getControls(this.props.children, true).length <= 1,
|
||||
'`Form.Item` cannot generate `validateStatus` and `help` automatically, ' +
|
||||
'while there are more than one `getFieldDecorator` in it.'
|
||||
);
|
||||
}
|
||||
|
||||
shouldComponentUpdate(...args) {
|
||||
@ -85,7 +81,7 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
return props.help;
|
||||
}
|
||||
|
||||
getControls(children, recursively) {
|
||||
getControls(children, recursively: boolean) {
|
||||
let controls: React.ReactElement<any>[] = [];
|
||||
const childrenArray = React.Children.toArray(children);
|
||||
for (let i = 0; i < childrenArray.length; i++) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import RcMenu, { Item, Divider, SubMenu, ItemGroup } from 'rc-menu';
|
||||
import animation from '../_util/openAnimation';
|
||||
import warning from 'warning';
|
||||
import warning from '../_util/warning';
|
||||
|
||||
export interface SelectParam {
|
||||
key: string;
|
||||
|
@ -10,7 +10,7 @@ import classNames from 'classnames';
|
||||
import { flatArray, treeMap } from './util';
|
||||
import assign from 'object-assign';
|
||||
import splitObject from '../_util/splitObject';
|
||||
import warning from 'warning';
|
||||
import warning from '../_util/warning';
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ import ReactDOM from 'react-dom';
|
||||
import Animate from 'rc-animate';
|
||||
import classNames from 'classnames';
|
||||
import omit from 'omit.js';
|
||||
import warning from 'warning';
|
||||
import Icon from '../icon';
|
||||
import warning from '../_util/warning';
|
||||
import splitObject from '../_util/splitObject';
|
||||
|
||||
export interface TagProps {
|
||||
|
Loading…
Reference in New Issue
Block a user