@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { forwardRef, isValidElement, useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { useAnalytics } from '../analytics/useAnalytics';
|
|
7
|
+
/**
|
|
8
|
+
* Unified link component that handles:
|
|
9
|
+
* - All link types (internal, external, blank)
|
|
10
|
+
* - UTM parameter appending from URL search params
|
|
11
|
+
* - Click tracking integration
|
|
12
|
+
* - Uses Next.js Link for all URLs (handles absolute URLs correctly)
|
|
13
|
+
* - Uses href="#" for blank links
|
|
14
|
+
*/
|
|
15
|
+
export const TrackedLink = forwardRef(function TrackedLink({ href, componentType = 'Link', location, analyticsContext, linkText, appendUtmParams = true, children, onClick, asChild = false, component, prefetch, replace, scroll, shallow, passHref, locale, ...props }, ref) {
|
|
16
|
+
const { trackClick } = useAnalytics();
|
|
17
|
+
const [finalHref, setFinalHref] = useState(href || '#');
|
|
18
|
+
// Handle UTM parameter appending
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!href || href === '#') {
|
|
21
|
+
setFinalHref('#');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!appendUtmParams) {
|
|
25
|
+
setFinalHref(href);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const search = typeof window !== 'undefined' ? window.location.search : '';
|
|
29
|
+
if (search && href.indexOf('?') < 0) {
|
|
30
|
+
setFinalHref((href + search));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
setFinalHref(href);
|
|
34
|
+
}
|
|
35
|
+
}, [href, appendUtmParams]);
|
|
36
|
+
// Get link text for tracking
|
|
37
|
+
const getLinkText = useCallback(() => {
|
|
38
|
+
if (linkText)
|
|
39
|
+
return linkText;
|
|
40
|
+
if (typeof children === 'string')
|
|
41
|
+
return children;
|
|
42
|
+
// Try to extract text from children
|
|
43
|
+
if (isValidElement(children)) {
|
|
44
|
+
const childrenElement = children;
|
|
45
|
+
const props = childrenElement.props;
|
|
46
|
+
if (typeof props?.children === 'string' && props.children) {
|
|
47
|
+
return props.children;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return '';
|
|
51
|
+
}, [linkText, children]);
|
|
52
|
+
const handleClick = useCallback((event) => {
|
|
53
|
+
// Track the click if analytics context is provided
|
|
54
|
+
if (analyticsContext) {
|
|
55
|
+
trackClick(componentType, getLinkText(), analyticsContext, {
|
|
56
|
+
targetUrl: href || undefined,
|
|
57
|
+
location: location || undefined,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Call the original onClick handler
|
|
61
|
+
onClick?.(event);
|
|
62
|
+
}, [analyticsContext, componentType, getLinkText, href, location, onClick, trackClick]);
|
|
63
|
+
const linkProps = {
|
|
64
|
+
prefetch,
|
|
65
|
+
replace,
|
|
66
|
+
scroll,
|
|
67
|
+
shallow,
|
|
68
|
+
locale,
|
|
69
|
+
};
|
|
70
|
+
if (asChild || component) {
|
|
71
|
+
const Component = (component || Slot);
|
|
72
|
+
return (_jsx(Link, { href: finalHref, onClick: handleClick, passHref: true, ...linkProps, children: _jsx(Component, { ref: ref, ...props, children: children }) }));
|
|
73
|
+
}
|
|
74
|
+
return (_jsx(Link, { href: finalHref, onClick: handleClick, prefetch: prefetch, replace: replace, scroll: scroll, shallow: shallow, passHref: passHref, locale: locale, ref: ref, ...props, children: children }));
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=TrackedLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrackedLink.js","sourceRoot":"","sources":["../../src/elements/TrackedLink.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,OAAO,IAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAA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AAI,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,WAAK,SAAS,YACjE,KAAC,SAAS,IAAC,GAAG,EAAE,GAAG,KAAM,KAAK,YAC3B,QAAQ,GACC,GACP,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,IAAI,IACH,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,KACJ,KAAK,YAER,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -14,6 +14,10 @@ export function BackgroundMedia({ responsiveVisual, overlayOpacity, className, a
|
|
|
14
14
|
: undefined;
|
|
15
15
|
const isVideo = isVisualVideo(visual);
|
|
16
16
|
const isMobileVideo = isVisualVideo(mobileVisual);
|
|
17
|
-
return (_jsxs("div", { className: cn('absolute inset-0 overflow-hidden', className), children: [!hideVisual && (_jsx("div", { className: cn('size-full', (hideMobileVisual || mobileVisual) && 'max-laptop:hidden'), children: _jsx(Visual, { visual: visual, className: "size-full object-cover object-center",
|
|
17
|
+
return (_jsxs("div", { className: cn('absolute inset-0 overflow-hidden', className), children: [!hideVisual && (_jsx("div", { className: cn('size-full', (hideMobileVisual || mobileVisual) && 'max-laptop:hidden'), children: _jsx(Visual, { visual: visual, className: "size-full object-cover object-center",
|
|
18
|
+
// Videos should autoplay, be muted, and loop for backgrounds
|
|
19
|
+
autoPlay: isVideo, muted: isVideo, loop: isVideo, controls: false, analyticsContext: analyticsContext, componentLabel: componentLabel }) })), mobileVisual && !hideMobileVisual && (_jsx("div", { className: "size-full block tablet:hidden", children: _jsx(Visual, { visual: mobileVisual, className: "size-full object-cover object-center",
|
|
20
|
+
// Videos should autoplay, be muted, and loop for backgrounds
|
|
21
|
+
autoPlay: isMobileVideo, muted: isMobileVideo, loop: isMobileVideo, controls: false, analyticsContext: analyticsContext, componentLabel: componentLabel }) })), hasOverlay && _jsx("div", { className: "absolute inset-0", style: overlayStyle, "aria-hidden": "true" })] }));
|
|
18
22
|
}
|
|
19
23
|
//# sourceMappingURL=BackgroundMedia.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackgroundMedia.js","sourceRoot":"","sources":["../../src/framework/BackgroundMedia.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAUjC,MAAM,UAAU,eAAe,CAAC,EAC9B,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,GACO;IACrB,IAAI,CAAC,gBAAgB;QAAE,OAAO,IAAI,CAAC;IAEnC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,CAAC;IAEhF,MAAM,UAAU,GAAG,cAAc,IAAI,cAAc,GAAG,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,UAAU;QAC7B,CAAC,CAAC;YACE,eAAe,EAAE,iBAAiB,cAAc,GAAG,GAAG,GAAG;SAC1D;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAElD,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,SAAS,CAAC,aAE9D,CAAC,UAAU,IAAI,CACd,cAAK,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,gBAAgB,IAAI,YAAY,CAAC,IAAI,mBAAmB,CAAC,YACxF,KAAC,MAAM,I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BAAgB,EAClC,cAAc,EAAE,cAAc,GAC9B,GACE,CACP,EAGA,YAAY,IAAI,CAAC,gBAAgB,IAAI,CACpC,cAAK,SAAS,EAAC,+BAA+B,YAC5C,KAAC,MAAM,IACL,MAAM,EAAE,YAAY,EACpB,SAAS,EAAC,sCAAsC;oBAChD,6DAA6D;oBAC7D,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,KAAK,EACf,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,GAC9B,GACE,CACP,EAGA,UAAU,IAAI,cAAK,SAAS,EAAC,kBAAkB,EAAC,KAAK,EAAE,YAAY,iBAAc,MAAM,GAAG,IACvF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
export function ComponentErrorIndicator({ type, message, component, id, details, inline = false, isProduction = false, }) {
|
|
3
|
+
// Don't show errors in production
|
|
3
4
|
if (isProduction)
|
|
4
5
|
return null;
|
|
5
6
|
const bgColor = {
|
|
6
|
-
validation: '#f97316e6',
|
|
7
|
-
parsing: '#ef4444e6',
|
|
8
|
-
render: '#dc2626e6',
|
|
9
|
-
data: '#eab308e6',
|
|
7
|
+
validation: '#f97316e6', // orange-500 with 90% opacity
|
|
8
|
+
parsing: '#ef4444e6', // red-500 with 90% opacity
|
|
9
|
+
render: '#dc2626e6', // red-600 with 90% opacity
|
|
10
|
+
data: '#eab308e6', // yellow-500 with 90% opacity
|
|
10
11
|
}[type];
|
|
11
12
|
const icon = {
|
|
12
13
|
validation: '⚠️',
|
|
@@ -15,8 +16,10 @@ export function ComponentErrorIndicator({ type, message, component, id, details,
|
|
|
15
16
|
data: '⚡',
|
|
16
17
|
}[type];
|
|
17
18
|
if (inline) {
|
|
19
|
+
// Inline version for embedding within components
|
|
18
20
|
return (_jsxs("span", { className: "inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium text-white", style: { backgroundColor: bgColor }, children: [_jsx("span", { children: icon }), _jsx("span", { children: message })] }));
|
|
19
21
|
}
|
|
22
|
+
// Full banner version
|
|
20
23
|
return (_jsx("div", { className: "relative z-40 text-white", style: { backgroundColor: bgColor }, children: _jsx("div", { className: "mx-auto max-w-7xl px-4 py-2", children: _jsxs("div", { className: "flex items-start gap-2 p-sm", children: [_jsx("span", { className: "text-lg", children: icon }), _jsxs("div", { className: "flex-1", children: [_jsxs("p", { className: "font-semibold", children: ["Component Error: ", component ? `${component}` : 'Unknown Component', id && ` (${id})`] }), _jsx("p", { className: "mt-0.5", children: message }), details !== undefined && details !== null && (_jsxs("details", { className: "mt-1", children: [_jsx("summary", { className: "cursor-pointer text-xs opacity-75 hover:opacity-100", children: "Show details" }), _jsx("pre", { className: "mt-1 overflow-auto rounded bg-black/20 p-2 text-xs", children: details instanceof Error
|
|
21
24
|
? details.stack || details.message
|
|
22
25
|
: typeof details === 'object'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentErrorIndicator.js","sourceRoot":"","sources":["../../src/framework/ComponentErrorIndicator.tsx"],"names":[],"mappings":";AAUA,MAAM,UAAU,uBAAuB,CAAC,EACtC,IAAI,EACJ,OAAO,EACP,SAAS,EACT,EAAE,EACF,OAAO,EACP,MAAM,GAAG,KAAK,EACd,YAAY,GAAG,KAAK,GACS;
|
|
1
|
+
{"version":3,"file":"ComponentErrorIndicator.js","sourceRoot":"","sources":["../../src/framework/ComponentErrorIndicator.tsx"],"names":[],"mappings":";AAUA,MAAM,UAAU,uBAAuB,CAAC,EACtC,IAAI,EACJ,OAAO,EACP,SAAS,EACT,EAAE,EACF,OAAO,EACP,MAAM,GAAG,KAAK,EACd,YAAY,GAAG,KAAK,GACS;IAC7B,kCAAkC;IAClC,IAAI,YAAY;QAAE,OAAO,IAAI,CAAC;IAE9B,MAAM,OAAO,GAAG;QACd,UAAU,EAAE,WA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AC,CAAC,OAAO,OAAO,KAAK,QAAQ;gDAC3B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gDAClC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GACjB,IACE,CACX,IACG,IACF,GACF,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** biome-ignore-all lint/suspicious/noConsole: Console is ok */
|
|
1
2
|
interface ComponentError {
|
|
2
3
|
type: 'validation' | 'parsing' | 'render' | 'data';
|
|
3
4
|
message: string;
|
|
@@ -5,7 +6,14 @@ interface ComponentError {
|
|
|
5
6
|
id?: string;
|
|
6
7
|
details?: unknown;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Shows a component error indicator in non-production environments
|
|
11
|
+
* Returns the error element to be included in the component's render
|
|
12
|
+
*/
|
|
8
13
|
export declare function showComponentError(error: ComponentError, isProduction?: boolean): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
/**
|
|
15
|
+
* Shows an inline error indicator (smaller, embedded version)
|
|
16
|
+
*/
|
|
9
17
|
export declare function showInlineError(error: ComponentError, isProduction?: boolean): import("react/jsx-runtime").JSX.Element | null;
|
|
10
18
|
export {};
|
|
11
19
|
//# sourceMappingURL=componentErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentErrors.d.ts","sourceRoot":"","sources":["../../src/framework/componentErrors.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"componentErrors.d.ts","sourceRoot":"","sources":["../../src/framework/componentErrors.tsx"],"names":[],"mappings":"AAAA,gEAAgE;AAIhE,UAAU,cAAc;IACtB,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,UAAQ,kDAU7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,UAAQ,kDAU1E"}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noConsole: Console is ok */
|
|
2
3
|
import { ComponentErrorIndicator } from './ComponentErrorIndicator';
|
|
4
|
+
/**
|
|
5
|
+
* Shows a component error indicator in non-production environments
|
|
6
|
+
* Returns the error element to be included in the component's render
|
|
7
|
+
*/
|
|
3
8
|
export function showComponentError(error, isProduction = false) {
|
|
4
9
|
if (isProduction)
|
|
5
10
|
return null;
|
|
11
|
+
// Also log to console for debugging
|
|
6
12
|
console.error(`Component Error [${error.component || 'Unknown'}]:`, {
|
|
7
13
|
...error,
|
|
8
14
|
timestamp: new Date().toISOString(),
|
|
9
15
|
});
|
|
10
16
|
return _jsx(ComponentErrorIndicator, { ...error, isProduction: isProduction });
|
|
11
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Shows an inline error indicator (smaller, embedded version)
|
|
20
|
+
*/
|
|
12
21
|
export function showInlineError(error, isProduction = false) {
|
|
13
22
|
if (isProduction)
|
|
14
23
|
return null;
|
|
24
|
+
// Also log to console for debugging
|
|
15
25
|
console.warn(`Component Warning [${error.component || 'Unknown'}]:`, {
|
|
16
26
|
...error,
|
|
17
27
|
timestamp: new Date().toISOString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentErrors.js","sourceRoot":"","sources":["../../src/framework/componentErrors.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"componentErrors.js","sourceRoot":"","sources":["../../src/framework/componentErrors.tsx"],"names":[],"mappings":";AAAA,gEAAgE;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAUpE;;;GAGG;AAEH,MAAM,UAAU,kBAAkB,CAAC,KAAqB,EAAE,YAAY,GAAG,KAAK;IAC5E,IAAI,YAAY;QAAE,OAAO,IAAI,CAAC;IAE9B,oCAAoC;IACpC,OAAO,CAAC,KAAK,CAAC,oBAAoB,KAAK,CAAC,SAAS,IAAI,SAAS,IAAI,EAAE;QAClE,GAAG,KAAK;QACR,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC,CAAC;IAEH,OAAO,KAAC,uBAAuB,OAAK,KAAK,EAAE,YAAY,EAAE,YAAY,GAAI,CAAC;AAC5E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAqB,EAAE,YAAY,GAAG,KAAK;IACzE,IAAI,YAAY;QAAE,OAAO,IAAI,CAAC;IAE9B,oCAAoC;IACpC,OAAO,CAAC,IAAI,CAAC,sBAAsB,KAAK,CAAC,SAAS,IAAI,SAAS,IAAI,EAAE;QACnE,GAAG,KAAK;QACR,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC,CAAC;IAEH,OAAO,KAAC,uBAAuB,OAAK,KAAK,EAAE,MAAM,QAAC,YAAY,EAAE,YAAY,GAAI,CAAC;AACnF,CAAC"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { IAnalyticsContext } from '@se-studio/core-data-types';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the useClickTracking hook.
|
|
4
|
+
*/
|
|
2
5
|
interface UseClickTrackingProps {
|
|
6
|
+
/** Type of component being tracked (e.g., 'Button', 'Link', 'Card') */
|
|
3
7
|
componentType: string;
|
|
8
|
+
/** Optional target URL for the click */
|
|
4
9
|
targetUrl?: string;
|
|
10
|
+
/** Text content of the link/button */
|
|
5
11
|
linkText: string;
|
|
12
|
+
/** Location label from CMS (optional) */
|
|
6
13
|
location: string | null | undefined;
|
|
14
|
+
/** Optional analytics context for enhanced tracking */
|
|
7
15
|
analytics?: IAnalyticsContext;
|
|
16
|
+
/** Function to call when tracking a click */
|
|
8
17
|
trackClick: (props: {
|
|
9
18
|
componentType: string;
|
|
10
19
|
url: string;
|
|
@@ -12,8 +21,38 @@ interface UseClickTrackingProps {
|
|
|
12
21
|
linkText: string;
|
|
13
22
|
location?: string;
|
|
14
23
|
} & IAnalyticsContext) => void;
|
|
24
|
+
/** Function to get the current page URL */
|
|
15
25
|
getCurrentPageUrl: () => string;
|
|
16
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook for tracking click events with analytics.
|
|
29
|
+
*
|
|
30
|
+
* Returns a click handler function that automatically tracks clicks with
|
|
31
|
+
* component type, link text, URLs, and analytics context.
|
|
32
|
+
*
|
|
33
|
+
* @param props - Click tracking configuration
|
|
34
|
+
* @returns Click handler function to attach to onClick events
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import { useClickTracking, useAnalytics } from '@se-studio/core-ui';
|
|
39
|
+
*
|
|
40
|
+
* function MyButton() {
|
|
41
|
+
* const { trackClick } = useAnalytics();
|
|
42
|
+
* const handleClick = useClickTracking({
|
|
43
|
+
* componentType: 'Button',
|
|
44
|
+
* targetUrl: '/signup',
|
|
45
|
+
* linkText: 'Sign up',
|
|
46
|
+
* location: 'hero',
|
|
47
|
+
* analytics: { page_title: 'Home' },
|
|
48
|
+
* trackClick,
|
|
49
|
+
* getCurrentPageUrl: () => window.location.href,
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* return <button onClick={handleClick}>Sign up</button>;
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
17
56
|
export declare function useClickTracking({ componentType, targetUrl, linkText, location, analytics, trackClick, getCurrentPageUrl, }: UseClickTrackingProps): () => void;
|
|
18
57
|
export {};
|
|
19
58
|
//# sourceMappingURL=useClickTracking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickTracking.d.ts","sourceRoot":"","sources":["../../src/hooks/useClickTracking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,UAAU,qBAAqB;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,UAAU,EAAE,CACV,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,iBAAiB,KAClB,IAAI,CAAC;IACV,iBAAiB,EAAE,MAAM,MAAM,CAAC;CACjC;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,aAAa,EACb,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,iBAAiB,GAClB,EAAE,qBAAqB,cAiBvB"}
|
|
1
|
+
{"version":3,"file":"useClickTracking.d.ts","sourceRoot":"","sources":["../../src/hooks/useClickTracking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE;;GAEG;AACH,UAAU,qBAAqB;IAC7B,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,uDAAuD;IACvD,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,6CAA6C;IAC7C,UAAU,EAAE,CACV,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,iBAAiB,KAClB,IAAI,CAAC;IACV,2CAA2C;IAC3C,iBAAiB,EAAE,MAAM,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,aAAa,EACb,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,iBAAiB,GAClB,EAAE,qBAAqB,cAiBvB"}
|
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for tracking click events with analytics.
|
|
5
|
+
*
|
|
6
|
+
* Returns a click handler function that automatically tracks clicks with
|
|
7
|
+
* component type, link text, URLs, and analytics context.
|
|
8
|
+
*
|
|
9
|
+
* @param props - Click tracking configuration
|
|
10
|
+
* @returns Click handler function to attach to onClick events
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { useClickTracking, useAnalytics } from '@se-studio/core-ui';
|
|
15
|
+
*
|
|
16
|
+
* function MyButton() {
|
|
17
|
+
* const { trackClick } = useAnalytics();
|
|
18
|
+
* const handleClick = useClickTracking({
|
|
19
|
+
* componentType: 'Button',
|
|
20
|
+
* targetUrl: '/signup',
|
|
21
|
+
* linkText: 'Sign up',
|
|
22
|
+
* location: 'hero',
|
|
23
|
+
* analytics: { page_title: 'Home' },
|
|
24
|
+
* trackClick,
|
|
25
|
+
* getCurrentPageUrl: () => window.location.href,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* return <button onClick={handleClick}>Sign up</button>;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
3
32
|
export function useClickTracking({ componentType, targetUrl, linkText, location, analytics, trackClick, getCurrentPageUrl, }) {
|
|
4
33
|
const handleClick = useCallback(() => {
|
|
5
34
|
const url = getCurrentPageUrl();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickTracking.js","sourceRoot":"","sources":["../../src/hooks/useClickTracking.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useClickTracking.js","sourceRoot":"","sources":["../../src/hooks/useClickTracking.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AA8BpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,aAAa,EACb,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,iBAAiB,GACK;IACtB,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAC;QAEhC,IAAI,SAAS,EAAE,CAAC;YACd,UAAU,CAAC;gBACT,aAAa;gBACb,GAAG,SAAS;gBACZ,GAAG;gBACH,SAAS;gBACT,QAAQ;gBACR,QAAQ,EAAE,QAAQ,IAAI,SAAS;aAChC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE7F,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @se-studio/core-ui
|
|
3
|
+
*
|
|
4
|
+
* Shared React UI component library with Tailwind CSS v4 and CMS infrastructure
|
|
5
|
+
* for SE Studio applications.
|
|
6
|
+
*
|
|
7
|
+
* This package provides:
|
|
8
|
+
* - CMS content rendering system with type-safe component mapping
|
|
9
|
+
* - React components for images, videos, animations, and rich text
|
|
10
|
+
* - Analytics integration hooks and providers
|
|
11
|
+
* - Utility functions for page metadata, error handling, and content extraction
|
|
12
|
+
* - Type-safe configuration system for CMS renderers
|
|
13
|
+
*
|
|
14
|
+
* @example Basic usage
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { CmsContent, Visual } from '@se-studio/core-ui';
|
|
17
|
+
* import { contentfulPageRest } from '@se-studio/contentful-rest-api';
|
|
18
|
+
*
|
|
19
|
+
* const page = await contentfulPageRest(config, 'home');
|
|
20
|
+
*
|
|
21
|
+
* export default function Page() {
|
|
22
|
+
* return <CmsContent content={page} config={rendererConfig} />;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Using Visual component
|
|
27
|
+
* ```tsx
|
|
28
|
+
* import { Visual } from '@se-studio/core-ui';
|
|
29
|
+
* import type { IVisual } from '@se-studio/core-data-types';
|
|
30
|
+
*
|
|
31
|
+
* <Visual visual={visualData} className="w-full" priority />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
export { AnalyticsProvider, useAnalyticsContext } from './analytics/AnalyticsProvider';
|
|
37
|
+
export { ConsoleAnalyticsAdapter } from './analytics/adapters';
|
|
38
|
+
export type { AnalyticsAdapter, ClickTrackingProperties, PageTrackingProperties, } from './analytics/types';
|
|
39
|
+
export { useAnalytics } from './analytics/useAnalytics';
|
|
1
40
|
export type { CmsRendererConfig, CmsRendererTypes } from './CmsRendererConfig';
|
|
2
41
|
export { ClientMonitor } from './components/ClientMonitor.js';
|
|
3
42
|
export type { CollectionMap, CollectionRenderer, CollectionRendererProps, EmbeddedCollectionMap, EmbeddedCollectionRenderer, } from './components/CmsCollection';
|
|
@@ -14,8 +53,9 @@ export type { IVisualProps } from './components/Visual';
|
|
|
14
53
|
export { calculateCropDetails, calculateImagePriority, calculateImageWidthStyleVariable, } from './components/Visual';
|
|
15
54
|
export { Visual } from './components/VisualComponent';
|
|
16
55
|
export { RtfOrString } from './elements/RtfOrString';
|
|
56
|
+
export type { TrackedLinkProps } from './elements/TrackedLink';
|
|
57
|
+
export { TrackedLink } from './elements/TrackedLink';
|
|
17
58
|
export { UtmLink } from './elements/UtmLink';
|
|
18
|
-
export { UtmLinkOrDiv } from './elements/UtmLinkOrDiv';
|
|
19
59
|
export { BackgroundMedia } from './framework/BackgroundMedia';
|
|
20
60
|
export { ComponentErrorIndicator } from './framework/ComponentErrorIndicator';
|
|
21
61
|
export { showComponentError, showInlineError } from './framework/componentErrors';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA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,MAAM,8BAA8B,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @se-studio/core-ui
|
|
3
|
+
*
|
|
4
|
+
* Shared React UI component library with Tailwind CSS v4 and CMS infrastructure
|
|
5
|
+
* for SE Studio applications.
|
|
6
|
+
*
|
|
7
|
+
* This package provides:
|
|
8
|
+
* - CMS content rendering system with type-safe component mapping
|
|
9
|
+
* - React components for images, videos, animations, and rich text
|
|
10
|
+
* - Analytics integration hooks and providers
|
|
11
|
+
* - Utility functions for page metadata, error handling, and content extraction
|
|
12
|
+
* - Type-safe configuration system for CMS renderers
|
|
13
|
+
*
|
|
14
|
+
* @example Basic usage
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { CmsContent, Visual } from '@se-studio/core-ui';
|
|
17
|
+
* import { contentfulPageRest } from '@se-studio/contentful-rest-api';
|
|
18
|
+
*
|
|
19
|
+
* const page = await contentfulPageRest(config, 'home');
|
|
20
|
+
*
|
|
21
|
+
* export default function Page() {
|
|
22
|
+
* return <CmsContent content={page} config={rendererConfig} />;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Using Visual component
|
|
27
|
+
* ```tsx
|
|
28
|
+
* import { Visual } from '@se-studio/core-ui';
|
|
29
|
+
* import type { IVisual } from '@se-studio/core-data-types';
|
|
30
|
+
*
|
|
31
|
+
* <Visual visual={visualData} className="w-full" priority />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
// Component and Collection Mapping Infrastructure
|
|
37
|
+
// Analytics
|
|
38
|
+
export { AnalyticsProvider, useAnalyticsContext } from './analytics/AnalyticsProvider';
|
|
39
|
+
// Analytics Adapters
|
|
40
|
+
export { ConsoleAnalyticsAdapter } from './analytics/adapters';
|
|
41
|
+
export { useAnalytics } from './analytics/useAnalytics';
|
|
1
42
|
export { ClientMonitor } from './components/ClientMonitor.js';
|
|
2
43
|
export { CmsCollection } from './components/CmsCollection';
|
|
3
44
|
export { CmsComponent } from './components/CmsComponent';
|
|
@@ -5,24 +46,30 @@ export { CmsContent } from './components/CmsContent';
|
|
|
5
46
|
export { CmsConversionErrors } from './components/CmsConversionErrors';
|
|
6
47
|
export { CmsEmbeddedContent } from './components/CmsEmbeddedContent';
|
|
7
48
|
export { Preview } from './components/Preview.js';
|
|
49
|
+
// Visual Components
|
|
8
50
|
export { calculateCropDetails, calculateImagePriority, calculateImageWidthStyleVariable, } from './components/Visual';
|
|
9
51
|
export { Visual } from './components/VisualComponent';
|
|
10
52
|
export { RtfOrString } from './elements/RtfOrString';
|
|
53
|
+
export { TrackedLink } from './elements/TrackedLink';
|
|
54
|
+
// Elements
|
|
11
55
|
export { UtmLink } from './elements/UtmLink';
|
|
12
|
-
export { UtmLinkOrDiv } from './elements/UtmLinkOrDiv';
|
|
13
56
|
export { BackgroundMedia } from './framework/BackgroundMedia';
|
|
57
|
+
// Framework Components
|
|
14
58
|
export { ComponentErrorIndicator } from './framework/ComponentErrorIndicator';
|
|
15
59
|
export { showComponentError, showInlineError } from './framework/componentErrors';
|
|
16
60
|
export { default as ResponsiveVisual } from './framework/ResponsiveVisual';
|
|
61
|
+
// Shared Hooks
|
|
17
62
|
export { useClickTracking } from './hooks/useClickTracking';
|
|
18
63
|
export { RTF } from './rtf/rtf';
|
|
19
64
|
export { buildPageMetadata } from './utils/buildPageMetadata';
|
|
65
|
+
// Shared Utilities
|
|
20
66
|
export { cn } from './utils/cn';
|
|
21
67
|
export { createCollectionProps, createComponentProps, extractCollectionInfo, extractComponentInfo, extractPageContext, } from './utils/componentUtils';
|
|
22
68
|
export { convertText } from './utils/convertText';
|
|
23
69
|
export { handleCmsError } from './utils/errorHandling';
|
|
24
70
|
export { getPreviewAssetIdProps, getPreviewFieldIdProps, getPreviewParentProps, getPreviewProps, } from './utils/previewUtils';
|
|
25
71
|
export { UnsupportedWarning } from './utils/UnsupportedWarning';
|
|
72
|
+
// Development Utilities
|
|
26
73
|
export { DEFAULT_ALLOWED_UNUSED, UnusedChecker } from './utils/UnusedChecker';
|
|
27
74
|
export { isAbsoluteUrl } from './utils/urlUtils';
|
|
28
75
|
export { calculateHorizontalPositionClassName } from './utils/visualPositions';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,kDAAkD;AAElD,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACvF,qBAAqB;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAS9D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQ3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAQrE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,oBAAoB;AACpB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,gCAAgC,GACjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,WAAW;AACX,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,uBAAuB;AACvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,mBAAmB;AACnB,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAYhC,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,wBAAwB;AACxB,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/rtf/rtf.d.ts
CHANGED
|
@@ -2,11 +2,52 @@ import { type Document } from '@contentful/rich-text-types';
|
|
|
2
2
|
import type { IContentContext } from '@se-studio/core-data-types';
|
|
3
3
|
import type { HTMLAttributes } from 'react';
|
|
4
4
|
import type { CmsRendererConfig } from '../CmsRendererConfig';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the RTF (Rich Text Field) component.
|
|
7
|
+
*/
|
|
5
8
|
export type RTFProps = {
|
|
9
|
+
/** Contentful rich text document to render */
|
|
6
10
|
content: Document;
|
|
11
|
+
/** Optional CMS renderer configuration for embedded content */
|
|
7
12
|
rendererConfig?: CmsRendererConfig;
|
|
13
|
+
/** Optional content context for embedded components */
|
|
8
14
|
contentContext?: IContentContext;
|
|
15
|
+
/** Optional CSS class for positioning embedded content */
|
|
9
16
|
embeddedPositionClassName?: string;
|
|
10
17
|
} & Omit<HTMLAttributes<HTMLElement>, 'content'>;
|
|
18
|
+
/**
|
|
19
|
+
* Renders Contentful rich text fields with support for embedded entries and assets.
|
|
20
|
+
*
|
|
21
|
+
* This component handles:
|
|
22
|
+
* - Standard rich text formatting (headings, paragraphs, lists, etc.)
|
|
23
|
+
* - Embedded entries (components, collections) via renderer config
|
|
24
|
+
* - Embedded assets (images, videos) via visual component renderer
|
|
25
|
+
* - Hyperlinks (internal and external)
|
|
26
|
+
* - Entry hyperlinks (links to CMS entries)
|
|
27
|
+
*
|
|
28
|
+
* @param content - Contentful rich text document
|
|
29
|
+
* @param rendererConfig - Optional CMS renderer configuration for embedded content
|
|
30
|
+
* @param contentContext - Optional content context for embedded components
|
|
31
|
+
* @param embeddedPositionClassName - Optional CSS class for positioning embedded content
|
|
32
|
+
* @param className - Additional CSS classes
|
|
33
|
+
* @param style - Additional inline styles
|
|
34
|
+
*
|
|
35
|
+
* @example Basic usage
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { RTF } from '@se-studio/core-ui';
|
|
38
|
+
*
|
|
39
|
+
* <RTF content={richTextField} />
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example With embedded content
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <RTF
|
|
45
|
+
* content={richTextField}
|
|
46
|
+
* rendererConfig={rendererConfig}
|
|
47
|
+
* contentContext={contentContext}
|
|
48
|
+
* embeddedPositionClassName="w-full col-span-full"
|
|
49
|
+
* />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
11
52
|
export declare function RTF({ content, className, style, rendererConfig, contentContext, embeddedPositionClassName, ...other }: RTFProps): import("react/jsx-runtime").JSX.Element;
|
|
12
53
|
//# sourceMappingURL=rtf.d.ts.map
|
package/dist/rtf/rtf.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rtf.d.ts","sourceRoot":"","sources":["../../src/rtf/rtf.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAW,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6F9D,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,QAAQ,CAAC;IAClB,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,CAAC;AAEjD,wBAAgB,GAAG,CAAC,EAClB,OAAO,EACP,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,GAAG,KAAK,EACT,EAAE,QAAQ,2CAOV"}
|
|
1
|
+
{"version":3,"file":"rtf.d.ts","sourceRoot":"","sources":["../../src/rtf/rtf.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAW,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6F9D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,8CAA8C;IAC9C,OAAO,EAAE,QAAQ,CAAC;IAClB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,uDAAuD;IACvD,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,0DAA0D;IAC1D,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,GAAG,CAAC,EAClB,OAAO,EACP,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,GAAG,KAAK,EACT,EAAE,QAAQ,2CAOV"}
|
package/dist/rtf/rtf.js
CHANGED
|
@@ -8,6 +8,7 @@ function createComplexLinksRenderer(rendererConfig, contentContext, embeddedPosi
|
|
|
8
8
|
if (!rendererConfig || !contentContext) {
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
11
|
+
// Track the position of embedded entries within this RTF document
|
|
11
12
|
let embeddedEntryCounter = 0;
|
|
12
13
|
return {
|
|
13
14
|
[INLINES.EMBEDDED_ENTRY]: (node) => {
|
|
@@ -36,6 +37,7 @@ function createComplexLinksRenderer(rendererConfig, contentContext, embeddedPosi
|
|
|
36
37
|
[BLOCKS.EMBEDDED_ENTRY]: (node) => {
|
|
37
38
|
const target = node.data.target;
|
|
38
39
|
if (target) {
|
|
40
|
+
// Capture the current index before incrementing for the next embedded entry
|
|
39
41
|
const currentIndex = embeddedEntryCounter++;
|
|
40
42
|
return (_jsx(CmsEmbeddedContent, { information: target, contentContext: contentContext, rendererConfig: rendererConfig, positionClassName: embeddedPositionClassName ?? 'w-full col-span-full', parentIndex: 0, embeddedIndex: currentIndex }));
|
|
41
43
|
}
|
|
@@ -59,6 +61,40 @@ function buildOptions(rendererConfig, contentContext, embeddedPositionClassName)
|
|
|
59
61
|
},
|
|
60
62
|
};
|
|
61
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Renders Contentful rich text fields with support for embedded entries and assets.
|
|
66
|
+
*
|
|
67
|
+
* This component handles:
|
|
68
|
+
* - Standard rich text formatting (headings, paragraphs, lists, etc.)
|
|
69
|
+
* - Embedded entries (components, collections) via renderer config
|
|
70
|
+
* - Embedded assets (images, videos) via visual component renderer
|
|
71
|
+
* - Hyperlinks (internal and external)
|
|
72
|
+
* - Entry hyperlinks (links to CMS entries)
|
|
73
|
+
*
|
|
74
|
+
* @param content - Contentful rich text document
|
|
75
|
+
* @param rendererConfig - Optional CMS renderer configuration for embedded content
|
|
76
|
+
* @param contentContext - Optional content context for embedded components
|
|
77
|
+
* @param embeddedPositionClassName - Optional CSS class for positioning embedded content
|
|
78
|
+
* @param className - Additional CSS classes
|
|
79
|
+
* @param style - Additional inline styles
|
|
80
|
+
*
|
|
81
|
+
* @example Basic usage
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { RTF } from '@se-studio/core-ui';
|
|
84
|
+
*
|
|
85
|
+
* <RTF content={richTextField} />
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example With embedded content
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <RTF
|
|
91
|
+
* content={richTextField}
|
|
92
|
+
* rendererConfig={rendererConfig}
|
|
93
|
+
* contentContext={contentContext}
|
|
94
|
+
* embeddedPositionClassName="w-full col-span-full"
|
|
95
|
+
* />
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
62
98
|
export function RTF({ content, className, style, rendererConfig, contentContext, embeddedPositionClassName, ...other }) {
|
|
63
99
|
const options = buildOptions(rendererConfig, contentContext, embeddedPositionClassName);
|
|
64
100
|
return (_jsx("div", { className: className, style: style, ...other, children: documentToReactComponents(content, options) }));
|
package/dist/rtf/rtf.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rtf.js","sourceRoot":"","sources":["../../src/rtf/rtf.tsx"],"names":[],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