@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 2.95 kB
Source Map (JSON)
{"version":3,"file":"Textarea.mjs","names":[],"sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n BoxProps,\n ElementProps,\n factory,\n Factory,\n getEnv,\n StylesApiProps,\n useProps,\n} from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { TextareaAutosize } from './Autosize';\n\nexport interface TextareaProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<TextareaFactory>,\n ElementProps<'textarea', 'size'> {\n __staticSelector?: string;\n\n /** If set, enables textarea height growing with its content @default false */\n autosize?: boolean;\n\n /** Maximum rows for autosize textarea to grow, ignored if `autosize` prop is not set */\n maxRows?: number;\n\n /** Minimum rows of autosize textarea, ignored if `autosize` prop is not set */\n minRows?: number;\n\n /** Controls `resize` CSS property @default 'none' */\n resize?: React.CSSProperties['resize'];\n\n /** Content rendered at the bottom of the input, inside the border */\n bottomSection?: React.ReactNode;\n\n /** Props passed down to the `bottomSection` element */\n bottomSectionProps?: React.ComponentProps<'div'>;\n}\n\nexport type TextareaFactory = Factory<{\n props: TextareaProps;\n ref: HTMLTextAreaElement;\n stylesNames: __InputStylesNames;\n}>;\n\nexport const Textarea = factory<TextareaFactory>((props) => {\n const {\n autosize,\n maxRows,\n minRows,\n __staticSelector,\n resize,\n bottomSection,\n bottomSectionProps,\n ...others\n } = useProps(['Input', 'InputWrapper', 'Textarea'], null, props);\n\n const shouldAutosize = autosize && getEnv() !== 'test';\n const autosizeProps = shouldAutosize ? { maxRows, minRows } : {};\n\n return (\n <InputBase<any>\n component={shouldAutosize ? TextareaAutosize : 'textarea'}\n {...others}\n __staticSelector={__staticSelector || 'Textarea'}\n __bottomSection={bottomSection}\n __bottomSectionProps={bottomSectionProps}\n multiline\n data-no-overflow={(autosize && maxRows === undefined) || undefined}\n __vars={{ '--input-resize': resize }}\n {...autosizeProps}\n />\n );\n});\n\nTextarea.classes = InputBase.classes;\nTextarea.displayName = '@mantine/core/Textarea';\n\nexport namespace Textarea {\n export type Props = TextareaProps;\n export type Factory = TextareaFactory;\n}\n"],"mappings":";;;;;;;;AA8CA,MAAa,WAAW,SAA0B,UAAU;CAC1D,MAAM,EACJ,UACA,SACA,SACA,kBACA,QACA,eACA,oBACA,GAAG,WACD,SAAS;EAAC;EAAS;EAAgB;CAAU,GAAG,MAAM,KAAK;CAE/D,MAAM,iBAAiB,YAAY,OAAO,MAAM;CAChD,MAAM,gBAAgB,iBAAiB;EAAE;EAAS;CAAQ,IAAI,CAAC;CAE/D,OACE,oBAAC,WAAD;EACE,WAAW,iBAAiB,mBAAmB;EAC/C,GAAI;EACJ,kBAAkB,oBAAoB;EACtC,iBAAiB;EACjB,sBAAsB;EACtB,WAAA;EACA,oBAAmB,YAAY,YAAY,KAAA,KAAc,KAAA;EACzD,QAAQ,EAAE,kBAAkB,OAAO;EACnC,GAAI;CACL,CAAA;AAEL,CAAC;AAED,SAAS,UAAU,UAAU;AAC7B,SAAS,cAAc"}