import React, {forwardRef} from "react"; import {useInput} from "@nextui-org/react"; export const SearchIcon = (props) => { return ( ); }; export const CloseFilledIcon = (props) => { return ( ); }; const styles = { label: "text-black/50 dark:text-white/90", input: [ "bg-transparent", "text-black/90 dark:text-white/90", "placeholder:text-default-700/50 dark:placeholder:text-white/60", ], innerWrapper: "bg-transparent", inputWrapper: [ "shadow-xl", "bg-default-200/50", "dark:bg-default/60", "backdrop-blur-xl", "backdrop-saturate-200", "hover:bg-default-200/70", "focus-within:!bg-default-200/50", "dark:hover:bg-default/70", "dark:focus-within:!bg-default/60", "!cursor-text", ], }; const MyInput = forwardRef((props, ref) => { const { Component, label, domRef, description, isClearable, startContent, endContent, shouldLabelBeOutside, shouldLabelBeInside, errorMessage, getBaseProps, getLabelProps, getInputProps, getInnerWrapperProps, getInputWrapperProps, getDescriptionProps, getErrorMessageProps, getClearButtonProps, } = useInput({ ...props, ref, // this is just for the example, the props bellow should be passed by the parent component label: "Search", type: "search", placeholder: "Type to search...", startContent: ( ), // custom styles classNames: { ...styles, }, }); const labelContent = ; const end = React.useMemo(() => { if (isClearable) { return {endContent || }; } return endContent; }, [isClearable, getClearButtonProps]); const innerWrapper = React.useMemo(() => { if (startContent || end) { return (
{startContent} {end}
); } return ; }, [startContent, end, getInputProps, getInnerWrapperProps]); return (
{shouldLabelBeOutside ? labelContent : null}
{ domRef.current?.focus(); }} onKeyDown={() => { domRef.current?.focus(); }} > {shouldLabelBeInside ? labelContent : null} {innerWrapper}
{description &&
{description}
} {errorMessage &&
{errorMessage}
}
); }); MyInput.displayName = "MyInput"; export default MyInput;