MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / FloatingLabelTextArea

Function FloatingLabelTextArea

components/floatingLabelInput.tsx:41–94  ·  view source on GitHub ↗
(props: {
  content: string;
  onChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
  labelText: string;
  helpTooltipText?: string;
  maxStringLength?: number;
  minHeight?: number;
  ref?: React.RefObject<HTMLTextAreaElement>;
})

Source from the content-addressed store, hash-verified

39}
40
41export function FloatingLabelTextArea(props: {
42 content: string;
43 onChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
44 labelText: string;
45 helpTooltipText?: string;
46 maxStringLength?: number;
47 minHeight?: number;
48 ref?: React.RefObject<HTMLTextAreaElement>;
49}) {
50 return (
51 <div className="w-full relative">
52 <AutoGrowingTextArea
53 className="w-full bg-gray-50 peer resize-none overflow-y-auto text-gray-800 pl-4 pr-10 pt-4 pb-2 rounded border-gray-200 focus:border-purple-600 focus:ring-purple-600 whitespace-pre-line outline-0"
54 ref={props.ref}
55 placeholder={""}
56 value={props.content}
57 onChange={props.onChange}
58 minHeight={props.minHeight}
59 />
60 {props.maxStringLength &&
61 props.content &&
62 props.content.length - props.maxStringLength > 50 && (
63 <div
64 className={classNames(
65 "absolute bottom-2 text-xs right-3 z-10",
66 props.content.length - props.maxStringLength >= 10
67 ? "text-red-500"
68 : "text-gray-500",
69 )}
70 >
71 {props.content.length}/{props.maxStringLength}
72 </div>
73 )}
74 {props.helpTooltipText && (
75 <div className="absolute top-3 right-3">
76 <QuestionMarkCircleIcon className="peer h-6 w-6 text-gray-400 hover:text-gray-500 transition rounded-full" />
77 <div className={classNames("right-0 -top-20 w-64 popup")}>
78 {props.helpTooltipText}
79 </div>
80 </div>
81 )}
82 <div
83 className={classNames(
84 "absolute pointer-events-none left-4 top-3 peer-focus:scale-75 peer-focus:-translate-y-5/8 text-gray-400 select-none transition duration-300",
85 props.content
86 ? "-translate-x-1/8 -translate-y-5/8 scale-75"
87 : "peer-focus:-translate-x-1/8",
88 )}
89 >
90 {props.labelText}
91 </div>
92 </div>
93 );
94}

Callers

nothing calls this directly

Calls 1

classNamesFunction · 0.90

Tested by

no test coverage detected