@primer/react
Version:
An implementation of GitHub's Primer Design System using React
94 lines • 4.17 kB
TypeScript
import type { RefObject } from 'react';
import React from 'react';
import type { TextInputProps } from '../TextInput';
import Token from '../Token/Token';
import type { TokenSizeKeys } from '../Token/TokenBase';
import type { WithSlotMarker } from '../utils/types';
type AnyReactComponent = React.ComponentType<React.PropsWithChildren<any>>;
/**
* @deprecated
*/
export type TextInputWithTokensProps<TokenComponentType extends AnyReactComponent = typeof Token> = {
/**
* The array of tokens to render
*/
tokens: TokenComponentType extends React.ComponentType<React.PropsWithChildren<infer TokenProps>> ? TokenProps[] : never;
/**
* The function that gets called when a token is removed
*/
onTokenRemove: (tokenId: string | number) => void;
/**
* The component used to render each token
*/
tokenComponent?: TokenComponentType;
/**
* 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 and text input
*/
size?: TokenSizeKeys;
/**
* Whether the remove buttons should be rendered in the tokens
*/
hideTokenRemoveButtons?: boolean;
/**
* The number of tokens to display before truncating
*/
visibleTokenCount?: number;
} & Omit<TextInputProps, 'size'>;
declare const TextInputWithTokens: React.ForwardRefExoticComponent<{
/**
* The array of tokens to render
*/
tokens: any[] | (Omit<(Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
ref?: ((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLAnchorElement> | null | undefined;
}) | (Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
ref?: ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
}) | (Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
ref?: ((instance: HTMLSpanElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLSpanElement> | null | undefined;
}), keyof import("..").TokenProps> & import("..").TokenProps & {
as?: "a" | "button" | "span" | undefined;
})[];
/**
* The function that gets called when a token is removed
*/
onTokenRemove: (tokenId: string | number) => void;
/**
* The component used to render each token
*/
tokenComponent?: import("../utils/polymorphic").ForwardRefComponent<"a" | "button" | "span", import("..").TokenProps> | AnyReactComponent | undefined;
/**
* 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 and text input
*/
size?: TokenSizeKeys;
/**
* Whether the remove buttons should be rendered in the tokens
*/
hideTokenRemoveButtons?: boolean;
/**
* The number of tokens to display before truncating
*/
visibleTokenCount?: number;
} & Omit<TextInputProps, "size"> & React.RefAttributes<HTMLInputElement>>;
/**
* @deprecated
*/
declare const _default: WithSlotMarker<typeof TextInputWithTokens>;
export default _default;
//# sourceMappingURL=TextInputWithTokens.d.ts.map