import { clsx } from 'clsx';
import { forwardRef } from 'react';
import { inputClassNameBase } from './_common.mjs';
import { useInputAttributes, useTextareaCharacterCount } from './contexts.mjs';
import { jsx } from 'react/jsx-runtime';

const TextArea = /*#__PURE__*/forwardRef(function TextArea({
  className,
  maxLength,
  ...restProps
}, reference) {
  const inputAttributes = useInputAttributes();
  const value = restProps.value ?? restProps.defaultValue ?? '';
  const currentLength = typeof value === 'string' ? value.length : String(value).length;
  useTextareaCharacterCount(currentLength, maxLength);
  return /*#__PURE__*/jsx("textarea", {
    ref: reference,
    className: clsx(className, inputClassNameBase(), 'np-text-area'),
    maxLength: maxLength,
    ...inputAttributes,
    ...restProps
  });
});

export { TextArea };
//# sourceMappingURL=TextArea.mjs.map
