@enonic/nextjs-adapter 3.3.0-B1 → 3.3.0-B2
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/dist/baseMappings.d.ts +1 -0
- package/{src/baseMappings.ts → dist/baseMappings.js} +4 -14
- package/dist/baseMappings.js.map +1 -0
- package/dist/client/getClientHydratedHtml.d.ts +1 -0
- package/{src/client/getClientHydratedHtml.tsx → dist/client/getClientHydratedHtml.jsx} +3 -6
- package/dist/client/getClientHydratedHtml.jsx.map +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -0
- package/dist/common/ComponentRegistry.d.ts +34 -0
- package/dist/common/ComponentRegistry.js +121 -0
- package/dist/common/ComponentRegistry.js.map +1 -0
- package/dist/common/UrlProcessor.d.ts +25 -0
- package/{src/common/UrlProcessor.ts → dist/common/UrlProcessor.js} +49 -70
- package/dist/common/UrlProcessor.js.map +1 -0
- package/dist/common/constants.d.ts +51 -0
- package/{src/common/constants.ts → dist/common/constants.js} +38 -44
- package/dist/common/constants.js.map +1 -0
- package/dist/common/env.d.ts +12 -0
- package/{src/common/env.ts → dist/common/env.js} +3 -14
- package/dist/common/env.js.map +1 -0
- package/dist/guillotine/applyProcessors.d.ts +2 -0
- package/dist/guillotine/applyProcessors.js +33 -0
- package/dist/guillotine/applyProcessors.js.map +1 -0
- package/dist/guillotine/buildComponentTree.d.ts +2 -0
- package/{src/guillotine/buildComponentTree.ts → dist/guillotine/buildComponentTree.js} +13 -25
- package/dist/guillotine/buildComponentTree.js.map +1 -0
- package/dist/guillotine/buildErrorResponse.d.ts +3 -0
- package/{src/guillotine/buildErrorResponse.ts → dist/guillotine/buildErrorResponse.js} +2 -10
- package/dist/guillotine/buildErrorResponse.js.map +1 -0
- package/dist/guillotine/buildPage.d.ts +2 -0
- package/dist/guillotine/buildPage.js +10 -0
- package/dist/guillotine/buildPage.js.map +1 -0
- package/dist/guillotine/collectComponentDescriptors.d.ts +6 -0
- package/{src/guillotine/collectComponentDescriptors.ts → dist/guillotine/collectComponentDescriptors.js} +13 -26
- package/dist/guillotine/collectComponentDescriptors.js.map +1 -0
- package/dist/guillotine/combineMultipleQueries.d.ts +2 -0
- package/{src/guillotine/combineMultipleQueries.ts → dist/guillotine/combineMultipleQueries.js} +9 -23
- package/dist/guillotine/combineMultipleQueries.js.map +1 -0
- package/dist/guillotine/createMetaData.d.ts +18 -0
- package/dist/guillotine/createMetaData.js +45 -0
- package/dist/guillotine/createMetaData.js.map +1 -0
- package/dist/guillotine/fetchContent.d.ts +9 -0
- package/dist/guillotine/fetchContent.js +222 -0
- package/dist/guillotine/fetchContent.js.map +1 -0
- package/dist/guillotine/fetchContentData.d.ts +2 -0
- package/dist/guillotine/fetchContentData.js +30 -0
- package/dist/guillotine/fetchContentData.js.map +1 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.d.ts +2 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.js +21 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
- package/dist/guillotine/fetchContentPathsForLocale.d.ts +2 -0
- package/dist/guillotine/fetchContentPathsForLocale.js +41 -0
- package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -0
- package/dist/guillotine/fetchFromApi.d.ts +3 -0
- package/dist/guillotine/fetchFromApi.js +76 -0
- package/dist/guillotine/fetchFromApi.js.map +1 -0
- package/dist/guillotine/fetchGuillotine.d.ts +3 -0
- package/dist/guillotine/fetchGuillotine.js +75 -0
- package/dist/guillotine/fetchGuillotine.js.map +1 -0
- package/dist/guillotine/fetchMetaData.d.ts +2 -0
- package/dist/guillotine/fetchMetaData.js +33 -0
- package/dist/guillotine/fetchMetaData.js.map +1 -0
- package/dist/guillotine/getCleanContentPathArrayOrThrow400.d.ts +2 -0
- package/{src/guillotine/getCleanContentPathArrayOrThrow400.ts → dist/guillotine/getCleanContentPathArrayOrThrow400.js} +5 -7
- package/dist/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
- package/dist/guillotine/getComponentConfig.d.ts +2 -0
- package/{src/guillotine/getComponentConfig.ts → dist/guillotine/getComponentConfig.js} +3 -5
- package/dist/guillotine/getComponentConfig.js.map +1 -0
- package/dist/guillotine/getContentAndComponentPaths.d.ts +1 -0
- package/{src/guillotine/getContentAndComponentPaths.ts → dist/guillotine/getContentAndComponentPaths.js} +6 -5
- package/dist/guillotine/getContentAndComponentPaths.js.map +1 -0
- package/dist/guillotine/getMetaData.d.ts +2 -0
- package/{src/guillotine/getMetaData.ts → dist/guillotine/getMetaData.js} +11 -18
- package/dist/guillotine/getMetaData.js.map +1 -0
- package/dist/guillotine/getParentRegion.d.ts +2 -0
- package/{src/guillotine/getParentRegion.ts → dist/guillotine/getParentRegion.js} +9 -23
- package/dist/guillotine/getParentRegion.js.map +1 -0
- package/dist/guillotine/getQueryAndVariables.d.ts +2 -0
- package/{src/guillotine/getQueryAndVariables.ts → dist/guillotine/getQueryAndVariables.js} +7 -23
- package/dist/guillotine/getQueryAndVariables.js.map +1 -0
- package/dist/guillotine/metadata/configQuery.d.ts +2 -0
- package/dist/guillotine/metadata/configQuery.js +36 -0
- package/dist/guillotine/metadata/configQuery.js.map +1 -0
- package/dist/guillotine/metadata/richTextQuery.d.ts +1 -0
- package/{src/guillotine/metadata/richTextQuery.ts → dist/guillotine/metadata/richTextQuery.js} +6 -8
- package/dist/guillotine/metadata/richTextQuery.js.map +1 -0
- package/dist/guillotine/parseComponentPath.d.ts +2 -0
- package/{src/guillotine/parseComponentPath.ts → dist/guillotine/parseComponentPath.js} +4 -8
- package/dist/guillotine/parseComponentPath.js.map +1 -0
- package/dist/guillotine/prefixFragmentCmpPath.d.ts +1 -0
- package/{src/guillotine/prefixFragmentCmpPath.ts → dist/guillotine/prefixFragmentCmpPath.js} +5 -5
- package/dist/guillotine/prefixFragmentCmpPath.js.map +1 -0
- package/dist/guillotine/processComponentConfig.d.ts +2 -0
- package/{src/guillotine/processComponentConfig.ts → dist/guillotine/processComponentConfig.js} +4 -12
- package/dist/guillotine/processComponentConfig.js.map +1 -0
- package/dist/guillotine/restrictComponentsToPath.d.ts +2 -0
- package/{src/guillotine/restrictComponentsToPath.ts → dist/guillotine/restrictComponentsToPath.js} +9 -19
- package/dist/guillotine/restrictComponentsToPath.js.map +1 -0
- package/dist/guillotine/validateData.d.ts +2 -0
- package/dist/guillotine/validateData.js +7 -0
- package/dist/guillotine/validateData.js.map +1 -0
- package/dist/guillotine/validateNotFound.d.ts +2 -0
- package/{src/guillotine/validateNotFound.ts → dist/guillotine/validateNotFound.js} +5 -9
- package/dist/guillotine/validateNotFound.js.map +1 -0
- package/dist/guillotine/validateShortcut.d.ts +2 -0
- package/{src/guillotine/validateShortcut.ts → dist/guillotine/validateShortcut.js} +12 -20
- package/dist/guillotine/validateShortcut.js.map +1 -0
- package/dist/i18n/LocaleContext.d.ts +7 -0
- package/dist/i18n/LocaleContext.jsx +50 -0
- package/dist/i18n/LocaleContext.jsx.map +1 -0
- package/dist/i18n/i18n.d.ts +12 -0
- package/dist/i18n/i18n.js +59 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/query/Shortcut.d.ts +1 -0
- package/{src/query/Shortcut.ts → dist/query/Shortcut.js} +1 -0
- package/dist/query/Shortcut.js.map +1 -0
- package/dist/server/getServerRenderedHtml.d.ts +1 -0
- package/dist/server/getServerRenderedHtml.js +4 -0
- package/dist/server/getServerRenderedHtml.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -0
- package/{src/types/component.ts → dist/types/component.d.ts} +23 -62
- package/dist/types/component.js +2 -0
- package/dist/types/component.js.map +1 -0
- package/dist/types/componentProps.d.ts +107 -0
- package/dist/types/componentProps.js +2 -0
- package/dist/types/componentProps.js.map +1 -0
- package/dist/types/guillotine.d.ts +344 -0
- package/dist/types/guillotine.js +2 -0
- package/dist/types/guillotine.js.map +1 -0
- package/dist/types/i18n.d.ts +7 -0
- package/dist/types/i18n.js +2 -0
- package/dist/types/i18n.js.map +1 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +19 -34
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/next.d.ts +6 -0
- package/dist/types/next.js +2 -0
- package/dist/types/next.js.map +1 -0
- package/dist/types/util.d.ts +3 -0
- package/dist/types/util.js +3 -0
- package/dist/types/util.js.map +1 -0
- package/dist/utils/addLineNumbers.d.ts +1 -0
- package/dist/utils/addLineNumbers.js +4 -0
- package/dist/utils/addLineNumbers.js.map +1 -0
- package/dist/utils/buildGuillotineRequestHeaders.d.ts +7 -0
- package/dist/utils/buildGuillotineRequestHeaders.js +16 -0
- package/dist/utils/buildGuillotineRequestHeaders.js.map +1 -0
- package/dist/utils/commonChars.d.ts +1 -0
- package/{src/utils/commonChars.ts → dist/utils/commonChars.js} +5 -4
- package/dist/utils/commonChars.js.map +1 -0
- package/dist/utils/enonicLog.d.ts +5 -0
- package/dist/utils/enonicLog.js +23 -0
- package/dist/utils/enonicLog.js.map +1 -0
- package/dist/utils/fixDoubleSlashes.d.ts +1 -0
- package/dist/utils/fixDoubleSlashes.js +4 -0
- package/dist/utils/fixDoubleSlashes.js.map +1 -0
- package/dist/utils/getAllLocales.d.ts +1 -0
- package/dist/utils/getAllLocales.js +5 -0
- package/dist/utils/getAllLocales.js.map +1 -0
- package/dist/utils/getContentApiUrl.d.ts +2 -0
- package/dist/utils/getContentApiUrl.js +15 -0
- package/dist/utils/getContentApiUrl.js.map +1 -0
- package/dist/utils/getLocaleMapping.d.ts +2 -0
- package/dist/utils/getLocaleMapping.js +19 -0
- package/dist/utils/getLocaleMapping.js.map +1 -0
- package/dist/utils/getLocaleMappingByLocale.d.ts +2 -0
- package/dist/utils/getLocaleMappingByLocale.js +13 -0
- package/dist/utils/getLocaleMappingByLocale.js.map +1 -0
- package/dist/utils/getLocaleMappingByProjectId.d.ts +2 -0
- package/dist/utils/getLocaleMappingByProjectId.js +16 -0
- package/dist/utils/getLocaleMappingByProjectId.js.map +1 -0
- package/dist/utils/getLocaleMappings.d.ts +2 -0
- package/{src/utils/getLocaleMappings.ts → dist/utils/getLocaleMappings.js} +8 -14
- package/dist/utils/getLocaleMappings.js.map +1 -0
- package/dist/utils/getRenderMode.d.ts +3 -0
- package/dist/utils/getRenderMode.js +8 -0
- package/dist/utils/getRenderMode.js.map +1 -0
- package/dist/utils/getRequestLocaleInfo.d.ts +6 -0
- package/{src/utils/getRequestLocaleInfo.ts → dist/utils/getRequestLocaleInfo.js} +12 -13
- package/dist/utils/getRequestLocaleInfo.js.map +1 -0
- package/dist/utils/getXpBaseUrl.d.ts +2 -0
- package/dist/utils/getXpBaseUrl.js +8 -0
- package/dist/utils/getXpBaseUrl.js.map +1 -0
- package/dist/utils/indent.d.ts +1 -0
- package/dist/utils/indent.js +5 -0
- package/dist/utils/indent.js.map +1 -0
- package/dist/utils/sanitizeGraphqlName.d.ts +1 -0
- package/{src/utils/sanitizeGraphqlName.ts → dist/utils/sanitizeGraphqlName.js} +3 -2
- package/dist/utils/sanitizeGraphqlName.js.map +1 -0
- package/dist/views/BaseComponent.d.ts +20 -0
- package/{src/views/BaseComponent.tsx → dist/views/BaseComponent.jsx} +49 -76
- package/dist/views/BaseComponent.jsx.map +1 -0
- package/dist/views/BaseContent.d.ts +3 -0
- package/dist/views/BaseContent.jsx +38 -0
- package/dist/views/BaseContent.jsx.map +1 -0
- package/dist/views/BaseLayout.d.ts +3 -0
- package/dist/views/BaseLayout.jsx +24 -0
- package/dist/views/BaseLayout.jsx.map +1 -0
- package/dist/views/BaseMacro.d.ts +6 -0
- package/{src/views/BaseMacro.tsx → dist/views/BaseMacro.jsx} +37 -42
- package/dist/views/BaseMacro.jsx.map +1 -0
- package/dist/views/BasePage.d.ts +3 -0
- package/dist/views/BasePage.jsx +34 -0
- package/dist/views/BasePage.jsx.map +1 -0
- package/dist/views/BasePart.d.ts +3 -0
- package/dist/views/BasePart.jsx +24 -0
- package/dist/views/BasePart.jsx.map +1 -0
- package/dist/views/Empty.d.ts +2 -0
- package/{src/views/Empty.tsx → dist/views/Empty.jsx} +1 -2
- package/dist/views/Empty.jsx.map +1 -0
- package/dist/views/Fragment.d.ts +3 -0
- package/dist/views/Fragment.jsx +30 -0
- package/dist/views/Fragment.jsx.map +1 -0
- package/dist/views/MainView.d.ts +3 -0
- package/dist/views/MainView.jsx +14 -0
- package/dist/views/MainView.jsx.map +1 -0
- package/dist/views/PropsView.d.ts +2 -0
- package/dist/views/PropsView.jsx +21 -0
- package/dist/views/PropsView.jsx.map +1 -0
- package/dist/views/Region.d.ts +6 -0
- package/{src/views/Region.tsx → dist/views/Region.jsx} +17 -41
- package/dist/views/Region.jsx.map +1 -0
- package/dist/views/RichTextView.d.ts +3 -0
- package/dist/views/RichTextView.jsx +65 -0
- package/dist/views/RichTextView.jsx.map +1 -0
- package/dist/views/SingleComponent.d.ts +4 -0
- package/dist/views/SingleComponent.jsx +10 -0
- package/dist/views/SingleComponent.jsx.map +1 -0
- package/dist/views/StaticContent.d.ts +10 -0
- package/dist/views/StaticContent.jsx +37 -0
- package/dist/views/StaticContent.jsx.map +1 -0
- package/dist/views/Text.d.ts +8 -0
- package/dist/views/Text.jsx +4 -0
- package/dist/views/Text.jsx.map +1 -0
- package/dist/views/macros/DefaultMacro.d.ts +3 -0
- package/dist/views/macros/DefaultMacro.jsx +4 -0
- package/dist/views/macros/DefaultMacro.jsx.map +1 -0
- package/dist/views/macros/DisableMacro.d.ts +3 -0
- package/dist/views/macros/DisableMacro.jsx +3 -0
- package/dist/views/macros/DisableMacro.jsx.map +1 -0
- package/package.json +19 -31
- package/src/client.ts +0 -2
- package/src/common/ComponentRegistry.ts +0 -159
- package/src/guillotine/applyProcessors.ts +0 -34
- package/src/guillotine/buildPage.ts +0 -15
- package/src/guillotine/createMetaData.ts +0 -72
- package/src/guillotine/fetchContent.ts +0 -240
- package/src/guillotine/fetchContentData.ts +0 -31
- package/src/guillotine/fetchContentPathsForAllLocales.ts +0 -21
- package/src/guillotine/fetchContentPathsForLocale.ts +0 -43
- package/src/guillotine/fetchFromApi.ts +0 -76
- package/src/guillotine/fetchGuillotine.ts +0 -76
- package/src/guillotine/fetchMetaData.ts +0 -31
- package/src/guillotine/metadata/configQuery.ts +0 -46
- package/src/guillotine/validateData.ts +0 -11
- package/src/i18n/LocaleContext.tsx +0 -59
- package/src/i18n/i18n.ts +0 -57
- package/src/index.ts +0 -42
- package/src/server/getServerRenderedHtml.ts +0 -3
- package/src/server.ts +0 -5
- package/src/types/componentProps.ts +0 -143
- package/src/types/guillotine.ts +0 -428
- package/src/types/i18n.ts +0 -8
- package/src/types/next.ts +0 -7
- package/src/types/util.ts +0 -5
- package/src/utils/addLineNumbers.ts +0 -3
- package/src/utils/buildGuillotineRequestHeaders.ts +0 -29
- package/src/utils/enonicLog.ts +0 -28
- package/src/utils/fixDoubleSlashes.ts +0 -3
- package/src/utils/getAllLocales.ts +0 -6
- package/src/utils/getContentApiUrl.ts +0 -20
- package/src/utils/getLocaleMapping.ts +0 -24
- package/src/utils/getLocaleMappingByLocale.ts +0 -19
- package/src/utils/getLocaleMappingByProjectId.ts +0 -21
- package/src/utils/getRenderMode.ts +0 -11
- package/src/utils/getXpBaseUrl.ts +0 -12
- package/src/utils/indent.ts +0 -4
- package/src/views/BaseContent.tsx +0 -47
- package/src/views/BaseLayout.tsx +0 -33
- package/src/views/BasePage.tsx +0 -42
- package/src/views/BasePart.tsx +0 -34
- package/src/views/Fragment.tsx +0 -41
- package/src/views/MainView.tsx +0 -22
- package/src/views/PropsView.tsx +0 -38
- package/src/views/RichTextView.tsx +0 -106
- package/src/views/SingleComponent.tsx +0 -19
- package/src/views/StaticContent.tsx +0 -39
- package/src/views/Text.tsx +0 -19
- package/src/views/macros/DefaultMacro.tsx +0 -9
- package/src/views/macros/DisableMacro.tsx +0 -8
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
12
|
+
import { getPhrase, loadPhrases } from './i18n';
|
|
13
|
+
const LocaleContext = createContext({
|
|
14
|
+
dictionary: {},
|
|
15
|
+
locale: '',
|
|
16
|
+
localize: (key, ...args) => key,
|
|
17
|
+
setLocale: (locale) => Promise.resolve({})
|
|
18
|
+
});
|
|
19
|
+
export const useLocaleContext = () => useContext(LocaleContext);
|
|
20
|
+
export const LocaleContextProvider = ({ children, locale: localeProps = '' }) => {
|
|
21
|
+
const [currentLocale, setLocaleState] = useState(localeProps);
|
|
22
|
+
const [dictionary, setPhrasesState] = useState({});
|
|
23
|
+
const [isLoaded, setLoadedState] = useState(false);
|
|
24
|
+
const setLocale = (locale) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
setLocaleState(locale);
|
|
26
|
+
setLoadedState(false);
|
|
27
|
+
return loadPhrases(locale).then((phrases) => {
|
|
28
|
+
setPhrasesState(phrases);
|
|
29
|
+
setLoadedState(true);
|
|
30
|
+
return phrases;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (localeProps) {
|
|
35
|
+
void setLocale(localeProps); // void to avoid @typescript-eslint/no-floating-promises
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
const localize = (key, ...args) => {
|
|
39
|
+
return isLoaded ? getPhrase(currentLocale, dictionary, key, ...args) : key;
|
|
40
|
+
};
|
|
41
|
+
return (<LocaleContext.Provider value={{
|
|
42
|
+
setLocale,
|
|
43
|
+
locale: currentLocale,
|
|
44
|
+
dictionary,
|
|
45
|
+
localize
|
|
46
|
+
}}>
|
|
47
|
+
{children}
|
|
48
|
+
</LocaleContext.Provider>);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=LocaleContext.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocaleContext.jsx","sourceRoot":"","sources":["../../src/i18n/LocaleContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;AAGb,OAAO,KAAK,EAAE,EAAC,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AAG9C,MAAM,aAAa,GAAG,aAAa,CAAoB;IACnD,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,CAAC,GAAW,EAAE,GAAG,IAAW,EAAE,EAAE,CAAC,GAAG;IAC9C,SAAS,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAClC,QAAQ,EACR,MAAM,EAAE,WAAW,GAAG,EAAE,EAI3B,EAAE,EAAE;IACD,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9D,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAO,EAAE,CAAC,CAAC;IACzD,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEnD,MAAM,SAAS,GAAG,CAAO,MAAc,EAAiB,EAAE;QACtD,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,cAAc,CAAC,KAAK,CAAC,CAAC;QAEtB,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACxC,eAAe,CAAC,OAAO,CAAC,CAAC;YACzB,cAAc,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,OAAO,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC,CAAA,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,WAAW,EAAE,CAAC;YACd,KAAK,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,wDAAwD;QACzF,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,GAAG,IAAW,EAAE,EAAE;QAC7C,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/E,CAAC,CAAC;IAEF,OAAO,CACH,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3B,SAAS;YACT,MAAM,EAAE,aAAa;YACrB,UAAU;YACV,QAAQ;SACX,CAAC,CACE;YAAA,CAAC,QAAQ,CACb;QAAA,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC5B,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Dict } from '../types';
|
|
2
|
+
export declare class I18n {
|
|
3
|
+
private static locale;
|
|
4
|
+
private static dictionary;
|
|
5
|
+
private static isLoaded;
|
|
6
|
+
static setLocale(locale: string): Promise<Dict>;
|
|
7
|
+
static localize(key: string, ...args: any[]): string;
|
|
8
|
+
static getLocale(): string;
|
|
9
|
+
static getDictionary(): Dict;
|
|
10
|
+
}
|
|
11
|
+
export declare const loadPhrases: (locale: string) => Promise<Dict>;
|
|
12
|
+
export declare const getPhrase: (locale: string, dict: Dict, key: string, ...args: any[]) => string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export class I18n {
|
|
11
|
+
static setLocale(locale) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
this.locale = locale;
|
|
14
|
+
this.isLoaded = false;
|
|
15
|
+
return loadPhrases(locale).then((phrases) => {
|
|
16
|
+
this.dictionary = phrases;
|
|
17
|
+
this.isLoaded = true;
|
|
18
|
+
return phrases;
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
static localize(key, ...args) {
|
|
23
|
+
return this.isLoaded ? getPhrase(this.locale, this.dictionary, key, ...args) : key;
|
|
24
|
+
}
|
|
25
|
+
static getLocale() {
|
|
26
|
+
return this.locale;
|
|
27
|
+
}
|
|
28
|
+
static getDictionary() {
|
|
29
|
+
return this.dictionary;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
I18n.locale = '';
|
|
33
|
+
I18n.dictionary = {};
|
|
34
|
+
I18n.isLoaded = false;
|
|
35
|
+
export const loadPhrases = (locale) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
return import(`@phrases/${locale}.json`)
|
|
37
|
+
.then((module) => module.default)
|
|
38
|
+
.catch((e) => {
|
|
39
|
+
console.error(`Failed to load phrases for locale "${locale}"`, e);
|
|
40
|
+
return {};
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
export const getPhrase = (locale, dict, key, ...args) => {
|
|
44
|
+
const template = dict[key];
|
|
45
|
+
if (!template) {
|
|
46
|
+
console.warn(`Missing localization phrase for locale "${locale}": <${key}>`);
|
|
47
|
+
return `<${key}>`;
|
|
48
|
+
}
|
|
49
|
+
if (args.length) {
|
|
50
|
+
let index = -1;
|
|
51
|
+
return template.replace(/{(\d+)?}/g, (match, digit) => {
|
|
52
|
+
var _a;
|
|
53
|
+
index++;
|
|
54
|
+
return (_a = args[digit || index]) !== null && _a !== void 0 ? _a : match;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return template;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":";;;;;;;;;AAGA,MAAM,OAAO,IAAI;IAKN,MAAM,CAAO,SAAS,CAAC,MAAc;;YACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YAEtB,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBACxC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;gBAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,OAAO,OAAO,CAAC;YACnB,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;IAEM,MAAM,CAAC,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAW;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACvF,CAAC;IAEM,MAAM,CAAC,SAAS;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,aAAa;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;;AAzBc,WAAM,GAAG,EAAE,CAAC;AACZ,eAAU,GAAS,EAAE,CAAC;AACtB,aAAQ,GAAG,KAAK,CAAC;AA0BpC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAO,MAAc,EAAiB,EAAE;IAC/D,OAAO,MAAM,CAAC,YAAY,MAAM,OAAO,CAAC;SACnC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;SAChC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,sCAAsC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACX,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,IAAU,EAAE,GAAW,EAAE,GAAG,IAAW,EAAE,EAAE;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,2CAA2C,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC;QAC7E,OAAO,IAAI,GAAG,GAAG,CAAC;IACtB,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;QACf,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;YAClD,KAAK,EAAE,CAAC;YACR,OAAO,MAAA,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,mCAAI,KAAK,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { APP_NAME, APP_NAME_DASHED, APP_NAME_UNDERSCORED, IS_DEV_MODE } from './common/env';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
export { ComponentRegistry } from './common/ComponentRegistry';
|
|
4
|
+
export { CATCH_ALL, JSESSIONID_HEADER, PORTAL_COMPONENT_ATTRIBUTE, PORTAL_REGION_ATTRIBUTE, PROJECT_ID_HEADER, RENDER_MODE, RENDER_MODE_HEADER, XP_BASE_URL_HEADER, XP_COMPONENT_TYPE, XP_REQUEST_TYPE } from './common/constants';
|
|
5
|
+
export { richTextQuery } from './guillotine/metadata/richTextQuery';
|
|
6
|
+
export { validateData } from './guillotine/validateData';
|
|
7
|
+
export { I18n } from './i18n/i18n';
|
|
8
|
+
export { getContentApiUrl } from './utils/getContentApiUrl';
|
|
9
|
+
export { getLocaleMapping } from './utils/getLocaleMapping';
|
|
10
|
+
export { getLocaleMappingByProjectId } from './utils/getLocaleMappingByProjectId';
|
|
11
|
+
export { getLocaleMappingByLocale } from './utils/getLocaleMappingByLocale';
|
|
12
|
+
export { getRequestLocaleInfo } from './utils/getRequestLocaleInfo';
|
|
13
|
+
export { sanitizeGraphqlName } from './utils/sanitizeGraphqlName';
|
|
14
|
+
export { UrlProcessor, getAsset, getUrl } from './common/UrlProcessor';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { APP_NAME, APP_NAME_DASHED, APP_NAME_UNDERSCORED, IS_DEV_MODE } from './common/env';
|
|
2
|
+
export { ComponentRegistry } from './common/ComponentRegistry';
|
|
3
|
+
export { CATCH_ALL, JSESSIONID_HEADER, PORTAL_COMPONENT_ATTRIBUTE, PORTAL_REGION_ATTRIBUTE, PROJECT_ID_HEADER, RENDER_MODE, RENDER_MODE_HEADER, XP_BASE_URL_HEADER, XP_COMPONENT_TYPE, XP_REQUEST_TYPE } from './common/constants';
|
|
4
|
+
export { richTextQuery } from './guillotine/metadata/richTextQuery';
|
|
5
|
+
export { validateData } from './guillotine/validateData';
|
|
6
|
+
export { I18n } from './i18n/i18n';
|
|
7
|
+
export { getContentApiUrl } from './utils/getContentApiUrl';
|
|
8
|
+
export { getLocaleMapping } from './utils/getLocaleMapping';
|
|
9
|
+
export { getLocaleMappingByProjectId } from './utils/getLocaleMappingByProjectId';
|
|
10
|
+
export { getLocaleMappingByLocale } from './utils/getLocaleMappingByLocale';
|
|
11
|
+
export { getRequestLocaleInfo } from './utils/getRequestLocaleInfo';
|
|
12
|
+
export { sanitizeGraphqlName } from './utils/sanitizeGraphqlName';
|
|
13
|
+
export { UrlProcessor, getAsset, getUrl } from './common/UrlProcessor';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,WAAW,EACd,MAAM,cAAc,CAAC;AAItB,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EACH,SAAS,EACT,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAC,aAAa,EAAC,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,2BAA2B,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAC,wBAAwB,EAAC,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,MAAM,EACT,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getShortcutQuery = "\n query($path:ID!){\n guillotine {\n get(key:$path) {\n ... on base_Shortcut {\n data {\n target {\n pageUrl(type: absolute)\n }\n parameters {\n name\n value\n }\n }\n }\n }\n }\n }";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shortcut.js","sourceRoot":"","sources":["../../src/query/Shortcut.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;IAiB5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getServerRenderedHtml(component: React.ReactNode): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getServerRenderedHtml.js","sourceRoot":"","sources":["../../src/server/getServerRenderedHtml.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,qBAAqB,CAAC,SAA0B;IAC5D,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { fetchContent } from './guillotine/fetchContent';
|
|
2
|
+
export { fetchContentPathsForAllLocales } from './guillotine/fetchContentPathsForAllLocales';
|
|
3
|
+
export { fetchContentPathsForLocale } from './guillotine/fetchContentPathsForLocale';
|
|
4
|
+
export { fetchFromApi } from './guillotine/fetchFromApi';
|
|
5
|
+
export { fetchGuillotine } from './guillotine/fetchGuillotine';
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { fetchContent } from './guillotine/fetchContent';
|
|
2
|
+
export { fetchContentPathsForAllLocales } from './guillotine/fetchContentPathsForAllLocales';
|
|
3
|
+
export { fetchContentPathsForLocale } from './guillotine/fetchContentPathsForLocale';
|
|
4
|
+
export { fetchFromApi } from './guillotine/fetchFromApi';
|
|
5
|
+
export { fetchGuillotine } from './guillotine/fetchGuillotine';
|
|
6
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,8BAA8B,EAAC,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAC,0BAA0B,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import type {XP_COMPONENT_TYPE} from '../common/constants';
|
|
2
|
-
import type {Context} from './next';
|
|
3
|
-
import type {
|
|
4
|
-
RichTextData as CompsRichTextData,
|
|
5
|
-
LinkData as CompsLinkData,
|
|
6
|
-
ImageData as CompsImageData,
|
|
7
|
-
MacroData as CompsMacroData
|
|
8
|
-
} from '@enonic/react-components';
|
|
9
|
-
|
|
10
|
-
// Differs from ComponentDefinition to avoid storing catchAll on all components
|
|
11
|
-
// catchAll is calculated in getType instead
|
|
1
|
+
import type { XP_COMPONENT_TYPE } from '../common/constants';
|
|
2
|
+
import type { Context } from './next';
|
|
3
|
+
import type { RichTextData as CompsRichTextData, LinkData as CompsLinkData, ImageData as CompsImageData, MacroData as CompsMacroData } from '@enonic/react-components';
|
|
12
4
|
export interface ComponentDefinitionParams {
|
|
13
|
-
query?: SelectedQueryMaybeVariablesFunc
|
|
14
|
-
configQuery?: string
|
|
15
|
-
processor?: DataProcessor
|
|
16
|
-
view?: React.FunctionComponent<any
|
|
5
|
+
query?: SelectedQueryMaybeVariablesFunc;
|
|
6
|
+
configQuery?: string;
|
|
7
|
+
processor?: DataProcessor;
|
|
8
|
+
view?: React.FunctionComponent<any>;
|
|
17
9
|
}
|
|
18
|
-
|
|
19
10
|
/**
|
|
20
11
|
* Object that configures the handling of a particular content type. All attributes are optional (see examples below), and missing values will fall back to default behavior:
|
|
21
12
|
* - 'query' (used in fetchContent.ts) Guillotine query for fetching content data, may also have a function that supplies guillotine variables. So, 'query' can EITHER be only a query string, OR also add a get-guillotine-variables function. In the latter case, 'query' can be an object with 'query' and 'variables' attributes, or an array where the query string is first and the get-variables function is second. Either way, the get-variables function takes two arguments: path (content path, mandatory) and context (next.js-supplied Context from getServerSideProps etc. Optional, and requires that fetchContent is called with the context, of course).
|
|
@@ -23,48 +14,36 @@ export interface ComponentDefinitionParams {
|
|
|
23
14
|
* - 'view' (used in BasePage.tsx) is a React component: top-level content-type-specific rendering with the props first fetched from guillotine (and then optionally preprocessed with the function in 'props').
|
|
24
15
|
*/
|
|
25
16
|
export interface ComponentDefinition {
|
|
26
|
-
catchAll?: boolean;
|
|
27
|
-
query?: SelectedQueryMaybeVariablesFunc
|
|
28
|
-
configQuery?: string
|
|
29
|
-
processor?: DataProcessor
|
|
30
|
-
view?: React.FunctionComponent<any
|
|
17
|
+
catchAll?: boolean;
|
|
18
|
+
query?: SelectedQueryMaybeVariablesFunc;
|
|
19
|
+
configQuery?: string;
|
|
20
|
+
processor?: DataProcessor;
|
|
21
|
+
view?: React.FunctionComponent<any>;
|
|
31
22
|
}
|
|
32
|
-
|
|
33
23
|
export interface ComponentDescriptor {
|
|
34
24
|
type?: ComponentDefinition;
|
|
35
25
|
component?: PageComponent;
|
|
36
26
|
queryAndVariables?: QueryAndVariables;
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
export type ComponentDictionary = Record<string, ComponentDefinitionParams>;
|
|
40
|
-
|
|
41
|
-
// NB! Always return null or empty object from processor for next is unable to serialize undefined
|
|
42
29
|
export type DataProcessor = (data: any, context?: Context, config?: any) => Promise<Record<string, any>>;
|
|
43
|
-
|
|
44
30
|
export interface FragmentData {
|
|
45
31
|
id: string;
|
|
46
32
|
fragment: {
|
|
47
33
|
components: PageComponent[];
|
|
48
|
-
}
|
|
34
|
+
};
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
export type ImageData = CompsImageData;
|
|
52
|
-
|
|
53
37
|
export interface LayoutData {
|
|
54
38
|
descriptor: string;
|
|
55
39
|
config?: any;
|
|
56
|
-
|
|
57
40
|
[customKeysFromQuery: string]: any;
|
|
58
41
|
}
|
|
59
|
-
|
|
60
42
|
export type LinkData = CompsLinkData;
|
|
61
|
-
|
|
62
43
|
export type MacroConfig = Record<string, any>;
|
|
63
|
-
|
|
64
44
|
export type MacroData = CompsMacroData;
|
|
65
|
-
|
|
66
45
|
export interface PageComponent {
|
|
67
|
-
[key: string]: any;
|
|
46
|
+
[key: string]: any;
|
|
68
47
|
type: XP_COMPONENT_TYPE;
|
|
69
48
|
path: string;
|
|
70
49
|
page?: PageData;
|
|
@@ -77,55 +56,37 @@ export interface PageComponent {
|
|
|
77
56
|
data?: any;
|
|
78
57
|
error?: any;
|
|
79
58
|
}
|
|
80
|
-
|
|
81
59
|
export interface PageData {
|
|
82
60
|
descriptor: string;
|
|
83
61
|
config?: any;
|
|
84
62
|
template?: string | null;
|
|
85
63
|
regions?: RegionTree;
|
|
86
64
|
}
|
|
87
|
-
|
|
88
65
|
export interface PageRegion {
|
|
89
66
|
name: string;
|
|
90
67
|
components: PageComponent[];
|
|
91
68
|
}
|
|
92
|
-
|
|
93
69
|
export interface PartData {
|
|
94
70
|
descriptor: string;
|
|
95
|
-
config: any;
|
|
96
|
-
|
|
71
|
+
config: any;
|
|
97
72
|
[customKeysFromQuery: string]: any;
|
|
98
73
|
}
|
|
99
|
-
|
|
100
74
|
export interface QueryAndVariables {
|
|
101
|
-
query: string
|
|
102
|
-
variables?: Record<string, any
|
|
75
|
+
query: string;
|
|
76
|
+
variables?: Record<string, any>;
|
|
103
77
|
}
|
|
104
|
-
|
|
105
78
|
export type QueryGetter = (path: string, context?: Context, config?: any) => string;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| {
|
|
111
|
-
query: string | QueryGetter
|
|
112
|
-
variables: VariablesGetter
|
|
113
|
-
}
|
|
114
|
-
| [string | QueryGetter, VariablesGetter];
|
|
115
|
-
|
|
79
|
+
export type SelectedQueryMaybeVariablesFunc = string | QueryGetter | {
|
|
80
|
+
query: string | QueryGetter;
|
|
81
|
+
variables: VariablesGetter;
|
|
82
|
+
} | [string | QueryGetter, VariablesGetter];
|
|
116
83
|
export type RegionTree = Record<string, PageRegion>;
|
|
117
|
-
|
|
118
84
|
export type RichTextData = CompsRichTextData;
|
|
119
|
-
|
|
120
85
|
export interface TextData {
|
|
121
86
|
value: RichTextData;
|
|
122
87
|
}
|
|
123
|
-
|
|
124
|
-
// TODO: also access as arguments: dataAsJson, pageAsJson, configAsJson from the first (meta) call here?
|
|
125
|
-
// Another option could be to let the component or page controller pass those values to NextJS by a header
|
|
126
88
|
export type VariablesGetter = (path: string, context?: Context, config?: any) => VariablesGetterResult;
|
|
127
|
-
|
|
128
89
|
export interface VariablesGetterResult {
|
|
129
|
-
[variables: string]: any
|
|
130
|
-
path: string
|
|
90
|
+
[variables: string]: any;
|
|
91
|
+
path: string;
|
|
131
92
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { DOMNode } from 'html-react-parser';
|
|
2
|
+
import type { RENDER_MODE, XP_REQUEST_TYPE } from '../common/constants';
|
|
3
|
+
import type { FragmentData, LayoutData, MacroConfig, MacroData, PageComponent, PageData, PartData, RichTextData, RegionTree } from './component';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
export interface BaseComponentProps {
|
|
6
|
+
component: PageComponent;
|
|
7
|
+
meta: MetaData;
|
|
8
|
+
common?: any;
|
|
9
|
+
}
|
|
10
|
+
export interface BaseLayoutProps {
|
|
11
|
+
component?: LayoutData;
|
|
12
|
+
path: string;
|
|
13
|
+
regions?: RegionTree;
|
|
14
|
+
common?: any;
|
|
15
|
+
meta: MetaData;
|
|
16
|
+
}
|
|
17
|
+
export interface BaseMacroProps {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
data: Omit<MacroData, 'ref'>;
|
|
20
|
+
meta: MetaData;
|
|
21
|
+
renderInEditMode?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface BasePageProps {
|
|
24
|
+
component?: PageData;
|
|
25
|
+
path?: string;
|
|
26
|
+
common?: any;
|
|
27
|
+
data?: any;
|
|
28
|
+
error?: string;
|
|
29
|
+
meta: MetaData;
|
|
30
|
+
}
|
|
31
|
+
export interface BasePartProps {
|
|
32
|
+
component?: PartData;
|
|
33
|
+
path: string;
|
|
34
|
+
common?: any;
|
|
35
|
+
data?: any;
|
|
36
|
+
error?: string;
|
|
37
|
+
meta: MetaData;
|
|
38
|
+
}
|
|
39
|
+
export interface FragmentProps {
|
|
40
|
+
page?: PageData;
|
|
41
|
+
component?: FragmentData;
|
|
42
|
+
common?: any;
|
|
43
|
+
meta: MetaData;
|
|
44
|
+
}
|
|
45
|
+
export interface LayoutProps {
|
|
46
|
+
layout: LayoutData;
|
|
47
|
+
path: string;
|
|
48
|
+
common: any;
|
|
49
|
+
meta: MetaData;
|
|
50
|
+
}
|
|
51
|
+
export interface MacroProps {
|
|
52
|
+
name: string;
|
|
53
|
+
children: string | React.ReactNode;
|
|
54
|
+
config: MacroConfig;
|
|
55
|
+
meta: MetaData;
|
|
56
|
+
}
|
|
57
|
+
export interface MetaData {
|
|
58
|
+
id: string;
|
|
59
|
+
type: string;
|
|
60
|
+
path: string;
|
|
61
|
+
requestType: XP_REQUEST_TYPE;
|
|
62
|
+
renderMode: RENDER_MODE;
|
|
63
|
+
requestedComponent?: PageComponent;
|
|
64
|
+
canRender: boolean;
|
|
65
|
+
catchAll: boolean;
|
|
66
|
+
apiUrl: string;
|
|
67
|
+
baseUrl: string;
|
|
68
|
+
locale: string;
|
|
69
|
+
defaultLocale: string;
|
|
70
|
+
}
|
|
71
|
+
export interface PageProps {
|
|
72
|
+
page: PageData;
|
|
73
|
+
path: string;
|
|
74
|
+
data?: any;
|
|
75
|
+
common?: any;
|
|
76
|
+
meta: MetaData;
|
|
77
|
+
}
|
|
78
|
+
export interface PartProps {
|
|
79
|
+
part: PartData;
|
|
80
|
+
path: string;
|
|
81
|
+
data?: any;
|
|
82
|
+
common?: any;
|
|
83
|
+
meta: MetaData;
|
|
84
|
+
}
|
|
85
|
+
export interface RegionProps {
|
|
86
|
+
name: string;
|
|
87
|
+
components?: PageComponent[];
|
|
88
|
+
className?: string;
|
|
89
|
+
common?: any;
|
|
90
|
+
meta: MetaData;
|
|
91
|
+
}
|
|
92
|
+
export interface RegionsProps {
|
|
93
|
+
page: PageData | null;
|
|
94
|
+
name?: string;
|
|
95
|
+
common?: any;
|
|
96
|
+
meta: MetaData;
|
|
97
|
+
}
|
|
98
|
+
export type Replacer = (domNode: DOMNode, data: RichTextData, meta: MetaData, renderMacroInEditMode: boolean) => ReplacerResult;
|
|
99
|
+
export type ReplacerResult = JSX.Element | DOMNode;
|
|
100
|
+
export interface RichTextViewProps {
|
|
101
|
+
data: RichTextData;
|
|
102
|
+
meta: MetaData;
|
|
103
|
+
className?: string;
|
|
104
|
+
tag?: string;
|
|
105
|
+
renderMacroInEditMode?: boolean;
|
|
106
|
+
customReplacer?: Replacer;
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentProps.js","sourceRoot":"","sources":["../../src/types/componentProps.ts"],"names":[],"mappings":""}
|