@prezly/theme-kit-nextjs 2.0.1-2 → 2.1.1
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/README.md +15 -15
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +23 -27
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +25 -37
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/index.js +8 -2
- package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -16
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +15 -15
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/index.js +23 -6
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.js +100 -118
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.js +68 -87
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +53 -64
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.js +69 -83
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/index.js +42 -8
- package/build/adapter-nextjs/page-props/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/lib/types.js +3 -1
- package/build/adapter-nextjs/page-props/search.js +31 -25
- package/build/adapter-nextjs/page-props/search.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +50 -29
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +19 -13
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +35 -33
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/index.js +25 -4
- package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/types.js +3 -1
- package/build/adapter-nextjs/page-props/story.js +64 -77
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js +26 -27
- package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +25 -34
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.js +16 -19
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +78 -84
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/PageSeo/index.js +21 -2
- package/build/components-nextjs/PageSeo/index.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +10 -5
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/types.js +3 -1
- package/build/components-nextjs/StorySeo/StorySeo.js +49 -69
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/components-nextjs/StorySeo/index.js +6 -1
- package/build/components-nextjs/StorySeo/index.js.map +1 -1
- package/build/components-nextjs/document.d.ts +2 -4
- package/build/components-nextjs/document.js +48 -34
- package/build/components-nextjs/document.js.map +1 -1
- package/build/components-nextjs/index.js +10 -3
- package/build/components-nextjs/index.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.js +191 -207
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +21 -21
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/index.js +18 -1
- package/build/data-fetching/api/index.js.map +1 -1
- package/build/data-fetching/api/queries.js +47 -76
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/index.js +20 -3
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +22 -22
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +38 -35
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/data-fetching/lib/index.js +12 -4
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/lib/isSdkError.js +8 -3
- package/build/data-fetching/lib/isSdkError.js.map +1 -1
- package/build/data-fetching/lib/isUuid.js +8 -3
- package/build/data-fetching/lib/isUuid.js.map +1 -1
- package/build/data-fetching/types.js +3 -1
- package/build/index.js +26 -9
- package/build/index.js.map +1 -1
- package/build/infinite-loading/index.js +25 -4
- package/build/infinite-loading/index.js.map +1 -1
- package/build/infinite-loading/types.js +3 -1
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +37 -42
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js +43 -50
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.js +50 -56
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/index.d.ts +1 -1
- package/build/intl/index.js +26 -4
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.js +122 -146
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.d.ts +1 -0
- package/build/intl/locale.js +108 -52
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +2 -3
- package/build/intl/localeConfig.js +14 -20
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.d.ts +2 -4
- package/build/intl/localeList.js +109 -1
- package/build/intl/localeList.js.map +1 -1
- package/build/intl/localeObject.js +82 -80
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +25 -35
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.js +28 -11
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +10 -5
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +10 -5
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +10 -5
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.js +10 -5
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +10 -5
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentStory.js +10 -5
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +21 -17
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +56 -52
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +10 -5
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +10 -5
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +16 -11
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.d.ts +1 -2
- package/build/newsroom-context/index.js +22 -2
- package/build/newsroom-context/index.js.map +1 -1
- package/build/sentry/client.js +9 -4
- package/build/sentry/client.js.map +1 -1
- package/build/sentry/common.js +29 -26
- package/build/sentry/common.js.map +1 -1
- package/build/sentry/index.js +8 -2
- package/build/sentry/index.js.map +1 -1
- package/build/sentry/server.js +9 -4
- package/build/sentry/server.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/types.js +3 -1
- package/build/utils/boilerplate.js +22 -7
- package/build/utils/boilerplate.js.map +1 -1
- package/build/utils/constants.js +7 -3
- package/build/utils/constants.js.map +1 -1
- package/build/utils/getAssetsUrl.js +9 -4
- package/build/utils/getAssetsUrl.js.map +1 -1
- package/build/utils/getDataRequestLink.js +12 -6
- package/build/utils/getDataRequestLink.js.map +1 -1
- package/build/utils/getLocalizedCategoryData.js +33 -33
- package/build/utils/getLocalizedCategoryData.js.map +1 -1
- package/build/utils/getNewsroomLogoUrl.js +21 -15
- package/build/utils/getNewsroomLogoUrl.js.map +1 -1
- package/build/utils/getPrivacyPortalUrl.js +13 -11
- package/build/utils/getPrivacyPortalUrl.js.map +1 -1
- package/build/utils/getStoryPublicationDate.js +14 -9
- package/build/utils/getStoryPublicationDate.js.map +1 -1
- package/build/utils/getUploadcareGroupUrl.js +10 -5
- package/build/utils/getUploadcareGroupUrl.js.map +1 -1
- package/build/utils/index.js +27 -10
- package/build/utils/index.js.map +1 -1
- package/build/utils/isEmbargoStory.js +8 -3
- package/build/utils/isEmbargoStory.js.map +1 -1
- package/package.json +13 -28
- package/src/@types/global.d.ts +7 -0
- package/src/__mocks__/languages.ts +416 -0
- package/src/__mocks__/story.ts +359 -0
- package/src/adapter-nextjs/api-handlers/fetchGalleries.ts +24 -0
- package/src/adapter-nextjs/api-handlers/fetchStories.ts +26 -0
- package/src/adapter-nextjs/api-handlers/index.ts +2 -0
- package/src/adapter-nextjs/getNewsroomServerSideProps.ts +29 -0
- package/src/adapter-nextjs/getNewsroomStaticProps.ts +29 -0
- package/src/adapter-nextjs/index.ts +6 -0
- package/src/adapter-nextjs/page-props/category.ts +157 -0
- package/src/adapter-nextjs/page-props/gallery.ts +114 -0
- package/src/adapter-nextjs/page-props/galleryAlbum.ts +89 -0
- package/src/adapter-nextjs/page-props/home.ts +113 -0
- package/src/adapter-nextjs/page-props/index.ts +26 -0
- package/src/adapter-nextjs/page-props/lib/types.ts +8 -0
- package/src/adapter-nextjs/page-props/search.ts +53 -0
- package/src/adapter-nextjs/page-props/sitemap/SitemapBuilder.ts +56 -0
- package/src/adapter-nextjs/page-props/sitemap/createPaths.ts +21 -0
- package/src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts +43 -0
- package/src/adapter-nextjs/page-props/sitemap/index.ts +5 -0
- package/src/adapter-nextjs/page-props/sitemap/types.ts +5 -0
- package/src/adapter-nextjs/page-props/story.ts +94 -0
- package/src/adapter-nextjs/page-props/storyPreview.ts +33 -0
- package/src/adapter-nextjs/processRequest.ts +49 -0
- package/src/adapter-nextjs/processStaticRequest.ts +32 -0
- package/src/components-nextjs/PageSeo/PageSeo.tsx +131 -0
- package/src/components-nextjs/PageSeo/index.ts +2 -0
- package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +7 -0
- package/src/components-nextjs/PageSeo/lib/types.ts +4 -0
- package/src/components-nextjs/StorySeo/StorySeo.tsx +82 -0
- package/src/components-nextjs/StorySeo/index.ts +1 -0
- package/src/components-nextjs/document.tsx +38 -0
- package/src/components-nextjs/index.ts +3 -0
- package/src/data-fetching/api/PrezlyApi.ts +304 -0
- package/src/data-fetching/api/getPrezlyApi.ts +24 -0
- package/src/data-fetching/api/index.ts +1 -0
- package/src/data-fetching/api/queries.ts +51 -0
- package/src/data-fetching/index.ts +3 -0
- package/src/data-fetching/lib/getAlgoliaSettings.ts +29 -0
- package/src/data-fetching/lib/getEnvVariables.ts +46 -0
- package/src/data-fetching/lib/index.ts +4 -0
- package/src/data-fetching/lib/isSdkError.ts +5 -0
- package/src/data-fetching/lib/isUuid.ts +5 -0
- package/src/data-fetching/types.ts +14 -0
- package/src/index.ts +9 -0
- package/src/infinite-loading/index.ts +4 -0
- package/src/infinite-loading/types.ts +5 -0
- package/src/infinite-loading/useInfiniteGalleriesLoading.ts +53 -0
- package/src/infinite-loading/useInfiniteLoading.ts +66 -0
- package/src/infinite-loading/useInfiniteStoriesLoading.ts +81 -0
- package/src/intl/index.ts +4 -0
- package/src/intl/languages.test.ts +232 -0
- package/src/intl/languages.ts +233 -0
- package/src/intl/locale.test.ts +95 -0
- package/src/intl/locale.ts +140 -0
- package/src/intl/localeConfig.js +23 -0
- package/src/intl/localeList.js +110 -0
- package/src/intl/localeObject.test.ts +81 -0
- package/src/intl/localeObject.ts +99 -0
- package/src/newsroom-context/context.tsx +115 -0
- package/src/newsroom-context/hooks/index.ts +11 -0
- package/src/newsroom-context/hooks/useAlgoliaSettings.ts +7 -0
- package/src/newsroom-context/hooks/useCategories.ts +7 -0
- package/src/newsroom-context/hooks/useCompanyInformation.ts +7 -0
- package/src/newsroom-context/hooks/useCurrentCategory.ts +7 -0
- package/src/newsroom-context/hooks/useCurrentLocale.ts +7 -0
- package/src/newsroom-context/hooks/useCurrentStory.ts +7 -0
- package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +37 -0
- package/src/newsroom-context/hooks/useGetTranslationUrl.ts +97 -0
- package/src/newsroom-context/hooks/useLanguages.ts +7 -0
- package/src/newsroom-context/hooks/useNewsroom.ts +7 -0
- package/src/newsroom-context/hooks/useNewsroomContext.ts +15 -0
- package/src/newsroom-context/index.ts +2 -0
- package/src/sentry/client.ts +7 -0
- package/src/sentry/common.ts +27 -0
- package/src/sentry/index.ts +2 -0
- package/src/sentry/server.ts +7 -0
- package/src/types.ts +51 -0
- package/src/utils/boilerplate.ts +27 -0
- package/src/utils/constants.ts +3 -0
- package/src/utils/getAssetsUrl.test.ts +9 -0
- package/src/utils/getAssetsUrl.ts +9 -0
- package/src/utils/getDataRequestLink.ts +14 -0
- package/src/utils/getLocalizedCategoryData.ts +47 -0
- package/src/utils/getNewsroomLogoUrl.ts +22 -0
- package/src/utils/getPrivacyPortalUrl.ts +25 -0
- package/src/utils/getStoryPublicationDate.tsx +15 -0
- package/src/utils/getUploadcareGroupUrl.ts +13 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/isEmbargoStory.ts +10 -0
- package/build/@types/global.d.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/data-fetching/api/queries.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG;IAC3B,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE;IACvD,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,EAAE;CAC5D,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACvB,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE;IAC5C,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE;CACtC,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/data-fetching/api/queries.ts"],"names":[],"mappings":";;;AAAA,MAAM,sBAAsB,GAAG;IAC3B,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE;IACvD,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,EAAE;CAC5D,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACvB,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE;IAC5C,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE;CACtC,CAAC;AAEF,SAAgB,YAAY,CAAC,YAAoB,EAAE,IAAY;IAC3D,OAAO;QACH,IAAI,EAAE;YACF,EAAE,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE;YAC5C,EAAE,IAAI,EAAE,EA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-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./lib"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-fetching/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-fetching/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ALGOLIA_APP_ID = 'UI4CNRAHQB',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAlgoliaSettings = void 0;
|
|
4
|
+
const getEnvVariables_1 = require("./getEnvVariables");
|
|
5
|
+
function getAlgoliaSettings(req) {
|
|
6
|
+
if (typeof window !== 'undefined') {
|
|
7
|
+
throw new Error('"getAlgoliaSettings" should only be used on back-end side.');
|
|
8
|
+
}
|
|
9
|
+
// `getEnvVariables` handles both cases for envs parsing - .env and request headers
|
|
10
|
+
const { ALGOLIA_API_KEY = '', ALGOLIA_APP_ID = 'UI4CNRAHQB', ALGOLIA_INDEX = 'public_stories_prod', } = (0, getEnvVariables_1.getEnvVariables)(req);
|
|
11
|
+
if (!ALGOLIA_API_KEY) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.error('"ALGOLIA_API_KEY" is not set in env variables. Search will not be enabled');
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
ALGOLIA_API_KEY,
|
|
17
|
+
ALGOLIA_APP_ID,
|
|
18
|
+
ALGOLIA_INDEX,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.getAlgoliaSettings = getAlgoliaSettings;
|
|
22
|
+
//# sourceMappingURL=getAlgoliaSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAlgoliaSettings.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getAlgoliaSettings.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"getAlgoliaSettings.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getAlgoliaSettings.ts"],"names":[],"mappings":";;;AAIA,uDAAoD;AAEpD,SAAgB,kBAAkB,CAAC,GAAqB;IACpD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;KACjF;IAED,mFAAmF;IACnF,MAAM,EACF,eAAe,GAAG,EAAE,EACpB,cAAc,GAAG,YAAY,EAC7B,aAAa,GAAG,qBAAqB,GACxC,GAAG,IAAA,iCAAe,EAAC,GAAG,CAAC,CAAC;IAEzB,IAAI,CAAC,eAAe,EAAE;QAClB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;KAC9F;IAED,OAAO;QACH,eAAe;QACf,cAAc;QACd,aAAa;KAChB,CAAC;AACN,CAAC;AAtBD,gDAsBC"}
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getEnvVariables = void 0;
|
|
7
|
+
const parse_data_url_1 = __importDefault(require("parse-data-url"));
|
|
2
8
|
function decodeJson(json) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
try {
|
|
10
|
+
const decoded = JSON.parse(json);
|
|
11
|
+
if (decoded && typeof decoded === 'object') {
|
|
12
|
+
return decoded;
|
|
13
|
+
}
|
|
7
14
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
catch {
|
|
16
|
+
// passthru
|
|
17
|
+
}
|
|
18
|
+
return {};
|
|
12
19
|
}
|
|
13
20
|
function decodeHttpEnv(header) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
if (header.startsWith('data:')) {
|
|
22
|
+
const parsed = (0, parse_data_url_1.default)(header);
|
|
23
|
+
if (parsed && parsed.contentType === 'application/json') {
|
|
24
|
+
const data = parsed.toBuffer().toString('utf-8');
|
|
25
|
+
return decodeJson(data);
|
|
26
|
+
}
|
|
27
|
+
return {}; // unsupported data-uri
|
|
28
|
+
}
|
|
29
|
+
return decodeJson(header);
|
|
30
|
+
}
|
|
31
|
+
function getEnvVariables(req) {
|
|
32
|
+
if (typeof window !== 'undefined') {
|
|
33
|
+
throw new Error('"getEnvVariables" should only be used on back-end side.');
|
|
34
|
+
}
|
|
35
|
+
const headerName = (process.env.HTTP_ENV_HEADER || '').toLowerCase();
|
|
36
|
+
if (headerName && req) {
|
|
37
|
+
const header = req.headers[headerName];
|
|
38
|
+
const httpEnv = decodeHttpEnv(header || '');
|
|
39
|
+
return { ...process.env, ...httpEnv };
|
|
19
40
|
}
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return decodeJson(header);
|
|
41
|
+
return { ...process.env };
|
|
24
42
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
throw new Error('"getEnvVariables" should only be used on back-end side.');
|
|
28
|
-
}
|
|
29
|
-
const headerName = (process.env.HTTP_ENV_HEADER || '').toLowerCase();
|
|
30
|
-
if (headerName && req) {
|
|
31
|
-
const header = req.headers[headerName];
|
|
32
|
-
const httpEnv = decodeHttpEnv(header || '');
|
|
33
|
-
return {
|
|
34
|
-
...process.env,
|
|
35
|
-
...httpEnv
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
...process.env
|
|
40
|
-
};
|
|
41
|
-
}
|
|
43
|
+
exports.getEnvVariables = getEnvVariables;
|
|
44
|
+
//# sourceMappingURL=getEnvVariables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvVariables.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getEnvVariables.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"getEnvVariables.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getEnvVariables.ts"],"names":[],"mappings":";;;;;;AACA,oEAA0C;AAI1C,SAAS,UAAU,CAAC,IAAY;IAC5B,IAAI;QACA,MAAM,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,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isUuid = exports.isSdkError = exports.getEnvVariables = exports.getAlgoliaSettings = void 0;
|
|
4
|
+
var getAlgoliaSettings_1 = require("./getAlgoliaSettings");
|
|
5
|
+
Object.defineProperty(exports, "getAlgoliaSettings", { enumerable: true, get: function () { return getAlgoliaSettings_1.getAlgoliaSettings; } });
|
|
6
|
+
var getEnvVariables_1 = require("./getEnvVariables");
|
|
7
|
+
Object.defineProperty(exports, "getEnvVariables", { enumerable: true, get: function () { return getEnvVariables_1.getEnvVariables; } });
|
|
8
|
+
var isSdkError_1 = require("./isSdkError");
|
|
9
|
+
Object.defineProperty(exports, "isSdkError", { enumerable: true, get: function () { return isSdkError_1.isSdkError; } });
|
|
10
|
+
var isUuid_1 = require("./isUuid");
|
|
11
|
+
Object.defineProperty(exports, "isUuid", { enumerable: true, get: function () { return isUuid_1.isUuid; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/index.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSdkError = void 0;
|
|
4
|
+
function isSdkError(error) {
|
|
5
|
+
return 'payload' in error;
|
|
6
|
+
}
|
|
7
|
+
exports.isSdkError = isSdkError;
|
|
8
|
+
//# sourceMappingURL=isSdkError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isSdkError.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/isSdkError.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"isSdkError.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/isSdkError.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,KAAU;IACjC,OAAO,SAAS,IAAI,KAAK,CAAC;AAC9B,CAAC;AAFD,gCAEC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isUuid = void 0;
|
|
1
4
|
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
+
function isUuid(input) {
|
|
6
|
+
return UUID_REGEX.test(input);
|
|
7
|
+
}
|
|
8
|
+
exports.isUuid = isUuid;
|
|
9
|
+
//# sourceMappingURL=isUuid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUuid.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/isUuid.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,gEAAgE,CAAC;AAEpF,
|
|
1
|
+
{"version":3,"file":"isUuid.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/isUuid.ts"],"names":[],"mappings":";;;AAAA,MAAM,UAAU,GAAG,gEAAgE,CAAC;AAEpF,SAAgB,MAAM,CAAC,KAAa;IAChC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC"}
|
package/build/index.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./adapter-nextjs"), exports);
|
|
18
|
+
__exportStar(require("./components-nextjs"), exports);
|
|
19
|
+
__exportStar(require("./data-fetching"), exports);
|
|
20
|
+
__exportStar(require("./infinite-loading"), exports);
|
|
21
|
+
__exportStar(require("./intl"), exports);
|
|
22
|
+
__exportStar(require("./newsroom-context"), exports);
|
|
23
|
+
__exportStar(require("./sentry"), exports);
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
__exportStar(require("./utils"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,qDAAmC;AACnC,yCAAuB;AACvB,qDAAmC;AACnC,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB"}
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.useInfiniteGalleriesLoading = exports.useInfiniteStoriesLoading = exports.useInfiniteLoading = void 0;
|
|
18
|
+
var useInfiniteLoading_1 = require("./useInfiniteLoading");
|
|
19
|
+
Object.defineProperty(exports, "useInfiniteLoading", { enumerable: true, get: function () { return useInfiniteLoading_1.useInfiniteLoading; } });
|
|
20
|
+
var useInfiniteStoriesLoading_1 = require("./useInfiniteStoriesLoading");
|
|
21
|
+
Object.defineProperty(exports, "useInfiniteStoriesLoading", { enumerable: true, get: function () { return useInfiniteStoriesLoading_1.useInfiniteStoriesLoading; } });
|
|
22
|
+
var useInfiniteGalleriesLoading_1 = require("./useInfiniteGalleriesLoading");
|
|
23
|
+
Object.defineProperty(exports, "useInfiniteGalleriesLoading", { enumerable: true, get: function () { return useInfiniteGalleriesLoading_1.useInfiniteGalleriesLoading; } });
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infinite-loading/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infinite-loading/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA;AAClC,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA;AACpC,0CAAwB"}
|
|
@@ -1,49 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInfiniteGalleriesLoading = void 0;
|
|
4
|
+
const useInfiniteLoading_1 = require("./useInfiniteLoading");
|
|
2
5
|
async function fetchGalleries(page, pageSize) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return result.json();
|
|
6
|
+
const result = await fetch('/api/fetch-galleries', {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
},
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
page,
|
|
13
|
+
pageSize,
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
if (!result.ok) {
|
|
17
|
+
const { message } = await result.json();
|
|
18
|
+
throw new Error(message);
|
|
19
|
+
}
|
|
20
|
+
return result.json();
|
|
20
21
|
}
|
|
21
|
-
|
|
22
22
|
/**
|
|
23
23
|
* NOTE: This hook depends on the presence of a Next API route (/api/fetch-galleries)!
|
|
24
24
|
* The handler for this route is exported from `apiHandlers/fetchGalleries.ts` file.
|
|
25
25
|
* See https://github.com/prezly/theme-nextjs-bea/blob/d381e9878187ca98815d240d3ffdf10a75993c14/pages/media/index.tsx#L23 for usage example
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
galleries: data,
|
|
46
|
-
isLoading,
|
|
47
|
-
loadMoreGalleries: loadMore
|
|
48
|
-
};
|
|
49
|
-
}
|
|
27
|
+
function useInfiniteGalleriesLoading(initialGalleries, pagination) {
|
|
28
|
+
const { canLoadMore, data, isLoading, loadMore } = (0, useInfiniteLoading_1.useInfiniteLoading)({
|
|
29
|
+
fetchingFn: async (nextPage, pageSize) => {
|
|
30
|
+
const { galleries } = await fetchGalleries(nextPage, pageSize);
|
|
31
|
+
return galleries;
|
|
32
|
+
},
|
|
33
|
+
initialData: initialGalleries,
|
|
34
|
+
pagination,
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
canLoadMore,
|
|
38
|
+
galleries: data,
|
|
39
|
+
isLoading,
|
|
40
|
+
loadMoreGalleries: loadMore,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.useInfiniteGalleriesLoading = useInfiniteGalleriesLoading;
|
|
44
|
+
//# sourceMappingURL=useInfiniteGalleriesLoading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteGalleriesLoading.js","sourceRoot":"","sources":["../../src/infinite-loading/useInfiniteGalleriesLoading.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"useInfiniteGalleriesLoading.js","sourceRoot":"","sources":["../../src/infinite-loading/useInfiniteGalleriesLoading.ts"],"names":[],"mappings":";;;AAGA,6DAA0D;AAE1D,KAAK,UAAU,cAAc,CACzB,IAAY,EACZ,QAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,sBAAsB,EAAE;QAC/C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACL,cAAc,EAAE,kBAAkB;SACrC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACjB,IAAI;YACJ,QAAQ;SACX,CAAC;KACL,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QACZ,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAED,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,SAAgB,2BAA2B,CACvC,gBAAmC,EACnC,UAA2B;IAE3B,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAA,uCAAkB,EAAkB;QACnF,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACrC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC/D,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,WAAW,EAAE,gBAAgB;QAC7B,UAAU;KACb,CAAC,CAAC;IAEH,OAAO;QACH,WAAW;QACX,SAAS,EAAE,IAAI;QACf,SAAS;QACT,iBAAiB,EAAE,QAAQ;KAC9B,CAAC;AACN,CAAC;AAnBD,kEAmBC"}
|
|
@@ -1,50 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
currentPage,
|
|
45
|
-
data,
|
|
46
|
-
isLoading: status === 'loading',
|
|
47
|
-
loadMore,
|
|
48
|
-
resetData
|
|
49
|
-
};
|
|
50
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInfiniteLoading = void 0;
|
|
4
|
+
const web_1 = require("@react-hookz/web");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useInfiniteLoading({ fetchingFn, initialData, pagination, }) {
|
|
7
|
+
const [data, setData] = (0, react_1.useState)(initialData);
|
|
8
|
+
const [currentPage, setCurrentPage] = (0, react_1.useState)(pagination.currentPage);
|
|
9
|
+
const { itemsTotal, pageSize } = pagination;
|
|
10
|
+
const pagesTotal = Math.ceil(itemsTotal / pageSize);
|
|
11
|
+
const canLoadMore = currentPage < pagesTotal;
|
|
12
|
+
const [{ error, status }, { execute: loadMoreFn }] = (0, web_1.useAsync)(async () => {
|
|
13
|
+
const nextPage = currentPage + 1;
|
|
14
|
+
const newData = await fetchingFn(nextPage, pageSize);
|
|
15
|
+
setCurrentPage(nextPage);
|
|
16
|
+
setData((currentData) => [...currentData, ...newData]);
|
|
17
|
+
});
|
|
18
|
+
const loadMore = (0, react_1.useCallback)(() => {
|
|
19
|
+
if (canLoadMore) {
|
|
20
|
+
loadMoreFn();
|
|
21
|
+
}
|
|
22
|
+
}, [canLoadMore, loadMoreFn]);
|
|
23
|
+
const resetData = (0, react_1.useCallback)(() => {
|
|
24
|
+
setData(initialData);
|
|
25
|
+
setCurrentPage(pagination.currentPage);
|
|
26
|
+
}, [pagination.currentPage, initialData]);
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
if (error) {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.error(error);
|
|
31
|
+
}
|
|
32
|
+
}, [error]);
|
|
33
|
+
return {
|
|
34
|
+
canLoadMore,
|
|
35
|
+
currentPage,
|
|
36
|
+
data,
|
|
37
|
+
isLoading: status === 'loading',
|
|
38
|
+
loadMore,
|
|
39
|
+
resetData,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.useInfiniteLoading = useInfiniteLoading;
|
|
43
|
+
//# sourceMappingURL=useInfiniteLoading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteLoading.js","sourceRoot":"","sources":["../../src/infinite-loading/useInfiniteLoading.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"useInfiniteLoading.js","sourceRoot":"","sources":["../../src/infinite-loading/useInfiniteLoading.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAC5C,iCAAyD;AAmBzD,SAAgB,kBAAkB,CAAI,EAClC,UAAU,EACV,WAAW,EACX,UAAU,GACE;IACZ,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAM,WAAW,CAAC,CAAC;IACnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,UAAU,CAAC,WAAW,CAAC,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