{"version":3,"file":"ListLoadErrorIndicator.mjs","names":[],"sources":["../../../../src/components/Loading/ListLoadErrorIndicator.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\n\nimport { Button } from '../Button';\nimport { useComponentContextIcons, useTranslationContext } from '../../context';\n\n/** Props of the component a paginated list renders when its first page failed to load. */\nexport type ListLoadErrorIndicatorProps = {\n  /** The error of the failed query. */\n  error: Error;\n  /** A retry is running; the list keeps this component on screen meanwhile. */\n  isRetrying: boolean;\n  /** Queries the first page again, unless a retry is running. */\n  retry: () => void;\n};\n\nexport type DefaultListLoadErrorIndicatorProps = ListLoadErrorIndicatorProps & {\n  /** Which list failed to load; picks the explanation. */\n  listType: 'channel' | 'thread';\n};\n\n/**\n * Shown in place of a list whose first page failed to load: an icon, a short explanation and a\n * button that queries the first page again.\n */\nexport const ListLoadErrorIndicator = ({\n  isRetrying,\n  listType,\n  retry,\n}: DefaultListLoadErrorIndicatorProps) => {\n  const { t } = useTranslationContext();\n  const { IconExclamationMark } = useComponentContextIcons();\n\n  const text =\n    listType === 'channel'\n      ? t('channelList.loadError.text', \"Couldn't load conversations\")\n      : t('threadList.loadError.text', \"Couldn't load threads\");\n\n  return (\n    <div\n      className={clsx(\n        'str-chat__list-load-error',\n        `str-chat__${listType}-list-load-error`,\n      )}\n    >\n      <IconExclamationMark className='str-chat__list-load-error__icon' />\n      <div className='str-chat__list-load-error__content'>\n        <p className='str-chat__list-load-error__title'>{text}</p>\n        {/* aria-disabled, not disabled: a disabled button would lose focus. */}\n        <Button\n          appearance='outline'\n          aria-busy={isRetrying}\n          aria-disabled={isRetrying}\n          className='str-chat__list-load-error__retry-button'\n          onClick={retry}\n          size='md'\n          variant='secondary'\n        >\n          {t('common.tryAgain.label', 'Try again')}\n        </Button>\n      </div>\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;;;AAyBA,IAAa,0BAA0B,EACrC,YACA,UACA,YACwC;CACxC,MAAM,EAAE,MAAM,sBAAsB;CACpC,MAAM,EAAE,wBAAwB,yBAAyB;CAEzD,MAAM,OACJ,aAAa,YACT,EAAE,8BAA8B,6BAA6B,IAC7D,EAAE,6BAA6B,uBAAuB;CAE5D,OACE,qBAAC,OAAD;EACE,WAAW,KACT,6BACA,aAAa,SAAS,iBACxB;YAJF,CAME,oBAAC,qBAAD,EAAqB,WAAU,kCAAmC,CAAA,GAClE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,KAAD;IAAG,WAAU;cAAoC;GAAQ,CAAA,GAEzD,oBAAC,QAAD;IACE,YAAW;IACX,aAAW;IACX,iBAAe;IACf,WAAU;IACV,SAAS;IACT,MAAK;IACL,SAAQ;cAEP,EAAE,yBAAyB,WAAW;GACjC,CAAA,CACL;IACF;;AAET"}