UNPKG

@primer/components

Version:
44 lines (43 loc) 1.93 kB
import React, { ComponentPropsWithoutRef } from 'react'; import { ComponentProps, MandateProps } from './utils/types'; import Token, { TokenProps } from './Token/Token'; import TokenLabel, { TokenLabelProps } from './Token/TokenLabel'; import TokenProfile, { TokenProfileProps } from './Token/TokenProfile'; import { TokenSizeKeys } from './Token/TokenBase'; import { TextInputProps } from './TextInput'; declare type AnyTokenProps = Partial<TokenProps & TokenLabelProps & TokenProfileProps>; declare type TokenDatum = MandateProps<AnyTokenProps, 'id' | 'text'>; declare type TextInputWithTokensInternalProps = { /** * The array of tokens to render */ tokens: TokenDatum[]; /** * The function that gets called when a token is removed */ onTokenRemove: (tokenId: string | number) => void; /** * The component used to render each token */ tokenComponent?: React.ComponentType<ComponentPropsWithoutRef<typeof Token> | ComponentPropsWithoutRef<typeof TokenLabel> | ComponentPropsWithoutRef<typeof TokenProfile>>; /** * The maximum height of the component. If the content in the input exceeds this height, * it will scroll vertically */ maxHeight?: React.CSSProperties['maxHeight']; /** * Whether tokens should render inline horizontally. By default, tokens wrap to new lines. */ preventTokenWrapping?: boolean; /** * The size of the tokens */ tokenSizeVariant?: TokenSizeKeys; /** * Whether the remove buttons should be rendered in the tokens */ hideTokenRemoveButtons?: boolean; } & TextInputProps; declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInputWithTokensInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>; export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>; export default TextInputWithTokens;