@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/api/auth.ts +292 -60
  3. package/bin/pz-install-plugins.js +1 -1
  4. package/package.json +3 -3
  5. package/types/index.ts +19 -6
  6. package/types/next-auth.d.ts +1 -1
  7. package/with-pz-config.js +8 -1
  8. package/components/theme-editor/blocks/accordion-block.tsx +0 -136
  9. package/components/theme-editor/blocks/block-renderer-registry.tsx +0 -77
  10. package/components/theme-editor/blocks/button-block.tsx +0 -593
  11. package/components/theme-editor/blocks/counter-block.tsx +0 -348
  12. package/components/theme-editor/blocks/divider-block.tsx +0 -20
  13. package/components/theme-editor/blocks/embed-block.tsx +0 -208
  14. package/components/theme-editor/blocks/group-block.tsx +0 -116
  15. package/components/theme-editor/blocks/hotspot-block.tsx +0 -147
  16. package/components/theme-editor/blocks/icon-block.tsx +0 -230
  17. package/components/theme-editor/blocks/image-block.tsx +0 -137
  18. package/components/theme-editor/blocks/image-gallery-block.tsx +0 -269
  19. package/components/theme-editor/blocks/input-block.tsx +0 -123
  20. package/components/theme-editor/blocks/link-block.tsx +0 -216
  21. package/components/theme-editor/blocks/lottie-block.tsx +0 -325
  22. package/components/theme-editor/blocks/map-block.tsx +0 -89
  23. package/components/theme-editor/blocks/slider-block.tsx +0 -595
  24. package/components/theme-editor/blocks/tab-block.tsx +0 -10
  25. package/components/theme-editor/blocks/text-block.tsx +0 -52
  26. package/components/theme-editor/blocks/video-block.tsx +0 -122
  27. package/components/theme-editor/components/action-toolbar.tsx +0 -305
  28. package/components/theme-editor/components/designer-overlay.tsx +0 -74
  29. package/components/theme-editor/components/with-designer-features.tsx +0 -142
  30. package/components/theme-editor/dynamic-font-loader.tsx +0 -79
  31. package/components/theme-editor/hooks/use-designer-features.tsx +0 -100
  32. package/components/theme-editor/hooks/use-external-designer.tsx +0 -95
  33. package/components/theme-editor/hooks/use-native-widget-data.ts +0 -188
  34. package/components/theme-editor/hooks/use-visibility-context.ts +0 -27
  35. package/components/theme-editor/placeholder-registry.ts +0 -31
  36. package/components/theme-editor/sections/before-after-section.tsx +0 -245
  37. package/components/theme-editor/sections/contact-form-section.tsx +0 -563
  38. package/components/theme-editor/sections/countdown-campaign-banner-section.tsx +0 -433
  39. package/components/theme-editor/sections/coupon-banner-section.tsx +0 -710
  40. package/components/theme-editor/sections/divider-section.tsx +0 -62
  41. package/components/theme-editor/sections/featured-product-spotlight-section.tsx +0 -507
  42. package/components/theme-editor/sections/find-in-store-section.tsx +0 -1995
  43. package/components/theme-editor/sections/hover-showcase-section.tsx +0 -326
  44. package/components/theme-editor/sections/image-hotspot-section.tsx +0 -142
  45. package/components/theme-editor/sections/installment-options-section.tsx +0 -1065
  46. package/components/theme-editor/sections/notification-banner-section.tsx +0 -173
  47. package/components/theme-editor/sections/order-tracking-lookup-section.tsx +0 -1379
  48. package/components/theme-editor/sections/posts-slider-section.tsx +0 -472
  49. package/components/theme-editor/sections/pre-order-launch-banner-section.tsx +0 -663
  50. package/components/theme-editor/sections/section-renderer-registry.tsx +0 -89
  51. package/components/theme-editor/sections/section-wrapper.tsx +0 -135
  52. package/components/theme-editor/sections/shipping-threshold-progress-section.tsx +0 -586
  53. package/components/theme-editor/sections/stats-counter-section.tsx +0 -486
  54. package/components/theme-editor/sections/tabs-section.tsx +0 -578
  55. package/components/theme-editor/theme-block.tsx +0 -102
  56. package/components/theme-editor/theme-placeholder-client.tsx +0 -218
  57. package/components/theme-editor/theme-placeholder-wrapper.tsx +0 -732
  58. package/components/theme-editor/theme-placeholder.tsx +0 -288
  59. package/components/theme-editor/theme-section.tsx +0 -1224
  60. package/components/theme-editor/theme-settings-context.tsx +0 -13
  61. package/components/theme-editor/utils/index.ts +0 -792
  62. package/components/theme-editor/utils/iterator-utils.ts +0 -234
  63. package/components/theme-editor/utils/publish-window.ts +0 -86
  64. package/components/theme-editor/utils/visibility-rules.ts +0 -188
@@ -1,325 +0,0 @@
1
- import React, { useEffect, useRef, useState, useCallback } from 'react';
2
- import { BlockRendererProps } from './block-renderer-registry';
3
-
4
- interface LottieAnimationData {
5
- [key: string]: unknown;
6
- }
7
-
8
- const LottieBlock = ({ block }: BlockRendererProps) => {
9
- const containerRef = useRef<HTMLDivElement>(null);
10
- const animationRef = useRef<unknown>(null);
11
- const [error, setError] = useState<string | null>(null);
12
- const [loading, setLoading] = useState<boolean>(false);
13
- const [animationData, setAnimationData] = useState<LottieAnimationData | null>(null);
14
-
15
- const properties = block.properties || {};
16
-
17
- // Resolve responsive values
18
- const resolveValue = <T,>(val: unknown, fallback: T): T => {
19
- if (val && typeof val === 'object' && 'desktop' in (val as Record<string, unknown>)) {
20
- return ((val as Record<string, T>).desktop as T) ?? fallback;
21
- }
22
- return (val as T) ?? fallback;
23
- };
24
-
25
- const source =
26
- typeof block.value === 'object' && block.value !== null
27
- ? (block.value as Record<string, string>).en ||
28
- (block.value as Record<string, string>).tr ||
29
- Object.values(block.value as Record<string, string>)[0] ||
30
- ''
31
- : (block.value as string) || '';
32
-
33
- const fileUrl = resolveValue<string>(properties.file, '');
34
- const autoplay = resolveValue<boolean>(properties.autoplay, true);
35
- const loop = resolveValue<boolean>(properties.loop, true);
36
- const speed = resolveValue<number>(properties.speed, 1);
37
- const direction = resolveValue<string>(properties.direction, 'forward');
38
- const hoverPlay = resolveValue<boolean>(properties.hover, false);
39
- const mode = resolveValue<string>(properties.mode, 'normal');
40
-
41
- const animationUrl = source || fileUrl;
42
-
43
- // Fetch animation data from URL
44
- useEffect(() => {
45
- if (!animationUrl) {
46
- setAnimationData(null);
47
- setError(null);
48
- setLoading(false);
49
- return;
50
- }
51
-
52
- let cancelled = false;
53
-
54
- const fetchAnimation = async () => {
55
- try {
56
- setLoading(true);
57
- setError(null);
58
-
59
- const response = await fetch(animationUrl);
60
-
61
- if (!response.ok) {
62
- throw new Error(`HTTP ${response.status}: Failed to load animation`);
63
- }
64
-
65
- const contentType = response.headers.get('content-type');
66
- if (contentType && !contentType.includes('application/json')) {
67
- throw new Error('Invalid file type. Expected JSON format.');
68
- }
69
-
70
- const data = await response.json();
71
-
72
- // Basic validation for Lottie JSON structure
73
- if (!data || typeof data !== 'object' || !data.v || !data.layers) {
74
- throw new Error('Invalid Lottie JSON format');
75
- }
76
-
77
- if (!cancelled) {
78
- setAnimationData(data);
79
- setError(null);
80
- }
81
- } catch (err) {
82
- if (!cancelled) {
83
- console.error('Lottie fetch error:', err);
84
- setError(
85
- err instanceof Error
86
- ? err.message
87
- : 'Network error: Failed to load animation'
88
- );
89
- setAnimationData(null);
90
- }
91
- } finally {
92
- if (!cancelled) {
93
- setLoading(false);
94
- }
95
- }
96
- };
97
-
98
- fetchAnimation();
99
-
100
- return () => {
101
- cancelled = true;
102
- };
103
- }, [animationUrl]);
104
-
105
- // Initialize lottie-web animation
106
- useEffect(() => {
107
- if (!animationData || !containerRef.current) return;
108
-
109
- let lottie: typeof import('lottie-web').default | null = null;
110
- let anim: ReturnType<typeof import('lottie-web').default.loadAnimation> | null = null;
111
- let mounted = true;
112
-
113
- const initAnimation = async () => {
114
- try {
115
- const lottieModule = await import('lottie-web');
116
- lottie = lottieModule.default;
117
-
118
- if (!mounted || !containerRef.current) return;
119
-
120
- // Create a new container div for each animation
121
- const animContainer = document.createElement('div');
122
- animContainer.style.width = '100%';
123
- animContainer.style.height = '100%';
124
-
125
- // Clear and append new container
126
- if (containerRef.current) {
127
- containerRef.current.innerHTML = '';
128
- containerRef.current.appendChild(animContainer);
129
- }
130
-
131
- if (!mounted) return;
132
-
133
- anim = lottie.loadAnimation({
134
- container: animContainer,
135
- renderer: 'svg',
136
- loop: mode === 'bounce' ? false : loop,
137
- autoplay: hoverPlay ? false : autoplay,
138
- animationData: animationData
139
- });
140
-
141
- animationRef.current = anim;
142
-
143
- // Set speed
144
- if (anim && typeof anim.setSpeed === 'function') {
145
- anim.setSpeed(speed);
146
- }
147
-
148
- // Set direction
149
- if (anim && typeof anim.setDirection === 'function') {
150
- anim.setDirection(direction === 'reverse' ? -1 : 1);
151
- }
152
-
153
- // Bounce mode: reverse direction on complete
154
- if (mode === 'bounce' && loop && anim) {
155
- anim.addEventListener('complete', () => {
156
- if (anim && typeof anim.setDirection === 'function' && typeof anim.play === 'function') {
157
- anim.setDirection(anim.playDirection === 1 ? -1 : 1);
158
- anim.play();
159
- }
160
- });
161
- }
162
- } catch (err) {
163
- console.error('Lottie init error:', err);
164
- if (mounted) {
165
- setError('Failed to initialize animation player');
166
- }
167
- }
168
- };
169
-
170
- initAnimation();
171
-
172
- return () => {
173
- mounted = false;
174
-
175
- // Cleanup animation with delay to avoid removeChild errors
176
- const cleanup = () => {
177
- try {
178
- if (anim && typeof anim.destroy === 'function') {
179
- anim.destroy();
180
- }
181
- } catch (e) {
182
- // Silently ignore cleanup errors
183
- console.debug('Animation cleanup error (safe to ignore):', e);
184
- }
185
- animationRef.current = null;
186
- };
187
-
188
- // Delay cleanup slightly to avoid race conditions
189
- setTimeout(cleanup, 0);
190
- };
191
- }, [animationData, autoplay, loop, speed, direction, hoverPlay, mode]);
192
-
193
- // Hover handlers
194
- const handleMouseEnter = useCallback(() => {
195
- if (hoverPlay && animationRef.current) {
196
- try {
197
- (animationRef.current as { play: () => void }).play();
198
- } catch (e) {
199
- console.warn('Error playing animation:', e);
200
- }
201
- }
202
- }, [hoverPlay]);
203
-
204
- const handleMouseLeave = useCallback(() => {
205
- if (hoverPlay && animationRef.current) {
206
- try {
207
- (animationRef.current as { stop: () => void }).stop();
208
- } catch (e) {
209
- console.warn('Error stopping animation:', e);
210
- }
211
- }
212
- }, [hoverPlay]);
213
-
214
- // Placeholder when no animation URL
215
- if (!animationUrl) {
216
- return (
217
- <div
218
- style={{
219
- minHeight: '200px',
220
- display: 'flex',
221
- flexDirection: 'column',
222
- alignItems: 'center',
223
- justifyContent: 'center',
224
- backgroundColor: '#f5f3ff',
225
- color: '#666',
226
- fontSize: '14px',
227
- gap: '8px'
228
- }}
229
- >
230
- <svg
231
- xmlns="http://www.w3.org/2000/svg"
232
- width="32"
233
- height="32"
234
- viewBox="0 0 24 24"
235
- fill="none"
236
- stroke="currentColor"
237
- strokeWidth="1.5"
238
- strokeLinecap="round"
239
- strokeLinejoin="round"
240
- style={{ opacity: 0.4 }}
241
- >
242
- <circle cx="12" cy="12" r="10" />
243
- <polygon points="10 8 16 12 10 16 10 8" />
244
- </svg>
245
- <span>Add a Lottie animation URL or upload a file</span>
246
- </div>
247
- );
248
- }
249
-
250
- // Loading state
251
- if (loading) {
252
- return (
253
- <div
254
- style={{
255
- minHeight: '200px',
256
- display: 'flex',
257
- flexDirection: 'column',
258
- alignItems: 'center',
259
- justifyContent: 'center',
260
- backgroundColor: '#f5f3ff',
261
- color: '#666',
262
- fontSize: '14px',
263
- gap: '8px'
264
- }}
265
- >
266
- <div
267
- style={{
268
- width: '32px',
269
- height: '32px',
270
- border: '3px solid #e0e7ff',
271
- borderTopColor: '#8b5cf6',
272
- borderRadius: '50%',
273
- animation: 'spin 1s linear infinite'
274
- }}
275
- />
276
- <span>Loading animation...</span>
277
- <style>
278
- {`
279
- @keyframes spin {
280
- to { transform: rotate(360deg); }
281
- }
282
- `}
283
- </style>
284
- </div>
285
- );
286
- }
287
-
288
- // Error state
289
- if (error) {
290
- return (
291
- <div
292
- style={{
293
- minHeight: '200px',
294
- display: 'flex',
295
- flexDirection: 'column',
296
- alignItems: 'center',
297
- justifyContent: 'center',
298
- backgroundColor: '#fef2f2',
299
- color: '#dc2626',
300
- fontSize: '14px',
301
- gap: '8px'
302
- }}
303
- >
304
- <span>⚠ {error}</span>
305
- </div>
306
- );
307
- }
308
-
309
- return (
310
- <div
311
- ref={containerRef}
312
- onMouseEnter={handleMouseEnter}
313
- onMouseLeave={handleMouseLeave}
314
- style={{
315
- width: '100%',
316
- height: '100%',
317
- display: 'flex',
318
- alignItems: 'center',
319
- justifyContent: 'center'
320
- }}
321
- />
322
- );
323
- };
324
-
325
- export default LottieBlock;
@@ -1,89 +0,0 @@
1
- import React from 'react';
2
- import { getResponsiveValue } from '../utils';
3
- import { BlockRendererProps } from './block-renderer-registry';
4
-
5
- const placeholderContainerStyles: React.CSSProperties = {
6
- minHeight: '300px',
7
- display: 'flex',
8
- flexDirection: 'column',
9
- alignItems: 'center',
10
- justifyContent: 'center',
11
- backgroundColor: '#f0f0f0',
12
- color: '#666',
13
- fontSize: '14px',
14
- gap: '8px'
15
- };
16
-
17
- const getMapEmbedUrl = (
18
- address: string,
19
- properties?: {
20
- zoom?: number;
21
- mapType?: string;
22
- }
23
- ) => {
24
-
25
- const encodedAddress = encodeURIComponent(address);
26
- const zoom = properties?.zoom ?? 14;
27
- const mapType = properties?.mapType === 'satellite' ? 'k' : 'm';
28
-
29
- return `https://maps.google.com/maps?q=${encodedAddress}&z=${zoom}&t=${mapType}&output=embed`;
30
- };
31
-
32
- const MapBlock = ({ block, currentBreakpoint = 'desktop' }: BlockRendererProps) => {
33
- const address =
34
- typeof block.value === 'object' && block.value !== null
35
- ? (block.value as Record<string, string>).en ||
36
- (block.value as Record<string, string>).tr ||
37
- Object.values(block.value as Record<string, string>)[0] ||
38
- ''
39
- : (block.value as string) || '';
40
-
41
- const properties = block.properties || {};
42
-
43
- const zoom = getResponsiveValue(properties.zoom, currentBreakpoint, 14) as number;
44
-
45
- const mapType = getResponsiveValue(properties.mapType, currentBreakpoint, 'roadmap') as string;
46
-
47
- if (!address) {
48
- return (
49
- <div style={placeholderContainerStyles}>
50
- <svg
51
- xmlns="http://www.w3.org/2000/svg"
52
- width="32"
53
- height="32"
54
- viewBox="0 0 24 24"
55
- fill="none"
56
- stroke="currentColor"
57
- strokeWidth="1.5"
58
- strokeLinecap="round"
59
- strokeLinejoin="round"
60
- style={{ opacity: 0.4 }}
61
- >
62
- <path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z" />
63
- <circle cx="12" cy="10" r="3" />
64
- </svg>
65
- <span>Enter an address to display the map</span>
66
- </div>
67
- );
68
- }
69
-
70
- const embedUrl = getMapEmbedUrl(address, { zoom, mapType });
71
-
72
- return (
73
- <iframe
74
- src={embedUrl}
75
- style={{
76
- width: '100%',
77
- height: '100%',
78
- border: 'none',
79
- minHeight: '300px'
80
- }}
81
- loading="lazy"
82
- allowFullScreen
83
- referrerPolicy="no-referrer-when-downgrade"
84
- title="Google Maps"
85
- />
86
- );
87
- };
88
-
89
- export default MapBlock;