|
|
@ -19,7 +19,12 @@ export interface TagProps { |
|
|
|
style?: React.CSSProperties; |
|
|
|
} |
|
|
|
|
|
|
|
export default class Tag extends React.Component<TagProps, any> { |
|
|
|
export interface TagState { |
|
|
|
closing: boolean; |
|
|
|
closed: boolean; |
|
|
|
} |
|
|
|
|
|
|
|
export default class Tag extends React.Component<TagProps, TagState> { |
|
|
|
static CheckableTag = CheckableTag; |
|
|
|
static defaultProps = { |
|
|
|
prefixCls: 'ant-tag', |
|
|
@ -35,7 +40,7 @@ export default class Tag extends React.Component<TagProps, any> { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
close = (e) => { |
|
|
|
close = (e: React.MouseEvent<HTMLElement>) => { |
|
|
|
const onClose = this.props.onClose; |
|
|
|
if (onClose) { |
|
|
|
onClose(e); |
|
|
@ -52,7 +57,7 @@ export default class Tag extends React.Component<TagProps, any> { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
animationEnd = (_, existed) => { |
|
|
|
animationEnd = (_: string, existed: boolean) => { |
|
|
|
if (!existed && !this.state.closed) { |
|
|
|
this.setState({ |
|
|
|
closed: true, |
|
|
@ -66,7 +71,8 @@ export default class Tag extends React.Component<TagProps, any> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isPresetColor(color) { |
|
|
|
isPresetColor(color?: string): boolean { |
|
|
|
if (!color) { return false; } |
|
|
|
return /^(pink|red|yellow|orange|cyan|green|blue|purple)(-inverse)?$/.test(color); |
|
|
|
} |
|
|
|
|
|
|
|