UNPKG

@grafana/ui

Version:
1 lines 1.58 kB
{"version":3,"file":"FieldSet.mjs","sources":["../../../../src/components/Forms/FieldSet.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { HTMLProps } from 'react';\nimport * as React from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\n\nimport { useStyles2 } from '../../themes/ThemeContext';\n\nimport { Legend } from './Legend';\n\nexport interface Props extends Omit<HTMLProps<HTMLFieldSetElement>, 'label'> {\n children: React.ReactNode[] | React.ReactNode;\n /** Label for the fieldset's legend */\n label?: React.ReactNode;\n}\n\nexport const FieldSet = ({ label, children, className, ...rest }: Props) => {\n const styles = useStyles2(getStyles);\n\n return (\n <fieldset className={cx(styles.wrapper, className)} {...rest}>\n {label && <Legend>{label}</Legend>}\n {children}\n </fieldset>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n marginBottom: theme.spacing(4),\n\n '&:last-child': {\n marginBottom: 0,\n },\n }),\n});\n"],"names":[],"mappings":";;;;;AAgBa,MAAA,QAAA,GAAW,CAAC,EAAE,KAAA,EAAO,UAAU,SAAW,EAAA,GAAG,MAAkB,KAAA;AAC1E,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA;AAEnC,EACE,uBAAA,IAAA,CAAC,cAAS,SAAW,EAAA,EAAA,CAAG,OAAO,OAAS,EAAA,SAAS,CAAI,EAAA,GAAG,IACrD,EAAA,QAAA,EAAA;AAAA,IAAS,KAAA,oBAAA,GAAA,CAAC,UAAQ,QAAM,EAAA,KAAA,EAAA,CAAA;AAAA,IACxB;AAAA,GACH,EAAA,CAAA;AAEJ;AAEA,MAAM,SAAA,GAAY,CAAC,KAA0B,MAAA;AAAA,EAC3C,SAAS,GAAI,CAAA;AAAA,IACX,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAE7B,cAAgB,EAAA;AAAA,MACd,YAAc,EAAA;AAAA;AAChB,GACD;AACH,CAAA,CAAA;;;;"}