@akinon/next 2.0.0-beta.20 → 2.0.0-beta.22
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/CHANGELOG.md +25 -0
- package/api/auth.ts +292 -60
- package/bin/pz-install-plugins.js +1 -1
- package/package.json +3 -3
- package/types/index.ts +19 -6
- package/types/next-auth.d.ts +1 -1
- package/with-pz-config.js +8 -1
- package/components/theme-editor/blocks/accordion-block.tsx +0 -136
- package/components/theme-editor/blocks/block-renderer-registry.tsx +0 -77
- package/components/theme-editor/blocks/button-block.tsx +0 -593
- package/components/theme-editor/blocks/counter-block.tsx +0 -348
- package/components/theme-editor/blocks/divider-block.tsx +0 -20
- package/components/theme-editor/blocks/embed-block.tsx +0 -208
- package/components/theme-editor/blocks/group-block.tsx +0 -116
- package/components/theme-editor/blocks/hotspot-block.tsx +0 -147
- package/components/theme-editor/blocks/icon-block.tsx +0 -230
- package/components/theme-editor/blocks/image-block.tsx +0 -137
- package/components/theme-editor/blocks/image-gallery-block.tsx +0 -269
- package/components/theme-editor/blocks/input-block.tsx +0 -123
- package/components/theme-editor/blocks/link-block.tsx +0 -216
- package/components/theme-editor/blocks/lottie-block.tsx +0 -325
- package/components/theme-editor/blocks/map-block.tsx +0 -89
- package/components/theme-editor/blocks/slider-block.tsx +0 -595
- package/components/theme-editor/blocks/tab-block.tsx +0 -10
- package/components/theme-editor/blocks/text-block.tsx +0 -52
- package/components/theme-editor/blocks/video-block.tsx +0 -122
- package/components/theme-editor/components/action-toolbar.tsx +0 -305
- package/components/theme-editor/components/designer-overlay.tsx +0 -74
- package/components/theme-editor/components/with-designer-features.tsx +0 -142
- package/components/theme-editor/dynamic-font-loader.tsx +0 -79
- package/components/theme-editor/hooks/use-designer-features.tsx +0 -100
- package/components/theme-editor/hooks/use-external-designer.tsx +0 -95
- package/components/theme-editor/hooks/use-native-widget-data.ts +0 -188
- package/components/theme-editor/hooks/use-visibility-context.ts +0 -27
- package/components/theme-editor/placeholder-registry.ts +0 -31
- package/components/theme-editor/sections/before-after-section.tsx +0 -245
- package/components/theme-editor/sections/contact-form-section.tsx +0 -563
- package/components/theme-editor/sections/countdown-campaign-banner-section.tsx +0 -433
- package/components/theme-editor/sections/coupon-banner-section.tsx +0 -710
- package/components/theme-editor/sections/divider-section.tsx +0 -62
- package/components/theme-editor/sections/featured-product-spotlight-section.tsx +0 -507
- package/components/theme-editor/sections/find-in-store-section.tsx +0 -1995
- package/components/theme-editor/sections/hover-showcase-section.tsx +0 -326
- package/components/theme-editor/sections/image-hotspot-section.tsx +0 -142
- package/components/theme-editor/sections/installment-options-section.tsx +0 -1065
- package/components/theme-editor/sections/notification-banner-section.tsx +0 -173
- package/components/theme-editor/sections/order-tracking-lookup-section.tsx +0 -1379
- package/components/theme-editor/sections/posts-slider-section.tsx +0 -472
- package/components/theme-editor/sections/pre-order-launch-banner-section.tsx +0 -663
- package/components/theme-editor/sections/section-renderer-registry.tsx +0 -89
- package/components/theme-editor/sections/section-wrapper.tsx +0 -135
- package/components/theme-editor/sections/shipping-threshold-progress-section.tsx +0 -586
- package/components/theme-editor/sections/stats-counter-section.tsx +0 -486
- package/components/theme-editor/sections/tabs-section.tsx +0 -578
- package/components/theme-editor/theme-block.tsx +0 -102
- package/components/theme-editor/theme-placeholder-client.tsx +0 -218
- package/components/theme-editor/theme-placeholder-wrapper.tsx +0 -732
- package/components/theme-editor/theme-placeholder.tsx +0 -288
- package/components/theme-editor/theme-section.tsx +0 -1224
- package/components/theme-editor/theme-settings-context.tsx +0 -13
- package/components/theme-editor/utils/index.ts +0 -792
- package/components/theme-editor/utils/iterator-utils.ts +0 -234
- package/components/theme-editor/utils/publish-window.ts +0 -86
- package/components/theme-editor/utils/visibility-rules.ts +0 -188
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
interface DynamicFontLoaderProps {
|
|
6
|
-
fontFamily?: string;
|
|
7
|
-
fontWeight?: string;
|
|
8
|
-
fontSubsets?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Client-side component to dynamically load Google Fonts
|
|
13
|
-
* Used for theme editor buttons that use custom fonts
|
|
14
|
-
*/
|
|
15
|
-
export function DynamicFontLoader({
|
|
16
|
-
fontFamily,
|
|
17
|
-
fontWeight,
|
|
18
|
-
fontSubsets
|
|
19
|
-
}: DynamicFontLoaderProps) {
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!fontFamily || fontFamily === 'inherit') return;
|
|
22
|
-
|
|
23
|
-
// Clean font family name (remove quotes and extra spaces)
|
|
24
|
-
const cleanFontFamily = fontFamily.replace(/['"]/g, '').trim();
|
|
25
|
-
|
|
26
|
-
// Skip if it's a system font
|
|
27
|
-
const systemFonts = [
|
|
28
|
-
'Arial',
|
|
29
|
-
'Helvetica',
|
|
30
|
-
'Times New Roman',
|
|
31
|
-
'Georgia',
|
|
32
|
-
'Courier New',
|
|
33
|
-
'Verdana'
|
|
34
|
-
];
|
|
35
|
-
if (systemFonts.includes(cleanFontFamily)) return;
|
|
36
|
-
|
|
37
|
-
// Build Google Fonts URL
|
|
38
|
-
const params = new URLSearchParams();
|
|
39
|
-
|
|
40
|
-
// Font family with weights
|
|
41
|
-
const weights = fontWeight || '100;300;400;500;600;700;800;900';
|
|
42
|
-
const fontParam = `${cleanFontFamily.replace(/\s+/g, '+')}:wght@${weights}`;
|
|
43
|
-
params.append('family', fontParam);
|
|
44
|
-
|
|
45
|
-
// Subsets
|
|
46
|
-
if (fontSubsets) {
|
|
47
|
-
params.append('subset', fontSubsets);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Display swap for better performance
|
|
51
|
-
params.append('display', 'swap');
|
|
52
|
-
|
|
53
|
-
const fontUrl = `https://fonts.googleapis.com/css2?${params.toString()}`;
|
|
54
|
-
|
|
55
|
-
// Check if link already exists
|
|
56
|
-
const existingLink = document.querySelector(`link[href="${fontUrl}"]`);
|
|
57
|
-
if (existingLink) return;
|
|
58
|
-
|
|
59
|
-
// Create and append link element
|
|
60
|
-
const link = document.createElement('link');
|
|
61
|
-
link.href = fontUrl;
|
|
62
|
-
link.rel = 'stylesheet';
|
|
63
|
-
link.id = `google-font-${cleanFontFamily
|
|
64
|
-
.replace(/\s+/g, '-')
|
|
65
|
-
.toLowerCase()}`;
|
|
66
|
-
|
|
67
|
-
document.head.appendChild(link);
|
|
68
|
-
|
|
69
|
-
// Cleanup on unmount
|
|
70
|
-
return () => {
|
|
71
|
-
const linkToRemove = document.getElementById(link.id);
|
|
72
|
-
if (linkToRemove) {
|
|
73
|
-
document.head.removeChild(linkToRemove);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}, [fontFamily, fontWeight, fontSubsets]);
|
|
77
|
-
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
|
|
5
|
-
interface BlockInfo {
|
|
6
|
-
id: string;
|
|
7
|
-
type: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface UseDesignerFeaturesProps {
|
|
12
|
-
blockId: string;
|
|
13
|
-
placeholderId: string;
|
|
14
|
-
sectionId: string;
|
|
15
|
-
isDesigner: boolean;
|
|
16
|
-
blockInfo?: BlockInfo;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function useDesignerFeatures({
|
|
20
|
-
blockId,
|
|
21
|
-
placeholderId,
|
|
22
|
-
sectionId,
|
|
23
|
-
isDesigner,
|
|
24
|
-
blockInfo
|
|
25
|
-
}: UseDesignerFeaturesProps) {
|
|
26
|
-
const handleClick = useCallback(
|
|
27
|
-
(e: React.MouseEvent) => {
|
|
28
|
-
if (isDesigner) {
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
e.stopPropagation();
|
|
31
|
-
|
|
32
|
-
if (window.parent) {
|
|
33
|
-
window.parent.postMessage(
|
|
34
|
-
{
|
|
35
|
-
type: 'SELECT_BLOCK',
|
|
36
|
-
data: {
|
|
37
|
-
placeholderId,
|
|
38
|
-
sectionId,
|
|
39
|
-
blockId,
|
|
40
|
-
blockType: blockInfo?.type,
|
|
41
|
-
blockLabel: blockInfo?.label
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
'*'
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
[isDesigner, blockId, placeholderId, sectionId, blockInfo]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const createActionHandler = useCallback(
|
|
53
|
-
(actionType: string) => () => {
|
|
54
|
-
if (window.parent) {
|
|
55
|
-
window.parent.postMessage(
|
|
56
|
-
{
|
|
57
|
-
type: actionType,
|
|
58
|
-
data: {
|
|
59
|
-
placeholderId,
|
|
60
|
-
sectionId,
|
|
61
|
-
blockId
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
'*'
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
[blockId, placeholderId, sectionId]
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const handleRename = useCallback(
|
|
72
|
-
(newLabel: string) => {
|
|
73
|
-
if (window.parent) {
|
|
74
|
-
window.parent.postMessage(
|
|
75
|
-
{
|
|
76
|
-
type: 'RENAME_BLOCK',
|
|
77
|
-
data: {
|
|
78
|
-
placeholderId,
|
|
79
|
-
sectionId,
|
|
80
|
-
blockId,
|
|
81
|
-
label: newLabel
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
'*'
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
[blockId, placeholderId, sectionId]
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
handleClick,
|
|
93
|
-
onMoveUp: createActionHandler('MOVE_BLOCK_UP'),
|
|
94
|
-
onMoveDown: createActionHandler('MOVE_BLOCK_DOWN'),
|
|
95
|
-
onDuplicate: createActionHandler('DUPLICATE_BLOCK'),
|
|
96
|
-
onToggleVisibility: createActionHandler('TOGGLE_BLOCK_VISIBILITY'),
|
|
97
|
-
onDelete: createActionHandler('DELETE_BLOCK'),
|
|
98
|
-
onRename: handleRename
|
|
99
|
-
};
|
|
100
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
registerPlaceholder,
|
|
6
|
-
unregisterPlaceholder
|
|
7
|
-
} from '../placeholder-registry';
|
|
8
|
-
|
|
9
|
-
interface UseExternalDesignerOptions {
|
|
10
|
-
placeholderId: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ExternalDesignerState {
|
|
14
|
-
isDesigner: boolean;
|
|
15
|
-
selectedSectionId: string | null;
|
|
16
|
-
selectedBlockId: string | null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function useExternalDesigner({
|
|
20
|
-
placeholderId
|
|
21
|
-
}: UseExternalDesignerOptions): ExternalDesignerState {
|
|
22
|
-
const [isDesigner, setIsDesigner] = useState(false);
|
|
23
|
-
const [selectedSectionId, setSelectedSectionId] = useState<string | null>(
|
|
24
|
-
null
|
|
25
|
-
);
|
|
26
|
-
const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (typeof window === 'undefined') {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const isInIframe = window.self !== window.top;
|
|
34
|
-
|
|
35
|
-
// Set isDesigner immediately if in iframe (don't wait for SET_THEME_EDITOR_COOKIE)
|
|
36
|
-
if (isInIframe) {
|
|
37
|
-
setIsDesigner(true);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (isInIframe && window.parent) {
|
|
41
|
-
// Only send IFRAME_READY once per page session to prevent re-initialization
|
|
42
|
-
if (
|
|
43
|
-
!(window as Window & { __iframeReadySent?: boolean }).__iframeReadySent
|
|
44
|
-
) {
|
|
45
|
-
window.parent.postMessage(
|
|
46
|
-
{
|
|
47
|
-
type: 'IFRAME_READY'
|
|
48
|
-
},
|
|
49
|
-
'*'
|
|
50
|
-
);
|
|
51
|
-
(window as Window & { __iframeReadySent?: boolean }).__iframeReadySent =
|
|
52
|
-
true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
registerPlaceholder(placeholderId);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const handleMessage = (event: MessageEvent) => {
|
|
59
|
-
const { type, data } = event.data || {};
|
|
60
|
-
|
|
61
|
-
// Also handle SET_THEME_EDITOR_COOKIE for backwards compatibility
|
|
62
|
-
if (type === 'SET_THEME_EDITOR_COOKIE' && data) {
|
|
63
|
-
setIsDesigner(true);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (type === 'SELECT_SECTION' && data?.placeholderId === placeholderId) {
|
|
67
|
-
setSelectedSectionId(data.sectionId ?? null);
|
|
68
|
-
setSelectedBlockId(null);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (type === 'SELECT_BLOCK' && data?.placeholderId === placeholderId) {
|
|
72
|
-
setSelectedSectionId(data.sectionId ?? null);
|
|
73
|
-
setSelectedBlockId(data.blockId ?? null);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (type === 'CLEAR_SELECTION') {
|
|
77
|
-
setSelectedSectionId(null);
|
|
78
|
-
setSelectedBlockId(null);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
window.addEventListener('message', handleMessage);
|
|
83
|
-
|
|
84
|
-
return () => {
|
|
85
|
-
window.removeEventListener('message', handleMessage);
|
|
86
|
-
unregisterPlaceholder(placeholderId);
|
|
87
|
-
};
|
|
88
|
-
}, [placeholderId]);
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
isDesigner,
|
|
92
|
-
selectedSectionId,
|
|
93
|
-
selectedBlockId
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
useGetWidgetQuery,
|
|
6
|
-
useGetWidgetSchemaQuery
|
|
7
|
-
} from '../../../data/client/misc';
|
|
8
|
-
|
|
9
|
-
export interface NativeWidgetBlock {
|
|
10
|
-
id: string;
|
|
11
|
-
type?: string;
|
|
12
|
-
label?: string;
|
|
13
|
-
styles?: Record<string, unknown>;
|
|
14
|
-
properties?: Record<string, unknown>;
|
|
15
|
-
value?: unknown;
|
|
16
|
-
blocks?: NativeWidgetBlock[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface NativeWidgetData {
|
|
20
|
-
blocks: Map<string, NativeWidgetBlock>;
|
|
21
|
-
sectionStyles: Record<string, unknown>;
|
|
22
|
-
sectionProperties: Record<string, unknown>;
|
|
23
|
-
isLoading: boolean;
|
|
24
|
-
getBlock: (blockId: string) => NativeWidgetBlock | undefined;
|
|
25
|
-
getSectionStyle: (key: string) => unknown;
|
|
26
|
-
getSectionProperty: (key: string) => unknown;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface UseNativeWidgetDataOptions {
|
|
30
|
-
widgetSlug: string;
|
|
31
|
-
sectionId: string;
|
|
32
|
-
skip?: boolean;
|
|
33
|
-
blockMeta?: Array<{ id: string; type: string; label: string }>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function parseAttributeValue(attrData: unknown): unknown {
|
|
37
|
-
if (attrData === undefined || attrData === null) return undefined;
|
|
38
|
-
|
|
39
|
-
if (typeof attrData === 'string') {
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(attrData);
|
|
42
|
-
} catch {
|
|
43
|
-
return attrData;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (typeof attrData === 'object' && attrData !== null && 'value' in attrData) {
|
|
48
|
-
const value = (attrData as { value?: unknown }).value;
|
|
49
|
-
if (typeof value === 'string') {
|
|
50
|
-
try {
|
|
51
|
-
return JSON.parse(value);
|
|
52
|
-
} catch {
|
|
53
|
-
return value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return attrData;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function extractResponsiveValue(value: unknown): unknown {
|
|
63
|
-
if (typeof value === 'object' && value !== null && 'desktop' in value) {
|
|
64
|
-
return (value as Record<string, unknown>).desktop;
|
|
65
|
-
}
|
|
66
|
-
return value;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function useNativeWidgetData({
|
|
70
|
-
widgetSlug,
|
|
71
|
-
sectionId,
|
|
72
|
-
skip = false,
|
|
73
|
-
blockMeta = []
|
|
74
|
-
}: UseNativeWidgetDataOptions): NativeWidgetData {
|
|
75
|
-
const [blockMap, setBlockMap] = useState<Map<string, NativeWidgetBlock>>(
|
|
76
|
-
() => new Map()
|
|
77
|
-
);
|
|
78
|
-
const [sectionStyles, setSectionStyles] = useState<Record<string, unknown>>({});
|
|
79
|
-
const [sectionProperties, setSectionProperties] = useState<Record<string, unknown>>({});
|
|
80
|
-
const blockMapRef = useRef(blockMap);
|
|
81
|
-
|
|
82
|
-
const { data: widgetData, isLoading: isWidgetLoading } = useGetWidgetQuery(
|
|
83
|
-
widgetSlug,
|
|
84
|
-
{ skip }
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const { data: schemaData, isLoading: isSchemaLoading } = useGetWidgetSchemaQuery(
|
|
88
|
-
widgetSlug,
|
|
89
|
-
{ skip }
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (skip) return;
|
|
94
|
-
|
|
95
|
-
const schema = schemaData?.schema;
|
|
96
|
-
const attributes = widgetData?.attributes;
|
|
97
|
-
|
|
98
|
-
const sectionMeta = schema?.[sectionId]?.metadata;
|
|
99
|
-
if (sectionMeta) {
|
|
100
|
-
if (sectionMeta.styles) {
|
|
101
|
-
setSectionStyles(sectionMeta.styles);
|
|
102
|
-
}
|
|
103
|
-
if (sectionMeta.properties) {
|
|
104
|
-
setSectionProperties(sectionMeta.properties);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const newBlockMap = new Map<string, NativeWidgetBlock>();
|
|
109
|
-
|
|
110
|
-
blockMeta.forEach((meta) => {
|
|
111
|
-
newBlockMap.set(meta.id, {
|
|
112
|
-
id: meta.id,
|
|
113
|
-
type: meta.type,
|
|
114
|
-
label: meta.label
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (schema) {
|
|
119
|
-
Object.entries(schema).forEach(([blockId, blockSchema]: [string, any]) => {
|
|
120
|
-
if (blockId === sectionId) return;
|
|
121
|
-
|
|
122
|
-
const metadata = blockSchema?.metadata || {};
|
|
123
|
-
const existing = newBlockMap.get(blockId);
|
|
124
|
-
const value = attributes ? parseAttributeValue(attributes[blockId]) : undefined;
|
|
125
|
-
|
|
126
|
-
newBlockMap.set(blockId, {
|
|
127
|
-
...existing,
|
|
128
|
-
id: blockId,
|
|
129
|
-
type: metadata.type || existing?.type,
|
|
130
|
-
label: blockSchema.label || existing?.label,
|
|
131
|
-
styles: metadata.styles || {},
|
|
132
|
-
properties: metadata.properties || {},
|
|
133
|
-
value
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
} else if (attributes) {
|
|
137
|
-
Object.keys(attributes).forEach((blockId) => {
|
|
138
|
-
const existing = newBlockMap.get(blockId);
|
|
139
|
-
const parsed = parseAttributeValue(attributes[blockId]);
|
|
140
|
-
|
|
141
|
-
if (typeof parsed === 'object' && parsed !== null) {
|
|
142
|
-
const payload = parsed as Record<string, unknown>;
|
|
143
|
-
newBlockMap.set(blockId, {
|
|
144
|
-
...existing,
|
|
145
|
-
id: blockId,
|
|
146
|
-
styles: (payload.styles as Record<string, unknown>) || existing?.styles,
|
|
147
|
-
properties: (payload.properties as Record<string, unknown>) || existing?.properties,
|
|
148
|
-
value: payload.value !== undefined ? payload.value : existing?.value
|
|
149
|
-
});
|
|
150
|
-
} else {
|
|
151
|
-
newBlockMap.set(blockId, {
|
|
152
|
-
...existing,
|
|
153
|
-
id: blockId,
|
|
154
|
-
value: parsed
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
setBlockMap(newBlockMap);
|
|
161
|
-
blockMapRef.current = newBlockMap;
|
|
162
|
-
}, [skip, widgetData, schemaData, sectionId, blockMeta]);
|
|
163
|
-
|
|
164
|
-
const getBlock = useCallback(
|
|
165
|
-
(blockId: string) => blockMapRef.current.get(blockId),
|
|
166
|
-
[]
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
const getSectionStyle = useCallback(
|
|
170
|
-
(key: string) => extractResponsiveValue(sectionStyles[key]),
|
|
171
|
-
[sectionStyles]
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
const getSectionProperty = useCallback(
|
|
175
|
-
(key: string) => extractResponsiveValue(sectionProperties[key]),
|
|
176
|
-
[sectionProperties]
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
blocks: blockMap,
|
|
181
|
-
sectionStyles,
|
|
182
|
-
sectionProperties,
|
|
183
|
-
isLoading: isWidgetLoading || isSchemaLoading,
|
|
184
|
-
getBlock,
|
|
185
|
-
getSectionStyle,
|
|
186
|
-
getSectionProperty
|
|
187
|
-
};
|
|
188
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { usePathname, useSearchParams } from 'next/navigation';
|
|
4
|
-
import { useSession } from 'next-auth/react';
|
|
5
|
-
|
|
6
|
-
import { useLocalization } from '../../../hooks/use-localization';
|
|
7
|
-
|
|
8
|
-
export const useVisibilityContext = (currentBreakpoint = 'desktop') => {
|
|
9
|
-
const pathname = usePathname();
|
|
10
|
-
const searchParams = useSearchParams();
|
|
11
|
-
const { status } = useSession();
|
|
12
|
-
const { locale, currency } = useLocalization();
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
authState:
|
|
16
|
-
status === 'authenticated'
|
|
17
|
-
? ('authenticated' as const)
|
|
18
|
-
: status === 'loading'
|
|
19
|
-
? ('loading' as const)
|
|
20
|
-
: ('guest' as const),
|
|
21
|
-
breakpoint: currentBreakpoint,
|
|
22
|
-
locale: String(locale || ''),
|
|
23
|
-
currency: String(currency || ''),
|
|
24
|
-
pathname: String(pathname || ''),
|
|
25
|
-
searchParams
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const placeholderRegistry = new Set<string>();
|
|
2
|
-
let registryTimeout: NodeJS.Timeout | null = null;
|
|
3
|
-
|
|
4
|
-
export const registerPlaceholder = (slug: string) => {
|
|
5
|
-
placeholderRegistry.add(slug);
|
|
6
|
-
|
|
7
|
-
if (registryTimeout) {
|
|
8
|
-
clearTimeout(registryTimeout);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
registryTimeout = setTimeout(() => {
|
|
12
|
-
if (
|
|
13
|
-
typeof window !== 'undefined' &&
|
|
14
|
-
window.parent &&
|
|
15
|
-
window.self !== window.top
|
|
16
|
-
) {
|
|
17
|
-
const availablePlaceholders = Array.from(placeholderRegistry);
|
|
18
|
-
window.parent.postMessage(
|
|
19
|
-
{
|
|
20
|
-
type: 'PLACEHOLDERS_AVAILABLE',
|
|
21
|
-
data: { placeholders: availablePlaceholders }
|
|
22
|
-
},
|
|
23
|
-
'*'
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}, 100);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const unregisterPlaceholder = (slug: string) => {
|
|
30
|
-
placeholderRegistry.delete(slug);
|
|
31
|
-
};
|