@se-studio/core-ui 1.0.13 → 1.0.15
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 +78 -14
- package/dist/CmsRendererConfig.d.ts +122 -0
- package/dist/CmsRendererConfig.d.ts.map +1 -1
- package/dist/analytics/AnalyticsProvider.d.ts +16 -0
- package/dist/analytics/AnalyticsProvider.d.ts.map +1 -0
- package/dist/analytics/AnalyticsProvider.js +22 -0
- package/dist/analytics/AnalyticsProvider.js.map +1 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.d.ts +12 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.d.ts.map +1 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.js +21 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.js.map +1 -0
- package/dist/analytics/adapters/index.d.ts +2 -0
- package/dist/analytics/adapters/index.d.ts.map +1 -0
- package/dist/analytics/adapters/index.js +2 -0
- package/dist/analytics/adapters/index.js.map +1 -0
- package/dist/analytics/types.d.ts +41 -0
- package/dist/analytics/types.d.ts.map +1 -0
- package/dist/analytics/types.js +2 -0
- package/dist/analytics/types.js.map +1 -0
- package/dist/analytics/useAnalytics.d.ts +45 -0
- package/dist/analytics/useAnalytics.d.ts.map +1 -0
- package/dist/analytics/useAnalytics.js +70 -0
- package/dist/analytics/useAnalytics.js.map +1 -0
- package/dist/components/ClientMonitor.d.ts +1 -0
- package/dist/components/ClientMonitor.d.ts.map +1 -1
- package/dist/components/ClientMonitor.js +223 -18
- package/dist/components/ClientMonitor.js.map +1 -1
- package/dist/components/CmsCollection.d.ts +47 -0
- package/dist/components/CmsCollection.d.ts.map +1 -1
- package/dist/components/CmsCollection.js +7 -0
- package/dist/components/CmsCollection.js.map +1 -1
- package/dist/components/CmsComponent.d.ts +47 -0
- package/dist/components/CmsComponent.d.ts.map +1 -1
- package/dist/components/CmsComponent.js +7 -0
- package/dist/components/CmsComponent.js.map +1 -1
- package/dist/components/CmsContent.d.ts +62 -0
- package/dist/components/CmsContent.d.ts.map +1 -1
- package/dist/components/CmsContent.js +53 -0
- package/dist/components/CmsContent.js.map +1 -1
- package/dist/components/CmsConversionErrors.js +2 -0
- package/dist/components/CmsConversionErrors.js.map +1 -1
- package/dist/components/CmsEmbeddedContent.d.ts +3 -0
- package/dist/components/CmsEmbeddedContent.d.ts.map +1 -1
- package/dist/components/CmsEmbeddedContent.js +3 -0
- package/dist/components/CmsEmbeddedContent.js.map +1 -1
- package/dist/components/CmsExternalComponent.d.ts +44 -0
- package/dist/components/CmsExternalComponent.d.ts.map +1 -1
- package/dist/components/CmsExternalComponent.js +7 -0
- package/dist/components/CmsExternalComponent.js.map +1 -1
- package/dist/components/ImageKitClientVideo.js +1 -0
- package/dist/components/ImageKitClientVideo.js.map +1 -1
- package/dist/components/SvgComponent.js +3 -1
- package/dist/components/SvgComponent.js.map +1 -1
- package/dist/components/VisualComponent.d.ts +47 -0
- package/dist/components/VisualComponent.d.ts.map +1 -1
- package/dist/components/VisualComponent.js +47 -0
- package/dist/components/VisualComponent.js.map +1 -1
- package/dist/elements/TrackedLink.d.ts +24 -0
- package/dist/elements/TrackedLink.d.ts.map +1 -0
- package/dist/elements/TrackedLink.js +76 -0
- package/dist/elements/TrackedLink.js.map +1 -0
- package/dist/framework/BackgroundMedia.js +5 -1
- package/dist/framework/BackgroundMedia.js.map +1 -1
- package/dist/framework/ComponentErrorIndicator.js +7 -4
- package/dist/framework/ComponentErrorIndicator.js.map +1 -1
- package/dist/framework/componentErrors.d.ts +8 -0
- package/dist/framework/componentErrors.d.ts.map +1 -1
- package/dist/framework/componentErrors.js +10 -0
- package/dist/framework/componentErrors.js.map +1 -1
- package/dist/hooks/useClickTracking.d.ts +39 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -1
- package/dist/hooks/useClickTracking.js +29 -0
- package/dist/hooks/useClickTracking.js.map +1 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/dist/rtf/rtf.d.ts +41 -0
- package/dist/rtf/rtf.d.ts.map +1 -1
- package/dist/rtf/rtf.js +36 -0
- package/dist/rtf/rtf.js.map +1 -1
- package/dist/utils/UnsupportedWarning.d.ts +23 -0
- package/dist/utils/UnsupportedWarning.d.ts.map +1 -1
- package/dist/utils/UnsupportedWarning.js +24 -0
- package/dist/utils/UnsupportedWarning.js.map +1 -1
- package/dist/utils/UnusedChecker.d.ts +39 -0
- package/dist/utils/UnusedChecker.d.ts.map +1 -1
- package/dist/utils/UnusedChecker.js +47 -3
- package/dist/utils/UnusedChecker.js.map +1 -1
- package/dist/utils/buildPageMetadata.d.ts +45 -0
- package/dist/utils/buildPageMetadata.d.ts.map +1 -1
- package/dist/utils/buildPageMetadata.js +37 -0
- package/dist/utils/buildPageMetadata.js.map +1 -1
- package/dist/utils/cn.d.ts +26 -0
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/cn.js +26 -0
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/componentUtils.d.ts +121 -0
- package/dist/utils/componentUtils.d.ts.map +1 -1
- package/dist/utils/componentUtils.js +80 -0
- package/dist/utils/componentUtils.js.map +1 -1
- package/dist/utils/convertText.js +10 -2
- package/dist/utils/convertText.js.map +1 -1
- package/dist/utils/errorHandling.d.ts +27 -0
- package/dist/utils/errorHandling.d.ts.map +1 -1
- package/dist/utils/errorHandling.js +33 -0
- package/dist/utils/errorHandling.js.map +1 -1
- package/dist/utils/previewUtils.js +2 -0
- package/dist/utils/previewUtils.js.map +1 -1
- package/package.json +22 -8
- package/dist/elements/UtmLinkOrDiv.d.ts +0 -5
- package/dist/elements/UtmLinkOrDiv.d.ts.map +0 -1
- package/dist/elements/UtmLinkOrDiv.js +0 -9
- package/dist/elements/UtmLinkOrDiv.js.map +0 -1
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract specific component information fields that a component needs.
|
|
3
|
+
* This is used when you only need a subset of the component fields.
|
|
4
|
+
*
|
|
5
|
+
* @param information - The full component information object
|
|
6
|
+
* @param keys - Array of keys to extract from the information object
|
|
7
|
+
* @returns Object with only the specified keys
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const props = extractComponentInfo(information, ['heading', 'body', 'links']);
|
|
12
|
+
* // props will have type { heading?: string | null, body?: unknown, links?: ReadonlyArray<ILinkProps> }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
1
15
|
export function extractComponentInfo(information, keys) {
|
|
2
16
|
const result = {};
|
|
3
17
|
for (const key of keys) {
|
|
@@ -7,6 +21,20 @@ export function extractComponentInfo(information, keys) {
|
|
|
7
21
|
}
|
|
8
22
|
return result;
|
|
9
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Extract specific collection information fields that a collection needs.
|
|
26
|
+
* This is used when you only need a subset of the collection fields.
|
|
27
|
+
*
|
|
28
|
+
* @param information - The full collection information object
|
|
29
|
+
* @param keys - Array of keys to extract from the information object
|
|
30
|
+
* @returns Object with only the specified keys
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const props = extractCollectionInfo(information, ['heading', 'body', 'contents']);
|
|
35
|
+
* // props will have type { heading?: string | null, body?: unknown, contents?: ReadonlyArray<CollectionContent> }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
10
38
|
export function extractCollectionInfo(information, keys) {
|
|
11
39
|
const result = {};
|
|
12
40
|
for (const key of keys) {
|
|
@@ -16,6 +44,18 @@ export function extractCollectionInfo(information, keys) {
|
|
|
16
44
|
}
|
|
17
45
|
return result;
|
|
18
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Extract specific page context fields that a component needs.
|
|
49
|
+
*
|
|
50
|
+
* @param pageContext - The full page context object
|
|
51
|
+
* @param keys - Array of keys to extract from the page context
|
|
52
|
+
* @returns Object with only the specified keys
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* const contextProps = extractPageContext(pageContext, ['articleLink', 'pageLink']);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
19
59
|
export function extractPageContext(pageContext, keys) {
|
|
20
60
|
const result = {};
|
|
21
61
|
for (const key of keys) {
|
|
@@ -25,6 +65,26 @@ export function extractPageContext(pageContext, keys) {
|
|
|
25
65
|
}
|
|
26
66
|
return result;
|
|
27
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Create props object for a component renderer from component information and page context.
|
|
70
|
+
* This function extracts the specified fields and combines them with additional props.
|
|
71
|
+
*
|
|
72
|
+
* @param config - Configuration specifying which props to extract
|
|
73
|
+
* @param information - The component information object
|
|
74
|
+
* @param pageContext - The page context object
|
|
75
|
+
* @param additionalProps - Additional props to include (optional)
|
|
76
|
+
* @returns Combined props object ready to pass to the component
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* const config = {
|
|
81
|
+
* componentProps: ['heading', 'body'],
|
|
82
|
+
* contextProps: ['pageLink'],
|
|
83
|
+
* } as const;
|
|
84
|
+
*
|
|
85
|
+
* const props = createComponentProps(config, information, pageContext);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
28
88
|
export function createComponentProps(config, information, pageContext, additionalProps) {
|
|
29
89
|
const componentProps = extractComponentInfo(information, config.componentProps);
|
|
30
90
|
const contextProps = extractPageContext(pageContext, config.contextProps);
|
|
@@ -34,6 +94,26 @@ export function createComponentProps(config, information, pageContext, additiona
|
|
|
34
94
|
...(additionalProps ?? {}),
|
|
35
95
|
};
|
|
36
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Create props object for a collection renderer from collection information and page context.
|
|
99
|
+
* This function extracts the specified fields and combines them with additional props.
|
|
100
|
+
*
|
|
101
|
+
* @param config - Configuration specifying which props to extract
|
|
102
|
+
* @param information - The collection information object
|
|
103
|
+
* @param pageContext - The page context object
|
|
104
|
+
* @param additionalProps - Additional props to include (optional)
|
|
105
|
+
* @returns Combined props object ready to pass to the collection
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```tsx
|
|
109
|
+
* const config = {
|
|
110
|
+
* collectionProps: ['heading', 'contents'],
|
|
111
|
+
* contextProps: ['articleLink'],
|
|
112
|
+
* } as const;
|
|
113
|
+
*
|
|
114
|
+
* const props = createCollectionProps(config, information, pageContext);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
37
117
|
export function createCollectionProps(config, information, pageContext, additionalProps) {
|
|
38
118
|
const collectionProps = extractCollectionInfo(information, config.collectionProps);
|
|
39
119
|
const contextProps = extractPageContext(pageContext, config.contextProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentUtils.js","sourceRoot":"","sources":["../../src/utils/componentUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"componentUtils.js","sourceRoot":"","sources":["../../src/utils/componentUtils.ts"],"names":[],"mappings":"AAkEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAA2B,EAC3B,IAAsB;IAEtB,MAAM,MAAM,GAAG,EAA6B,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAA4B,EAC5B,IAAsB;IAEtB,MAAM,MAAM,GAAG,EAA8B,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAA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ragment } from 'react';
|
|
4
4
|
const specialChars = {
|
|
5
5
|
'®': 'align-super text-[0.6em]',
|
|
6
|
+
// "©": "align-super p-sm",
|
|
7
|
+
// "℠": "align-super p-sm",
|
|
6
8
|
};
|
|
7
9
|
const pattern = new RegExp(`(${Object.keys(specialChars).join('|')})`, 'g');
|
|
8
10
|
export function convertText(text) {
|
|
@@ -18,14 +20,20 @@ export function convertText(text) {
|
|
|
18
20
|
if (special === undefined) {
|
|
19
21
|
return part;
|
|
20
22
|
}
|
|
21
|
-
return (
|
|
23
|
+
return (
|
|
24
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: Index is ok here
|
|
25
|
+
_jsx("span", { className: special, children: part }, i));
|
|
22
26
|
});
|
|
23
27
|
if (result.length === 1) {
|
|
24
28
|
return result[0];
|
|
25
29
|
}
|
|
26
30
|
return result;
|
|
27
31
|
}
|
|
28
|
-
const mapped = split.map((s, index) => (
|
|
32
|
+
const mapped = split.map((s, index) => (
|
|
33
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: Index is ok here
|
|
34
|
+
_jsxs(Fragment, { children: [index > 0 && _jsx("br", {}), _jsx("span", { children: s.split(new RegExp(`(${Object.keys(specialChars).join('|')})`, 'g')).map((part, i) => specialChars[part] !== undefined ? (
|
|
35
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: Index is ok here
|
|
36
|
+
_jsx("span", { className: specialChars[part], children: part }, i)) : (part)) })] }, index)));
|
|
29
37
|
return mapped;
|
|
30
38
|
}
|
|
31
39
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertText.js","sourceRoot":"","sources":["../../src/utils/convertText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,0BAA0B;
|
|
1
|
+
{"version":3,"file":"convertText.js","source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,CAAC,EAAE,CAAC;gBACxB,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACrC,iEAAiE;QACjE,MAAC,QAAQ,eACN,KAAK,GAAG,CAAC,IAAI,cAAM,EACpB,yBACG,CAAC,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CACpF,YAAY,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;oBACjC,iEAAiE;oBACjE,eAAc,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,YACxC,IAAI,IADI,CAAC,CAEL,CACR,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CACF,GACI,KAbM,KAAK,CAcT,CACZ,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -5,6 +5,33 @@ interface ErrorContext {
|
|
|
5
5
|
preview?: boolean;
|
|
6
6
|
slug?: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Handles CMS-related errors with appropriate error display or Next.js notFound.
|
|
10
|
+
*
|
|
11
|
+
* In production, returns Next.js notFound() to show 404 page.
|
|
12
|
+
* In development, returns an error component with detailed error information.
|
|
13
|
+
*
|
|
14
|
+
* @param error - The error that occurred (any type)
|
|
15
|
+
* @param context - Error context (type, params, preview, slug)
|
|
16
|
+
* @param buildInformation - Build configuration (isProduction, etc.)
|
|
17
|
+
* @returns Next.js notFound() in production, or error component in development
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { handleCmsError } from '@se-studio/core-ui';
|
|
22
|
+
*
|
|
23
|
+
* try {
|
|
24
|
+
* const page = await contentfulPageRest(config, slug);
|
|
25
|
+
* if (!page) throw new Error('Page not found');
|
|
26
|
+
* } catch (error) {
|
|
27
|
+
* return handleCmsError(error, {
|
|
28
|
+
* type: 'page',
|
|
29
|
+
* slug,
|
|
30
|
+
* preview: false,
|
|
31
|
+
* }, buildInfo);
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
8
35
|
export declare function handleCmsError(error: unknown, context: ErrorContext, buildInformation: IBuildInformation): import("react/jsx-runtime").JSX.Element;
|
|
9
36
|
export {};
|
|
10
37
|
//# sourceMappingURL=errorHandling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandling.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAWD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,YAAY,EACrB,gBAAgB,EAAE,iBAAiB,2CA2BpC"}
|
|
1
|
+
{"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandling.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,YAAY,EACrB,gBAAgB,EAAE,iBAAiB,2CA2BpC"}
|
|
@@ -1,27 +1,60 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { notFound } from 'next/navigation';
|
|
3
3
|
import { CmsDataError } from '../components/CmsDataError';
|
|
4
|
+
// Helper function to detect Next.js notFound errors
|
|
4
5
|
function isNotFoundError(error) {
|
|
5
6
|
return (error instanceof Error &&
|
|
6
7
|
(error.message === 'NEXT_HTTP_ERROR_FALLBACK;404' ||
|
|
7
8
|
error.digest === 'NEXT_HTTP_ERROR_FALLBACK;404'));
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Handles CMS-related errors with appropriate error display or Next.js notFound.
|
|
12
|
+
*
|
|
13
|
+
* In production, returns Next.js notFound() to show 404 page.
|
|
14
|
+
* In development, returns an error component with detailed error information.
|
|
15
|
+
*
|
|
16
|
+
* @param error - The error that occurred (any type)
|
|
17
|
+
* @param context - Error context (type, params, preview, slug)
|
|
18
|
+
* @param buildInformation - Build configuration (isProduction, etc.)
|
|
19
|
+
* @returns Next.js notFound() in production, or error component in development
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { handleCmsError } from '@se-studio/core-ui';
|
|
24
|
+
*
|
|
25
|
+
* try {
|
|
26
|
+
* const page = await contentfulPageRest(config, slug);
|
|
27
|
+
* if (!page) throw new Error('Page not found');
|
|
28
|
+
* } catch (error) {
|
|
29
|
+
* return handleCmsError(error, {
|
|
30
|
+
* type: 'page',
|
|
31
|
+
* slug,
|
|
32
|
+
* preview: false,
|
|
33
|
+
* }, buildInfo);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
9
37
|
export function handleCmsError(error, context, buildInformation) {
|
|
38
|
+
// Re-throw notFound errors so Next.js can handle them properly
|
|
10
39
|
if (isNotFoundError(error)) {
|
|
11
40
|
throw error;
|
|
12
41
|
}
|
|
42
|
+
// Add timestamp to context
|
|
13
43
|
const enhancedContext = {
|
|
14
44
|
...context,
|
|
15
45
|
timestamp: new Date().toISOString(),
|
|
16
46
|
};
|
|
47
|
+
// Log error details
|
|
17
48
|
console.error('CMS Data Error:', {
|
|
18
49
|
error,
|
|
19
50
|
context: enhancedContext,
|
|
20
51
|
stack: error instanceof Error ? error.stack : undefined,
|
|
21
52
|
});
|
|
22
53
|
if (buildInformation.isProduction) {
|
|
54
|
+
// Send error to server for logging
|
|
23
55
|
return notFound();
|
|
24
56
|
}
|
|
57
|
+
// Return error component for non-production environments
|
|
25
58
|
return _jsx(CmsDataError, { error: error, context: enhancedContext });
|
|
26
59
|
}
|
|
27
60
|
//# sourceMappingURL=errorHandling.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../src/utils/errorHandling.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../src/utils/errorHandling.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAU1D,oDAAoD;AACpD,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,CAAC,KAAK,CAAC,OAAO,KAAK,8BAA8B;YAC9C,KAA6B,CAAC,MAAM,KAAK,8BAA8B,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAc,EACd,OAAqB,EACrB,gBAAmC;IAEnC,+DAA+D;IAC/D,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC;IACd,CAAC;IAED,2BAA2B;IAC3B,MAAM,eAAe,GAAG;QACtB,GAAG,OAAO;QACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IAEF,oBAAoB;IACpB,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE;QAC/B,KAAK;QACL,OAAO,EAAE,eAAe;QACxB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KACxD,CAAC,CAAC;IAEH,IAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC;QAClC,mCAAmC;QACnC,OAAO,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED,yDAAyD;IACzD,OAAO,KAAC,YAAY,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,GAAI,CAAC;AAClE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"previewUtils.js","sourceRoot":"","sources":["../../src/utils/previewUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"previewUtils.js","sourceRoot":"","sources":["../../src/utils/previewUtils.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,8EAA8E;AAO9E,MAAM,UAAU,eAAe,CAC7B,EACE,OAAO,EACP,OAAO,EACP,OAAO,GAKR,EACD,SAAkB;IAElB,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IAEjC,OAAO;QACL,0BAA0B,EAAE,OAAO;QACnC,0BAA0B,EAAE,OAAO;QACnC,0BAA0B,EAAE,OAAO;KACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EAAW,EAAE,OAAgB,EAAE,SAAS,GAAG,KAAK;IACrF,OAAO,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgB,EAAE,SAAS,GAAG,KAAK;IACxE,OAAO,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,WAAwC,EAAE,SAAS,GAAG,KAAK;IAC/F,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IACnC,OAAO,eAAe,CACpB;QACE,OAAO,EAAE,WAAW,CAAC,QAAQ;QAC7B,OAAO,EAAE,WAAW,CAAC,aAAa;KACnC,EACD,SAAS,CACV,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/core-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Shared React UI component library with Tailwind CSS v4 for SE Studio applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,38 +25,52 @@
|
|
|
25
25
|
"components",
|
|
26
26
|
"ui",
|
|
27
27
|
"tailwind",
|
|
28
|
+
"tailwindcss",
|
|
28
29
|
"design-system",
|
|
29
|
-
"typescript"
|
|
30
|
+
"typescript",
|
|
31
|
+
"contentful",
|
|
32
|
+
"cms",
|
|
33
|
+
"nextjs",
|
|
34
|
+
"next.js",
|
|
35
|
+
"ui-library",
|
|
36
|
+
"component-library",
|
|
37
|
+
"rich-text",
|
|
38
|
+
"analytics"
|
|
30
39
|
],
|
|
40
|
+
"homepage": "https://github.com/Something-Else-Studio/se-core-product#readme",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/Something-Else-Studio/se-core-product/issues"
|
|
43
|
+
},
|
|
31
44
|
"peerDependencies": {
|
|
32
45
|
"next": "^15.0.0",
|
|
33
46
|
"react": "^19.0.0",
|
|
34
47
|
"react-dom": "^19.0.0"
|
|
35
48
|
},
|
|
36
49
|
"dependencies": {
|
|
37
|
-
"@contentful/live-preview": "^4.
|
|
50
|
+
"@contentful/live-preview": "^4.7.0",
|
|
38
51
|
"@contentful/rich-text-react-renderer": "^16.1.6",
|
|
39
52
|
"@contentful/rich-text-types": "^17.2.5",
|
|
40
53
|
"@extractus/oembed-extractor": "^4.0.9",
|
|
54
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
41
55
|
"change-case": "^5.4.4",
|
|
42
56
|
"clsx": "^2.1.1",
|
|
43
57
|
"html-entities": "^2.6.0",
|
|
44
58
|
"tailwind-merge": "^3.4.0",
|
|
45
|
-
"@se-studio/contentful-rest-api": "1.0.
|
|
46
|
-
"@se-studio/core-data-types": "1.0.
|
|
59
|
+
"@se-studio/contentful-rest-api": "1.0.15",
|
|
60
|
+
"@se-studio/core-data-types": "1.0.15"
|
|
47
61
|
},
|
|
48
62
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "^2.3.
|
|
63
|
+
"@biomejs/biome": "^2.3.7",
|
|
50
64
|
"@testing-library/jest-dom": "^6.9.1",
|
|
51
65
|
"@testing-library/react": "^16.3.0",
|
|
52
66
|
"@types/node": "^24.10.1",
|
|
53
|
-
"@types/react": "^19.2.
|
|
67
|
+
"@types/react": "^19.2.7",
|
|
54
68
|
"@types/react-dom": "^19.2.3",
|
|
55
69
|
"@vitejs/plugin-react": "^5.1.1",
|
|
56
70
|
"jsdom": "^27.2.0",
|
|
57
71
|
"next": "^15.5.6",
|
|
58
72
|
"typescript": "^5.9.3",
|
|
59
|
-
"vitest": "^4.0.
|
|
73
|
+
"vitest": "^4.0.14"
|
|
60
74
|
},
|
|
61
75
|
"scripts": {
|
|
62
76
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { LinkProps } from 'next/link';
|
|
2
|
-
import type React from 'react';
|
|
3
|
-
import type { PropsWithChildren } from 'react';
|
|
4
|
-
export declare const UtmLinkOrDiv: React.FC<PropsWithChildren<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps<Record<string, unknown>>> & Omit<LinkProps<Record<string, unknown>>, 'href'> & Partial<Pick<LinkProps<Record<string, unknown>>, 'href'>> & React.RefAttributes<HTMLAnchorElement>>>;
|
|
5
|
-
//# sourceMappingURL=UtmLinkOrDiv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UtmLinkOrDiv.d.ts","sourceRoot":"","sources":["../../src/elements/UtmLinkOrDiv.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CACjC,iBAAiB,CACf,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAC3F,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GACzD,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CACzC,CAcF,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { UtmLink } from './UtmLink';
|
|
3
|
-
export const UtmLinkOrDiv = ({ href, className, style, children, ...props }) => {
|
|
4
|
-
if (href) {
|
|
5
|
-
return (_jsx(UtmLink, { href: href, className: className, style: style, ...props, children: children }));
|
|
6
|
-
}
|
|
7
|
-
return (_jsx("div", { className: className, style: style, children: children }));
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=UtmLinkOrDiv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UtmLinkOrDiv.js","sourceRoot":"","sources":["../../src/elements/UtmLinkOrDiv.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,YAAY,GAOrB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACrD,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CACL,KAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,KAAM,KAAK,YAC/D,QAAQ,GACD,CACX,CAAC;IACJ,CAAC;IACD,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,YACpC,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|