import { Story, Preview, Props, Meta } from "@storybook/addon-docs/blocks";
import { ComponentHeading } from "../../storybook-components";
import { ORIENTATION } from "../../types";
import { Stack } from "../Stack";
import { Textarea } from "./Textarea";

<Meta title="Components/Forms/Textarea" component={Textarea} />

<ComponentHeading
  componentName="Textarea"
  description="Multi-line text input with automatic resizing"
  sourcePath="src/components/Textarea/Textarea.tsx"
/>

```jsx
import { Textarea } from "@aptible/arrow-ds";
```

<Preview>
  <Story name="Default">
    <Textarea placeholder="This Textarea expands automatically up to eight rows" />
  </Story>
</Preview>

## Props

These props extend `TextareaHTMLAttributes<HTMLTextAreaElement>`.

<Props of={Textarea} />

## Demos

### Sizing

The `rows` prop defines the default/minimum size. The `maxRows` prop is the number of rows allowed
before making the `Textarea` scrollable.

<Preview>
  <Story name="Sizing">
    <Textarea rows={2} maxRows={3} placeholder="Two or three rows" />
  </Story>
</Preview>

### Resizing

The `resize` prop sets whether an element is resizable, and if so, in which directions.
The `maxRows` prop is not compatible with the `resize` prop and should throw a TS error if you try to use both.

<Preview>
  <Story name="Resizing">
    <Stack orientation={ORIENTATION.VERTICAL}>
      <Textarea placeholder="vertical" resize="vertical" />
      <Textarea placeholder="horizontal" resize="horizontal" />
      <Textarea placeholder="both" resize="both" />
      <Textarea placeholder="none" resize="none" />
    </Stack>
  </Story>
</Preview>

### With monospace font

<Preview>
  <Story name="Code editor">
    <Textarea placeholder="Monospace font" rows={10} className="font-mono" />
  </Story>
</Preview>
