{"version":3,"file":"WidgetCard.mjs","names":["React","Fragment","DeleteIcon","makeStyles","CircularProgress","clsx","useTranslation","FUICard","FUICardHeaderMenu","FUIMenuItem","WidgetCard","props","children","headerActions","className","widgetType","id","layout","params","setParam","onDelete","loading","errors","theme","other","t","useStyles","root","display","darkRoot","background","color","anyRoot","justifyContent","overflow","padding","handle","cursor","backgroundColor","palette","action","hover","loadingContent","flex","flexDirection","alignItems","innerWidgetContentContainer","height","minWidth","spacing","classes","raised","test","body","defaultValue"],"sources":["../../../src/UI/widgets/WidgetCard.jsx"],"sourcesContent":["import React, { Fragment } from 'react';\nimport { DeleteIcon } from '@fluentui/react-icons';\nimport { makeStyles, CircularProgress } from '@material-ui/core';\nimport clsx from 'clsx';\nimport { useTranslation } from 'react-i18next';\nimport FUICard, { FUICardHeaderMenu } from '../surfaces/cards/fluentCards/FUICard';\nimport FUIMenuItem from './FluentComponents/FUIMenuItem';\n\n/**\n * Core component for dashboard widget cards\n */\nconst 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    ...other\n  } = props;\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    },\n    loadingContent: {\n      flex: 1,\n      display: 'flex',\n      flexDirection: 'column',\n      alignItems: 'center',\n      justifyContent: 'center'\n    },\n    innerWidgetContentContainer: {\n      height: '100%',\n      minWidth: widgetType === 'ProgressBarWidget' ? 0 : 270,\n      display: 'flex',\n      flexDirection: 'column',\n      justifyContent: 'space-between',\n      padding: theme.spacing(2)\n    }\n  }));\n  const classes = useStyles();\n\n  const raised = /(^|\\s)react-draggable-dragging(\\s|$)/.test(className ?? '');\n  let body = children;\n  if (loading) {\n    body = (\n      <div className={classes.loadingContent}>\n        <CircularProgress color='secondary' size={64} />\n      </div>\n    );\n  }\n  if (errors && !body) {\n    body = (\n      <div>\n        {t('ui.widgets.unexpectedError', { defaultValue: 'Unexpected error' })}\n      </div>\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\nexport default WidgetCard;\n"],"mappings":";;;;;;;;;;;AAWA,MAAMU,cAAcC,UAAU;CAC5B,MAAM,EACJC,UACAC,eACAC,WACAC,YACAC,IACAC,QACAC,QACAC,UACAC,UACAC,SACAC,QACAC,OACA,GAAGC,UACDb;CACJ,MAAM,EAAEc,MAAMnB,gBAAgB;CA4C9B,MAAM4C,UA1CY/C,YAAYoB,aAAW;EACvCI,MAAM,EACJ,kDAAkD,EAChDC,SAAS,QACX,EACD;EACDC,UAAU;GACR,kDAAkD,EAChDD,SAAS,QACV;GACDE,YAAY;GACZC,OAAO;GACR;EACDC,SAAS,EACP,0BAA0B;GACxBC,gBAAgB;GAChBC,UAAU;GACVC,SAAS;GACX,EACD;EACDC,QAAQ;GACNC,QAAQ;GACR,WAAW,EACTC,iBAAiBf,QAAMgB,QAAQC,OAAOC,OACxC;GACD;EACDC,gB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