UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

96 lines (95 loc) 4.08 kB
import { WithSlotMarker } from "../utils/types/Slots.js"; import { ForwardRefComponent } from "../utils/polymorphic.js"; import { TextInputProps } from "../TextInput/TextInput.js"; import { TokenSizeKeys } from "../Token/constants.js"; import Token, { TokenProps as TokenProps$1 } from "../Token/Token.js"; import React, { RefObject } from "react"; //#region src/TextInputWithTokens/TextInputWithTokens.d.ts type AnyReactComponent = React.ComponentType<React.PropsWithChildren<any>>; /** * @deprecated */ 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?: RefObject<HTMLAnchorElement> | ((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]) | null | undefined; }) | (Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & { ref?: RefObject<HTMLButtonElement> | ((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]) | null | undefined; }) | (Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & { ref?: RefObject<HTMLSpanElement> | ((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]) | null | undefined; }), keyof TokenProps$1> & TokenProps$1 & { 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?: ForwardRefComponent<"a" | "button" | "span", TokenProps$1> | 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>; //#endregion export { TextInputWithTokensProps, _default as default };