@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.
Files changed (189) hide show
  1. package/.eslintrc.js +12 -0
  2. package/CHANGELOG.md +377 -7
  3. package/__tests__/next-config.test.ts +83 -0
  4. package/__tests__/tsconfig.json +23 -0
  5. package/api/auth.ts +133 -44
  6. package/api/barcode-search.ts +59 -0
  7. package/api/cache.ts +41 -5
  8. package/api/client.ts +21 -4
  9. package/api/form.ts +85 -0
  10. package/api/image-proxy.ts +75 -0
  11. package/api/product-categories.ts +53 -0
  12. package/api/similar-product-list.ts +63 -0
  13. package/api/similar-products.ts +111 -0
  14. package/api/virtual-try-on.ts +382 -0
  15. package/assets/styles/index.scss +84 -0
  16. package/babel.config.js +6 -0
  17. package/bin/pz-generate-routes.js +115 -0
  18. package/bin/pz-prebuild.js +1 -0
  19. package/bin/pz-predev.js +1 -0
  20. package/bin/pz-run-tests.js +99 -0
  21. package/bin/run-prebuild-tests.js +46 -0
  22. package/components/accordion.tsx +20 -5
  23. package/components/button.tsx +51 -36
  24. package/components/client-root.tsx +138 -2
  25. package/components/file-input.tsx +65 -3
  26. package/components/index.ts +1 -0
  27. package/components/input.tsx +1 -1
  28. package/components/link.tsx +46 -16
  29. package/components/logger-popup.tsx +213 -0
  30. package/components/modal.tsx +32 -16
  31. package/components/plugin-module.tsx +62 -3
  32. package/components/price.tsx +2 -2
  33. package/components/select.tsx +1 -1
  34. package/components/selected-payment-option-view.tsx +21 -0
  35. package/components/theme-editor/blocks/accordion-block.tsx +136 -0
  36. package/components/theme-editor/blocks/block-renderer-registry.tsx +77 -0
  37. package/components/theme-editor/blocks/button-block.tsx +593 -0
  38. package/components/theme-editor/blocks/counter-block.tsx +348 -0
  39. package/components/theme-editor/blocks/divider-block.tsx +20 -0
  40. package/components/theme-editor/blocks/embed-block.tsx +208 -0
  41. package/components/theme-editor/blocks/group-block.tsx +116 -0
  42. package/components/theme-editor/blocks/hotspot-block.tsx +147 -0
  43. package/components/theme-editor/blocks/icon-block.tsx +230 -0
  44. package/components/theme-editor/blocks/image-block.tsx +137 -0
  45. package/components/theme-editor/blocks/image-gallery-block.tsx +269 -0
  46. package/components/theme-editor/blocks/input-block.tsx +123 -0
  47. package/components/theme-editor/blocks/link-block.tsx +216 -0
  48. package/components/theme-editor/blocks/lottie-block.tsx +325 -0
  49. package/components/theme-editor/blocks/map-block.tsx +89 -0
  50. package/components/theme-editor/blocks/slider-block.tsx +595 -0
  51. package/components/theme-editor/blocks/tab-block.tsx +10 -0
  52. package/components/theme-editor/blocks/text-block.tsx +52 -0
  53. package/components/theme-editor/blocks/video-block.tsx +122 -0
  54. package/components/theme-editor/components/action-toolbar.tsx +305 -0
  55. package/components/theme-editor/components/designer-overlay.tsx +74 -0
  56. package/components/theme-editor/components/with-designer-features.tsx +142 -0
  57. package/components/theme-editor/dynamic-font-loader.tsx +79 -0
  58. package/components/theme-editor/hooks/use-designer-features.tsx +100 -0
  59. package/components/theme-editor/hooks/use-external-designer.tsx +95 -0
  60. package/components/theme-editor/hooks/use-native-widget-data.ts +188 -0
  61. package/components/theme-editor/hooks/use-visibility-context.ts +27 -0
  62. package/components/theme-editor/placeholder-registry.ts +31 -0
  63. package/components/theme-editor/sections/before-after-section.tsx +245 -0
  64. package/components/theme-editor/sections/contact-form-section.tsx +563 -0
  65. package/components/theme-editor/sections/countdown-campaign-banner-section.tsx +433 -0
  66. package/components/theme-editor/sections/coupon-banner-section.tsx +710 -0
  67. package/components/theme-editor/sections/divider-section.tsx +62 -0
  68. package/components/theme-editor/sections/featured-product-spotlight-section.tsx +507 -0
  69. package/components/theme-editor/sections/find-in-store-section.tsx +1995 -0
  70. package/components/theme-editor/sections/hover-showcase-section.tsx +326 -0
  71. package/components/theme-editor/sections/image-hotspot-section.tsx +142 -0
  72. package/components/theme-editor/sections/installment-options-section.tsx +1065 -0
  73. package/components/theme-editor/sections/notification-banner-section.tsx +173 -0
  74. package/components/theme-editor/sections/order-tracking-lookup-section.tsx +1379 -0
  75. package/components/theme-editor/sections/posts-slider-section.tsx +472 -0
  76. package/components/theme-editor/sections/pre-order-launch-banner-section.tsx +663 -0
  77. package/components/theme-editor/sections/section-renderer-registry.tsx +89 -0
  78. package/components/theme-editor/sections/section-wrapper.tsx +135 -0
  79. package/components/theme-editor/sections/shipping-threshold-progress-section.tsx +586 -0
  80. package/components/theme-editor/sections/stats-counter-section.tsx +486 -0
  81. package/components/theme-editor/sections/tabs-section.tsx +578 -0
  82. package/components/theme-editor/theme-block.tsx +102 -0
  83. package/components/theme-editor/theme-placeholder-client.tsx +218 -0
  84. package/components/theme-editor/theme-placeholder-wrapper.tsx +732 -0
  85. package/components/theme-editor/theme-placeholder.tsx +288 -0
  86. package/components/theme-editor/theme-section.tsx +1224 -0
  87. package/components/theme-editor/theme-settings-context.tsx +13 -0
  88. package/components/theme-editor/utils/index.ts +792 -0
  89. package/components/theme-editor/utils/iterator-utils.ts +234 -0
  90. package/components/theme-editor/utils/publish-window.ts +86 -0
  91. package/components/theme-editor/utils/visibility-rules.ts +188 -0
  92. package/data/client/account.ts +17 -2
  93. package/data/client/api.ts +2 -0
  94. package/data/client/basket.ts +66 -5
  95. package/data/client/checkout.ts +391 -99
  96. package/data/client/misc.ts +38 -2
  97. package/data/client/product.ts +19 -2
  98. package/data/client/user.ts +16 -8
  99. package/data/server/category.ts +11 -9
  100. package/data/server/flatpage.ts +11 -4
  101. package/data/server/form.ts +15 -4
  102. package/data/server/landingpage.ts +11 -4
  103. package/data/server/list.ts +5 -4
  104. package/data/server/menu.ts +11 -3
  105. package/data/server/product.ts +111 -55
  106. package/data/server/seo.ts +14 -4
  107. package/data/server/special-page.ts +5 -4
  108. package/data/server/widget.ts +90 -5
  109. package/data/urls.ts +16 -5
  110. package/hocs/client/with-segment-defaults.tsx +2 -2
  111. package/hocs/server/with-segment-defaults.tsx +65 -20
  112. package/hooks/index.ts +4 -0
  113. package/hooks/use-localization.ts +24 -10
  114. package/hooks/use-logger-context.tsx +114 -0
  115. package/hooks/use-logger.ts +92 -0
  116. package/hooks/use-loyalty-availability.ts +21 -0
  117. package/hooks/use-payment-options.ts +2 -1
  118. package/hooks/use-pz-params.ts +37 -0
  119. package/hooks/use-router.ts +51 -14
  120. package/hooks/use-sentry-uncaught-errors.ts +24 -0
  121. package/instrumentation/index.ts +10 -1
  122. package/instrumentation/node.ts +2 -20
  123. package/jest.config.js +25 -0
  124. package/lib/cache-handler.mjs +534 -16
  125. package/lib/cache.ts +272 -37
  126. package/localization/index.ts +2 -1
  127. package/localization/provider.tsx +2 -5
  128. package/middlewares/bfcache-headers.ts +18 -0
  129. package/middlewares/checkout-provider.ts +1 -1
  130. package/middlewares/complete-gpay.ts +32 -26
  131. package/middlewares/complete-masterpass.ts +33 -26
  132. package/middlewares/complete-wallet.ts +182 -0
  133. package/middlewares/default.ts +360 -215
  134. package/middlewares/index.ts +10 -2
  135. package/middlewares/locale.ts +34 -11
  136. package/middlewares/masterpass-rest-callback.ts +230 -0
  137. package/middlewares/oauth-login.ts +200 -57
  138. package/middlewares/pretty-url.ts +21 -8
  139. package/middlewares/redirection-payment.ts +32 -26
  140. package/middlewares/saved-card-redirection.ts +33 -26
  141. package/middlewares/three-d-redirection.ts +32 -26
  142. package/middlewares/url-redirection.ts +11 -1
  143. package/middlewares/wallet-complete-redirection.ts +206 -0
  144. package/package.json +25 -10
  145. package/plugins.d.ts +19 -4
  146. package/plugins.js +10 -1
  147. package/redux/actions.ts +47 -0
  148. package/redux/middlewares/checkout.ts +63 -138
  149. package/redux/middlewares/index.ts +14 -10
  150. package/redux/middlewares/pre-order/address.ts +7 -2
  151. package/redux/middlewares/pre-order/attribute-based-shipping-option.ts +7 -1
  152. package/redux/middlewares/pre-order/data-source-shipping-option.ts +7 -1
  153. package/redux/middlewares/pre-order/delivery-option.ts +7 -1
  154. package/redux/middlewares/pre-order/index.ts +16 -10
  155. package/redux/middlewares/pre-order/installment-option.ts +8 -1
  156. package/redux/middlewares/pre-order/payment-option-reset.ts +37 -0
  157. package/redux/middlewares/pre-order/payment-option.ts +7 -1
  158. package/redux/middlewares/pre-order/pre-order-validation.ts +8 -3
  159. package/redux/middlewares/pre-order/redirection.ts +8 -2
  160. package/redux/middlewares/pre-order/set-pre-order.ts +6 -2
  161. package/redux/middlewares/pre-order/shipping-option.ts +7 -1
  162. package/redux/middlewares/pre-order/shipping-step.ts +5 -1
  163. package/redux/reducers/checkout.ts +23 -3
  164. package/redux/reducers/index.ts +11 -3
  165. package/redux/reducers/root.ts +7 -2
  166. package/redux/reducers/widget.ts +80 -0
  167. package/sentry/index.ts +69 -13
  168. package/tailwind/content.js +16 -0
  169. package/types/commerce/account.ts +5 -1
  170. package/types/commerce/checkout.ts +35 -1
  171. package/types/commerce/widget.ts +33 -0
  172. package/types/index.ts +101 -6
  173. package/types/next-auth.d.ts +2 -2
  174. package/types/widget.ts +80 -0
  175. package/utils/app-fetch.ts +7 -2
  176. package/utils/generate-commerce-search-params.ts +3 -2
  177. package/utils/get-checkout-path.ts +3 -0
  178. package/utils/get-root-hostname.ts +28 -0
  179. package/utils/index.ts +64 -10
  180. package/utils/localization.ts +4 -0
  181. package/utils/mobile-3d-iframe.ts +8 -2
  182. package/utils/override-middleware.ts +7 -12
  183. package/utils/pz-segments.ts +92 -0
  184. package/utils/redirect-ignore.ts +35 -0
  185. package/utils/redirect.ts +9 -3
  186. package/utils/redirection-iframe.ts +8 -2
  187. package/utils/widget-styles.ts +107 -0
  188. package/views/error-page.tsx +93 -0
  189. package/with-pz-config.js +13 -6
@@ -0,0 +1,173 @@
1
+ 'use client';
2
+
3
+ import React, { useState } from 'react';
4
+ import { getResponsiveValue, resolveThemeCssVariables } from '../utils';
5
+ import { Section } from '../theme-section';
6
+ import { useThemeSettingsContext } from '../theme-settings-context';
7
+ import { twMerge } from 'tailwind-merge';
8
+ import clsx from 'clsx';
9
+ import ThemeBlock from '../theme-block';
10
+
11
+ interface NotificationBannerSectionProps {
12
+ section: Section;
13
+ currentBreakpoint?: string;
14
+ isDesigner?: boolean;
15
+ placeholderId?: string;
16
+ selectedBlockId?: string | null;
17
+ }
18
+
19
+ export default function NotificationBannerSection({
20
+ section,
21
+ currentBreakpoint = 'desktop',
22
+ isDesigner = false,
23
+ placeholderId = '',
24
+ selectedBlockId = null
25
+ }: NotificationBannerSectionProps) {
26
+ const themeSettings = useThemeSettingsContext();
27
+ const [isDismissed, setIsDismissed] = useState(false);
28
+
29
+ const styles = section.styles || {};
30
+ const properties = section.properties || {};
31
+
32
+ const gradientStart = resolveThemeCssVariables(
33
+ getResponsiveValue(styles['background-gradient-start'], currentBreakpoint, '#a8e063') as string,
34
+ themeSettings
35
+ );
36
+ const gradientEnd = resolveThemeCssVariables(
37
+ getResponsiveValue(styles['background-gradient-end'], currentBreakpoint, '#d4fc79') as string,
38
+ themeSettings
39
+ );
40
+ const borderRadius = getResponsiveValue(styles['border-radius'], currentBreakpoint, '16px') as string;
41
+ const paddingTop = getResponsiveValue(styles['padding-top'], currentBreakpoint, 20);
42
+ const paddingRight = getResponsiveValue(styles['padding-right'], currentBreakpoint, 24);
43
+ const paddingBottom = getResponsiveValue(styles['padding-bottom'], currentBreakpoint, 20);
44
+ const paddingLeft = getResponsiveValue(styles['padding-left'], currentBreakpoint, 24);
45
+ const gap = getResponsiveValue(styles.gap, currentBreakpoint, 16);
46
+ const maxWidth = getResponsiveValue(styles['max-width'], currentBreakpoint, 'normal') as string;
47
+ const closeButtonColor = resolveThemeCssVariables(
48
+ getResponsiveValue(styles['close-button-color'], currentBreakpoint, '#33691e') as string,
49
+ themeSettings
50
+ );
51
+ const iconBgColor = resolveThemeCssVariables(
52
+ getResponsiveValue(styles['icon-background-color'], currentBreakpoint, '#ffffff40') as string,
53
+ themeSettings
54
+ );
55
+
56
+ const dismissible = getResponsiveValue(properties.dismissible, currentBreakpoint, true);
57
+
58
+ const maxWidthClass =
59
+ maxWidth === 'narrow'
60
+ ? 'max-w-4xl'
61
+ : maxWidth === 'normal'
62
+ ? 'max-w-7xl'
63
+ : maxWidth === 'full'
64
+ ? 'w-full'
65
+ : '';
66
+
67
+ const hasMaxWidth = maxWidth !== 'none' && maxWidth !== 'full';
68
+
69
+ const renderBlock = (block: any) => {
70
+ return (
71
+ <ThemeBlock
72
+ key={block.id}
73
+ block={block}
74
+ placeholderId={placeholderId}
75
+ sectionId={section.id}
76
+ isDesigner={isDesigner}
77
+ isSelected={selectedBlockId === block.id}
78
+ selectedBlockId={selectedBlockId}
79
+ currentBreakpoint={currentBreakpoint}
80
+ onMoveUp={() => {
81
+ if (window.parent) window.parent.postMessage({ type: 'MOVE_BLOCK_UP', data: { placeholderId, sectionId: section.id, blockId: block.id } }, '*');
82
+ }}
83
+ onMoveDown={() => {
84
+ if (window.parent) window.parent.postMessage({ type: 'MOVE_BLOCK_DOWN', data: { placeholderId, sectionId: section.id, blockId: block.id } }, '*');
85
+ }}
86
+ onDuplicate={() => {
87
+ if (window.parent) window.parent.postMessage({ type: 'DUPLICATE_BLOCK', data: { placeholderId, sectionId: section.id, blockId: block.id } }, '*');
88
+ }}
89
+ onToggleVisibility={() => {
90
+ if (window.parent) window.parent.postMessage({ type: 'TOGGLE_BLOCK_VISIBILITY', data: { placeholderId, sectionId: section.id, blockId: block.id } }, '*');
91
+ }}
92
+ onDelete={() => {
93
+ if (window.parent) window.parent.postMessage({ type: 'DELETE_BLOCK', data: { placeholderId, sectionId: section.id, blockId: block.id } }, '*');
94
+ }}
95
+ onRename={(newLabel) => {
96
+ if (window.parent) window.parent.postMessage({ type: 'RENAME_BLOCK', data: { placeholderId, sectionId: section.id, blockId: block.id, label: newLabel } }, '*');
97
+ }}
98
+ />
99
+ );
100
+ };
101
+
102
+ if (isDismissed && !isDesigner) {
103
+ return null;
104
+ }
105
+
106
+ const iconBlock = section.blocks?.find(b => b.type === 'icon');
107
+ const contentBlocks = section.blocks?.filter(b => b.type !== 'icon') || [];
108
+
109
+ return (
110
+ <div
111
+ className={twMerge(
112
+ clsx(
113
+ 'relative flex items-center transition-all duration-300',
114
+ hasMaxWidth && 'mx-auto',
115
+ maxWidthClass,
116
+ isDismissed && isDesigner && 'opacity-50'
117
+ )
118
+ )}
119
+ style={{
120
+ background: `linear-gradient(135deg, ${gradientStart} 0%, ${gradientEnd} 100%)`,
121
+ borderRadius,
122
+ paddingTop: typeof paddingTop === 'number' ? `${paddingTop}px` : paddingTop as string,
123
+ paddingRight: typeof paddingRight === 'number' ? `${paddingRight}px` : paddingRight as string,
124
+ paddingBottom: typeof paddingBottom === 'number' ? `${paddingBottom}px` : paddingBottom as string,
125
+ paddingLeft: typeof paddingLeft === 'number' ? `${paddingLeft}px` : paddingLeft as string,
126
+ gap: typeof gap === 'number' ? `${gap}px` : gap as string
127
+ }}
128
+ >
129
+ {iconBlock && (
130
+ <div
131
+ className="shrink-0 rounded-xl flex items-center justify-center"
132
+ style={{
133
+ backgroundColor: iconBgColor,
134
+ width: '56px',
135
+ height: '56px'
136
+ }}
137
+ >
138
+ {renderBlock(iconBlock)}
139
+ </div>
140
+ )}
141
+
142
+ <div className="flex-1 min-w-0">
143
+ {contentBlocks.map(block => renderBlock(block))}
144
+ </div>
145
+
146
+ {Boolean(dismissible) && (
147
+ <button
148
+ onClick={() => setIsDismissed(true)}
149
+ className={clsx(
150
+ 'shrink-0 flex items-center justify-center rounded-full transition-colors duration-200',
151
+ 'hover:bg-white/30 w-8 h-8'
152
+ )}
153
+ style={{ color: closeButtonColor }}
154
+ aria-label="Dismiss notification"
155
+ >
156
+ <svg
157
+ width="18"
158
+ height="18"
159
+ viewBox="0 0 24 24"
160
+ fill="none"
161
+ stroke="currentColor"
162
+ strokeWidth="2"
163
+ strokeLinecap="round"
164
+ strokeLinejoin="round"
165
+ >
166
+ <path d="M18 6L6 18" />
167
+ <path d="M6 6l12 12" />
168
+ </svg>
169
+ </button>
170
+ )}
171
+ </div>
172
+ );
173
+ }