choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
48 lines (47 loc) • 1.62 kB
TypeScript
import React, { Component, CSSProperties, HTMLAttributes } from 'react';
import CheckableTag from './CheckableTag';
import { PresetColorType } from '../_util/colors';
import { LiteralUnion } from '../_util/type';
import ConfigContext, { ConfigContextValue } from '../config-provider/ConfigContext';
export { CheckableTagProps } from './CheckableTag';
export interface TagProps extends HTMLAttributes<HTMLDivElement> {
prefixCls?: string;
className?: string;
color?: LiteralUnion<PresetColorType, string>;
/** 标签是否可以关闭 */
closable?: boolean;
visible?: boolean;
/** 关闭时的回调 */
onClose?: Function;
/** 动画关闭后的回调 */
afterClose?: Function;
style?: CSSProperties;
}
export interface TagState {
closing: boolean;
closed: boolean;
visible: boolean;
}
export default class Tag extends Component<TagProps, TagState> {
static get contextType(): typeof ConfigContext;
static displayName: string;
static CheckableTag: typeof CheckableTag;
static defaultProps: {
closable: boolean;
};
static getDerivedStateFromProps(nextProps: TagProps): {
visible: boolean | undefined;
} | null;
context: ConfigContextValue;
state: {
closing: boolean;
closed: boolean;
visible: boolean;
};
componentDidUpdate(_prevProps: TagProps, prevState: TagState): void;
handleIconClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
close: () => void;
show: () => void;
animationEnd: (_: string, existed: boolean) => void;
render(): JSX.Element;
}