mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
fix: some tsc errors (#2804)
This commit is contained in:
parent
5d39bd9c54
commit
5dcce12c2c
@ -3,7 +3,7 @@ import Select, { Option, OptGroup } from '../select';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export interface AutoCompleteProps {
|
||||
size?: string;
|
||||
size?: 'large' | 'small' | 'default';
|
||||
className?: string;
|
||||
notFoundContent?: Element;
|
||||
dataSource: Array<any>;
|
||||
|
@ -35,6 +35,7 @@ interface ButtonProps {
|
||||
shape?: ButtonShape;
|
||||
size?: ButtonSize;
|
||||
onClick?: React.FormEventHandler;
|
||||
onMouseUp?: React.FormEventHandler;
|
||||
loading?: boolean;
|
||||
disabled?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
|
@ -1 +1,2 @@
|
||||
module.exports = require('../../date-picker/locale/en_US');
|
||||
import en_US from '../../date-picker/locale/en_US';
|
||||
export default en_US;
|
||||
|
@ -1 +1,2 @@
|
||||
module.exports = require('../../date-picker/locale/ru_RU');
|
||||
import ru_RU from '../../date-picker/locale/ru_RU';
|
||||
export default ru_RU;
|
||||
|
@ -1 +1,2 @@
|
||||
module.exports = require('../../date-picker/locale/zh_CN');
|
||||
import zh_CN from '../../date-picker/locale/zh_CN';
|
||||
export default zh_CN;
|
||||
|
@ -2,8 +2,9 @@
|
||||
// https://github.com/WickyNilliams/enquire.js/issues/82
|
||||
import assign from 'object-assign';
|
||||
if (typeof window !== 'undefined') {
|
||||
const matchMediaPolyfill = function matchMediaPolyfill() {
|
||||
const matchMediaPolyfill = function matchMediaPolyfill(mediaQuery: string): MediaQueryList {
|
||||
return {
|
||||
media: mediaQuery,
|
||||
matches: false,
|
||||
addListener() {
|
||||
},
|
||||
@ -23,7 +24,7 @@ export interface CarouselProps {
|
||||
/** 动画效果函数,可取 scrollx, fade */
|
||||
effect?: CarouselEffect;
|
||||
/** 是否显示面板指示点 */
|
||||
dots?: SlickCarouselboolean;
|
||||
dots?: boolean;
|
||||
/** 垂直显示 */
|
||||
vertical?: boolean;
|
||||
/** 是否自动切换 */
|
||||
|
@ -59,6 +59,7 @@ export default class CheckboxGroup extends React.Component<CheckboxGroupProps, C
|
||||
}
|
||||
getOptions() {
|
||||
const { options } = this.props;
|
||||
// https://github.com/Microsoft/TypeScript/issues/7960
|
||||
return options.map(option => {
|
||||
if (typeof option === 'string') {
|
||||
return {
|
||||
|
@ -60,10 +60,10 @@ export default function createPicker(TheCalendar) {
|
||||
});
|
||||
|
||||
// 需要选择时间时,点击 ok 时才触发 onChange
|
||||
let pickerChangeHandler = {
|
||||
let pickerChangeHandler: Object = {
|
||||
onChange: this.handleChange,
|
||||
};
|
||||
let calendarHandler = {
|
||||
let calendarHandler: Object = {
|
||||
onOk: this.handleChange,
|
||||
// fix https://github.com/ant-design/ant-design/issues/1902
|
||||
onSelect: (value, cause) => {
|
||||
@ -95,7 +95,7 @@ export default function createPicker(TheCalendar) {
|
||||
);
|
||||
|
||||
// default width for showTime
|
||||
const pickerStyle = {};
|
||||
const pickerStyle = { width: undefined };
|
||||
if (props.showTime) {
|
||||
pickerStyle.width = 180;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export default function wrapPicker(Picker, defaultFormat?) {
|
||||
|
||||
getFormatter() {
|
||||
const format = this.props.format;
|
||||
const formatter = new DateTimeFormat(format, this.getLocale().lang.format);
|
||||
const formatter = new DateTimeFormat(format as string, this.getLocale().lang.format);
|
||||
return formatter;
|
||||
},
|
||||
|
||||
|
@ -28,31 +28,31 @@ export interface FormProps {
|
||||
}
|
||||
|
||||
// function create
|
||||
export type CreateFormOptions = {
|
||||
export type WrappedFormUtils = {
|
||||
/** 获取一组输入控件的值,如不传入参数,则获取全部组件的值*/
|
||||
getFieldsValue(): (fieldNames?: Array<string>) => any;
|
||||
getFieldsValue(fieldNames?: Array<string>): Object;
|
||||
/** 获取一个输入控件的值*/
|
||||
getFieldValue(): (fieldName: string) => any;
|
||||
getFieldValue(fieldName: string): any;
|
||||
/** 设置一组输入控件的值*/
|
||||
setFieldsValue(): (obj: Object) => void;
|
||||
setFieldsValue(obj: Object): void;
|
||||
/** 设置一组输入控件的值*/
|
||||
setFields(): (obj: Object) => void;
|
||||
setFields(obj: Object): void;
|
||||
/** 校验并获取一组输入域的值与 Error*/
|
||||
validateFields(): (fieldNames?: Array<string>, options?: Object, callback?: (erros: any, values: any) => void) => any;
|
||||
validateFields(fieldNames?: Array<string>, options?: Object, callback?: (erros: any, values: any) => void): any;
|
||||
/** 与 `validateFields` 相似,但校验完后,如果校验不通过的菜单域不在可见范围内,则自动滚动进可见范围 */
|
||||
validateFieldsAndScroll(): (
|
||||
validateFieldsAndScroll(
|
||||
fieldNames?: Array<string>,
|
||||
options?: Object,
|
||||
callback?: (erros: any, values: any) => void
|
||||
) => any;
|
||||
): void;
|
||||
/** 获取某个输入控件的 Error */
|
||||
getFieldError(): (name: string) => Object;
|
||||
getFieldError(name: string): Object[];
|
||||
/** 判断一个输入控件是否在校验状态*/
|
||||
isFieldValidating(): (name: string) => Object;
|
||||
isFieldValidating(name: string): boolean;
|
||||
/**重置一组输入控件的值与状态,如不传入参数,则重置所有组件*/
|
||||
resetFields(): (names?: Array<string>) => void;
|
||||
resetFields(names?: Array<string>): void;
|
||||
|
||||
getFieldsValue(): (id: string, options: {
|
||||
getFieldProps(id: string, options: {
|
||||
/** 子节点的值的属性,如 Checkbox 的是 'checked'*/
|
||||
valuePropName?: string;
|
||||
/** 子节点的初始值,类型、可选值均由子节点决定*/
|
||||
@ -65,11 +65,11 @@ export type CreateFormOptions = {
|
||||
rules?: Array<any>;
|
||||
/** 必填输入控件唯一标志*/
|
||||
id?: string;
|
||||
}) => Array<any>;
|
||||
}): Array<any>;
|
||||
}
|
||||
|
||||
export interface FormComponentProps {
|
||||
form: CreateFormOptions;
|
||||
form: WrappedFormUtils;
|
||||
}
|
||||
|
||||
export class FormComponent extends React.Component<FormComponentProps, {}> {
|
||||
|
@ -3,6 +3,7 @@ import classNames from 'classnames';
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
import Row from '../row';
|
||||
import Col from '../col';
|
||||
import { WrappedFormUtils } from './Form';
|
||||
import { FIELD_META_PROP } from './constants';
|
||||
|
||||
export interface FormItemLabelColOption {
|
||||
@ -12,7 +13,8 @@ export interface FormItemLabelColOption {
|
||||
|
||||
export interface FormItemProps {
|
||||
prefixCls?: string;
|
||||
label?: React.ReactNode;
|
||||
id?: string;
|
||||
label?: string;
|
||||
labelCol?: FormItemLabelColOption;
|
||||
wrapperCol?: FormItemLabelColOption;
|
||||
help?: React.ReactNode;
|
||||
@ -22,6 +24,11 @@ export interface FormItemProps {
|
||||
className?: string;
|
||||
required?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
colon?: boolean;
|
||||
}
|
||||
|
||||
export interface FormItemContext {
|
||||
form: WrappedFormUtils;
|
||||
}
|
||||
|
||||
export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
@ -33,7 +40,7 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
|
||||
static propTypes = {
|
||||
prefixCls: React.PropTypes.string,
|
||||
label: React.PropTypes.node,
|
||||
label: React.PropTypes.string,
|
||||
labelCol: React.PropTypes.object,
|
||||
help: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.bool]),
|
||||
validateStatus: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'validating']),
|
||||
@ -49,6 +56,8 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
form: React.PropTypes.object,
|
||||
};
|
||||
|
||||
context: FormItemContext;
|
||||
|
||||
shouldComponentUpdate(...args) {
|
||||
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from 'react';
|
||||
import * as React from 'react';
|
||||
import { PropTypes } from 'react';
|
||||
import createDOMForm from 'rc-form/lib/createDOMForm';
|
||||
import Form from './Form';
|
||||
import FormItem from './FormItem';
|
||||
|
@ -3,6 +3,7 @@ import * as React from 'react';
|
||||
export interface IconProps {
|
||||
type: string;
|
||||
className?: string;
|
||||
title?: string;
|
||||
onClick?: (e) => void;
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@ import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export interface GroupProps {
|
||||
size?: 'large' | 'small' | 'default';
|
||||
className?: string;
|
||||
size?: 'large' | 'small' | 'default';
|
||||
children?: any;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export default function Group(props: GroupProps) {
|
||||
const Group: React.StatelessComponent<GroupProps> = (props) => {
|
||||
const className = classNames({
|
||||
'ant-input-group': true,
|
||||
'ant-input-group-lg': props.size === 'large',
|
||||
@ -20,8 +20,10 @@ export default function Group(props: GroupProps) {
|
||||
{props.children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Group.propTypes = {
|
||||
children: React.PropTypes.any,
|
||||
};
|
||||
|
||||
export default Group;
|
||||
|
@ -34,21 +34,25 @@ interface AutoSizeType {
|
||||
|
||||
export interface InputProps {
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
type: string;
|
||||
id?: number | string;
|
||||
value?: any;
|
||||
defaultValue?: any;
|
||||
placeholder?: string;
|
||||
size?: 'large' | 'default' | 'small';
|
||||
disabled?: boolean;
|
||||
readOnly?: boolean;
|
||||
addonBefore?: React.ReactNode;
|
||||
addonAfter?: React.ReactNode;
|
||||
onPressEnter?: (e) => any;
|
||||
onKeyDown?: (e) => any;
|
||||
onChange?: (e) => any;
|
||||
onPressEnter?: React.FormEventHandler;
|
||||
onKeyDown?: React.FormEventHandler;
|
||||
onChange?: React.FormEventHandler;
|
||||
autosize?: boolean | AutoSizeType;
|
||||
}
|
||||
|
||||
export default class Input extends Component<InputProps, any> {
|
||||
static Group: any;
|
||||
static defaultProps = {
|
||||
defaultValue: '',
|
||||
disabled: false,
|
||||
@ -121,8 +125,8 @@ export default class Input extends Component<InputProps, any> {
|
||||
if (type !== 'textarea' || !autosize || !this.refs.input) {
|
||||
return;
|
||||
}
|
||||
const minRows = autosize ? autosize.minRows : null;
|
||||
const maxRows = autosize ? autosize.maxRows : null;
|
||||
const minRows = autosize ? (autosize as AutoSizeType).minRows : null;
|
||||
const maxRows = autosize ? (autosize as AutoSizeType).maxRows : null;
|
||||
const textareaStyles = calculateNodeHeight(this.refs.input, false, minRows, maxRows);
|
||||
this.setState({ textareaStyles });
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ title:
|
||||
en-US: Search box
|
||||
---
|
||||
|
||||
## zh-CN:
|
||||
## zh-CN
|
||||
|
||||
带有搜索按钮的输入框。
|
||||
|
||||
## en-US:
|
||||
## en-US
|
||||
|
||||
Example of creating a search box by grouping a standard input with a search button.
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { PropTypes } from 'react';
|
||||
import * as React from 'react';
|
||||
import { PropTypes } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import assign from 'object-assign';
|
||||
import splitObject from '../_util/splitObject';
|
||||
|
||||
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||
const objectOrNumber = PropTypes.oneOfType([PropTypes.object, PropTypes.number]);
|
||||
import splitObject from '../_util/splitObject';
|
||||
|
||||
interface ColSize {
|
||||
span?: number;
|
||||
@ -15,6 +16,7 @@ interface ColSize {
|
||||
}
|
||||
|
||||
export interface ColProps {
|
||||
className?: string;
|
||||
span?: number;
|
||||
order?: number;
|
||||
offset?: number;
|
||||
@ -26,7 +28,7 @@ export interface ColProps {
|
||||
lg?: ColSize;
|
||||
}
|
||||
|
||||
export default function Col(props: ColProps) {
|
||||
const Col: React.StatelessComponent<ColProps> = (props) => {
|
||||
const [{ span, order, offset, push, pull, className, children }, others] = splitObject(props,
|
||||
['span', 'order', 'offset', 'push', 'pull', 'className', 'children']);
|
||||
let sizeClassObj = {};
|
||||
@ -58,7 +60,7 @@ export default function Col(props: ColProps) {
|
||||
}, sizeClassObj));
|
||||
|
||||
return <div {...others} className={classes}>{children}</div>;
|
||||
}
|
||||
};
|
||||
|
||||
Col.propTypes = {
|
||||
span: stringOrNumber,
|
||||
@ -73,3 +75,5 @@ Col.propTypes = {
|
||||
md: objectOrNumber,
|
||||
lg: objectOrNumber,
|
||||
};
|
||||
|
||||
export default Col;
|
||||
|
@ -5,10 +5,12 @@ import assign from 'object-assign';
|
||||
import splitObject from '../_util/splitObject';
|
||||
|
||||
export interface RowProps {
|
||||
className?: string;
|
||||
gutter?: number;
|
||||
type?: 'flex';
|
||||
align?: 'top' | 'middle' | 'bottom';
|
||||
justify?: 'start' | 'end' | 'center' | 'space-around' | 'space-between';
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export default class Row extends React.Component<RowProps, any> {
|
||||
@ -37,7 +39,7 @@ export default class Row extends React.Component<RowProps, any> {
|
||||
marginLeft: gutter / -2,
|
||||
marginRight: gutter / -2,
|
||||
}, style) : style;
|
||||
const cols = Children.map(children, col => {
|
||||
const cols = Children.map(children, (col) => {
|
||||
if (!col) {
|
||||
return null;
|
||||
}
|
||||
|
@ -7,7 +7,12 @@ import classNames from 'classnames';
|
||||
import { getConfirmLocale } from './locale';
|
||||
import assign from 'object-assign';
|
||||
|
||||
class ActionButton extends React.Component {
|
||||
export interface ActionButtonProps {
|
||||
type: 'primary' | 'ghost' | 'dashed';
|
||||
actionFn: Function;
|
||||
closeModal: Function;
|
||||
}
|
||||
class ActionButton extends React.Component<ActionButtonProps, any> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
|
@ -1 +1,2 @@
|
||||
module.exports = require('rc-pagination/lib/locale/en_US');
|
||||
import en_US from 'rc-pagination/lib/locale/en_US';
|
||||
export default en_US;
|
||||
|
@ -1 +1,2 @@
|
||||
module.exports = require('rc-pagination/lib/locale/zh_CN');
|
||||
import zh_CN from 'rc-pagination/lib/locale/zh_CN';
|
||||
export default zh_CN;
|
||||
|
@ -42,6 +42,8 @@ export interface SelectContext {
|
||||
};
|
||||
}
|
||||
|
||||
export { Option, OptGroup }
|
||||
|
||||
export default class Select extends React.Component<SelectProps, any> {
|
||||
static Option = Option;
|
||||
static OptGroup = OptGroup;
|
||||
|
@ -5,7 +5,11 @@ import Icon from '../icon';
|
||||
import Checkbox from '../checkbox';
|
||||
import Radio from '../radio';
|
||||
|
||||
const FilterDropdownMenuWrapper = ({ onClick, children }) => (
|
||||
export interface FilterDropdownMenuWrapperProps {
|
||||
onClick?: Function;
|
||||
children?: any;
|
||||
}
|
||||
const FilterDropdownMenuWrapper: React.StatelessComponent<FilterDropdownMenuWrapperProps> = ({ onClick, children }) => (
|
||||
<div className="ant-table-filter-dropdown" onClick={onClick}>{children}</div>
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import Animate from 'rc-animate';
|
||||
import Icon from '../icon';
|
||||
import classNames from 'classnames';
|
||||
|
@ -8,6 +8,7 @@ import assign from 'object-assign';
|
||||
|
||||
// TimePicker
|
||||
export interface TimePickerProps {
|
||||
size: 'large' | 'default' | 'small';
|
||||
/** 默认时间 */
|
||||
value?: string | Date;
|
||||
/** 初始默认时间 */
|
||||
@ -15,7 +16,7 @@ export interface TimePickerProps {
|
||||
/** 展示的时间格式 : "HH:mm:ss"、"HH:mm"、"mm:ss" */
|
||||
format?: string;
|
||||
/** 时间发生变化的回调 */
|
||||
onChange?: (Date: Date) => void;
|
||||
onChange?: (date: Date, dateString: string) => void;
|
||||
/** 禁用全部操作 */
|
||||
disabled?: boolean;
|
||||
/** 没有值的时候显示的内容 */
|
||||
@ -33,6 +34,13 @@ export interface TimePickerProps {
|
||||
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export interface TimePickerContext {
|
||||
antLocale?: {
|
||||
TimePicker?: any,
|
||||
};
|
||||
}
|
||||
|
||||
export default class TimePicker extends React.Component<TimePickerProps, any> {
|
||||
static defaultProps = {
|
||||
format: 'HH:mm:ss',
|
||||
@ -56,8 +64,10 @@ export default class TimePicker extends React.Component<TimePickerProps, any> {
|
||||
antLocale: React.PropTypes.object,
|
||||
};
|
||||
|
||||
context: TimePickerContext;
|
||||
|
||||
getFormatter() {
|
||||
return new DateTimeFormat(this.props.format, this.getLocale().format);
|
||||
return new DateTimeFormat(this.props.format as string, this.getLocale().format);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +105,7 @@ export default class TimePicker extends React.Component<TimePickerProps, any> {
|
||||
handleChange = (value) => {
|
||||
this.props.onChange(
|
||||
value ? new Date(value.getTime()) : null,
|
||||
value ? this.getFormatter().format(value) : '',
|
||||
value ? this.getFormatter().format(value) : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ export interface TimeLineItemProps {
|
||||
/** 指定圆圈颜色 */
|
||||
color?: string;
|
||||
dot?: React.ReactNode;
|
||||
pending?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ export interface TooltipProps {
|
||||
visible?: boolean;
|
||||
trigger?: 'hover' | 'focus' | 'click';
|
||||
overlay?: React.ReactNode;
|
||||
openClassName?: string;
|
||||
}
|
||||
|
||||
export default class Tooltip extends React.Component<TooltipProps, any> {
|
||||
|
33
custom-typings.d.ts
vendored
33
custom-typings.d.ts
vendored
@ -8,7 +8,7 @@ declare module 'react-addons-pure-render-mixin' {
|
||||
}
|
||||
|
||||
declare module 'gregorian-calendar-format' {
|
||||
export default function({}): string;
|
||||
export default function(format: string, localeFormat: Object): string;
|
||||
}
|
||||
|
||||
declare module 'gregorian-calendar' {
|
||||
@ -127,7 +127,7 @@ declare module 'rc-cascader' {
|
||||
}
|
||||
|
||||
declare module 'array-tree-filter' {
|
||||
export default function(): any;
|
||||
export default function(tree: any, filter: any): any;
|
||||
}
|
||||
|
||||
declare module 'rc-checkbox' {
|
||||
@ -143,16 +143,25 @@ declare module 'rc-dropdown' {
|
||||
}
|
||||
|
||||
declare module 'rc-editor-mention' {
|
||||
export default function(): any;
|
||||
export const Nav: any;
|
||||
export const toString: any;
|
||||
export const toEditorState: any;
|
||||
export const getMentions: any;
|
||||
const exports: any;
|
||||
export default exports;
|
||||
}
|
||||
|
||||
declare module 'rc-progress' {
|
||||
export default function(): any;
|
||||
export const Circle: any;
|
||||
const exports: any;
|
||||
export default exports;
|
||||
}
|
||||
|
||||
declare module 'rc-menu' {
|
||||
export const SubMenu: any;
|
||||
export const Item: any;
|
||||
export const Divider: any;
|
||||
export const ItemGroup: any;
|
||||
export default function(): any;
|
||||
}
|
||||
|
||||
@ -178,11 +187,19 @@ declare module 'rc-input-number' {
|
||||
}
|
||||
|
||||
declare module 'rc-pagination' {
|
||||
export default function(): any;
|
||||
const exports: any;
|
||||
export default exports;
|
||||
}
|
||||
|
||||
declare module 'rc-pagination/lib/locale/zh_CN' {
|
||||
const exports: any;
|
||||
export default exports;
|
||||
}
|
||||
|
||||
declare module 'rc-notification' {
|
||||
export default function(): any;
|
||||
export function newInstance(config: Object): any;
|
||||
const exports: any;
|
||||
export default exports;
|
||||
}
|
||||
|
||||
declare module 'rc-dialog' {
|
||||
@ -228,7 +245,9 @@ declare module 'rc-upload' {
|
||||
}
|
||||
|
||||
declare module 'rc-collapse' {
|
||||
export default function(): any;
|
||||
export const Panel: any;
|
||||
const exports: any;
|
||||
export default exports;
|
||||
}
|
||||
|
||||
declare module 'rc-form/lib/createDOMForm' {
|
||||
|
@ -141,6 +141,7 @@
|
||||
"eslint-fix": "eslint --fix components test site scripts ./*.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
|
||||
"test": "npm run lint && npm run dist",
|
||||
"jest": "jest",
|
||||
"postinstall": "typings install",
|
||||
"pre-publish": "node ./scripts/prepub",
|
||||
"prepublish": "antd-tools run guard",
|
||||
"pub": "antd-tools run update-self && antd-tools run pub",
|
||||
|
Loading…
Reference in New Issue
Block a user