@grafana/ui
Version:
Grafana Components Library
1 lines • 2.28 kB
Source Map (JSON)
{"version":3,"file":"TextArea.mjs","sources":["../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { forwardRef, HTMLProps } from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\n\nimport { useStyles2 } from '../../themes/ThemeContext';\nimport { getFocusStyle, sharedInputStyle } from '../Forms/commonStyles';\n\nexport interface Props extends Omit<HTMLProps<HTMLTextAreaElement>, 'size'> {\n /** Show an invalid state around the input */\n invalid?: boolean;\n}\n\n/**\n * Use for multi line inputs like descriptions.\n *\n * https://developers.grafana.com/ui/latest/index.html?path=/docs/inputs-textarea--docs\n */\nexport const TextArea = forwardRef<HTMLTextAreaElement, Props>(({ invalid, className, ...props }, ref) => {\n const styles = useStyles2(getTextAreaStyle, invalid);\n\n return <textarea {...props} className={cx(styles.textarea, className)} ref={ref} />;\n});\n\nconst getTextAreaStyle = (theme: GrafanaTheme2, invalid = false) => ({\n textarea: cx(\n sharedInputStyle(theme),\n getFocusStyle(theme),\n css({\n display: 'block',\n borderRadius: theme.shape.radius.default,\n padding: `${theme.spacing.gridSize / 4}px ${theme.spacing.gridSize}px`,\n width: '100%',\n borderColor: invalid ? theme.colors.error.border : theme.components.input.borderColor,\n })\n ),\n});\n\nTextArea.displayName = 'TextArea';\n"],"names":[],"mappings":";;;;;;;AAkBO,MAAM,QAAA,GAAW,WAAuC,CAAC,EAAE,SAAS,SAAA,EAAW,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AACxG,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,gBAAA,EAAkB,OAAO,CAAA;AAEnD,EAAA,uBAAO,GAAA,CAAC,UAAA,EAAA,EAAU,GAAG,KAAA,EAAO,SAAA,EAAW,GAAG,MAAA,CAAO,QAAA,EAAU,SAAS,CAAA,EAAG,GAAA,EAAU,CAAA;AACnF,CAAC;AAED,MAAM,gBAAA,GAAmB,CAAC,KAAA,EAAsB,OAAA,GAAU,KAAA,MAAW;AAAA,EACnE,QAAA,EAAU,EAAA;AAAA,IACR,iBAAiB,KAAK,CAAA;AAAA,IACtB,cAAc,KAAK,CAAA;AAAA,IACnB,GAAA,CAAI;AAAA,MACF,OAAA,EAAS,OAAA;AAAA,MACT,YAAA,EAAc,KAAA,CAAM,KAAA,CAAM,MAAA,CAAO,OAAA;AAAA,MACjC,OAAA,EAAS,GAAG,KAAA,CAAM,OAAA,CAAQ,WAAW,CAAC,CAAA,GAAA,EAAM,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,EAAA,CAAA;AAAA,MAClE,KAAA,EAAO,MAAA;AAAA,MACP,WAAA,EAAa,UAAU,KAAA,CAAM,MAAA,CAAO,MAAM,MAAA,GAAS,KAAA,CAAM,WAAW,KAAA,CAAM;AAAA,KAC3E;AAAA;AAEL,CAAA,CAAA;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA;;;;"}