import React, { forwardRef } from "react"; import { XMarkIcon } from "@navikt/aksel-icons"; import { AkselColor } from "../types"; import { cl, composeEventHandlers } from "../utils/helpers"; import { useI18n } from "../utils/i18n/i18n.hooks"; export interface ChipsRemovableProps extends React.ButtonHTMLAttributes { children: string; /** * @deprecated Use `data-color` prop instead. */ variant?: "action" | "neutral"; /** * Click callback */ onDelete?: () => void; /** * Overrides inherited color. * @see 🏷️ {@link AkselColor} * @see [📝 Documentation](https://aksel.nav.no/grunnleggende/styling/farger-tokens) */ "data-color"?: AkselColor; } export const RemovableChips = forwardRef< HTMLButtonElement, ChipsRemovableProps >( ( { children, variant, onDelete, className, onClick, type = "button", "data-color": color, ...rest }, ref, ) => { const translate = useI18n("Chips"); return ( ); }, ); function variantToColor( variant?: ChipsRemovableProps["variant"], ): AkselColor | undefined { switch (variant) { case "action": return "accent"; case "neutral": return "neutral"; default: return undefined; } } export default RemovableChips;