import { clsx } from 'clsx' import { createEffect, createSignal, Show } from 'solid-js' import styles from './GrowingTextarea.module.scss' type Props = { class?: string placeholder: string initialValue?: string value: (string) => void maxLength?: number allowEnterKey: boolean variant?: 'bordered' fieldName?: string textAreaRef?: (el: HTMLTextAreaElement) => void } export const GrowingTextarea = (props: Props) => { const [value, setValue] = createSignal('') const [isFocused, setIsFocused] = createSignal(false) createEffect(() => { if (props.maxLength && props.initialValue?.length > props.maxLength) { setValue(props.initialValue?.slice(0, props.maxLength)) } else { setValue(props.initialValue ?? '') } }) const handleChangeValue = (event) => { setValue(event.target.value) } const handleKeyDown = async (event) => { if (event.key === 'Enter' && event.shiftKey) { return } if (event.key === 'Enter' && !event.shiftKey && value()?.trim().length > 0) { event.preventDefault() } } return (
0, })} > 0}>
{props.fieldName}