UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 2.67 kB
{"version":3,"file":"Textarea.cjs","names":["factory","useProps","getEnv","InputBase","TextareaAutosize"],"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\nexport type TextareaFactory = Factory<{\n props: TextareaProps;\n ref: HTMLTextAreaElement;\n stylesNames: __InputStylesNames;\n}>;\n\nexport const Textarea = factory<TextareaFactory>((props) => {\n const { autosize, maxRows, minRows, __staticSelector, resize, ...others } = useProps(\n ['Input', 'InputWrapper', 'Textarea'],\n null,\n props\n );\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 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":";;;;;;;;;AAwCA,MAAa,WAAWA,gBAAAA,SAA0B,UAAU;CAC1D,MAAM,EAAE,UAAU,SAAS,SAAS,kBAAkB,QAAQ,GAAG,WAAWC,kBAAAA,SAC1E;EAAC;EAAS;EAAgB;CAAU,GACpC,MACA,KACF;CAEA,MAAM,iBAAiB,YAAYC,gBAAAA,OAAO,MAAM;CAChD,MAAM,gBAAgB,iBAAiB;EAAE;EAAS;CAAQ,IAAI,CAAC;CAE/D,OACE,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;EACE,WAAW,iBAAiBC,iBAAAA,mBAAmB;EAC/C,GAAI;EACJ,kBAAkB,oBAAoB;EACtC,WAAA;EACA,oBAAmB,YAAY,YAAY,KAAA,KAAc,KAAA;EACzD,QAAQ,EAAE,kBAAkB,OAAO;EACnC,GAAI;CACL,CAAA;AAEL,CAAC;AAED,SAAS,UAAUD,kBAAAA,UAAU;AAC7B,SAAS,cAAc"}