@digigov/ui 0.11.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +4 -0
- package/.prettierrc.js +3 -0
- package/.rush/temp/package-deps_build.json +176 -0
- package/.rush/temp/shrinkwrap-deps.json +278 -0
- package/CHANGELOG.json +796 -0
- package/CHANGELOG.md +22 -1
- package/docs/components.mdx +1 -0
- package/docs/create-a-new-service.mdx +93 -0
- package/docs/create-common-page-layout.mdx +205 -0
- package/docs/create-static-page.mdx +179 -0
- package/docs/edit-start-page.mdx +143 -0
- package/docs/index.mdx +66 -0
- package/docs/introduction.mdx +34 -0
- package/package.json +31 -8
- package/src/api/APIErrors.tsx +44 -0
- package/src/api/APIProvider.tsx +27 -0
- package/src/api/fetchAPI.ts +45 -0
- package/src/api/index.spec.tsx +419 -0
- package/{esm/api/index.js → src/api/index.tsx} +6 -3
- package/{api → src/api}/introduction.md +0 -0
- package/src/api/useResource.tsx +96 -0
- package/src/api/useResourceAction.tsx +80 -0
- package/src/api/useResourceQuery.tsx +177 -0
- package/src/api/utils.tsx +156 -0
- package/src/app/App.tsx +33 -0
- package/{app/Confirmation/index.d.ts → src/app/Confirmation/index.tsx} +0 -0
- package/{app/Footer/index.d.ts → src/app/Footer/index.tsx} +0 -0
- package/{es/app/Header/HeaderLogo.js → src/app/Header/HeaderLogo.tsx} +9 -7
- package/src/app/Header/HeaderSection.tsx +13 -0
- package/src/app/Header/HeaderTitle.tsx +24 -0
- package/{app → src/app}/Header/__snapshots__/index.spec.tsx.snap +0 -0
- package/{app → src/app}/Header/index.mdx +0 -0
- package/src/app/Header/index.spec.tsx +32 -0
- package/{esm/app/Header/index.js → src/app/Header/index.tsx} +10 -4
- package/src/app/NotFound/index.tsx +21 -0
- package/src/app/OutdatedBrowserBanner.tsx +37 -0
- package/src/app/PageTitle.tsx +70 -0
- package/{app → src/app}/QrCodeScanner/__snapshots__/index.spec.tsx.snap +0 -0
- package/{app → src/app}/QrCodeScanner/index.mdx +0 -0
- package/src/app/QrCodeScanner/index.spec.tsx +19 -0
- package/src/app/QrCodeScanner/index.tsx +90 -0
- package/src/app/i18n.tsx +44 -0
- package/{app/index.d.ts → src/app/index.ts} +0 -0
- package/{core → src/core}/Accordion/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/Accordion/index.mdx +0 -0
- package/src/core/Accordion/index.spec.tsx +30 -0
- package/src/core/Accordion/index.tsx +86 -0
- package/{core → src/core}/Blockquote/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/Blockquote/index.mdx +0 -0
- package/src/core/Blockquote/index.spec.tsx +10 -0
- package/{esm/core/Blockquote/index.js → src/core/Blockquote/index.tsx} +9 -7
- package/{core/Breadcrumbs/index.d.ts → src/core/Breadcrumbs/index.tsx} +0 -0
- package/{esm/core/Button/BackButton.js → src/core/Button/BackButton.tsx} +10 -8
- package/src/core/Button/ButtonLink.tsx +20 -0
- package/src/core/Button/CallToAction.tsx +31 -0
- package/src/core/Button/Icon.tsx +9 -0
- package/{core → src/core}/Button/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/Button/index.mdx +0 -0
- package/src/core/Button/index.spec.tsx +8 -0
- package/src/core/Button/index.tsx +46 -0
- package/{core/Card/index.d.ts → src/core/Card/index.tsx} +0 -0
- package/{core → src/core}/Details/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/Details/index.mdx +0 -0
- package/src/core/Details/index.spec.tsx +38 -0
- package/{core/Details/index.d.ts → src/core/Details/index.tsx} +2 -0
- package/src/core/Divider/index.tsx +13 -0
- package/{core → src/core}/ErrorSummary/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/ErrorSummary/index.mdx +0 -0
- package/src/core/ErrorSummary/index.spec.tsx +10 -0
- package/{core/ErrorSummary/index.d.ts → src/core/ErrorSummary/index.tsx} +1 -0
- package/{core/Hidden/index.d.ts → src/core/Hidden/index.tsx} +0 -0
- package/{core → src/core}/Link/__snapshots__/index.spec.tsx.snap +0 -0
- package/src/core/Link/index.spec.tsx +22 -0
- package/src/core/Link/index.tsx +41 -0
- package/{core/List/List.d.ts → src/core/List/List.tsx} +2 -0
- package/{core/List/ListItem.d.ts → src/core/List/ListItem.tsx} +2 -0
- package/src/core/List/ListItemContent.tsx +32 -0
- package/src/core/List/ListItemIcon.tsx +31 -0
- package/src/core/List/ListItemText.tsx +23 -0
- package/src/core/List/ListItemTitle.tsx +37 -0
- package/{core → src/core}/List/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/List/index.mdx +0 -0
- package/src/core/List/index.spec.tsx +10 -0
- package/{core/List/index.d.ts → src/core/List/index.tsx} +0 -0
- package/src/core/NavList/NavList.tsx +103 -0
- package/src/core/NavList/NavListContext.tsx +85 -0
- package/src/core/NavList/NavListItem.tsx +143 -0
- package/src/core/NavList/NavListItemBase.tsx +146 -0
- package/src/core/NavList/NavListSubMenu.tsx +33 -0
- package/{core → src/core}/NavList/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/NavList/index.mdx +0 -0
- package/src/core/NavList/index.spec.tsx +10 -0
- package/{core/NavList/index.d.ts → src/core/NavList/index.tsx} +0 -0
- package/{core → src/core}/NotificationBanner/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/NotificationBanner/index.mdx +0 -0
- package/src/core/NotificationBanner/index.spec.tsx +27 -0
- package/src/core/NotificationBanner/index.tsx +52 -0
- package/{core → src/core}/ServiceBadge/ServiceBadge.mdx +0 -0
- package/{core → src/core}/ServiceBadge/index.mdx +0 -0
- package/src/core/ServiceBadge/index.tsx +35 -0
- package/{core → src/core}/SummaryList/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/SummaryList/index.mdx +0 -0
- package/src/core/SummaryList/index.spec.tsx +28 -0
- package/{core/SummaryList/index.d.ts → src/core/SummaryList/index.tsx} +2 -0
- package/{core/Table/index.d.ts → src/core/Table/index.tsx} +0 -0
- package/{core → src/core}/Tabs/index.mdx +0 -0
- package/src/core/Tabs/index.tsx +36 -0
- package/{core/VisuallyHidden/index.d.ts → src/core/VisuallyHidden/index.tsx} +0 -0
- package/{core → src/core}/WarningText/__snapshots__/index.spec.tsx.snap +0 -0
- package/{core → src/core}/WarningText/index.mdx +0 -0
- package/src/core/WarningText/index.spec.tsx +10 -0
- package/{core/WarningText/index.d.ts → src/core/WarningText/index.tsx} +1 -0
- package/{core/index.d.ts → src/core/index.ts} +3 -0
- package/src/custom.d.ts +8 -0
- package/{es → src}/form/inputs/Input/index.mdx +0 -0
- package/src/govgr/Footer/Copyright.tsx +64 -0
- package/{govgr/Footer/HellenicRepublicLogo.d.ts → src/govgr/Footer/HellenicRepublicLogo.tsx} +1 -0
- package/src/govgr/Footer/LicenseCCSA.tsx +24 -0
- package/{es → src}/govgr/Footer/index.mdx +0 -0
- package/src/govgr/Footer/index.tsx +49 -0
- package/{esm/govgr/Footer/logo.js → src/govgr/Footer/logo.ts} +1 -1
- package/{esm/govgr/Footer/logos/logo-el.js → src/govgr/Footer/logos/logo-el.ts} +1 -1
- package/{esm/govgr/Footer/logos/logo-en.js → src/govgr/Footer/logos/logo-en.ts} +1 -1
- package/{es → src}/govgr/Logo/govgr-logo.svg +0 -0
- package/{govgr/Logo/index.d.ts → src/govgr/Logo/index.tsx} +2 -0
- package/{es/govgr/Logo/logo.js → src/govgr/Logo/logo.ts} +1 -1
- package/{govgr/index.d.ts → src/govgr/index.ts} +0 -0
- package/src/hooks/useDebounce.ts +50 -0
- package/src/hooks/useLatest.ts +12 -0
- package/{esm/hooks/useOutdatedBrowserCheck.js → src/hooks/useOutdatedBrowserCheck.ts} +16 -15
- package/src/hooks/useSearch.ts +47 -0
- package/src/hooks/useTogglableSections.tsx +102 -0
- package/{index.d.ts → src/index.ts} +0 -0
- package/{es → src}/layouts/Basic/Bottom/index.mdx +0 -0
- package/{layouts/Basic/Bottom/index.d.ts → src/layouts/Basic/Bottom/index.tsx} +1 -0
- package/{es → src}/layouts/Basic/Content/index.mdx +0 -0
- package/src/layouts/Basic/Content/index.tsx +24 -0
- package/{es → src}/layouts/Basic/Main/index.mdx +0 -0
- package/{layouts/Basic/Main/index.d.ts → src/layouts/Basic/Main/index.tsx} +1 -0
- package/{es → src}/layouts/Basic/Masthead/index.mdx +0 -0
- package/{layouts/Basic/Masthead/index.d.ts → src/layouts/Basic/Masthead/index.tsx} +2 -0
- package/{es → src}/layouts/Basic/Side/index.mdx +0 -0
- package/{esm/layouts/Basic/Side/index.js → src/layouts/Basic/Side/index.tsx} +5 -3
- package/{es → src}/layouts/Basic/Top/index.mdx +0 -0
- package/{es/layouts/Basic/Top/index.js → src/layouts/Basic/Top/index.tsx} +7 -5
- package/{es → src}/layouts/Basic/__snapshots__/index.spec.tsx.snap +0 -0
- package/{es → src}/layouts/Basic/index.mdx +0 -0
- package/src/layouts/Basic/index.spec.tsx +24 -0
- package/{layouts/Basic/index.d.ts → src/layouts/Basic/index.tsx} +2 -0
- package/{layouts/Grid/index.d.ts → src/layouts/Grid/index.tsx} +0 -0
- package/{layouts/index.d.ts → src/layouts/index.ts} +0 -0
- package/src/locales/el.ts +60 -0
- package/{esm/locales/en.js → src/locales/en.ts} +25 -11
- package/{es → src}/router/index.mdx +0 -0
- package/src/router/index.tsx +28 -0
- package/src/test-utils/delay.ts +9 -0
- package/src/test-utils/mountWithTheme.tsx +33 -0
- package/{es → src}/themes/govgr.js +33 -29
- package/src/themes/grnet.js +109 -0
- package/src/themes/index.tsx +38 -0
- package/src/typography/Caption.tsx +15 -0
- package/src/typography/NormalText.tsx +7 -0
- package/src/typography/Paragraph.tsx +9 -0
- package/src/typography/Title.tsx +51 -0
- package/{es → src}/typography/index.mdx +0 -0
- package/{typography/index.d.ts → src/typography/index.ts} +0 -0
- package/src/utils/evaluateBrowserVersion.ts +346 -0
- package/src/utils/withDeprecation.tsx +97 -0
- package/tsconfig.json +18 -0
- package/tsconfig.production.json +27 -0
- package/ui.build.log +17 -0
- package/LICENSE +0 -0
- package/api/APIErrors.d.ts +0 -22
- package/api/APIErrors.js +0 -117
- package/api/APIProvider.d.ts +0 -15
- package/api/APIProvider.js +0 -43
- package/api/fetchAPI.d.ts +0 -18
- package/api/fetchAPI.js +0 -64
- package/api/index.d.ts +0 -9
- package/api/index.js +0 -104
- package/api/index.spec.d.ts +0 -1
- package/api/index.spec.js +0 -584
- package/api/useResource.d.ts +0 -11
- package/api/useResource.js +0 -144
- package/api/useResourceAction.d.ts +0 -2
- package/api/useResourceAction.js +0 -157
- package/api/useResourceQuery.d.ts +0 -18
- package/api/useResourceQuery.js +0 -229
- package/api/utils.d.ts +0 -6
- package/api/utils.js +0 -250
- package/app/App.d.ts +0 -14
- package/app/App.js +0 -49
- package/app/Confirmation/index.js +0 -44
- package/app/Footer/index.js +0 -200
- package/app/Header/HeaderLogo.d.ts +0 -3
- package/app/Header/HeaderLogo.js +0 -30
- package/app/Header/HeaderSection.d.ts +0 -5
- package/app/Header/HeaderSection.js +0 -20
- package/app/Header/HeaderTitle.d.ts +0 -5
- package/app/Header/HeaderTitle.js +0 -30
- package/app/Header/index.d.ts +0 -11
- package/app/Header/index.js +0 -106
- package/app/Header/index.spec.d.ts +0 -1
- package/app/Header/index.spec.js +0 -45
- package/app/NotFound/index.d.ts +0 -3
- package/app/NotFound/index.js +0 -29
- package/app/OutdatedBrowserBanner.d.ts +0 -2
- package/app/OutdatedBrowserBanner.js +0 -41
- package/app/PageTitle.d.ts +0 -10
- package/app/PageTitle.js +0 -76
- package/app/QrCodeScanner/index.d.ts +0 -29
- package/app/QrCodeScanner/index.js +0 -85
- package/app/QrCodeScanner/index.spec.d.ts +0 -1
- package/app/QrCodeScanner/index.spec.js +0 -26
- package/app/i18n.d.ts +0 -10
- package/app/i18n.js +0 -57
- package/app/index.js +0 -70
- package/core/Accordion/index.d.ts +0 -21
- package/core/Accordion/index.js +0 -127
- package/core/Accordion/index.spec.d.ts +0 -1
- package/core/Accordion/index.spec.js +0 -19
- package/core/Blockquote/index.d.ts +0 -3
- package/core/Blockquote/index.js +0 -29
- package/core/Blockquote/index.spec.d.ts +0 -1
- package/core/Blockquote/index.spec.js +0 -21
- package/core/Breadcrumbs/index.js +0 -44
- package/core/Button/BackButton.d.ts +0 -3
- package/core/Button/BackButton.js +0 -34
- package/core/Button/ButtonLink.d.ts +0 -4
- package/core/Button/ButtonLink.js +0 -28
- package/core/Button/CallToAction.d.ts +0 -7
- package/core/Button/CallToAction.js +0 -41
- package/core/Button/Icon.d.ts +0 -2
- package/core/Button/Icon.js +0 -19
- package/core/Button/index.d.ts +0 -15
- package/core/Button/index.js +0 -121
- package/core/Button/index.spec.d.ts +0 -1
- package/core/Button/index.spec.js +0 -21
- package/core/Card/index.js +0 -57
- package/core/Details/index.js +0 -35
- package/core/Details/index.spec.d.ts +0 -1
- package/core/Details/index.spec.js +0 -27
- package/core/Divider/index.d.ts +0 -5
- package/core/Divider/index.js +0 -20
- package/core/ErrorSummary/index.js +0 -19
- package/core/ErrorSummary/index.spec.d.ts +0 -1
- package/core/ErrorSummary/index.spec.js +0 -21
- package/core/Hidden/index.js +0 -18
- package/core/Link/index.d.ts +0 -12
- package/core/Link/index.js +0 -50
- package/core/Link/index.spec.d.ts +0 -1
- package/core/Link/index.spec.js +0 -31
- package/core/List/List.js +0 -19
- package/core/List/ListItem.js +0 -19
- package/core/List/ListItemContent.d.ts +0 -7
- package/core/List/ListItemContent.js +0 -45
- package/core/List/ListItemIcon.d.ts +0 -7
- package/core/List/ListItemIcon.js +0 -48
- package/core/List/ListItemText.d.ts +0 -8
- package/core/List/ListItemText.js +0 -36
- package/core/List/ListItemTitle.d.ts +0 -10
- package/core/List/ListItemTitle.js +0 -44
- package/core/List/index.js +0 -96
- package/core/List/index.spec.d.ts +0 -1
- package/core/List/index.spec.js +0 -21
- package/core/NavList/NavList.d.ts +0 -17
- package/core/NavList/NavList.js +0 -99
- package/core/NavList/NavListContext.d.ts +0 -20
- package/core/NavList/NavListContext.js +0 -102
- package/core/NavList/NavListItem.d.ts +0 -13
- package/core/NavList/NavListItem.js +0 -171
- package/core/NavList/NavListItemBase.d.ts +0 -16
- package/core/NavList/NavListItemBase.js +0 -161
- package/core/NavList/NavListSubMenu.d.ts +0 -8
- package/core/NavList/NavListSubMenu.js +0 -52
- package/core/NavList/index.js +0 -68
- package/core/NavList/index.spec.d.ts +0 -1
- package/core/NavList/index.spec.js +0 -21
- package/core/NotificationBanner/index.d.ts +0 -18
- package/core/NotificationBanner/index.js +0 -78
- package/core/NotificationBanner/index.spec.d.ts +0 -1
- package/core/NotificationBanner/index.spec.js +0 -32
- package/core/ServiceBadge/index.d.ts +0 -9
- package/core/ServiceBadge/index.js +0 -36
- package/core/SummaryList/index.js +0 -79
- package/core/SummaryList/index.spec.d.ts +0 -1
- package/core/SummaryList/index.spec.js +0 -19
- package/core/Table/index.js +0 -96
- package/core/Tabs/index.d.ts +0 -16
- package/core/Tabs/index.js +0 -88
- package/core/VisuallyHidden/index.js +0 -18
- package/core/WarningText/index.js +0 -19
- package/core/WarningText/index.spec.d.ts +0 -1
- package/core/WarningText/index.spec.js +0 -21
- package/core/index.js +0 -199
- package/custom.d.js +0 -1
- package/es/api/APIErrors.js +0 -96
- package/es/api/APIProvider.js +0 -25
- package/es/api/fetchAPI.js +0 -49
- package/es/api/index.js +0 -13
- package/es/api/index.spec.js +0 -546
- package/es/api/introduction.md +0 -6
- package/es/api/useResource.js +0 -128
- package/es/api/useResourceAction.js +0 -141
- package/es/api/useResourceQuery.js +0 -208
- package/es/api/utils.js +0 -233
- package/es/app/App.js +0 -27
- package/es/app/Confirmation/index.js +0 -3
- package/es/app/Footer/index.js +0 -15
- package/es/app/Header/HeaderSection.js +0 -7
- package/es/app/Header/HeaderTitle.js +0 -17
- package/es/app/Header/__snapshots__/index.spec.tsx.snap +0 -393
- package/es/app/Header/index.js +0 -13
- package/es/app/Header/index.mdx +0 -50
- package/es/app/Header/index.spec.js +0 -32
- package/es/app/NotFound/index.js +0 -12
- package/es/app/OutdatedBrowserBanner.js +0 -24
- package/es/app/PageTitle.js +0 -57
- package/es/app/QrCodeScanner/__snapshots__/index.spec.tsx.snap +0 -22
- package/es/app/QrCodeScanner/index.js +0 -64
- package/es/app/QrCodeScanner/index.mdx +0 -22
- package/es/app/QrCodeScanner/index.spec.js +0 -13
- package/es/app/i18n.js +0 -36
- package/es/app/index.js +0 -5
- package/es/core/Accordion/__snapshots__/index.spec.tsx.snap +0 -78
- package/es/core/Accordion/index.js +0 -67
- package/es/core/Accordion/index.mdx +0 -104
- package/es/core/Accordion/index.spec.js +0 -9
- package/es/core/Blockquote/__snapshots__/index.spec.tsx.snap +0 -13
- package/es/core/Blockquote/index.js +0 -16
- package/es/core/Blockquote/index.mdx +0 -61
- package/es/core/Blockquote/index.spec.js +0 -9
- package/es/core/Breadcrumbs/index.js +0 -3
- package/es/core/Button/BackButton.js +0 -21
- package/es/core/Button/ButtonLink.js +0 -16
- package/es/core/Button/CallToAction.js +0 -27
- package/es/core/Button/Icon.js +0 -7
- package/es/core/Button/__snapshots__/index.spec.tsx.snap +0 -13
- package/es/core/Button/index.js +0 -36
- package/es/core/Button/index.mdx +0 -65
- package/es/core/Button/index.spec.js +0 -9
- package/es/core/Card/index.js +0 -4
- package/es/core/Details/__snapshots__/index.spec.tsx.snap +0 -50
- package/es/core/Details/index.js +0 -5
- package/es/core/Details/index.mdx +0 -34
- package/es/core/Details/index.spec.js +0 -17
- package/es/core/Divider/index.js +0 -7
- package/es/core/ErrorSummary/__snapshots__/index.spec.tsx.snap +0 -322
- package/es/core/ErrorSummary/index.js +0 -3
- package/es/core/ErrorSummary/index.mdx +0 -61
- package/es/core/ErrorSummary/index.spec.js +0 -9
- package/es/core/Hidden/index.js +0 -1
- package/es/core/Link/__snapshots__/index.spec.tsx.snap +0 -31
- package/es/core/Link/index.js +0 -26
- package/es/core/Link/index.spec.js +0 -21
- package/es/core/List/List.js +0 -3
- package/es/core/List/ListItem.js +0 -3
- package/es/core/List/ListItemContent.js +0 -27
- package/es/core/List/ListItemIcon.js +0 -29
- package/es/core/List/ListItemText.js +0 -19
- package/es/core/List/ListItemTitle.js +0 -25
- package/es/core/List/__snapshots__/index.spec.tsx.snap +0 -322
- package/es/core/List/index.js +0 -7
- package/es/core/List/index.mdx +0 -40
- package/es/core/List/index.spec.js +0 -9
- package/es/core/NavList/NavList.js +0 -78
- package/es/core/NavList/NavListContext.js +0 -80
- package/es/core/NavList/NavListItem.js +0 -141
- package/es/core/NavList/NavListItemBase.js +0 -133
- package/es/core/NavList/NavListSubMenu.js +0 -27
- package/es/core/NavList/__snapshots__/index.spec.tsx.snap +0 -334
- package/es/core/NavList/index.js +0 -5
- package/es/core/NavList/index.mdx +0 -185
- package/es/core/NavList/index.spec.js +0 -9
- package/es/core/NotificationBanner/__snapshots__/index.spec.tsx.snap +0 -737
- package/es/core/NotificationBanner/index.js +0 -35
- package/es/core/NotificationBanner/index.mdx +0 -77
- package/es/core/NotificationBanner/index.spec.js +0 -20
- package/es/core/ServiceBadge/ServiceBadge.mdx +0 -0
- package/es/core/ServiceBadge/index.js +0 -20
- package/es/core/ServiceBadge/index.mdx +0 -42
- package/es/core/SummaryList/__snapshots__/index.spec.tsx.snap +0 -57
- package/es/core/SummaryList/index.js +0 -7
- package/es/core/SummaryList/index.mdx +0 -82
- package/es/core/SummaryList/index.spec.js +0 -9
- package/es/core/Table/index.js +0 -7
- package/es/core/Tabs/index.js +0 -37
- package/es/core/Tabs/index.mdx +0 -54
- package/es/core/VisuallyHidden/index.js +0 -1
- package/es/core/WarningText/__snapshots__/index.spec.tsx.snap +0 -336
- package/es/core/WarningText/index.js +0 -3
- package/es/core/WarningText/index.mdx +0 -46
- package/es/core/WarningText/index.spec.js +0 -9
- package/es/core/index.js +0 -14
- package/es/custom.d.js +0 -0
- package/es/govgr/Footer/Copyright.js +0 -37
- package/es/govgr/Footer/HellenicRepublicLogo.js +0 -3
- package/es/govgr/Footer/LicenseCCSA.js +0 -18
- package/es/govgr/Footer/index.js +0 -21
- package/es/govgr/Footer/logo.js +0 -1
- package/es/govgr/Footer/logos/logo-el.js +0 -1
- package/es/govgr/Footer/logos/logo-en.js +0 -1
- package/es/govgr/Logo/index.js +0 -3
- package/es/govgr/index.js +0 -4
- package/es/hooks/useDebounce.js +0 -41
- package/es/hooks/useLatest.js +0 -12
- package/es/hooks/useOutdatedBrowserCheck.js +0 -46
- package/es/hooks/useSearch.js +0 -25
- package/es/hooks/useTogglableSections.js +0 -96
- package/es/index.js +0 -5
- package/es/layouts/Basic/Bottom/index.js +0 -3
- package/es/layouts/Basic/Content/index.js +0 -18
- package/es/layouts/Basic/Main/index.js +0 -3
- package/es/layouts/Basic/Masthead/index.js +0 -4
- package/es/layouts/Basic/Side/index.js +0 -7
- package/es/layouts/Basic/index.js +0 -8
- package/es/layouts/Basic/index.spec.js +0 -10
- package/es/layouts/Grid/index.js +0 -1
- package/es/layouts/index.js +0 -2
- package/es/locales/el.js +0 -45
- package/es/locales/en.js +0 -45
- package/es/router/index.js +0 -15
- package/es/test-utils/delay.js +0 -31
- package/es/test-utils/mountWithTheme.js +0 -30
- package/es/themes/grnet.js +0 -110
- package/es/themes/index.js +0 -2
- package/es/typography/Caption.js +0 -7
- package/es/typography/NormalText.js +0 -3
- package/es/typography/Paragraph.js +0 -2
- package/es/typography/Title.js +0 -48
- package/es/typography/index.js +0 -8
- package/es/utils/evaluateBrowserVersion.js +0 -201
- package/es/utils/withDeprecation.js +0 -103
- package/esm/api/APIErrors.js +0 -96
- package/esm/api/APIProvider.js +0 -25
- package/esm/api/fetchAPI.js +0 -49
- package/esm/api/index.spec.js +0 -546
- package/esm/api/introduction.md +0 -6
- package/esm/api/useResource.js +0 -128
- package/esm/api/useResourceAction.js +0 -141
- package/esm/api/useResourceQuery.js +0 -208
- package/esm/api/utils.js +0 -233
- package/esm/app/App.js +0 -27
- package/esm/app/Confirmation/index.js +0 -3
- package/esm/app/Footer/index.js +0 -15
- package/esm/app/Header/HeaderLogo.js +0 -17
- package/esm/app/Header/HeaderSection.js +0 -7
- package/esm/app/Header/HeaderTitle.js +0 -17
- package/esm/app/Header/__snapshots__/index.spec.tsx.snap +0 -393
- package/esm/app/Header/index.mdx +0 -50
- package/esm/app/Header/index.spec.js +0 -32
- package/esm/app/NotFound/index.js +0 -12
- package/esm/app/OutdatedBrowserBanner.js +0 -24
- package/esm/app/PageTitle.js +0 -57
- package/esm/app/QrCodeScanner/__snapshots__/index.spec.tsx.snap +0 -22
- package/esm/app/QrCodeScanner/index.js +0 -64
- package/esm/app/QrCodeScanner/index.mdx +0 -22
- package/esm/app/QrCodeScanner/index.spec.js +0 -13
- package/esm/app/i18n.js +0 -36
- package/esm/app/index.js +0 -5
- package/esm/core/Accordion/__snapshots__/index.spec.tsx.snap +0 -78
- package/esm/core/Accordion/index.js +0 -67
- package/esm/core/Accordion/index.mdx +0 -104
- package/esm/core/Accordion/index.spec.js +0 -9
- package/esm/core/Blockquote/__snapshots__/index.spec.tsx.snap +0 -13
- package/esm/core/Blockquote/index.mdx +0 -61
- package/esm/core/Blockquote/index.spec.js +0 -9
- package/esm/core/Breadcrumbs/index.js +0 -3
- package/esm/core/Button/ButtonLink.js +0 -16
- package/esm/core/Button/CallToAction.js +0 -27
- package/esm/core/Button/Icon.js +0 -7
- package/esm/core/Button/__snapshots__/index.spec.tsx.snap +0 -13
- package/esm/core/Button/index.js +0 -36
- package/esm/core/Button/index.mdx +0 -65
- package/esm/core/Button/index.spec.js +0 -9
- package/esm/core/Card/index.js +0 -4
- package/esm/core/Details/__snapshots__/index.spec.tsx.snap +0 -50
- package/esm/core/Details/index.js +0 -5
- package/esm/core/Details/index.mdx +0 -34
- package/esm/core/Details/index.spec.js +0 -17
- package/esm/core/Divider/index.js +0 -7
- package/esm/core/ErrorSummary/__snapshots__/index.spec.tsx.snap +0 -322
- package/esm/core/ErrorSummary/index.js +0 -3
- package/esm/core/ErrorSummary/index.mdx +0 -61
- package/esm/core/ErrorSummary/index.spec.js +0 -9
- package/esm/core/Hidden/index.js +0 -1
- package/esm/core/Link/__snapshots__/index.spec.tsx.snap +0 -31
- package/esm/core/Link/index.js +0 -26
- package/esm/core/Link/index.spec.js +0 -21
- package/esm/core/List/List.js +0 -3
- package/esm/core/List/ListItem.js +0 -3
- package/esm/core/List/ListItemContent.js +0 -27
- package/esm/core/List/ListItemIcon.js +0 -29
- package/esm/core/List/ListItemText.js +0 -19
- package/esm/core/List/ListItemTitle.js +0 -25
- package/esm/core/List/__snapshots__/index.spec.tsx.snap +0 -322
- package/esm/core/List/index.js +0 -7
- package/esm/core/List/index.mdx +0 -40
- package/esm/core/List/index.spec.js +0 -9
- package/esm/core/NavList/NavList.js +0 -78
- package/esm/core/NavList/NavListContext.js +0 -80
- package/esm/core/NavList/NavListItem.js +0 -141
- package/esm/core/NavList/NavListItemBase.js +0 -133
- package/esm/core/NavList/NavListSubMenu.js +0 -27
- package/esm/core/NavList/__snapshots__/index.spec.tsx.snap +0 -334
- package/esm/core/NavList/index.js +0 -5
- package/esm/core/NavList/index.mdx +0 -185
- package/esm/core/NavList/index.spec.js +0 -9
- package/esm/core/NotificationBanner/__snapshots__/index.spec.tsx.snap +0 -737
- package/esm/core/NotificationBanner/index.js +0 -35
- package/esm/core/NotificationBanner/index.mdx +0 -77
- package/esm/core/NotificationBanner/index.spec.js +0 -20
- package/esm/core/ServiceBadge/ServiceBadge.mdx +0 -0
- package/esm/core/ServiceBadge/index.js +0 -20
- package/esm/core/ServiceBadge/index.mdx +0 -42
- package/esm/core/SummaryList/__snapshots__/index.spec.tsx.snap +0 -57
- package/esm/core/SummaryList/index.js +0 -7
- package/esm/core/SummaryList/index.mdx +0 -82
- package/esm/core/SummaryList/index.spec.js +0 -9
- package/esm/core/Table/index.js +0 -7
- package/esm/core/Tabs/index.js +0 -37
- package/esm/core/Tabs/index.mdx +0 -54
- package/esm/core/VisuallyHidden/index.js +0 -1
- package/esm/core/WarningText/__snapshots__/index.spec.tsx.snap +0 -336
- package/esm/core/WarningText/index.js +0 -3
- package/esm/core/WarningText/index.mdx +0 -46
- package/esm/core/WarningText/index.spec.js +0 -9
- package/esm/core/index.js +0 -14
- package/esm/custom.d.js +0 -0
- package/esm/form/inputs/Input/index.mdx +0 -10
- package/esm/govgr/Footer/Copyright.js +0 -37
- package/esm/govgr/Footer/HellenicRepublicLogo.js +0 -3
- package/esm/govgr/Footer/LicenseCCSA.js +0 -18
- package/esm/govgr/Footer/index.js +0 -21
- package/esm/govgr/Footer/index.mdx +0 -97
- package/esm/govgr/Logo/govgr-logo.svg +0 -1
- package/esm/govgr/Logo/index.js +0 -3
- package/esm/govgr/Logo/logo.js +0 -1
- package/esm/govgr/index.js +0 -4
- package/esm/hooks/useDebounce.js +0 -41
- package/esm/hooks/useLatest.js +0 -12
- package/esm/hooks/useSearch.js +0 -25
- package/esm/hooks/useTogglableSections.js +0 -96
- package/esm/index.js +0 -10
- package/esm/layouts/Basic/Bottom/index.js +0 -3
- package/esm/layouts/Basic/Bottom/index.mdx +0 -37
- package/esm/layouts/Basic/Content/index.js +0 -18
- package/esm/layouts/Basic/Content/index.mdx +0 -64
- package/esm/layouts/Basic/Main/index.js +0 -3
- package/esm/layouts/Basic/Main/index.mdx +0 -64
- package/esm/layouts/Basic/Masthead/index.js +0 -4
- package/esm/layouts/Basic/Masthead/index.mdx +0 -74
- package/esm/layouts/Basic/Side/index.mdx +0 -71
- package/esm/layouts/Basic/Top/index.js +0 -11
- package/esm/layouts/Basic/Top/index.mdx +0 -74
- package/esm/layouts/Basic/__snapshots__/index.spec.tsx.snap +0 -54
- package/esm/layouts/Basic/index.js +0 -8
- package/esm/layouts/Basic/index.mdx +0 -62
- package/esm/layouts/Basic/index.spec.js +0 -10
- package/esm/layouts/Grid/index.js +0 -1
- package/esm/layouts/index.js +0 -2
- package/esm/locales/el.js +0 -45
- package/esm/router/index.js +0 -15
- package/esm/router/index.mdx +0 -40
- package/esm/test-utils/delay.js +0 -31
- package/esm/test-utils/mountWithTheme.js +0 -30
- package/esm/themes/govgr.js +0 -79
- package/esm/themes/grnet.js +0 -110
- package/esm/themes/index.js +0 -2
- package/esm/typography/Caption.js +0 -7
- package/esm/typography/NormalText.js +0 -3
- package/esm/typography/Paragraph.js +0 -2
- package/esm/typography/Title.js +0 -48
- package/esm/typography/index.js +0 -8
- package/esm/typography/index.mdx +0 -32
- package/esm/utils/evaluateBrowserVersion.js +0 -201
- package/esm/utils/withDeprecation.js +0 -103
- package/form/inputs/Input/index.mdx +0 -10
- package/govgr/Footer/Copyright.d.ts +0 -8
- package/govgr/Footer/Copyright.js +0 -52
- package/govgr/Footer/HellenicRepublicLogo.js +0 -19
- package/govgr/Footer/LicenseCCSA.d.ts +0 -3
- package/govgr/Footer/LicenseCCSA.js +0 -33
- package/govgr/Footer/index.d.ts +0 -13
- package/govgr/Footer/index.js +0 -39
- package/govgr/Footer/index.mdx +0 -97
- package/govgr/Footer/logo.d.ts +0 -2
- package/govgr/Footer/logo.js +0 -8
- package/govgr/Footer/logos/logo-el.d.ts +0 -2
- package/govgr/Footer/logos/logo-el.js +0 -8
- package/govgr/Footer/logos/logo-en.d.ts +0 -2
- package/govgr/Footer/logos/logo-en.js +0 -8
- package/govgr/Logo/govgr-logo.svg +0 -1
- package/govgr/Logo/index.js +0 -19
- package/govgr/Logo/logo.d.ts +0 -2
- package/govgr/Logo/logo.js +0 -8
- package/govgr/index.js +0 -57
- package/hooks/useDebounce.d.ts +0 -3
- package/hooks/useDebounce.js +0 -63
- package/hooks/useLatest.d.ts +0 -3
- package/hooks/useLatest.js +0 -26
- package/hooks/useOutdatedBrowserCheck.d.ts +0 -2
- package/hooks/useOutdatedBrowserCheck.js +0 -60
- package/hooks/useSearch.d.ts +0 -4
- package/hooks/useSearch.js +0 -40
- package/hooks/useTogglableSections.d.ts +0 -18
- package/hooks/useTogglableSections.js +0 -108
- package/index.js +0 -70
- package/layouts/Basic/Bottom/index.js +0 -19
- package/layouts/Basic/Bottom/index.mdx +0 -37
- package/layouts/Basic/Content/index.d.ts +0 -5
- package/layouts/Basic/Content/index.js +0 -31
- package/layouts/Basic/Content/index.mdx +0 -64
- package/layouts/Basic/Main/index.js +0 -19
- package/layouts/Basic/Main/index.mdx +0 -64
- package/layouts/Basic/Masthead/index.js +0 -27
- package/layouts/Basic/Masthead/index.mdx +0 -74
- package/layouts/Basic/Side/index.d.ts +0 -3
- package/layouts/Basic/Side/index.js +0 -20
- package/layouts/Basic/Side/index.mdx +0 -71
- package/layouts/Basic/Top/index.d.ts +0 -3
- package/layouts/Basic/Top/index.js +0 -24
- package/layouts/Basic/Top/index.mdx +0 -74
- package/layouts/Basic/__snapshots__/index.spec.tsx.snap +0 -54
- package/layouts/Basic/index.js +0 -97
- package/layouts/Basic/index.mdx +0 -62
- package/layouts/Basic/index.spec.d.ts +0 -1
- package/layouts/Basic/index.spec.js +0 -20
- package/layouts/Grid/index.js +0 -18
- package/layouts/index.js +0 -34
- package/locales/el.d.ts +0 -46
- package/locales/el.js +0 -52
- package/locales/en.d.ts +0 -46
- package/locales/en.js +0 -52
- package/router/index.d.ts +0 -9
- package/router/index.js +0 -37
- package/router/index.mdx +0 -40
- package/test-utils/delay.d.ts +0 -2
- package/test-utils/delay.js +0 -45
- package/test-utils/mountWithTheme.d.ts +0 -3
- package/test-utils/mountWithTheme.js +0 -43
- package/themes/govgr.d.ts +0 -3
- package/themes/govgr.js +0 -89
- package/themes/grnet.d.ts +0 -2
- package/themes/grnet.js +0 -128
- package/themes/index.d.ts +0 -32
- package/themes/index.js +0 -19
- package/typography/Caption.d.ts +0 -7
- package/typography/Caption.js +0 -20
- package/typography/NormalText.d.ts +0 -5
- package/typography/NormalText.js +0 -19
- package/typography/Paragraph.d.ts +0 -6
- package/typography/Paragraph.js +0 -13
- package/typography/Title.d.ts +0 -9
- package/typography/Title.js +0 -63
- package/typography/index.js +0 -97
- package/typography/index.mdx +0 -32
- package/utils/evaluateBrowserVersion.d.ts +0 -15
- package/utils/evaluateBrowserVersion.js +0 -216
- package/utils/withDeprecation.d.ts +0 -16
- package/utils/withDeprecation.js +0 -116
package/esm/api/index.spec.js
DELETED
|
@@ -1,546 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
5
|
-
|
|
6
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
7
|
-
import React, { Suspense, useEffect } from 'react';
|
|
8
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
9
|
-
import fetchMock from 'fetch-mock';
|
|
10
|
-
import { APIProvider, useResource, useResourceAction, useResourceMany, APIErrors } from '@digigov/ui/api/index';
|
|
11
|
-
import delay from '@digigov/ui/test-utils/delay';
|
|
12
|
-
import fetchAPI from '@digigov/ui/api/fetchAPI';
|
|
13
|
-
import 'whatwg-fetch';
|
|
14
|
-
|
|
15
|
-
var _ref2 = /*#__PURE__*/React.createElement("span", null, "something went wrong");
|
|
16
|
-
|
|
17
|
-
var HandleError = function HandleError(_ref) {
|
|
18
|
-
var error = _ref.error;
|
|
19
|
-
|
|
20
|
-
if (error.name === 'APIError') {
|
|
21
|
-
error = error.error;
|
|
22
|
-
|
|
23
|
-
if (error.status === 404) {
|
|
24
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, "Not found");
|
|
25
|
-
}
|
|
26
|
-
} // TODO: render the <SomethingWentWrong /> page here
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return _ref2;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var makeWrapper = function makeWrapper(_ref3) {
|
|
33
|
-
var config = _ref3.config,
|
|
34
|
-
token = _ref3.token;
|
|
35
|
-
return function (_ref4) {
|
|
36
|
-
var children = _ref4.children;
|
|
37
|
-
return /*#__PURE__*/React.createElement(Suspense, {
|
|
38
|
-
fallback: 'Loading'
|
|
39
|
-
}, /*#__PURE__*/React.createElement(APIErrors, {
|
|
40
|
-
fallback: HandleError
|
|
41
|
-
}, /*#__PURE__*/React.createElement(APIProvider, {
|
|
42
|
-
config: config,
|
|
43
|
-
token: token
|
|
44
|
-
}, children)));
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
var BASE_URL = 'http://test/api';
|
|
49
|
-
var TOKEN = 'mytoken';
|
|
50
|
-
var DELAY = 100;
|
|
51
|
-
|
|
52
|
-
var buildMockOptions = function buildMockOptions(_ref5) {
|
|
53
|
-
var resource = _ref5.resource,
|
|
54
|
-
_ref5$method = _ref5.method,
|
|
55
|
-
method = _ref5$method === void 0 ? 'GET' : _ref5$method,
|
|
56
|
-
_ref5$authenticated = _ref5.authenticated,
|
|
57
|
-
authenticated = _ref5$authenticated === void 0 ? true : _ref5$authenticated,
|
|
58
|
-
_ref5$query = _ref5.query,
|
|
59
|
-
query = _ref5$query === void 0 ? {} : _ref5$query,
|
|
60
|
-
response = _ref5.response,
|
|
61
|
-
_ref5$delay = _ref5.delay,
|
|
62
|
-
delay = _ref5$delay === void 0 ? DELAY / 2 : _ref5$delay;
|
|
63
|
-
var headers = {
|
|
64
|
-
'content-type': 'application/json'
|
|
65
|
-
};
|
|
66
|
-
var options = {
|
|
67
|
-
delay: delay
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if (authenticated) {
|
|
71
|
-
headers.Authorization = "Token ".concat(TOKEN);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var params = new URLSearchParams(query).toString();
|
|
75
|
-
return ["".concat(BASE_URL, "/").concat(resource).concat(params && "?".concat(params)), response, _extends({
|
|
76
|
-
headers: headers,
|
|
77
|
-
method: method
|
|
78
|
-
}, options)];
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
var getAPI = function getAPI() {
|
|
82
|
-
return {
|
|
83
|
-
config: {
|
|
84
|
-
baseURL: BASE_URL
|
|
85
|
-
},
|
|
86
|
-
token: TOKEN
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
var wrapper = makeWrapper(getAPI());
|
|
91
|
-
describe('fetchAPI', function () {
|
|
92
|
-
fetchMock.config.overwriteRoutes = true;
|
|
93
|
-
afterAll(function () {
|
|
94
|
-
fetchMock.restore();
|
|
95
|
-
});
|
|
96
|
-
beforeEach(fetchMock.resetBehavior);
|
|
97
|
-
beforeEach(fetchMock.resetHistory);
|
|
98
|
-
it('fetchAPI gets', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
99
|
-
var resource, path, _yield$fetchAPI, data;
|
|
100
|
-
|
|
101
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
102
|
-
while (1) {
|
|
103
|
-
switch (_context.prev = _context.next) {
|
|
104
|
-
case 0:
|
|
105
|
-
resource = 'resource';
|
|
106
|
-
path = 'some_id';
|
|
107
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
108
|
-
resource: "".concat(resource, "/").concat(path, "/"),
|
|
109
|
-
response: {
|
|
110
|
-
value: 'SWR'
|
|
111
|
-
}
|
|
112
|
-
})));
|
|
113
|
-
_context.next = 5;
|
|
114
|
-
return fetchAPI(resource, {
|
|
115
|
-
path: path
|
|
116
|
-
}, getAPI());
|
|
117
|
-
|
|
118
|
-
case 5:
|
|
119
|
-
_yield$fetchAPI = _context.sent;
|
|
120
|
-
data = _yield$fetchAPI.data;
|
|
121
|
-
expect(data.value).toBe('SWR');
|
|
122
|
-
expect(fetchMock.calls()).toHaveLength(1);
|
|
123
|
-
|
|
124
|
-
case 9:
|
|
125
|
-
case "end":
|
|
126
|
-
return _context.stop();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}, _callee);
|
|
130
|
-
})));
|
|
131
|
-
});
|
|
132
|
-
describe('useResource', function () {
|
|
133
|
-
fetchMock.config.overwriteRoutes = true;
|
|
134
|
-
afterAll(function () {
|
|
135
|
-
fetchMock.restore();
|
|
136
|
-
});
|
|
137
|
-
beforeEach(fetchMock.resetBehavior);
|
|
138
|
-
beforeEach(fetchMock.resetHistory);
|
|
139
|
-
it('useResource should return data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
140
|
-
var resource, Page, _render, container, _container$firstChild, _container$firstChild2;
|
|
141
|
-
|
|
142
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
143
|
-
while (1) {
|
|
144
|
-
switch (_context2.prev = _context2.next) {
|
|
145
|
-
case 0:
|
|
146
|
-
Page = function _Page() {
|
|
147
|
-
var _useResource = useResource(resource),
|
|
148
|
-
data = _useResource.data;
|
|
149
|
-
|
|
150
|
-
return /*#__PURE__*/React.createElement("div", null, "hello, ", data === null || data === void 0 ? void 0 : data.value);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
resource = 'resource';
|
|
154
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
155
|
-
resource: resource,
|
|
156
|
-
response: {
|
|
157
|
-
value: 'SWR'
|
|
158
|
-
}
|
|
159
|
-
})));
|
|
160
|
-
_render = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
161
|
-
wrapper: wrapper
|
|
162
|
-
}), container = _render.container;
|
|
163
|
-
expect(container.firstChild).not.toBe(null);
|
|
164
|
-
|
|
165
|
-
if (!container.firstChild) {
|
|
166
|
-
_context2.next = 10;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild = container.firstChild) === null || _container$firstChild === void 0 ? void 0 : _container$firstChild.textContent).toMatchInlineSnapshot("\"hello, \"");
|
|
171
|
-
_context2.next = 9;
|
|
172
|
-
return delay(DELAY);
|
|
173
|
-
|
|
174
|
-
case 9:
|
|
175
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild2 = container.firstChild) === null || _container$firstChild2 === void 0 ? void 0 : _container$firstChild2.textContent).toMatchInlineSnapshot("\"hello, SWR\"");
|
|
176
|
-
|
|
177
|
-
case 10:
|
|
178
|
-
expect(fetchMock.calls()).toHaveLength(1);
|
|
179
|
-
|
|
180
|
-
case 11:
|
|
181
|
-
case "end":
|
|
182
|
-
return _context2.stop();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}, _callee2);
|
|
186
|
-
})));
|
|
187
|
-
it('should run duplicate request once', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
188
|
-
var _container$firstChild3, _container$firstChild4;
|
|
189
|
-
|
|
190
|
-
var resource, Page, _render2, container;
|
|
191
|
-
|
|
192
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
193
|
-
while (1) {
|
|
194
|
-
switch (_context3.prev = _context3.next) {
|
|
195
|
-
case 0:
|
|
196
|
-
Page = function _Page2() {
|
|
197
|
-
useResource(resource);
|
|
198
|
-
|
|
199
|
-
var _useResource2 = useResource(resource),
|
|
200
|
-
duplData = _useResource2.data;
|
|
201
|
-
|
|
202
|
-
return /*#__PURE__*/React.createElement("div", null, "hello, ", duplData === null || duplData === void 0 ? void 0 : duplData.value);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
resource = 'dupliresource';
|
|
206
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
207
|
-
resource: resource,
|
|
208
|
-
response: {
|
|
209
|
-
value: 'myvalue'
|
|
210
|
-
}
|
|
211
|
-
})));
|
|
212
|
-
_render2 = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
213
|
-
wrapper: wrapper
|
|
214
|
-
}), container = _render2.container;
|
|
215
|
-
expect(container.firstChild).not.toBe(null);
|
|
216
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild3 = container.firstChild) === null || _container$firstChild3 === void 0 ? void 0 : _container$firstChild3.textContent).toMatchInlineSnapshot("\"hello, \"");
|
|
217
|
-
_context3.next = 8;
|
|
218
|
-
return delay(DELAY);
|
|
219
|
-
|
|
220
|
-
case 8:
|
|
221
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild4 = container.firstChild) === null || _container$firstChild4 === void 0 ? void 0 : _container$firstChild4.textContent).toMatchInlineSnapshot("\"hello, myvalue\"");
|
|
222
|
-
expect(fetchMock.calls()).toHaveLength(1);
|
|
223
|
-
|
|
224
|
-
case 10:
|
|
225
|
-
case "end":
|
|
226
|
-
return _context3.stop();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}, _callee3);
|
|
230
|
-
})));
|
|
231
|
-
});
|
|
232
|
-
describe('useResourceAction', function () {
|
|
233
|
-
fetchMock.config.overwriteRoutes = true;
|
|
234
|
-
afterAll(function () {
|
|
235
|
-
fetchMock.restore();
|
|
236
|
-
});
|
|
237
|
-
beforeEach(fetchMock.resetBehavior);
|
|
238
|
-
beforeEach(fetchMock.resetHistory);
|
|
239
|
-
it('useResourceAction should return result ', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
240
|
-
var _container$firstChild5, _container$firstChild6;
|
|
241
|
-
|
|
242
|
-
var resource, Page, _render3, container;
|
|
243
|
-
|
|
244
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
245
|
-
while (1) {
|
|
246
|
-
switch (_context4.prev = _context4.next) {
|
|
247
|
-
case 0:
|
|
248
|
-
Page = function _Page3() {
|
|
249
|
-
var _useResourceAction = useResourceAction(resource, undefined, 'POST', {
|
|
250
|
-
some: 'data'
|
|
251
|
-
}, undefined),
|
|
252
|
-
data = _useResourceAction.data,
|
|
253
|
-
fetch = _useResourceAction.fetch;
|
|
254
|
-
|
|
255
|
-
useEffect(function () {
|
|
256
|
-
fetch();
|
|
257
|
-
}, []);
|
|
258
|
-
return /*#__PURE__*/React.createElement("div", null, "hello, ", data && data.value);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
resource = 'resourceaction';
|
|
262
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
263
|
-
resource: resource,
|
|
264
|
-
response: {
|
|
265
|
-
value: 'myvalue'
|
|
266
|
-
},
|
|
267
|
-
method: 'POST'
|
|
268
|
-
})));
|
|
269
|
-
_render3 = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
270
|
-
wrapper: wrapper
|
|
271
|
-
}), container = _render3.container;
|
|
272
|
-
expect(container.firstChild).not.toBe(null);
|
|
273
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild5 = container.firstChild) === null || _container$firstChild5 === void 0 ? void 0 : _container$firstChild5.textContent).toMatchInlineSnapshot("\"hello, \"");
|
|
274
|
-
_context4.next = 8;
|
|
275
|
-
return delay(DELAY * 2);
|
|
276
|
-
|
|
277
|
-
case 8:
|
|
278
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild6 = container.firstChild) === null || _container$firstChild6 === void 0 ? void 0 : _container$firstChild6.textContent).toMatchInlineSnapshot("\"hello, myvalue\"");
|
|
279
|
-
expect(fetchMock.calls()).toHaveLength(1);
|
|
280
|
-
|
|
281
|
-
case 10:
|
|
282
|
-
case "end":
|
|
283
|
-
return _context4.stop();
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}, _callee4);
|
|
287
|
-
})));
|
|
288
|
-
it('useResourceAction should be invalidated and run twice', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
289
|
-
var _container$firstChild7, _container$firstChild8, _container$firstChild9, _container$firstChild10;
|
|
290
|
-
|
|
291
|
-
var resource, Page, _render4, container;
|
|
292
|
-
|
|
293
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
294
|
-
while (1) {
|
|
295
|
-
switch (_context5.prev = _context5.next) {
|
|
296
|
-
case 0:
|
|
297
|
-
Page = function _Page4() {
|
|
298
|
-
var _useResourceAction2 = useResourceAction(resource, undefined, 'POST', {
|
|
299
|
-
some: 'data'
|
|
300
|
-
}, undefined),
|
|
301
|
-
data = _useResourceAction2.data,
|
|
302
|
-
fetch = _useResourceAction2.fetch,
|
|
303
|
-
invalidate = _useResourceAction2.invalidate;
|
|
304
|
-
|
|
305
|
-
useEffect(function () {
|
|
306
|
-
fetch();
|
|
307
|
-
}, []);
|
|
308
|
-
useEffect(function () {
|
|
309
|
-
setTimeout(function () {
|
|
310
|
-
invalidate();
|
|
311
|
-
}, DELAY * 2);
|
|
312
|
-
setTimeout(function () {
|
|
313
|
-
fetch();
|
|
314
|
-
}, DELAY * 3);
|
|
315
|
-
}, []);
|
|
316
|
-
return /*#__PURE__*/React.createElement("div", null, "hello, ", data && data.value);
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
resource = 'resourceactiondouble';
|
|
320
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
321
|
-
resource: resource,
|
|
322
|
-
response: {
|
|
323
|
-
value: 'myvalue'
|
|
324
|
-
},
|
|
325
|
-
method: 'POST'
|
|
326
|
-
})));
|
|
327
|
-
_render4 = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
328
|
-
wrapper: wrapper
|
|
329
|
-
}), container = _render4.container;
|
|
330
|
-
expect(container.firstChild).not.toBe(null);
|
|
331
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild7 = container.firstChild) === null || _container$firstChild7 === void 0 ? void 0 : _container$firstChild7.textContent).toMatchInlineSnapshot("\"hello, \"");
|
|
332
|
-
_context5.next = 8;
|
|
333
|
-
return delay(DELAY);
|
|
334
|
-
|
|
335
|
-
case 8:
|
|
336
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild8 = container.firstChild) === null || _container$firstChild8 === void 0 ? void 0 : _container$firstChild8.textContent).toMatchInlineSnapshot("\"hello, myvalue\"");
|
|
337
|
-
_context5.next = 11;
|
|
338
|
-
return delay(DELAY);
|
|
339
|
-
|
|
340
|
-
case 11:
|
|
341
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild9 = container.firstChild) === null || _container$firstChild9 === void 0 ? void 0 : _container$firstChild9.textContent).toMatchInlineSnapshot("\"hello, \"");
|
|
342
|
-
_context5.next = 14;
|
|
343
|
-
return delay(DELAY * 2);
|
|
344
|
-
|
|
345
|
-
case 14:
|
|
346
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild10 = container.firstChild) === null || _container$firstChild10 === void 0 ? void 0 : _container$firstChild10.textContent).toMatchInlineSnapshot("\"hello, myvalue\"");
|
|
347
|
-
expect(fetchMock.calls()).toHaveLength(2);
|
|
348
|
-
|
|
349
|
-
case 16:
|
|
350
|
-
case "end":
|
|
351
|
-
return _context5.stop();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}, _callee5);
|
|
355
|
-
})));
|
|
356
|
-
});
|
|
357
|
-
describe('useResourceMany', function () {
|
|
358
|
-
fetchMock.config.overwriteRoutes = true;
|
|
359
|
-
afterAll(function () {
|
|
360
|
-
fetchMock.restore();
|
|
361
|
-
});
|
|
362
|
-
beforeEach(fetchMock.resetBehavior);
|
|
363
|
-
beforeEach(fetchMock.resetHistory); //check this test again (loading/hello)
|
|
364
|
-
|
|
365
|
-
it('useResourceMany should return data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
366
|
-
var _container$firstChild11, _container$firstChild12;
|
|
367
|
-
|
|
368
|
-
var resource, Page, _render5, container;
|
|
369
|
-
|
|
370
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
371
|
-
while (1) {
|
|
372
|
-
switch (_context6.prev = _context6.next) {
|
|
373
|
-
case 0:
|
|
374
|
-
Page = function _Page5() {
|
|
375
|
-
var _useResourceMany = useResourceMany(resource),
|
|
376
|
-
data = _useResourceMany.data;
|
|
377
|
-
|
|
378
|
-
return /*#__PURE__*/React.createElement("div", null, "hello, ", data && data.join(''));
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
resource = 'resourceMany';
|
|
382
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
383
|
-
resource: resource,
|
|
384
|
-
query: {
|
|
385
|
-
offset: 0,
|
|
386
|
-
limit: 30
|
|
387
|
-
},
|
|
388
|
-
response: {
|
|
389
|
-
data: ['S', 'W', 'R'],
|
|
390
|
-
meta: {
|
|
391
|
-
total: 1,
|
|
392
|
-
count: 3
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
})));
|
|
396
|
-
_render5 = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
397
|
-
wrapper: wrapper
|
|
398
|
-
}), container = _render5.container;
|
|
399
|
-
expect(container.firstChild).not.toBe(null);
|
|
400
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild11 = container.firstChild) === null || _container$firstChild11 === void 0 ? void 0 : _container$firstChild11.textContent).toMatchInlineSnapshot("\"Loading\"");
|
|
401
|
-
_context6.next = 8;
|
|
402
|
-
return delay(DELAY * 2);
|
|
403
|
-
|
|
404
|
-
case 8:
|
|
405
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild12 = container.firstChild) === null || _container$firstChild12 === void 0 ? void 0 : _container$firstChild12.textContent).toMatchInlineSnapshot("\"hello, SWR\"");
|
|
406
|
-
expect(fetchMock.calls()).toHaveLength(1);
|
|
407
|
-
|
|
408
|
-
case 10:
|
|
409
|
-
case "end":
|
|
410
|
-
return _context6.stop();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}, _callee6);
|
|
414
|
-
})));
|
|
415
|
-
it('useResourceMany should handle hasNext, hasPrevious', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
416
|
-
var _container$firstChild13, _container$firstChild14;
|
|
417
|
-
|
|
418
|
-
var resource, Page, _render6, container;
|
|
419
|
-
|
|
420
|
-
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
421
|
-
while (1) {
|
|
422
|
-
switch (_context7.prev = _context7.next) {
|
|
423
|
-
case 0:
|
|
424
|
-
Page = function _Page6() {
|
|
425
|
-
var _useResourceMany2 = useResourceMany(resource),
|
|
426
|
-
hasNext = _useResourceMany2.hasNext,
|
|
427
|
-
hasPrevious = _useResourceMany2.hasPrevious;
|
|
428
|
-
|
|
429
|
-
return /*#__PURE__*/React.createElement("div", null, hasNext ? '' : 'no', " next,", hasPrevious ? '' : 'no', " previous");
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
resource = 'resourceManyhasNext';
|
|
433
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
434
|
-
resource: resource,
|
|
435
|
-
query: {
|
|
436
|
-
offset: 0,
|
|
437
|
-
limit: 30
|
|
438
|
-
},
|
|
439
|
-
response: {
|
|
440
|
-
data: ['S', 'W', 'R'],
|
|
441
|
-
meta: {
|
|
442
|
-
total: 1,
|
|
443
|
-
count: 3
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
})));
|
|
447
|
-
_render6 = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
448
|
-
wrapper: wrapper
|
|
449
|
-
}), container = _render6.container;
|
|
450
|
-
expect(container.firstChild).not.toBe(null);
|
|
451
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild13 = container.firstChild) === null || _container$firstChild13 === void 0 ? void 0 : _container$firstChild13.textContent).toMatchInlineSnapshot("\"Loading\"");
|
|
452
|
-
_context7.next = 8;
|
|
453
|
-
return delay(DELAY);
|
|
454
|
-
|
|
455
|
-
case 8:
|
|
456
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild14 = container.firstChild) === null || _container$firstChild14 === void 0 ? void 0 : _container$firstChild14.textContent).toMatchInlineSnapshot("\"no next,no previous\"");
|
|
457
|
-
expect(fetchMock.calls()).toHaveLength(1);
|
|
458
|
-
|
|
459
|
-
case 10:
|
|
460
|
-
case "end":
|
|
461
|
-
return _context7.stop();
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}, _callee7);
|
|
465
|
-
})));
|
|
466
|
-
it('useResourceMany should handle setPage with custom limit option', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
467
|
-
var _container$firstChild15, _container$firstChild16, _container$firstChild17;
|
|
468
|
-
|
|
469
|
-
var resource, Page, _render7, container, getByText;
|
|
470
|
-
|
|
471
|
-
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
472
|
-
while (1) {
|
|
473
|
-
switch (_context8.prev = _context8.next) {
|
|
474
|
-
case 0:
|
|
475
|
-
Page = function _Page7() {
|
|
476
|
-
var _useResourceMany3 = useResourceMany(resource, {
|
|
477
|
-
limit: 10
|
|
478
|
-
}),
|
|
479
|
-
data = _useResourceMany3.data,
|
|
480
|
-
setPage = _useResourceMany3.setPage,
|
|
481
|
-
page = _useResourceMany3.page;
|
|
482
|
-
|
|
483
|
-
var nextPage = function nextPage() {
|
|
484
|
-
setPage(page + 1);
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
return /*#__PURE__*/React.createElement("div", null, "hello, ", data.join(''), /*#__PURE__*/React.createElement("button", {
|
|
488
|
-
onClick: nextPage
|
|
489
|
-
}, "next"));
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
resource = 'resourceManysetpage';
|
|
493
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
494
|
-
resource: resource,
|
|
495
|
-
query: {
|
|
496
|
-
offset: 0,
|
|
497
|
-
limit: 10
|
|
498
|
-
},
|
|
499
|
-
response: {
|
|
500
|
-
data: ['S', 'W', 'R'],
|
|
501
|
-
meta: {
|
|
502
|
-
total: 3,
|
|
503
|
-
count: 100
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
})));
|
|
507
|
-
fetchMock.mock.apply(fetchMock, _toConsumableArray(buildMockOptions({
|
|
508
|
-
resource: resource,
|
|
509
|
-
query: {
|
|
510
|
-
offset: 10,
|
|
511
|
-
limit: 10
|
|
512
|
-
},
|
|
513
|
-
response: {
|
|
514
|
-
data: ['R', 'W', 'S'],
|
|
515
|
-
meta: {
|
|
516
|
-
total: 3,
|
|
517
|
-
count: 100
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
})));
|
|
521
|
-
_render7 = render( /*#__PURE__*/React.createElement(Page, null), {
|
|
522
|
-
wrapper: wrapper
|
|
523
|
-
}), container = _render7.container, getByText = _render7.getByText;
|
|
524
|
-
expect(container.firstChild).not.toBe(null);
|
|
525
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild15 = container.firstChild) === null || _container$firstChild15 === void 0 ? void 0 : _container$firstChild15.textContent).toMatchInlineSnapshot("\"Loading\"");
|
|
526
|
-
_context8.next = 9;
|
|
527
|
-
return delay(DELAY);
|
|
528
|
-
|
|
529
|
-
case 9:
|
|
530
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild16 = container.firstChild) === null || _container$firstChild16 === void 0 ? void 0 : _container$firstChild16.textContent).toMatchInlineSnapshot("\"hello, SWRnext\"");
|
|
531
|
-
fireEvent.click(getByText('next'));
|
|
532
|
-
_context8.next = 13;
|
|
533
|
-
return delay(DELAY * 2);
|
|
534
|
-
|
|
535
|
-
case 13:
|
|
536
|
-
expect(container === null || container === void 0 ? void 0 : (_container$firstChild17 = container.firstChild) === null || _container$firstChild17 === void 0 ? void 0 : _container$firstChild17.textContent).toMatchInlineSnapshot("\"hello, RWSnext\"");
|
|
537
|
-
expect(fetchMock.calls()).toHaveLength(2);
|
|
538
|
-
|
|
539
|
-
case 15:
|
|
540
|
-
case "end":
|
|
541
|
-
return _context8.stop();
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}, _callee8);
|
|
545
|
-
})));
|
|
546
|
-
});
|
package/esm/api/introduction.md
DELETED
package/esm/api/useResource.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import { getQueryKey, processResponse } from '@digigov/ui/api/utils';
|
|
5
|
-
import { useQuery, queryCache } from 'react-query';
|
|
6
|
-
import { useAPI } from '@digigov/ui/api';
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
export function useResource(resource, id, query, options, suspense) {
|
|
9
|
-
var _useAPI = useAPI(),
|
|
10
|
-
baseURL = _useAPI.config.baseURL,
|
|
11
|
-
token = _useAPI.token;
|
|
12
|
-
|
|
13
|
-
var _useState = useState({
|
|
14
|
-
url: '',
|
|
15
|
-
dataSet: false
|
|
16
|
-
}),
|
|
17
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
-
_useState2$ = _useState2[0],
|
|
19
|
-
url = _useState2$.url,
|
|
20
|
-
dataSet = _useState2$.dataSet,
|
|
21
|
-
setFetchOpts = _useState2[1];
|
|
22
|
-
|
|
23
|
-
function customFetcher(_x, _x2) {
|
|
24
|
-
return _customFetcher.apply(this, arguments);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _customFetcher() {
|
|
28
|
-
_customFetcher = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fetchUrl, options) {
|
|
29
|
-
var response, _yield$processRespons, _data, _error;
|
|
30
|
-
|
|
31
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
|
-
while (1) {
|
|
33
|
-
switch (_context.prev = _context.next) {
|
|
34
|
-
case 0:
|
|
35
|
-
setFetchOpts({
|
|
36
|
-
url: fetchUrl,
|
|
37
|
-
dataSet: false
|
|
38
|
-
});
|
|
39
|
-
_context.next = 3;
|
|
40
|
-
return fetch(fetchUrl, options);
|
|
41
|
-
|
|
42
|
-
case 3:
|
|
43
|
-
response = _context.sent;
|
|
44
|
-
_context.prev = 4;
|
|
45
|
-
_context.next = 7;
|
|
46
|
-
return processResponse(response);
|
|
47
|
-
|
|
48
|
-
case 7:
|
|
49
|
-
_yield$processRespons = _context.sent;
|
|
50
|
-
_data = _yield$processRespons.data;
|
|
51
|
-
_error = _yield$processRespons.error;
|
|
52
|
-
|
|
53
|
-
if (!_error) {
|
|
54
|
-
_context.next = 12;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return _context.abrupt("return", Promise.reject(_error));
|
|
59
|
-
|
|
60
|
-
case 12:
|
|
61
|
-
if (!_data) {
|
|
62
|
-
_context.next = 14;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return _context.abrupt("return", Promise.resolve(_data));
|
|
67
|
-
|
|
68
|
-
case 14:
|
|
69
|
-
_context.next = 19;
|
|
70
|
-
break;
|
|
71
|
-
|
|
72
|
-
case 16:
|
|
73
|
-
_context.prev = 16;
|
|
74
|
-
_context.t0 = _context["catch"](4);
|
|
75
|
-
return _context.abrupt("return", Promise.reject(_context.t0.error));
|
|
76
|
-
|
|
77
|
-
case 19:
|
|
78
|
-
case "end":
|
|
79
|
-
return _context.stop();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}, _callee, null, [[4, 16]]);
|
|
83
|
-
}));
|
|
84
|
-
return _customFetcher.apply(this, arguments);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
var queryKey = getQueryKey(resource, id, query, null, options, 'GET', baseURL, token);
|
|
88
|
-
var enabled = true;
|
|
89
|
-
var resolvedQueryKey;
|
|
90
|
-
|
|
91
|
-
if (typeof queryKey === 'function') {
|
|
92
|
-
try {
|
|
93
|
-
resolvedQueryKey = queryKey();
|
|
94
|
-
} catch (err) {
|
|
95
|
-
enabled = false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var _useQuery = useQuery(resolvedQueryKey || queryKey, customFetcher, {
|
|
100
|
-
enabled: enabled,
|
|
101
|
-
refetchOnWindowFocus: false,
|
|
102
|
-
refetchOnMount: false,
|
|
103
|
-
suspense: suspense || false,
|
|
104
|
-
cacheTime: 300000,
|
|
105
|
-
staleTime: 20000,
|
|
106
|
-
retry: false,
|
|
107
|
-
useErrorBoundary: false // falls back to suspense
|
|
108
|
-
|
|
109
|
-
}),
|
|
110
|
-
status = _useQuery.status,
|
|
111
|
-
data = _useQuery.data,
|
|
112
|
-
error = _useQuery.error,
|
|
113
|
-
isFetching = _useQuery.isFetching,
|
|
114
|
-
refetch = _useQuery.refetch;
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
data: data,
|
|
118
|
-
loading: isFetching,
|
|
119
|
-
loaded: ['error', 'success'].includes(status),
|
|
120
|
-
error: error,
|
|
121
|
-
invalidate: function invalidate() {
|
|
122
|
-
queryCache.invalidateQueries(resolvedQueryKey || queryKey);
|
|
123
|
-
},
|
|
124
|
-
fetch: refetch,
|
|
125
|
-
dataSet: dataSet,
|
|
126
|
-
url: url
|
|
127
|
-
};
|
|
128
|
-
}
|