@akinon/next 2.0.0-beta.20 → 2.0.0-beta.21
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 +23 -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,218 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import ThemeSection, { Section } from './theme-section';
|
|
5
|
-
import {
|
|
6
|
-
registerPlaceholder,
|
|
7
|
-
unregisterPlaceholder
|
|
8
|
-
} from './placeholder-registry';
|
|
9
|
-
import { useVisibilityContext } from './hooks/use-visibility-context';
|
|
10
|
-
import { applyVisibilityRulesToSections } from './utils/visibility-rules';
|
|
11
|
-
import { isPublishWindowVisible } from './utils/publish-window';
|
|
12
|
-
|
|
13
|
-
// Global flag to track if IFRAME_READY has been sent (survives component remount)
|
|
14
|
-
declare global {
|
|
15
|
-
interface Window {
|
|
16
|
-
__iframeReadySent?: boolean;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface ThemePlaceholderClientProps {
|
|
21
|
-
slug: string;
|
|
22
|
-
initialSections?: Section[];
|
|
23
|
-
initialPlaceholderId?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function ThemePlaceholderClient({
|
|
27
|
-
slug,
|
|
28
|
-
initialSections = [],
|
|
29
|
-
initialPlaceholderId = ''
|
|
30
|
-
}: ThemePlaceholderClientProps) {
|
|
31
|
-
const [sections, setSections] = useState<Section[]>(initialSections);
|
|
32
|
-
const [placeholderSlug, setPlaceholderSlug] =
|
|
33
|
-
useState<string>(initialPlaceholderId);
|
|
34
|
-
const [selectedSectionId, setSelectedSectionId] = useState<string | null>(
|
|
35
|
-
null
|
|
36
|
-
);
|
|
37
|
-
const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null);
|
|
38
|
-
const [currentBreakpoint, setCurrentBreakpoint] = useState<string>('desktop');
|
|
39
|
-
const [isDesigner, setIsDesigner] = useState(false);
|
|
40
|
-
const visibilityContext = useVisibilityContext(currentBreakpoint);
|
|
41
|
-
const renderedSections = applyVisibilityRulesToSections(
|
|
42
|
-
sections,
|
|
43
|
-
visibilityContext
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (typeof window === 'undefined') {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const checkDesignerMode = () => {
|
|
52
|
-
return window.self !== window.top;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const isInIframe = checkDesignerMode();
|
|
56
|
-
|
|
57
|
-
if (isInIframe && window.parent) {
|
|
58
|
-
// Only send IFRAME_READY once per page session to prevent re-initialization
|
|
59
|
-
if (!window.__iframeReadySent) {
|
|
60
|
-
window.parent.postMessage(
|
|
61
|
-
{
|
|
62
|
-
type: 'IFRAME_READY'
|
|
63
|
-
},
|
|
64
|
-
'*'
|
|
65
|
-
);
|
|
66
|
-
window.__iframeReadySent = true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
registerPlaceholder(slug);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const handleMessage = (event: MessageEvent) => {
|
|
73
|
-
switch (event.data?.type) {
|
|
74
|
-
case 'SET_THEME_EDITOR_COOKIE':
|
|
75
|
-
if (event.data.data) {
|
|
76
|
-
setIsDesigner(true);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
|
|
80
|
-
case 'LOAD_THEME':
|
|
81
|
-
case 'UPDATE_THEME': {
|
|
82
|
-
const theme = event.data.data?.theme;
|
|
83
|
-
if (theme?.placeholders) {
|
|
84
|
-
const placeholder = theme.placeholders.find(
|
|
85
|
-
(p: { slug: string }) => p.slug === slug
|
|
86
|
-
);
|
|
87
|
-
if (placeholder) {
|
|
88
|
-
setPlaceholderSlug(placeholder.slug);
|
|
89
|
-
if (placeholder.sections) {
|
|
90
|
-
setSections(placeholder.sections);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
case 'SELECT_SECTION': {
|
|
98
|
-
const { sectionId } = event.data.data || {};
|
|
99
|
-
if (sectionId) {
|
|
100
|
-
setSelectedSectionId(sectionId);
|
|
101
|
-
setSelectedBlockId(null);
|
|
102
|
-
}
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
case 'SELECT_BLOCK': {
|
|
107
|
-
const { blockId } = event.data.data || {};
|
|
108
|
-
if (blockId) {
|
|
109
|
-
setSelectedBlockId(blockId);
|
|
110
|
-
setSelectedSectionId(null);
|
|
111
|
-
}
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
case 'CHANGE_BREAKPOINT': {
|
|
116
|
-
const { breakpoint } = event.data.data || {};
|
|
117
|
-
if (breakpoint) {
|
|
118
|
-
setCurrentBreakpoint(breakpoint);
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
case 'CLEAR_SELECTION': {
|
|
124
|
-
setSelectedSectionId(null);
|
|
125
|
-
setSelectedBlockId(null);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
window.addEventListener('message', handleMessage);
|
|
132
|
-
return () => {
|
|
133
|
-
window.removeEventListener('message', handleMessage);
|
|
134
|
-
unregisterPlaceholder(slug);
|
|
135
|
-
};
|
|
136
|
-
}, [slug]);
|
|
137
|
-
|
|
138
|
-
const sendAction = (
|
|
139
|
-
action: string,
|
|
140
|
-
data: {
|
|
141
|
-
placeholderId?: string;
|
|
142
|
-
sectionId?: string;
|
|
143
|
-
blockId?: string;
|
|
144
|
-
label?: string;
|
|
145
|
-
}
|
|
146
|
-
) => {
|
|
147
|
-
if (window.parent) {
|
|
148
|
-
window.parent.postMessage(
|
|
149
|
-
{
|
|
150
|
-
type: action,
|
|
151
|
-
data
|
|
152
|
-
},
|
|
153
|
-
'*'
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<div data-placeholder={slug} className="theme-placeholder">
|
|
160
|
-
{renderedSections
|
|
161
|
-
.sort((a, b) => a.order - b.order)
|
|
162
|
-
.filter((section) =>
|
|
163
|
-
!section.hidden &&
|
|
164
|
-
(isDesigner ||
|
|
165
|
-
isPublishWindowVisible(section.properties?.['publish-window']))
|
|
166
|
-
)
|
|
167
|
-
.map((section) => (
|
|
168
|
-
<ThemeSection
|
|
169
|
-
key={section.id}
|
|
170
|
-
section={section}
|
|
171
|
-
placeholderId={placeholderSlug}
|
|
172
|
-
isDesigner={isDesigner}
|
|
173
|
-
isSelected={selectedSectionId === section.id}
|
|
174
|
-
selectedBlockId={selectedBlockId}
|
|
175
|
-
currentBreakpoint={currentBreakpoint}
|
|
176
|
-
onSelect={setSelectedSectionId}
|
|
177
|
-
onMoveUp={() =>
|
|
178
|
-
sendAction('MOVE_SECTION_UP', {
|
|
179
|
-
placeholderId: placeholderSlug,
|
|
180
|
-
sectionId: section.id
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
onMoveDown={() =>
|
|
184
|
-
sendAction('MOVE_SECTION_DOWN', {
|
|
185
|
-
placeholderId: placeholderSlug,
|
|
186
|
-
sectionId: section.id
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
onDuplicate={() =>
|
|
190
|
-
sendAction('DUPLICATE_SECTION', {
|
|
191
|
-
placeholderId: placeholderSlug,
|
|
192
|
-
sectionId: section.id
|
|
193
|
-
})
|
|
194
|
-
}
|
|
195
|
-
onToggleVisibility={() =>
|
|
196
|
-
sendAction('TOGGLE_SECTION_VISIBILITY', {
|
|
197
|
-
placeholderId: placeholderSlug,
|
|
198
|
-
sectionId: section.id
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
onDelete={() =>
|
|
202
|
-
sendAction('DELETE_SECTION', {
|
|
203
|
-
placeholderId: placeholderSlug,
|
|
204
|
-
sectionId: section.id
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
onRename={(newLabel) =>
|
|
208
|
-
sendAction('RENAME_SECTION', {
|
|
209
|
-
placeholderId: placeholderSlug,
|
|
210
|
-
sectionId: section.id,
|
|
211
|
-
label: newLabel
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
/>
|
|
215
|
-
))}
|
|
216
|
-
</div>
|
|
217
|
-
);
|
|
218
|
-
}
|