import React, { MouseEvent } from "react"; import classNames from "classnames"; import { Box, BoxProps } from "../Box"; import { Flex } from "../Flex"; import { Icon, ICON_TYPE } from "../Icon"; import { Text } from "../Text"; import { bem } from "../../utilities/bem"; import isUndefined from "../../utilities/isUndefined"; const cn = "Token"; export enum TOKEN_STATUS { DANGER = "danger", DEFAULT = "default", } interface TokenProps extends BoxProps { /** * Label for the token, precedes child text */ label?: string; /** * If true, an "X" button will be shown on the right of the token */ removable?: boolean; /** * Callback to execute when the remove button is clicked */ onRemove?: (event: MouseEvent) => void; /** * Changes styles based on status */ variant?: TOKEN_STATUS; } const TokenGroup = ({ className, ...rest }: BoxProps) => { return ; }; export const Token = ({ children, label, className, onRemove, removable = false, variant = TOKEN_STATUS.DEFAULT, ...rest }: TokenProps) => { const handleClick = (event: MouseEvent): void => { if (!isUndefined(onRemove)) { onRemove(event); } }; return ( {variant === TOKEN_STATUS.DANGER && ( )} {label && ( {label} )} {children} {removable && ( )} ); }; Token.Group = TokenGroup;