{"version":3,"file":"WidgetCard.mjs","names":["DeleteIcon","makeStyles","CircularProgress","lighten","clsx","React","useTranslation","FUICard","FUICardHeaderMenu","FUIMenuItem","WidgetCard","props","children","headerActions","className","widgetType","id","layout","params","setParam","onDelete","loading","errors","theme","hideWidgetName","innerPadding","contentHeight","contentMaxHeight","other","t","useStyles","root","display","darkRoot","background","color","anyRoot","justifyContent","overflow","padding","handle","cursor","backgroundColor","palette","action","hover","loadingContent","flex","flexDirection","alignItems","innerWidgetContentContainer","height","maxHeight","minWidth","spacing","classes","raised","test","body","defaultValue"],"sources":["../../src/dashboard/WidgetCard.jsx"],"sourcesContent":["import { DeleteIcon } from '@fluentui/react-icons';\nimport { makeStyles, CircularProgress, lighten } from '@material-ui/core';\nimport clsx from 'clsx';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\nimport FUICard, { FUICardHeaderMenu } from '../UI/surfaces/cards/fluentCards/FUICard';\nimport FUIMenuItem from '../UI/widgets/FluentComponents/FUIMenuItem';\n\n/**\n * Core component for dashboard widget cards\n */\nexport const WidgetCard = (props) => {\n  const {\n    children,\n    headerActions,\n    className,\n    widgetType,\n    id,\n    layout,\n    params,\n    setParam,\n    onDelete,\n    loading,\n    errors,\n    theme,\n    hideWidgetName,\n    innerPadding,\n    contentHeight,\n    contentMaxHeight,\n    ...other\n  } = props;\n\n  const { t } = useTranslation();\n\n  const useStyles = makeStyles((theme) => ({\n    root: {\n      '&.react-resizable-hide .react-resizable-handle': {\n        display: 'none'\n      }\n    },\n    darkRoot: {\n      '&.react-resizable-hide .react-resizable-handle': {\n        display: 'none'\n      },\n      background: '#424242',\n      color: 'white'\n    },\n    anyRoot: {\n      '& .MuiCardContent-root': {\n        justifyContent: 'space-between',\n        overflow: 'auto',\n        padding: 0\n      }\n    },\n    handle: {\n      cursor: 'move',\n      '&:hover': {\n        backgroundColor: theme.palette.action.hover\n      },\n      display: hideWidgetName && 'none'\n    },\n    loadingContent: {\n      flex: 1,\n      display: 'flex',\n      flexDirection: 'column',\n      alignItems: 'center',\n      justifyContent: 'center'\n    },\n    innerWidgetContentContainer: {\n      height:\n        widgetType === 'TransformerLoadWidget'\n          ? 'auto'\n          : contentHeight\n          ? contentHeight\n          : '100%',\n      maxHeight: contentMaxHeight ? contentMaxHeight : '',\n      minWidth: widgetType === 'ProgressBarWidget' ? 0 : 270,\n      display: 'flex',\n      flexDirection: 'column',\n      justifyContent: 'space-between',\n      padding:\n        innerPadding ||\n        (widgetType === 'VEERegisterRead' ? 0 : theme.spacing(2))\n    }\n  }));\n  const classes = useStyles();\n  const raised = /(^|\\s)react-draggable-dragging(\\s|$)/.test(className ?? '');\n\n  let body = children;\n  if (loading && !body) {\n    body = (\n      <div className={classes.loadingContent}>\n        <CircularProgress size={64} />\n      </div>\n    );\n  }\n  if (errors && !body) {\n    body = (\n      <div>\n        {t('dashboard.widgetCard.unexpectedError', {\n          defaultValue: 'Unexpected error'\n        })}\n      </div>\n    );\n  }\n\n  return (\n    <FUICard\n      {...other}\n      className={clsx(\n        className,\n        theme === 'dark' ? classes.darkRoot : classes.root,\n        classes.anyRoot\n      )}\n      raised={raised}\n      CardHeaderProps={{\n        className: classes.handle,\n        'data-handle': true\n      }}\n      headerActions={\n        <>\n          {headerActions}\n          <FUICardHeaderMenu>\n            <FUIMenuItem\n              onClick={onDelete}\n              fluentIcon={DeleteIcon}\n              primary={t('common.delete', { defaultValue: 'Delete' })}\n            />\n          </FUICardHeaderMenu>\n        </>\n      }\n    >\n      <div className={classes.innerWidgetContentContainer}>{body}</div>\n    </FUICard>\n  );\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAaU,cAAcC,UAAU;CACnC,MAAM,EACJC,UACAC,eACAC,WACAC,YACAC,IACAC,QACAC,QACAC,UACAC,UACAC,SACAC,QACAC,OACAC,gBACAC,cACAC,eACAC,kBACA,GAAGC,UACDjB;CAEJ,MAAM,EAAEkB,MAAMvB,gBAAgB;CAqD9B,MAAMiD,UAnDYtD,YAAYsB,aAAW;EACvCQ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