@akinon/projectzero 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 (138) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/app-template/CHANGELOG.md +138 -0
  3. package/app-template/next.config.mjs +0 -1
  4. package/app-template/package.json +31 -30
  5. package/app-template/src/app/[pz]/[...prettyurl]/page.tsx +2 -2
  6. package/app-template/src/app/[pz]/account/layout.tsx +2 -1
  7. package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/blog/[slug]/page.tsx +4 -2
  8. package/app-template/src/app/[pz]/category/[pk]/page.tsx +11 -1
  9. package/app-template/src/app/[pz]/group-product/[pk]/page.tsx +2 -2
  10. package/app-template/src/app/[pz]/layout.tsx +3 -1
  11. package/app-template/src/app/[pz]/list/page.tsx +11 -1
  12. package/app-template/src/app/[pz]/page.tsx +13 -35
  13. package/app-template/src/app/[pz]/pages/[slug]/page.tsx +19 -0
  14. package/app-template/src/app/[pz]/product/[pk]/page.tsx +2 -2
  15. package/app-template/src/app/api/barcode-search/route.ts +1 -1
  16. package/app-template/src/app/api/cache/route.ts +1 -1
  17. package/app-template/src/app/api/image-proxy/route.ts +1 -1
  18. package/app-template/src/app/api/logout/route.ts +1 -1
  19. package/app-template/src/app/api/product-categories/route.ts +1 -1
  20. package/app-template/src/app/api/similar-product-list/route.ts +1 -1
  21. package/app-template/src/app/api/similar-products/route.ts +1 -1
  22. package/app-template/src/app/api/virtual-try-on/route.ts +1 -1
  23. package/app-template/src/app/api/web-vitals/route.ts +1 -1
  24. package/app-template/src/components/quantity-selector.tsx +16 -4
  25. package/app-template/src/components/widget-content.tsx +3 -3
  26. package/app-template/src/routes/index.ts +6 -6
  27. package/app-template/src/utils/__tests__/theme-page-context.test.ts +145 -0
  28. package/app-template/src/utils/theme-page-context.ts +309 -0
  29. package/app-template/src/views/basket/basket-item.tsx +107 -691
  30. package/app-template/src/views/basket/index.ts +0 -2
  31. package/app-template/src/views/basket/summary.tsx +75 -496
  32. package/app-template/src/views/breadcrumb.tsx +38 -13
  33. package/app-template/src/views/category/category-header.tsx +66 -289
  34. package/app-template/src/views/category/category-info.tsx +24 -173
  35. package/app-template/src/views/category/filters/index.tsx +48 -208
  36. package/app-template/src/views/category/layout.tsx +5 -7
  37. package/app-template/src/views/checkout/index.tsx +0 -5
  38. package/app-template/src/views/checkout/steps/payment/index.tsx +2 -5
  39. package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +1 -72
  40. package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +40 -171
  41. package/app-template/src/views/checkout/steps/shipping/address-box.tsx +12 -74
  42. package/app-template/src/views/checkout/steps/shipping/addresses.tsx +45 -128
  43. package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +27 -232
  44. package/app-template/src/views/checkout/summary.tsx +29 -303
  45. package/app-template/src/views/footer.tsx +13 -415
  46. package/app-template/src/views/guest-login/index.tsx +1 -1
  47. package/app-template/src/views/header/action-menu.tsx +45 -277
  48. package/app-template/src/views/header/band.tsx +21 -6
  49. package/app-template/src/views/header/index.tsx +47 -109
  50. package/app-template/src/views/header/mini-basket.tsx +45 -820
  51. package/app-template/src/views/header/navbar.tsx +111 -178
  52. package/app-template/src/views/header/search/index.tsx +32 -71
  53. package/app-template/src/views/header/search/results.tsx +65 -127
  54. package/app-template/src/views/product/accordion-wrapper.tsx +43 -135
  55. package/app-template/src/views/product/index.ts +1 -1
  56. package/app-template/src/views/product/layout.tsx +7 -2
  57. package/app-template/src/views/product/misc-buttons.tsx +25 -339
  58. package/app-template/src/views/product/product-actions.tsx +8 -137
  59. package/app-template/src/views/product/product-info.tsx +31 -69
  60. package/app-template/src/views/product/product-share.tsx +8 -11
  61. package/app-template/src/views/product/slider.tsx +79 -117
  62. package/app-template/src/views/product-item/index.tsx +46 -119
  63. package/app-template/src/widgets/footer-social.tsx +16 -47
  64. package/app-template/src/widgets/footer-subscription/index.tsx +17 -183
  65. package/dist/commands/plugins.js +23 -2
  66. package/package.json +1 -1
  67. package/app-template/src/app/[commerce]/[locale]/[currency]/pages/[slug]/page.tsx +0 -15
  68. package/app-template/src/views/basket/basket-summary-context.tsx +0 -560
  69. package/app-template/src/views/basket/designer-context.tsx +0 -617
  70. package/app-template/src/views/breadcrumb/breadcrumb-client.tsx +0 -190
  71. package/app-template/src/views/breadcrumb/breadcrumb-registrar.tsx +0 -286
  72. package/app-template/src/views/breadcrumb/constants.ts +0 -15
  73. package/app-template/src/views/breadcrumb/index.tsx +0 -127
  74. package/app-template/src/views/category/native-widget-context.tsx +0 -257
  75. package/app-template/src/views/category/product-list-registrar.tsx +0 -665
  76. package/app-template/src/views/checkout/checkout-address-registrar.tsx +0 -254
  77. package/app-template/src/views/checkout/checkout-buttons-registrar.tsx +0 -183
  78. package/app-template/src/views/checkout/checkout-delivery-method-registrar.tsx +0 -259
  79. package/app-template/src/views/checkout/checkout-payment-options-registrar.tsx +0 -253
  80. package/app-template/src/views/checkout/checkout-summary-registrar.tsx +0 -183
  81. package/app-template/src/views/checkout/constants.ts +0 -5
  82. package/app-template/src/views/checkout/steps/payment/options/masterpass-rest.tsx +0 -15
  83. package/app-template/src/views/checkout/steps/payment/options/saved-card.tsx +0 -18
  84. package/app-template/src/views/footer/footer-app-banner-context.tsx +0 -326
  85. package/app-template/src/views/footer/footer-bottom-context.tsx +0 -215
  86. package/app-template/src/views/footer/footer-bottom-wrapper.tsx +0 -74
  87. package/app-template/src/views/footer/footer-layout-constants.ts +0 -35
  88. package/app-template/src/views/footer/footer-layout-registrar.tsx +0 -342
  89. package/app-template/src/views/footer/footer-layout-switcher.tsx +0 -110
  90. package/app-template/src/views/footer/footer-menu-context.tsx +0 -211
  91. package/app-template/src/views/footer/footer-native-widgets.tsx +0 -60
  92. package/app-template/src/views/footer/footer-social-context.tsx +0 -254
  93. package/app-template/src/views/footer/footer-subscription-context.tsx +0 -210
  94. package/app-template/src/views/footer/footer-utils.ts +0 -43
  95. package/app-template/src/views/footer/footer-value-props-context.tsx +0 -326
  96. package/app-template/src/views/footer/logo-settings.ts +0 -183
  97. package/app-template/src/views/footer/native-widget-config.ts +0 -262
  98. package/app-template/src/views/footer/subscription-settings.ts +0 -122
  99. package/app-template/src/views/footer/use-footer-logo.ts +0 -162
  100. package/app-template/src/views/header/designer-context.tsx +0 -261
  101. package/app-template/src/views/header/header-announcement-registrar.tsx +0 -267
  102. package/app-template/src/views/header/header-client-wrapper.tsx +0 -496
  103. package/app-template/src/views/header/header-content.tsx +0 -1026
  104. package/app-template/src/views/header/header-currency-registrar.tsx +0 -348
  105. package/app-template/src/views/header/header-icons-context.tsx +0 -262
  106. package/app-template/src/views/header/header-language-registrar.tsx +0 -348
  107. package/app-template/src/views/header/header-layout-context.tsx +0 -143
  108. package/app-template/src/views/header/header-layout-registrar.tsx +0 -658
  109. package/app-template/src/views/header/header-logo-context.tsx +0 -228
  110. package/app-template/src/views/header/header-logo.tsx +0 -118
  111. package/app-template/src/views/header/header-mini-basket-context.tsx +0 -524
  112. package/app-template/src/views/header/header-search-registrar.tsx +0 -511
  113. package/app-template/src/views/header/header-text-slider-registrar.tsx +0 -382
  114. package/app-template/src/views/header/inline-search.tsx +0 -262
  115. package/app-template/src/views/header/navbar-menu-context.tsx +0 -219
  116. package/app-template/src/views/header/search/search-input.tsx +0 -61
  117. package/app-template/src/views/header/server-settings-parser.ts +0 -1105
  118. package/app-template/src/views/header/use-header-icons.ts +0 -241
  119. package/app-template/src/views/header/use-header-logo.ts +0 -213
  120. package/app-template/src/views/header/use-navbar-menu.ts +0 -179
  121. package/app-template/src/views/product/accordion-section.tsx +0 -61
  122. package/app-template/src/views/product/custom-button-group.tsx +0 -69
  123. package/app-template/src/views/product/favorites-button-section.tsx +0 -69
  124. package/app-template/src/views/product/find-in-store-section.tsx +0 -60
  125. package/app-template/src/views/product/product-info-section.tsx +0 -140
  126. package/app-template/src/views/product/quantity-section.tsx +0 -73
  127. package/app-template/src/views/product/sale-tag.tsx +0 -10
  128. package/app-template/src/views/product/share-section.tsx +0 -357
  129. package/app-template/src/views/product/variants-section.tsx +0 -126
  130. package/app-template/src/views/product-detail/constants.ts +0 -272
  131. package/app-template/src/views/product-detail/index.ts +0 -10
  132. package/app-template/src/views/product-detail/product-detail-registrar.tsx +0 -616
  133. package/app-template/src/widgets/footer-app-banner.tsx +0 -444
  134. package/app-template/src/widgets/footer-bottom.tsx +0 -127
  135. package/app-template/src/widgets/footer-menu-compact.tsx +0 -238
  136. package/app-template/src/widgets/footer-menu-two.tsx +0 -298
  137. package/app-template/src/widgets/footer-social-client.tsx +0 -251
  138. package/app-template/src/widgets/footer-value-props.tsx +0 -201
@@ -1,11 +1,7 @@
1
1
  import 'server-only';
2
2
 
3
+ import { Link, Icon } from '@theme/components';
3
4
  import { getWidgetData } from '@akinon/next/data/server';
4
- import FooterSocialClient from './footer-social-client';
5
-
6
- type ThemeConfig = {
7
- theme_settings: string | object;
8
- };
9
5
 
10
6
  type TargetBlank = {
11
7
  value: string;
@@ -35,50 +31,23 @@ type FooterSocialType = {
35
31
  };
36
32
 
37
33
  export default async function FooterSocial() {
38
- const themeConfig = await getWidgetData<ThemeConfig>({
39
- slug: 'theme-config'
40
- });
41
-
42
- let socialNetworks = {};
43
- try {
44
- if (themeConfig?.attributes?.theme_settings) {
45
- const settingsRaw = themeConfig.attributes.theme_settings;
46
- let settings;
47
-
48
- if (typeof settingsRaw === 'string') {
49
- settings = JSON.parse(settingsRaw);
50
- } else if (
51
- typeof settingsRaw === 'object' &&
52
- settingsRaw !== null &&
53
- 'value' in settingsRaw
54
- ) {
55
- const value = (settingsRaw as any).value;
56
- settings = typeof value === 'string' ? JSON.parse(value) : value;
57
- } else {
58
- settings = settingsRaw;
59
- }
60
-
61
- socialNetworks = settings.socialNetworks || {};
62
- }
63
- } catch (e) {
64
- console.error('Error parsing theme settings:', e);
65
- }
66
-
67
- const activeNetworks = Object.entries(socialNetworks)
68
- .filter(([_, value]: [string, any]) => value.icon)
69
- .map(([key, value]: [string, any]) => ({
70
- key,
71
- url: value.url || '#',
72
- icon: value.icon
73
- }));
74
-
75
34
  const data = await getWidgetData<FooterSocialType>({ slug: 'footer-social' });
76
- const socialItems = data?.attributes?.social_items || [];
77
35
 
78
36
  return (
79
- <FooterSocialClient
80
- activeNetworks={activeNetworks}
81
- socialItems={socialItems}
82
- />
37
+ <div className="flex flex-wrap items-center justify-around py-4 border-t border-gray md:justify-center">
38
+ {data?.attributes?.social_items?.map((item, i) => (
39
+ <Link
40
+ key={i}
41
+ href={item?.value?.redirect_url}
42
+ className="p-2 border rounded-full border-gray md:mr-1 md:last:mr-0"
43
+ target={item?.value?.is_target_blank === 'true' ? '_blank' : '_self'}
44
+ >
45
+ <Icon
46
+ size={18}
47
+ name={item?.value?.icon_class?.replace('pz-icon-', '')}
48
+ />
49
+ </Link>
50
+ ))}
51
+ </div>
83
52
  );
84
53
  }
@@ -1,196 +1,30 @@
1
- 'use client';
1
+ import 'server-only';
2
2
 
3
- import type { CSSProperties } from 'react';
4
- import clsx from 'clsx';
5
- import { useDesignerFeatures } from '@akinon/next/components/theme-editor/hooks/use-designer-features';
3
+ import { getWidgetData } from '@akinon/next/data/server';
6
4
 
7
5
  import FooterSubscriptionForm from './footer-subscription-form';
8
- import {
9
- FOOTER_PLACEHOLDER_ID,
10
- FOOTER_SUBSCRIPTION_SECTION_ID
11
- } from '../../views/footer/native-widget-config';
12
- import {
13
- FOOTER_SUBSCRIPTION_BLOCKS,
14
- FOOTER_SUBSCRIPTION_DEFAULT_CONTENT
15
- } from '../../views/footer/subscription-settings';
16
- import { useFooterSubscriptionDesigner } from '../../views/footer/footer-subscription-context';
17
6
 
18
- type FooterSubscriptionProps = {
19
- title?: string;
20
- description?: string;
21
- };
22
-
23
- type FooterSubscriptionBlockConfig =
24
- typeof FOOTER_SUBSCRIPTION_BLOCKS[keyof typeof FOOTER_SUBSCRIPTION_BLOCKS];
25
-
26
- const extractTextValue = (value: unknown): string | undefined => {
27
- if (value == null) {
28
- return undefined;
29
- }
30
-
31
- if (typeof value === 'string' || typeof value === 'number') {
32
- return String(value);
33
- }
34
-
35
- if (typeof value === 'object') {
36
- const record = value as Record<string, unknown>;
37
- const candidateKeys = [
38
- 'content',
39
- 'value',
40
- 'text',
41
- 'label',
42
- 'default',
43
- 'desktop',
44
- 'mobile',
45
- 'tablet'
46
- ];
47
-
48
- for (const key of candidateKeys) {
49
- const candidate = record[key];
50
- if (typeof candidate === 'string' && candidate.trim().length > 0) {
51
- return candidate;
52
- }
53
- }
54
-
55
- for (const objValue of Object.values(record)) {
56
- if (typeof objValue === 'string' && objValue.trim().length > 0) {
57
- return objValue;
58
- }
59
- }
60
- }
61
-
62
- return undefined;
63
- };
64
-
65
- const kebabToCamel = (str: string): string =>
66
- str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
67
-
68
- const normalizeStyles = (
69
- styles: Record<string, unknown> | undefined
70
- ): CSSProperties => {
71
- if (!styles) return {};
72
-
73
- const result: Record<string, string | number> = {};
74
-
75
- for (const [key, value] of Object.entries(styles)) {
76
- if (value == null) continue;
77
-
78
- const camelKey = kebabToCamel(key);
79
- let resolved: unknown = value;
80
-
81
- if (typeof value === 'object' && !Array.isArray(value)) {
82
- const responsive = value as Record<string, unknown>;
83
- resolved = responsive.desktop ?? responsive.mobile ?? responsive.tablet;
84
- }
85
-
86
- if (resolved != null) {
87
- if (typeof resolved === 'number') {
88
- result[camelKey] = resolved;
89
- } else if (typeof resolved === 'string') {
90
- result[camelKey] = resolved;
91
- }
92
- }
93
- }
94
-
95
- return result as CSSProperties;
7
+ type FooterSubscriptionType = {
8
+ description: {
9
+ value: string;
10
+ };
11
+ title: {
12
+ value: string;
13
+ };
96
14
  };
97
15
 
98
- function useSubscriptionBlock(blockConfig: FooterSubscriptionBlockConfig) {
99
- const { isDesigner, selectedBlockId, getBlock, blockVersion } =
100
- useFooterSubscriptionDesigner();
101
- const blockState = blockVersion >= 0 ? getBlock(blockConfig.id) : undefined;
102
- const styles = normalizeStyles(blockState?.styles as Record<string, unknown>);
103
- const { handleClick } = useDesignerFeatures({
104
- blockId: blockConfig.id,
105
- placeholderId: FOOTER_PLACEHOLDER_ID,
106
- sectionId: FOOTER_SUBSCRIPTION_SECTION_ID,
107
- isDesigner,
108
- blockInfo: {
109
- id: blockConfig.id,
110
- type: blockConfig.type,
111
- label: blockConfig.label
112
- }
16
+ export default async function FooterSubscription() {
17
+ const data = await getWidgetData<FooterSubscriptionType>({
18
+ slug: 'footer-subscription'
113
19
  });
114
20
 
115
- return {
116
- styles,
117
- isDesigner,
118
- isSelected: selectedBlockId === blockConfig.id,
119
- onClick: isDesigner ? handleClick : undefined,
120
- content: extractTextValue(blockState?.value)
121
- };
122
- }
123
-
124
- export default function FooterSubscription({
125
- title,
126
- description
127
- }: FooterSubscriptionProps) {
128
- const titleBlock = useSubscriptionBlock(FOOTER_SUBSCRIPTION_BLOCKS.TITLE);
129
- const descriptionBlock = useSubscriptionBlock(
130
- FOOTER_SUBSCRIPTION_BLOCKS.DESCRIPTION
131
- );
132
- const formBlock = useSubscriptionBlock(FOOTER_SUBSCRIPTION_BLOCKS.FORM);
133
- const displayTitle =
134
- titleBlock.content || title || FOOTER_SUBSCRIPTION_DEFAULT_CONTENT.title;
135
- const displayDescription =
136
- descriptionBlock.content ||
137
- description ||
138
- FOOTER_SUBSCRIPTION_DEFAULT_CONTENT.description;
139
- const shouldRenderDescription =
140
- descriptionBlock.isDesigner || Boolean(displayDescription);
141
-
142
21
  return (
143
- <div className="w-full max-w-[331px]">
144
- <h3
145
- style={titleBlock.styles}
146
- data-block-id={
147
- titleBlock.isDesigner
148
- ? FOOTER_SUBSCRIPTION_BLOCKS.TITLE.id
149
- : undefined
150
- }
151
- onClick={titleBlock.onClick}
152
- className={clsx(
153
- 'mb-4 text-lg text-[#121212]',
154
- titleBlock.isDesigner && 'cursor-pointer',
155
- titleBlock.isSelected && 'ring-2 ring-blue-500 ring-offset-2 rounded'
156
- )}
157
- >
158
- {displayTitle}
22
+ <div className="py-4 border-t md:border-t-0 lg:pl-7">
23
+ <h3 className="mb-1 text-xs font-medium">
24
+ {data?.attributes?.title?.value}
159
25
  </h3>
160
-
161
- {shouldRenderDescription && (
162
- <p
163
- style={descriptionBlock.styles}
164
- data-block-id={
165
- descriptionBlock.isDesigner
166
- ? FOOTER_SUBSCRIPTION_BLOCKS.DESCRIPTION.id
167
- : undefined
168
- }
169
- onClick={descriptionBlock.onClick}
170
- className={clsx(
171
- 'text-sm text-[#121212] text-opacity-75 mb-6 leading-relaxed',
172
- descriptionBlock.isDesigner && 'cursor-pointer',
173
- descriptionBlock.isSelected &&
174
- 'ring-2 ring-blue-500 ring-offset-2 rounded'
175
- )}
176
- >
177
- {displayDescription}
178
- </p>
179
- )}
180
-
181
- <div
182
- style={formBlock.styles}
183
- data-block-id={
184
- formBlock.isDesigner ? FOOTER_SUBSCRIPTION_BLOCKS.FORM.id : undefined
185
- }
186
- onClick={formBlock.onClick}
187
- className={clsx(
188
- formBlock.isDesigner && 'cursor-pointer inline-block',
189
- formBlock.isSelected && 'ring-2 ring-blue-500 ring-offset-2 rounded'
190
- )}
191
- >
192
- <FooterSubscriptionForm />
193
- </div>
26
+ <p className="mb-2 text-xs">{data?.attributes?.description?.value}</p>
27
+ <FooterSubscriptionForm />
194
28
  </div>
195
29
  );
196
30
  }
@@ -60,7 +60,10 @@ function checkVersion(pkg) {
60
60
  const pkgInfo = (yield response.json());
61
61
  const latestVersion = pkgInfo['dist-tags'].latest;
62
62
  if (!semver_1.default.satisfies(pkg.dependencies['@akinon/next'], latestVersion)) {
63
- console.warn(`\x1b[43mWarning: The "${packageName}" package is currently at version ${pkg.dependencies['@akinon/next']}. Please upgrade it to the latest version (${latestVersion}) to ensure plugin compatibility.`, '\x1b[0m\n');
63
+ console.warn(`\x1b[43m Warning: The "${packageName}" package is currently at`, `\x1b[41m version ${pkg.dependencies['@akinon/next']}`, `\x1b[43m Please upgrade it to the latest version (${latestVersion}) to ensure plugin compatibility.`, '\x1b[0m\n');
64
+ }
65
+ else {
66
+ console.log(`\x1b[42m Info: The package "${packageName}" is currently in the current version (${latestVersion}).`, '\x1b[0m\n');
64
67
  }
65
68
  }
66
69
  catch (error) {
@@ -82,7 +85,25 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
82
85
  throw new Error('plugins.js was not found in either of the expected locations.');
83
86
  }
84
87
  }
85
- const pkg = require(path_1.default.resolve(rootDir, './package.json'));
88
+ function findPackageJson() {
89
+ const packageJsonPaths = [
90
+ path_1.default.resolve(rootDir, './package.json'),
91
+ path_1.default.resolve(rootDir, './apps/projectzeronext/package.json')
92
+ ];
93
+ for (const packageJsonPath of packageJsonPaths) {
94
+ try {
95
+ const pkg = require(packageJsonPath);
96
+ if (pkg.dependencies['@akinon/next']) {
97
+ return pkg;
98
+ }
99
+ }
100
+ catch (error) {
101
+ continue;
102
+ }
103
+ }
104
+ throw new Error('Could not find package.json with @akinon/next dependency');
105
+ }
106
+ const pkg = findPackageJson();
86
107
  yield checkVersion(pkg);
87
108
  const pluginsFilePath = findPluginsFilePath();
88
109
  let installedPlugins = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "2.0.0-beta.20",
3
+ "version": "2.0.0-beta.21",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {
@@ -1,15 +0,0 @@
1
- import ThemePlaceholder from '@akinon/next/components/theme-editor/theme-placeholder';
2
- import { withSegmentDefaults } from '@akinon/next/hocs/server';
3
- import { PageProps } from '@akinon/next/types';
4
-
5
- export const dynamic = 'force-dynamic';
6
-
7
- async function Page({ params }: PageProps<{ slug: string }>) {
8
- return (
9
- <div className="min-h-screen">
10
- <ThemePlaceholder slug={`page-${params.slug}`} />
11
- </div>
12
- );
13
- }
14
-
15
- export default withSegmentDefaults(Page, { segmentType: 'page' });