import * as React from 'react'; import { TextControl, tailwind } from '@tesseract-design/web-base'; import { useFallbackId } from '@modal-sh/react-utils'; const { tw } = tailwind; const UrlInputDerivedElementComponent = 'input' as const; /** * Derived HTML element of the {@link UrlInput} component. */ export type UrlInputDerivedElement = HTMLElementTagNameMap[ typeof UrlInputDerivedElementComponent ]; /** * Props of the {@link UrlInput} component. */ export interface UrlInputProps extends Omit, 'size' | 'type' | 'label' | 'inputMode'> { /** * Short textual description indicating the nature of the component's value. */ label?: React.ReactNode, /** * Short textual description as guidelines for valid input values. */ hint?: React.ReactNode, /** * Size of the component. */ size?: TextControl.Size, /** * Should the component display a border? */ border?: boolean, /** * Should the component occupy the whole width of its parent? */ block?: boolean, /** * Style of the component. */ variant?: TextControl.Variant, /** * Is the label hidden? */ hiddenLabel?: boolean, /** * Visual length of the input. */ length?: number, } /** * Component for inputting URLs. */ export const UrlInput = React.forwardRef(( { label, hint, size = 'medium' as const, border = false, block = false, variant = 'default' as const, hiddenLabel = false, className, style, length, id: idProp, ...etcProps }: UrlInputProps, forwardedRef, ) => { const labelId = React.useId(); const id = useFallbackId(idProp); return (
{label && ( <> {' '} )} {hint && (
{hint}
)}
{border && ( )}
); }); UrlInput.displayName = 'UrlInput'; UrlInput.defaultProps = { label: undefined, hint: undefined, size: 'medium', border: false, block: false, variant: 'default', hiddenLabel: false, length: undefined, };