@akinon/next 2.0.0-beta.2 → 2.0.0-beta.20
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/.eslintrc.js +12 -0
- package/CHANGELOG.md +377 -7
- package/__tests__/next-config.test.ts +83 -0
- package/__tests__/tsconfig.json +23 -0
- package/api/auth.ts +133 -44
- package/api/barcode-search.ts +59 -0
- package/api/cache.ts +41 -5
- package/api/client.ts +21 -4
- package/api/form.ts +85 -0
- package/api/image-proxy.ts +75 -0
- package/api/product-categories.ts +53 -0
- package/api/similar-product-list.ts +63 -0
- package/api/similar-products.ts +111 -0
- package/api/virtual-try-on.ts +382 -0
- package/assets/styles/index.scss +84 -0
- package/babel.config.js +6 -0
- package/bin/pz-generate-routes.js +115 -0
- package/bin/pz-prebuild.js +1 -0
- package/bin/pz-predev.js +1 -0
- package/bin/pz-run-tests.js +99 -0
- package/bin/run-prebuild-tests.js +46 -0
- package/components/accordion.tsx +20 -5
- package/components/button.tsx +51 -36
- package/components/client-root.tsx +138 -2
- package/components/file-input.tsx +65 -3
- package/components/index.ts +1 -0
- package/components/input.tsx +1 -1
- package/components/link.tsx +46 -16
- package/components/logger-popup.tsx +213 -0
- package/components/modal.tsx +32 -16
- package/components/plugin-module.tsx +62 -3
- package/components/price.tsx +2 -2
- package/components/select.tsx +1 -1
- package/components/selected-payment-option-view.tsx +21 -0
- package/components/theme-editor/blocks/accordion-block.tsx +136 -0
- package/components/theme-editor/blocks/block-renderer-registry.tsx +77 -0
- package/components/theme-editor/blocks/button-block.tsx +593 -0
- package/components/theme-editor/blocks/counter-block.tsx +348 -0
- package/components/theme-editor/blocks/divider-block.tsx +20 -0
- package/components/theme-editor/blocks/embed-block.tsx +208 -0
- package/components/theme-editor/blocks/group-block.tsx +116 -0
- package/components/theme-editor/blocks/hotspot-block.tsx +147 -0
- package/components/theme-editor/blocks/icon-block.tsx +230 -0
- package/components/theme-editor/blocks/image-block.tsx +137 -0
- package/components/theme-editor/blocks/image-gallery-block.tsx +269 -0
- package/components/theme-editor/blocks/input-block.tsx +123 -0
- package/components/theme-editor/blocks/link-block.tsx +216 -0
- package/components/theme-editor/blocks/lottie-block.tsx +325 -0
- package/components/theme-editor/blocks/map-block.tsx +89 -0
- package/components/theme-editor/blocks/slider-block.tsx +595 -0
- package/components/theme-editor/blocks/tab-block.tsx +10 -0
- package/components/theme-editor/blocks/text-block.tsx +52 -0
- package/components/theme-editor/blocks/video-block.tsx +122 -0
- package/components/theme-editor/components/action-toolbar.tsx +305 -0
- package/components/theme-editor/components/designer-overlay.tsx +74 -0
- package/components/theme-editor/components/with-designer-features.tsx +142 -0
- package/components/theme-editor/dynamic-font-loader.tsx +79 -0
- package/components/theme-editor/hooks/use-designer-features.tsx +100 -0
- package/components/theme-editor/hooks/use-external-designer.tsx +95 -0
- package/components/theme-editor/hooks/use-native-widget-data.ts +188 -0
- package/components/theme-editor/hooks/use-visibility-context.ts +27 -0
- package/components/theme-editor/placeholder-registry.ts +31 -0
- package/components/theme-editor/sections/before-after-section.tsx +245 -0
- package/components/theme-editor/sections/contact-form-section.tsx +563 -0
- package/components/theme-editor/sections/countdown-campaign-banner-section.tsx +433 -0
- package/components/theme-editor/sections/coupon-banner-section.tsx +710 -0
- package/components/theme-editor/sections/divider-section.tsx +62 -0
- package/components/theme-editor/sections/featured-product-spotlight-section.tsx +507 -0
- package/components/theme-editor/sections/find-in-store-section.tsx +1995 -0
- package/components/theme-editor/sections/hover-showcase-section.tsx +326 -0
- package/components/theme-editor/sections/image-hotspot-section.tsx +142 -0
- package/components/theme-editor/sections/installment-options-section.tsx +1065 -0
- package/components/theme-editor/sections/notification-banner-section.tsx +173 -0
- package/components/theme-editor/sections/order-tracking-lookup-section.tsx +1379 -0
- package/components/theme-editor/sections/posts-slider-section.tsx +472 -0
- package/components/theme-editor/sections/pre-order-launch-banner-section.tsx +663 -0
- package/components/theme-editor/sections/section-renderer-registry.tsx +89 -0
- package/components/theme-editor/sections/section-wrapper.tsx +135 -0
- package/components/theme-editor/sections/shipping-threshold-progress-section.tsx +586 -0
- package/components/theme-editor/sections/stats-counter-section.tsx +486 -0
- package/components/theme-editor/sections/tabs-section.tsx +578 -0
- package/components/theme-editor/theme-block.tsx +102 -0
- package/components/theme-editor/theme-placeholder-client.tsx +218 -0
- package/components/theme-editor/theme-placeholder-wrapper.tsx +732 -0
- package/components/theme-editor/theme-placeholder.tsx +288 -0
- package/components/theme-editor/theme-section.tsx +1224 -0
- package/components/theme-editor/theme-settings-context.tsx +13 -0
- package/components/theme-editor/utils/index.ts +792 -0
- package/components/theme-editor/utils/iterator-utils.ts +234 -0
- package/components/theme-editor/utils/publish-window.ts +86 -0
- package/components/theme-editor/utils/visibility-rules.ts +188 -0
- package/data/client/account.ts +17 -2
- package/data/client/api.ts +2 -0
- package/data/client/basket.ts +66 -5
- package/data/client/checkout.ts +391 -99
- package/data/client/misc.ts +38 -2
- package/data/client/product.ts +19 -2
- package/data/client/user.ts +16 -8
- package/data/server/category.ts +11 -9
- package/data/server/flatpage.ts +11 -4
- package/data/server/form.ts +15 -4
- package/data/server/landingpage.ts +11 -4
- package/data/server/list.ts +5 -4
- package/data/server/menu.ts +11 -3
- package/data/server/product.ts +111 -55
- package/data/server/seo.ts +14 -4
- package/data/server/special-page.ts +5 -4
- package/data/server/widget.ts +90 -5
- package/data/urls.ts +16 -5
- package/hocs/client/with-segment-defaults.tsx +2 -2
- package/hocs/server/with-segment-defaults.tsx +65 -20
- package/hooks/index.ts +4 -0
- package/hooks/use-localization.ts +24 -10
- package/hooks/use-logger-context.tsx +114 -0
- package/hooks/use-logger.ts +92 -0
- package/hooks/use-loyalty-availability.ts +21 -0
- package/hooks/use-payment-options.ts +2 -1
- package/hooks/use-pz-params.ts +37 -0
- package/hooks/use-router.ts +51 -14
- package/hooks/use-sentry-uncaught-errors.ts +24 -0
- package/instrumentation/index.ts +10 -1
- package/instrumentation/node.ts +2 -20
- package/jest.config.js +25 -0
- package/lib/cache-handler.mjs +534 -16
- package/lib/cache.ts +272 -37
- package/localization/index.ts +2 -1
- package/localization/provider.tsx +2 -5
- package/middlewares/bfcache-headers.ts +18 -0
- package/middlewares/checkout-provider.ts +1 -1
- package/middlewares/complete-gpay.ts +32 -26
- package/middlewares/complete-masterpass.ts +33 -26
- package/middlewares/complete-wallet.ts +182 -0
- package/middlewares/default.ts +360 -215
- package/middlewares/index.ts +10 -2
- package/middlewares/locale.ts +34 -11
- package/middlewares/masterpass-rest-callback.ts +230 -0
- package/middlewares/oauth-login.ts +200 -57
- package/middlewares/pretty-url.ts +21 -8
- package/middlewares/redirection-payment.ts +32 -26
- package/middlewares/saved-card-redirection.ts +33 -26
- package/middlewares/three-d-redirection.ts +32 -26
- package/middlewares/url-redirection.ts +11 -1
- package/middlewares/wallet-complete-redirection.ts +206 -0
- package/package.json +25 -10
- package/plugins.d.ts +19 -4
- package/plugins.js +10 -1
- package/redux/actions.ts +47 -0
- package/redux/middlewares/checkout.ts +63 -138
- package/redux/middlewares/index.ts +14 -10
- package/redux/middlewares/pre-order/address.ts +7 -2
- package/redux/middlewares/pre-order/attribute-based-shipping-option.ts +7 -1
- package/redux/middlewares/pre-order/data-source-shipping-option.ts +7 -1
- package/redux/middlewares/pre-order/delivery-option.ts +7 -1
- package/redux/middlewares/pre-order/index.ts +16 -10
- package/redux/middlewares/pre-order/installment-option.ts +8 -1
- package/redux/middlewares/pre-order/payment-option-reset.ts +37 -0
- package/redux/middlewares/pre-order/payment-option.ts +7 -1
- package/redux/middlewares/pre-order/pre-order-validation.ts +8 -3
- package/redux/middlewares/pre-order/redirection.ts +8 -2
- package/redux/middlewares/pre-order/set-pre-order.ts +6 -2
- package/redux/middlewares/pre-order/shipping-option.ts +7 -1
- package/redux/middlewares/pre-order/shipping-step.ts +5 -1
- package/redux/reducers/checkout.ts +23 -3
- package/redux/reducers/index.ts +11 -3
- package/redux/reducers/root.ts +7 -2
- package/redux/reducers/widget.ts +80 -0
- package/sentry/index.ts +69 -13
- package/tailwind/content.js +16 -0
- package/types/commerce/account.ts +5 -1
- package/types/commerce/checkout.ts +35 -1
- package/types/commerce/widget.ts +33 -0
- package/types/index.ts +101 -6
- package/types/next-auth.d.ts +2 -2
- package/types/widget.ts +80 -0
- package/utils/app-fetch.ts +7 -2
- package/utils/generate-commerce-search-params.ts +3 -2
- package/utils/get-checkout-path.ts +3 -0
- package/utils/get-root-hostname.ts +28 -0
- package/utils/index.ts +64 -10
- package/utils/localization.ts +4 -0
- package/utils/mobile-3d-iframe.ts +8 -2
- package/utils/override-middleware.ts +7 -12
- package/utils/pz-segments.ts +92 -0
- package/utils/redirect-ignore.ts +35 -0
- package/utils/redirect.ts +9 -3
- package/utils/redirection-iframe.ts +8 -2
- package/utils/widget-styles.ts +107 -0
- package/views/error-page.tsx +93 -0
- package/with-pz-config.js +13 -6
|
@@ -0,0 +1,218 @@
|
|
|
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
|
+
}
|