@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,219 +0,0 @@
1
- 'use client';
2
-
3
- import {
4
- createContext,
5
- PropsWithChildren,
6
- useCallback,
7
- useContext,
8
- useEffect,
9
- useRef,
10
- useState
11
- } from 'react';
12
- import { useExternalDesigner } from '@akinon/next/components/theme-editor/hooks/use-external-designer';
13
- import { useNativeWidgetData } from '@akinon/next/components/theme-editor/hooks/use-native-widget-data';
14
-
15
- export const NAVBAR_MENU_PLACEHOLDER_ID = 'header';
16
- export const NAVBAR_MENU_SECTION_ID = 'header-nav';
17
- export const NAVBAR_MENU_WIDGET_SLUG = 'header-nav-settings-2';
18
-
19
- export const NAVBAR_MENU_BLOCK = {
20
- id: 'header-nav-menu-item',
21
- type: 'text',
22
- label: 'Menu Items'
23
- } as const;
24
-
25
- const BLOCK_META = [NAVBAR_MENU_BLOCK];
26
-
27
- interface ThemeBlock {
28
- id: string;
29
- type: string;
30
- label: string;
31
- styles?: Record<string, unknown>;
32
- properties?: Record<string, unknown>;
33
- value?: unknown;
34
- }
35
-
36
- interface ThemeSection {
37
- id: string;
38
- blocks: ThemeBlock[];
39
- }
40
-
41
- interface ThemePlaceholder {
42
- slug: string;
43
- sections: ThemeSection[];
44
- }
45
-
46
- interface NavbarMenuContextValue {
47
- isDesigner: boolean;
48
- selectedBlockId: string | null;
49
- getBlockStyles: (blockId: string) => Record<string, unknown> | undefined;
50
- getBlockProperties: (blockId: string) => Record<string, unknown> | undefined;
51
- }
52
-
53
- const NavbarMenuContext = createContext<NavbarMenuContextValue>({
54
- isDesigner: false,
55
- selectedBlockId: null,
56
- getBlockStyles: () => undefined,
57
- getBlockProperties: () => undefined
58
- });
59
-
60
- export const NavbarMenuProvider = ({ children }: PropsWithChildren) => {
61
- const designerState = useExternalDesigner({
62
- placeholderId: NAVBAR_MENU_PLACEHOLDER_ID
63
- });
64
-
65
- const isDesignerRef = useRef(false);
66
- const [isDesignerChecked, setIsDesignerChecked] = useState(false);
67
-
68
- useEffect(() => {
69
- if (typeof window === 'undefined') return;
70
- isDesignerRef.current = window.self !== window.top;
71
- setIsDesignerChecked(true);
72
- }, []);
73
-
74
- const isDesigner = isDesignerRef.current;
75
-
76
- const [themeBlocks, setThemeBlocks] = useState<Map<string, ThemeBlock>>(
77
- new Map()
78
- );
79
- const hasReceivedThemeStyles = useRef(false);
80
- const hasRegisteredNativeWidget = useRef(false);
81
- const themeBlocksRef = useRef<Map<string, ThemeBlock>>(new Map());
82
-
83
- const widgetData = useNativeWidgetData({
84
- widgetSlug: NAVBAR_MENU_WIDGET_SLUG,
85
- sectionId: NAVBAR_MENU_SECTION_ID,
86
- skip: !isDesignerChecked || isDesigner,
87
- blockMeta: BLOCK_META
88
- });
89
-
90
- const getBlockWithStyles = useCallback(
91
- (blockDef: typeof NAVBAR_MENU_BLOCK) => {
92
- const existingBlock = themeBlocksRef.current.get(blockDef.id);
93
- return {
94
- id: blockDef.id,
95
- type: blockDef.type,
96
- label: blockDef.label,
97
- properties: existingBlock?.properties || {},
98
- styles: existingBlock?.styles || {}
99
- };
100
- },
101
- []
102
- );
103
-
104
- useEffect(() => {
105
- if (hasRegisteredNativeWidget.current) return;
106
-
107
- const isInIframe =
108
- typeof window !== 'undefined' && window.self !== window.top;
109
- if (!isInIframe || !window.parent) return;
110
-
111
- const nativeWidgetConfig = {
112
- placeholderId: NAVBAR_MENU_PLACEHOLDER_ID,
113
- section: {
114
- id: NAVBAR_MENU_SECTION_ID,
115
- type: 'native',
116
- label: 'Navigation Menu',
117
- blocks: [getBlockWithStyles(NAVBAR_MENU_BLOCK)]
118
- }
119
- };
120
-
121
- window.parent.postMessage(
122
- {
123
- type: 'REGISTER_NATIVE_WIDGETS',
124
- data: { widgets: [nativeWidgetConfig] }
125
- },
126
- '*'
127
- );
128
-
129
- hasRegisteredNativeWidget.current = true;
130
- }, [getBlockWithStyles]);
131
-
132
- useEffect(() => {
133
- if (!isDesignerChecked || isDesigner || widgetData.isLoading) return;
134
- if (hasReceivedThemeStyles.current) return;
135
-
136
- const blockMap = new Map<string, ThemeBlock>();
137
- widgetData.blocks.forEach((block) => {
138
- blockMap.set(block.id, {
139
- id: block.id,
140
- type: block.type || 'text',
141
- label: block.label || block.id,
142
- styles: block.styles,
143
- properties: block.properties,
144
- value: block.value
145
- });
146
- });
147
-
148
- if (blockMap.size > 0) {
149
- setThemeBlocks(blockMap);
150
- themeBlocksRef.current = blockMap;
151
- }
152
- }, [isDesignerChecked, isDesigner, widgetData.isLoading, widgetData.blocks]);
153
-
154
- const indexBlocks = useCallback(
155
- (blocks: ThemeBlock[], map: Map<string, ThemeBlock>) => {
156
- blocks.forEach((block) => {
157
- map.set(block.id, block);
158
- });
159
- },
160
- []
161
- );
162
-
163
- useEffect(() => {
164
- const handleMessage = (event: MessageEvent) => {
165
- const { type, data } = event.data || {};
166
-
167
- if (
168
- (type === 'UPDATE_THEME' || type === 'LOAD_THEME') &&
169
- data?.theme?.placeholders
170
- ) {
171
- const placeholder = data.theme.placeholders?.find(
172
- (p: ThemePlaceholder) => p.slug === NAVBAR_MENU_PLACEHOLDER_ID
173
- );
174
-
175
- const navSection = placeholder?.sections?.find(
176
- (s: ThemeSection) => s.id === NAVBAR_MENU_SECTION_ID
177
- );
178
-
179
- if (navSection?.blocks) {
180
- const blockMap = new Map<string, ThemeBlock>();
181
- indexBlocks(navSection.blocks, blockMap);
182
-
183
- if (blockMap.size > 0) {
184
- hasReceivedThemeStyles.current = true;
185
- setThemeBlocks(blockMap);
186
- themeBlocksRef.current = blockMap;
187
- }
188
- }
189
- }
190
- };
191
-
192
- window.addEventListener('message', handleMessage);
193
- return () => window.removeEventListener('message', handleMessage);
194
- }, [indexBlocks]);
195
-
196
- const getBlockStyles = useCallback(
197
- (blockId: string) => themeBlocks.get(blockId)?.styles,
198
- [themeBlocks]
199
- );
200
-
201
- const getBlockProperties = useCallback(
202
- (blockId: string) => themeBlocks.get(blockId)?.properties,
203
- [themeBlocks]
204
- );
205
-
206
- return (
207
- <NavbarMenuContext.Provider
208
- value={{
209
- ...designerState,
210
- getBlockStyles,
211
- getBlockProperties
212
- }}
213
- >
214
- {children}
215
- </NavbarMenuContext.Provider>
216
- );
217
- };
218
-
219
- export const useNavbarMenuDesigner = () => useContext(NavbarMenuContext);
@@ -1,61 +0,0 @@
1
- 'use client';
2
-
3
- import { forwardRef, InputHTMLAttributes } from 'react';
4
- import clsx from 'clsx';
5
- import { Icon } from '@theme/components';
6
-
7
- interface SearchInputProps extends InputHTMLAttributes<HTMLInputElement> {
8
- label?: string;
9
- onSearchClick?: () => void;
10
- error?: string;
11
- startAdornment?: React.ReactNode;
12
- }
13
-
14
- export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
15
- (props, ref) => {
16
- const { label, onSearchClick, error, className, startAdornment, ...rest } =
17
- props;
18
-
19
- return (
20
- <div className={clsx('flex flex-col', className)}>
21
- <div
22
- className={clsx(
23
- 'relative flex items-center border h-12 px-4',
24
- error ? 'border-error' : 'border-black'
25
- )}
26
- >
27
- {startAdornment}
28
- <div className="flex-1 flex flex-col justify-center">
29
- {label && (
30
- <span className="text-[10px] text-black-750 leading-none tracking-wider">
31
- {label}
32
- </span>
33
- )}
34
- <input
35
- ref={ref}
36
- type="text"
37
- className={clsx(
38
- 'w-full text-base leading-[15px] tracking-[0.64px] text-black-750',
39
- 'bg-transparent border-none outline-none',
40
- 'placeholder:text-black-750/75 font-jost',
41
- label ? 'mt-0.5' : ''
42
- )}
43
- {...rest}
44
- />
45
- </div>
46
- <button
47
- type="button"
48
- onClick={onSearchClick}
49
- className="flex items-center justify-center ml-2"
50
- aria-label="Search"
51
- >
52
- <Icon name="search" size={20} className="text-black" />
53
- </button>
54
- </div>
55
- {error && <span className="mt-1 text-sm text-error">{error}</span>}
56
- </div>
57
- );
58
- }
59
- );
60
-
61
- SearchInput.displayName = 'SearchInput';