mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
chore: fix ts define
This commit is contained in:
parent
d75d049b5c
commit
9bea463638
@ -68,13 +68,19 @@ const AutoComplete: React.RefForwardingComponent<Select, AutoCompleteProps> = (p
|
||||
}
|
||||
switch (typeof item) {
|
||||
case 'string':
|
||||
return <Option key={item}>{item}</Option>;
|
||||
case 'object':
|
||||
return (
|
||||
<Option key={(item as DataSourceItemObject).value}>
|
||||
<Option key={item} value={item}>
|
||||
{item}
|
||||
</Option>
|
||||
);
|
||||
case 'object': {
|
||||
const { value: optionValue } = item as DataSourceItemObject;
|
||||
return (
|
||||
<Option key={optionValue} value={optionValue}>
|
||||
{(item as DataSourceItemObject).text}
|
||||
</Option>
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error('AutoComplete[dataSource] only supports type `string[] | Object[]`.');
|
||||
}
|
||||
|
@ -59,7 +59,12 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
const suffix = locale.year === '年' ? '年' : '';
|
||||
const options: React.ReactElement<any>[] = [];
|
||||
for (let index = start; index < end; index++) {
|
||||
options.push(<Option key={`${index}`}>{index + suffix}</Option>);
|
||||
const optionValue = `${index}`;
|
||||
options.push(
|
||||
<Option key={optionValue} value={optionValue}>
|
||||
{index + suffix}
|
||||
</Option>,
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Select
|
||||
@ -92,7 +97,12 @@ export default class Header extends React.Component<HeaderProps, any> {
|
||||
}
|
||||
|
||||
for (let index = start; index < end; index++) {
|
||||
options.push(<Option key={`${index}`}>{months[index]}</Option>);
|
||||
const optionValue = `${index}`;
|
||||
options.push(
|
||||
<Option key={optionValue} value={optionValue}>
|
||||
{months[index]}
|
||||
</Option>,
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Select
|
||||
|
@ -1,56 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Icon, { IconProps } from './index';
|
||||
|
||||
const customCache = new Set<string>();
|
||||
|
||||
export interface CustomIconOptions {
|
||||
scriptUrl?: string;
|
||||
extraCommonProps?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export default function create(options: CustomIconOptions = {}): React.SFC<IconProps> {
|
||||
const { scriptUrl, extraCommonProps = {} } = options;
|
||||
|
||||
/**
|
||||
* DOM API required.
|
||||
* Make sure in browser environment.
|
||||
* The Custom Icon will create a <script/>
|
||||
* that loads SVG symbols and insert the SVG Element into the document body.
|
||||
*/
|
||||
if (
|
||||
typeof document !== 'undefined' &&
|
||||
typeof window !== 'undefined' &&
|
||||
typeof document.createElement === 'function' &&
|
||||
typeof scriptUrl === 'string' &&
|
||||
scriptUrl.length &&
|
||||
!customCache.has(scriptUrl)
|
||||
) {
|
||||
const script = document.createElement('script');
|
||||
script.setAttribute('src', scriptUrl);
|
||||
script.setAttribute('data-namespace', scriptUrl);
|
||||
customCache.add(scriptUrl);
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
const Iconfont: React.SFC<IconProps> = props => {
|
||||
const { type, children, ...restProps } = props;
|
||||
|
||||
// component > children > type
|
||||
let content = null;
|
||||
if (props.type) {
|
||||
content = <use xlinkHref={`#${type}`} />;
|
||||
}
|
||||
if (children) {
|
||||
content = children;
|
||||
}
|
||||
return (
|
||||
<Icon {...extraCommonProps} {...restProps}>
|
||||
{content}
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
Iconfont.displayName = 'Iconfont';
|
||||
|
||||
return Iconfont;
|
||||
}
|
@ -58,7 +58,7 @@ export function normalizeColumns(elements: React.ReactChildren) {
|
||||
return;
|
||||
}
|
||||
const column: any = {
|
||||
...element.props,
|
||||
...(element.props as any),
|
||||
};
|
||||
if (element.key) {
|
||||
column.key = element.key;
|
||||
|
@ -124,7 +124,7 @@
|
||||
"rc-progress": "~2.5.0",
|
||||
"rc-rate": "~2.5.0",
|
||||
"rc-resize-observer": "^0.1.0",
|
||||
"rc-select": "~10.0.0-alpha.28",
|
||||
"rc-select": "~10.0.0-alpha.29",
|
||||
"rc-slider": "~8.7.1",
|
||||
"rc-steps": "~3.5.0",
|
||||
"rc-switch": "~1.9.0",
|
||||
|
Loading…
Reference in New Issue
Block a user