未验证 提交 4aeb811b 编写于 作者: W Wei Zhu 提交者: GitHub

Remove deprecations (#8351)

上级 b8b591c5
import * as React from 'react';
import CalendarLocale from 'rc-calendar/lib/locale/zh_CN';
import RcCalendar from 'rc-calendar';
import warning from 'warning';
export default class Calendar extends React.Component<any, any> {
static defaultProps = {
locale: CalendarLocale,
prefixCls: 'ant-calendar',
};
render() {
warning(false, 'DatePicker.Calendar is deprecated, use Calendar instead.');
return <RcCalendar {...this.props} />;
}
}
......@@ -6,7 +6,6 @@ import createPicker from './createPicker';
import wrapPicker from './wrapPicker';
import RangePicker from './RangePicker';
import WeekPicker from './WeekPicker';
import Calendar from './Calendar';
import { TimePickerProps } from '../time-picker';
export interface PickerProps {
......@@ -40,7 +39,6 @@ export interface DatePickerProps extends PickerProps, SinglePickerProps {
showTime?: TimePickerProps | boolean;
showToday?: boolean;
open?: boolean;
toggleOpen?: (e: {open: boolean}) => void;
disabledTime?: (current: moment.Moment) => {
disabledHours?: () => number[],
disabledMinutes?: () => number[],
......@@ -84,7 +82,6 @@ export interface WeexPickerProps extends PickerProps, SinglePickerProps {
Object.assign(DatePicker, {
RangePicker: wrapPicker(RangePicker),
Calendar,
MonthPicker,
WeekPicker: wrapPicker(WeekPicker, 'YYYY-Wo'),
});
......
......@@ -3,7 +3,7 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel';
import classNames from 'classnames';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { generateShowHourMinuteSecond } from '../time-picker';
import warning from '../_util/warning';
declare const require: Function;
function getColumns({ showHour, showMinute, showSecond, use12Hours }: any) {
......@@ -41,17 +41,8 @@ export default function wrapPicker(Picker: React.ComponentClass<any>, defaultFor
};
handleOpenChange = (open: boolean) => {
const { onOpenChange, toggleOpen } = this.props;
const { onOpenChange } = this.props;
onOpenChange(open);
if (toggleOpen) {
warning(
false,
'`toggleOpen` is deprecated and will be removed in the future, ' +
'please use `onOpenChange` instead, see: https://u.ant.design/date-picker-on-open-change',
);
toggleOpen({ open });
}
}
getDefaultLocale() {
......
......@@ -18,9 +18,6 @@ export interface FormCreateOption<T> {
export interface FormProps {
layout?: 'horizontal' | 'inline' | 'vertical';
horizontal?: boolean;
inline?: boolean;
vertical?: boolean;
form?: WrappedFormUtils;
onSubmit?: React.FormEventHandler<any>;
style?: React.CSSProperties;
......@@ -170,26 +167,20 @@ export default class Form extends React.Component<FormProps, any> {
}
getChildContext() {
const { layout, vertical } = this.props;
const { layout } = this.props;
return {
vertical: layout === 'vertical' || vertical,
vertical: layout === 'vertical',
};
}
render() {
const {
prefixCls, hideRequiredMark, className = '', layout,
// @deprecated
inline, horizontal, vertical,
} = this.props;
warning(
!inline && !horizontal && !vertical,
'`Form[inline|horizontal|vertical]` is deprecated, please use `Form[layout]` instead.',
);
const formClassName = classNames(prefixCls, {
[`${prefixCls}-horizontal`]: (!inline && !vertical && layout === 'horizontal') || horizontal,
[`${prefixCls}-vertical`]: layout === 'vertical' || vertical,
[`${prefixCls}-inline`]: layout === 'inline' || inline,
[`${prefixCls}-horizontal`]: layout === 'horizontal',
[`${prefixCls}-vertical`]: layout === 'vertical',
[`${prefixCls}-inline`]: layout === 'inline',
[`${prefixCls}-hide-required-mark`]: hideRequiredMark,
}, className);
......@@ -197,9 +188,6 @@ export default class Form extends React.Component<FormProps, any> {
'prefixCls',
'className',
'layout',
'inline',
'horizontal',
'vertical',
'form',
'hideRequiredMark',
]);
......
......@@ -9,7 +9,7 @@ Form is used to collect, validate, and submit the user input, usually contains v
## Form
You can align the controls of a `form` using one of the following attributes
You can align the controls of a `form` using the `layout` prop
- `horizontal`:to horizontally align the `label`s and controls of the fields. (Default)
- `vertical`:to vertically align the `label`s and controls of the fields.
......@@ -38,10 +38,7 @@ A form field is defined using `<Form.Item />`.
| -------- | ----------- | ---- | ------------- |
| form | Decorated by `Form.create()` will be automatically set `this.props.form` property, so just pass to form, you don't need to set it by yourself after 1.7.0. | object | n/a |
| hideRequiredMark | Hide required mark of all form items | Boolean | false |
| horizontal | Use horizontal layout(Deprecated after 2.8) | boolean | true |
| inline | Use inline alignment(Deprecated after 2.8) | boolean | false |
| layout | Define form layout(Support after 2.8) | 'horizontal'\|'vertical'\|'inline' | 'horizontal' |
| vertical | Use vertical layout(Deprecated after 2.8) | boolean | false |
| onSubmit | Defines a function will be called if form data validation is successful. | Function(e:Event) | |
### Form.create(options)
......
......@@ -40,10 +40,7 @@ title: Form
| --- | --- | --- | --- |
| form | 经 `Form.create()` 包装过的组件会自带 `this.props.form` 属性,直接传给 Form 即可。1.7.0 之后无需设置 | object | 无 |
| hideRequiredMark | 隐藏所有表单项的必选标记 | Boolean | false |
| horizontal | 水平排列布局(2.8 之后废弃) | boolean | true |
| inline | 行内排列布局(2.8 之后废弃) | boolean | false |
| layout | 表单布局(2.8 之后支持) | 'horizontal'\|'vertical'\|'inline' | 'horizontal' |
| vertical | 垂直排列布局(2.8 之后废弃) | boolean | false |
| onSubmit | 数据验证成功后回调事件 | Function(e:Event) | |
### Form.create(options)
......
......@@ -222,9 +222,6 @@ export default class Input extends React.Component<InputProps, any> {
}
render() {
if (this.props.type === 'textarea') {
return <TextArea {...this.props as any} ref={this.saveInput} />;
}
return this.renderLabeledInput(this.renderInput());
}
}
......@@ -26,7 +26,7 @@ Keyboard and mouse can be used for providing or changing data.
| prefix | The prefix icon for the Input. | string\|ReactNode | |
| size | The size of the input box. Note: in the context of a form, the `large` size is used. Available: `large` `default` `small` | string | `default` |
| suffix | The suffix icon for the Input. | string\|ReactNode | |
| type | The type of input, `text` or `textarea`(`type=textarea` are deprecated after `2.12`, please use `Input.TextArea`) | string | `text` |
| type | The type of input, see: [MDN](https://developer.mozilla.org/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types)(use `Input.TextArea` instead of `type="textarea"`) | string | `text` |
| value | The input content value | string | |
| onPressEnter | The callback function that is triggered when Enter key is pressed. | function(e) | |
......
......@@ -26,7 +26,7 @@ title: Input
| prefix | 带有前缀图标的 input | string\|ReactNode | |
| size | 控件大小。注:标准表单内的输入框大小限制为 `large`。可选 `large` `default` `small` | string | `default` |
| suffix | 带有后缀图标的 input | string\|ReactNode | |
| type | 声明 input 类型,同原生 input 标签的 type 属性。另外提供 `type="textarea"`(该 type `2.12` 后废弃,请直接使用 `Input.TextArea`)。 | string | `text` |
| type | 声明 input 类型,同原生 input 标签的 type 属性,见:[MDN](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input#属性)(请直接使用 `Input.TextArea` 代替 `type="textarea"`)。 | string | `text` |
| value | 输入框内容 | string | |
| onPressEnter | 按下回车的回调 | function(e) | |
......
......@@ -24,15 +24,14 @@ When need to mention someone or something.
| API | Description | Type |
| --- | ----------- | ---- |
| getMentions | get mentioned people in current contentState | Function(ContentState: contentState): string\[] |
| toContentState (recommended) | convert string to ContentState | Function(value: string): ContentState |
| toEditorState (Backward compatible) | convert string to ContentState | Function(value: string): ContentState |
| toContentState | convert string to ContentState | Function(value: string): ContentState |
| toString | convert ContentState to string | Function(contentState: ContentState): string |
### Mention
| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| defaultValue | default value | ContentState, you can use `Mention.toContentState` or `Mention.toEditorState` to convert text to `ContentState` | null |
| defaultValue | default value | ContentState, you can use `Mention.toContentState` to convert text to `ContentState` | null |
| disabled | Tell if the input is disabled. | boolean | false |
| getSuggestionContainer | rendered to the root of the menu. Default rendered to the body dom. If gets any problem of the menu while scrolling. Try to make the root the dom scrolled, and make it position relative. | function | () => document.body |
| loading | loading mode | boolean | false |
......
......@@ -46,10 +46,6 @@ export default class Mention extends React.Component<MentionProps, MentionState>
static Nav = Nav;
static toString = toString;
static toContentState = toEditorState;
static toEditorState = (text: string) => {
console.warn('Mention.toEditorState is deprecated. Use toContentState instead.');
return toEditorState(text);
}
private mentionEle: any;
constructor(props: MentionProps) {
super(props);
......
......@@ -25,15 +25,14 @@ title: Mention
| API | 说明 | 类型 |
| --- | --- | --- |
| getMentions | 获取当前 contentState 中提到的人的列表 | Function(contentState: ContentState): string\[] |
| toContentState(推荐) | 把字符串转成 ContentState | Function(value: string): ContentState |
| toEditorState(兼容) | 把字符串转成 ContentState | Function(value: string): ContentState |
| toContentState | 把字符串转成 ContentState | Function(value: string): ContentState |
| toString | 把 ContentState 转成字符串 | Function(contentState: ContentState): string |
### Mention
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| defaultValue | 默认值 | ContentState, 可以用 `Mention.toContentState(text)` `Mention.toEditorState(text)` 把文字转换成 ContentState | null |
| defaultValue | 默认值 | ContentState, 可以用 `Mention.toContentState(text)` 把文字转换成 ContentState | null |
| disabled | 是否禁用状态. | boolean | false |
| getSuggestionContainer | 菜单渲染父节点。默认渲染到 body 上,如果你遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位 | function() | () => document.body |
| loading | 加载中 | boolean | false |
......
......@@ -25,7 +25,6 @@ Select component to select value from options.
| -------- | ----------- | ---- | ------- |
| allowClear | Show clear button. | boolean | false |
| autoFocus | Get focus by default | boolean | false |
| combobox | Enable combobox mode (can not set multiple at the same time). (Deprecated after 2.9, use `mode` instead) | boolean | false |
| defaultActiveFirstOption | Whether active first option by default | boolean | true |
| defaultValue | Initial selected option. | string\|string\[] | - |
| disabled | Whether disabled select | boolean | false |
......@@ -39,14 +38,12 @@ Select component to select value from options.
| maxTagCount | Max tag count to show | number | - |
| maxTagPlaceholder | Placeholder for not showing tags | ReactNode/function(omittedValues) | - |
| mode | Set mode of Select (Support after 2.9) | 'multiple' \| 'tags' \| 'combobox' | - |
| multiple | Allow multiple select (Deprecated after 2.9, use `mode` instead) | boolean | false |
| notFoundContent | Specify content to show when no result matches.. | string | 'Not Found' |
| optionFilterProp | Which prop value of option will be used for filter if filterOption is true | string | value |
| optionLabelProp | Which prop value of option will render as content of select. | string | `children` |
| placeholder | Placeholder of select | string\|ReactNode | - |
| showSearch | Whether show search input in single mode. | boolean | false |
| size | Size of Select input. `default` `large` `small` | string | default |
| tags | When tagging is enabled the user can select from pre-existing options or create a new tag by picking the first choice, which is what the user has typed into the search box so far. (Deprecated after 2.9, use `mode` instead) | boolean | false |
| tokenSeparators | Separator used to tokenize on tag/multiple mode | string\[] | |
| value | Current selected option. | string\|string\[] | - |
| onBlur | Called when blur | function | - |
......
......@@ -4,7 +4,6 @@ import RcSelect, { Option, OptGroup } from 'rc-select';
import classNames from 'classnames';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import defaultLocale from '../locale-provider/default';
import warning from '../_util/warning';
export interface AbstractSelectProps {
prefixCls?: string;
......@@ -36,9 +35,6 @@ export interface SelectProps extends AbstractSelectProps {
value?: SelectValue;
defaultValue?: SelectValue;
mode?: 'default' | 'multiple' | 'tags' | 'combobox';
multiple?: boolean;
tags?: boolean;
combobox?: boolean;
optionLabelProp?: string;
onChange?: (value: SelectValue) => void;
onSelect?: (value: SelectValue, option: Object) => any;
......@@ -118,10 +114,6 @@ export default class Select extends React.Component<SelectProps, {}> {
className = '',
size,
mode,
// @deprecated
multiple,
tags,
combobox,
...restProps,
} = this.props;
const cls = classNames({
......@@ -130,15 +122,15 @@ export default class Select extends React.Component<SelectProps, {}> {
}, className);
let { notFoundContent, optionLabelProp } = this.props;
const isCombobox = mode === 'combobox' || combobox;
const isCombobox = mode === 'combobox';
if (isCombobox) {
// children 带 dom 结构时,无法填入输入框
optionLabelProp = optionLabelProp || 'value';
}
const modeConfig = {
multiple: mode === 'multiple' || multiple,
tags: mode === 'tags' || tags,
multiple: mode === 'multiple',
tags: mode === 'tags',
combobox: isCombobox,
};
......@@ -158,17 +150,6 @@ export default class Select extends React.Component<SelectProps, {}> {
}
render() {
const {
// @deprecated
multiple,
tags,
combobox,
} = this.props;
warning(
!multiple && !tags && !combobox,
'`Select[multiple|tags|combobox]` is deprecated, please use `Select[mode]` instead.',
);
return (
<LocaleReceiver
componentName="Select"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册