UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 2.62 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\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<TextareaProps>;\n\nexport const Textarea = factory<TextareaFactory>((props) => {\n const { autosize, maxRows, minRows, __staticSelector, resize, ...others } = useProps(\n 'Textarea',\n defaultProps,\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"],"mappings":";;;;;;;;;AAwCA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,WAAWA,gBAAAA,SAA0B,UAAU;CAC1D,MAAM,EAAE,UAAU,SAAS,SAAS,kBAAkB,QAAQ,GAAG,WAAWC,kBAAAA,SAC1E,YACA,cACA,MACD;CAED,MAAM,iBAAiB,YAAYC,gBAAAA,QAAQ,KAAK;CAChD,MAAM,gBAAgB,iBAAiB;EAAE;EAAS;EAAS,GAAG,EAAE;AAEhE,QACE,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,QAAQ;EACpC,GAAI;EACJ,CAAA;EAEJ;AAEF,SAAS,UAAUD,kBAAAA,UAAU;AAC7B,SAAS,cAAc"}