@akinon/pz-theme 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 (62) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.json +27 -0
  3. package/readme.md +23 -0
  4. package/src/blocks/accordion-block.tsx +136 -0
  5. package/src/blocks/block-renderer-registry.tsx +77 -0
  6. package/src/blocks/button-block.tsx +593 -0
  7. package/src/blocks/counter-block.tsx +348 -0
  8. package/src/blocks/divider-block.tsx +20 -0
  9. package/src/blocks/embed-block.tsx +208 -0
  10. package/src/blocks/group-block.tsx +116 -0
  11. package/src/blocks/hotspot-block.tsx +147 -0
  12. package/src/blocks/icon-block.tsx +230 -0
  13. package/src/blocks/image-block.tsx +142 -0
  14. package/src/blocks/image-gallery-block.tsx +269 -0
  15. package/src/blocks/input-block.tsx +123 -0
  16. package/src/blocks/link-block.tsx +216 -0
  17. package/src/blocks/lottie-block.tsx +325 -0
  18. package/src/blocks/map-block.tsx +89 -0
  19. package/src/blocks/slider-block.tsx +595 -0
  20. package/src/blocks/tab-block.tsx +10 -0
  21. package/src/blocks/text-block.tsx +52 -0
  22. package/src/blocks/video-block.tsx +122 -0
  23. package/src/components/action-toolbar.tsx +305 -0
  24. package/src/components/designer-overlay.tsx +74 -0
  25. package/src/components/with-designer-features.tsx +142 -0
  26. package/src/dynamic-font-loader.tsx +79 -0
  27. package/src/hooks/use-designer-features.tsx +100 -0
  28. package/src/hooks/use-visibility-context.ts +27 -0
  29. package/src/index.ts +21 -0
  30. package/src/placeholder-registry.ts +31 -0
  31. package/src/sections/before-after-section.tsx +245 -0
  32. package/src/sections/contact-form-section.tsx +564 -0
  33. package/src/sections/countdown-campaign-banner-section.tsx +433 -0
  34. package/src/sections/coupon-banner-section.tsx +710 -0
  35. package/src/sections/divider-section.tsx +62 -0
  36. package/src/sections/featured-product-spotlight-section.tsx +507 -0
  37. package/src/sections/find-in-store-section.tsx +1995 -0
  38. package/src/sections/hover-showcase-section.tsx +326 -0
  39. package/src/sections/image-hotspot-section.tsx +142 -0
  40. package/src/sections/installment-options-section.tsx +1065 -0
  41. package/src/sections/notification-banner-section.tsx +173 -0
  42. package/src/sections/order-tracking-lookup-section.tsx +1379 -0
  43. package/src/sections/posts-slider-section.tsx +472 -0
  44. package/src/sections/pre-order-launch-banner-section.tsx +687 -0
  45. package/src/sections/section-renderer-registry.tsx +89 -0
  46. package/src/sections/section-wrapper.tsx +135 -0
  47. package/src/sections/shipping-threshold-progress-section.tsx +586 -0
  48. package/src/sections/stats-counter-section.tsx +486 -0
  49. package/src/sections/tabs-section.tsx +578 -0
  50. package/src/theme-block.tsx +102 -0
  51. package/src/theme-page-context.tsx +27 -0
  52. package/src/theme-placeholder-client.tsx +218 -0
  53. package/src/theme-placeholder-wrapper.tsx +786 -0
  54. package/src/theme-placeholder.tsx +305 -0
  55. package/src/theme-section.tsx +1241 -0
  56. package/src/theme-settings-context.tsx +13 -0
  57. package/src/utils/index.ts +791 -0
  58. package/src/utils/iterator-utils.test.ts +224 -0
  59. package/src/utils/iterator-utils.ts +617 -0
  60. package/src/utils/page-context-discovery.ts +119 -0
  61. package/src/utils/publish-window.ts +86 -0
  62. package/src/utils/visibility-rules.ts +188 -0
@@ -0,0 +1,224 @@
1
+ import { buildIteratorBlock, resolveBlockBindings } from './iterator-utils';
2
+
3
+ describe('iterator-utils', () => {
4
+ it('resolves generic page-context bindings for text and button blocks', () => {
5
+ const pageContext = {
6
+ product: {
7
+ title: 'Spring Sneaker',
8
+ url: '/products/spring-sneaker'
9
+ }
10
+ };
11
+
12
+ const resolvedText = resolveBlockBindings({
13
+ block: {
14
+ id: 'text-1',
15
+ type: 'text',
16
+ label: 'Heading',
17
+ value: 'Fallback title',
18
+ properties: {
19
+ dataBinding: 'product.title'
20
+ },
21
+ styles: {},
22
+ order: 0,
23
+ hidden: false
24
+ },
25
+ sectionDataSource: {
26
+ type: 'page-context',
27
+ details: {
28
+ pageContext: {
29
+ pageType: 'product',
30
+ rootPath: 'product'
31
+ }
32
+ }
33
+ },
34
+ pageContext
35
+ });
36
+
37
+ const resolvedButton = resolveBlockBindings({
38
+ block: {
39
+ id: 'button-1',
40
+ type: 'button',
41
+ label: 'CTA',
42
+ value: 'Fallback CTA',
43
+ properties: {
44
+ dataBinding: 'product.url',
45
+ dataBindingTarget: 'url',
46
+ url: '#'
47
+ },
48
+ styles: {},
49
+ order: 1,
50
+ hidden: false
51
+ },
52
+ sectionDataSource: {
53
+ type: 'page-context',
54
+ details: {
55
+ pageContext: {
56
+ pageType: 'product',
57
+ rootPath: 'product'
58
+ }
59
+ }
60
+ },
61
+ pageContext
62
+ });
63
+
64
+ expect(resolvedText.value).toBe('Spring Sneaker');
65
+ expect(resolvedButton.properties.url).toBe('/products/spring-sneaker');
66
+ });
67
+
68
+ it('builds iterators from page-context arrays and resolves item bindings', () => {
69
+ const pageContext = {
70
+ product: {
71
+ images: [
72
+ {
73
+ url: 'https://cdn.example.com/image-1.jpg',
74
+ alt: 'Image 1'
75
+ },
76
+ {
77
+ url: 'https://cdn.example.com/image-2.jpg',
78
+ alt: 'Image 2'
79
+ }
80
+ ]
81
+ }
82
+ };
83
+
84
+ const iteratorBlock = buildIteratorBlock({
85
+ iteratorBlock: {
86
+ id: 'group-1',
87
+ type: 'group',
88
+ label: 'Image Iterator',
89
+ value: undefined,
90
+ properties: {
91
+ iteratorDataPath: 'product.images',
92
+ iteratorCount: 2,
93
+ useIteratorCount: true
94
+ },
95
+ styles: {},
96
+ order: 0,
97
+ hidden: false,
98
+ isIterator: true,
99
+ iteratorDataPath: 'product.images',
100
+ blocks: [
101
+ {
102
+ id: 'image-1',
103
+ type: 'image',
104
+ label: 'Image',
105
+ value: '',
106
+ properties: {
107
+ dataBinding: 'item.url',
108
+ alt: ''
109
+ },
110
+ styles: {},
111
+ order: 0,
112
+ hidden: false
113
+ }
114
+ ]
115
+ },
116
+ sectionDataSource: {
117
+ type: 'page-context',
118
+ details: {
119
+ pageContext: {
120
+ pageType: 'product',
121
+ rootPath: 'product'
122
+ }
123
+ }
124
+ },
125
+ pageContext
126
+ });
127
+
128
+ expect(iteratorBlock.blocks).toHaveLength(2);
129
+ expect(iteratorBlock.blocks?.[0].value).toBe(
130
+ 'https://cdn.example.com/image-1.jpg'
131
+ );
132
+ expect(iteratorBlock.blocks?.[1].value).toBe(
133
+ 'https://cdn.example.com/image-2.jpg'
134
+ );
135
+ });
136
+
137
+ it('resolves basket page-context bindings and basket item iterators', () => {
138
+ const pageContext = {
139
+ basket: {
140
+ totalAmount: '799.90',
141
+ items: [
142
+ {
143
+ title: 'Spring Sneaker',
144
+ image: 'https://cdn.example.com/image-1.jpg',
145
+ url: '/products/spring-sneaker'
146
+ }
147
+ ]
148
+ }
149
+ };
150
+
151
+ const resolvedText = resolveBlockBindings({
152
+ block: {
153
+ id: 'text-2',
154
+ type: 'text',
155
+ label: 'Basket Total',
156
+ value: 'Fallback total',
157
+ properties: {
158
+ dataBinding: 'basket.totalAmount'
159
+ },
160
+ styles: {},
161
+ order: 0,
162
+ hidden: false
163
+ },
164
+ sectionDataSource: {
165
+ type: 'page-context',
166
+ details: {
167
+ pageContext: {
168
+ pageType: 'basket',
169
+ rootPath: 'basket'
170
+ }
171
+ }
172
+ },
173
+ pageContext
174
+ });
175
+
176
+ const iteratorBlock = buildIteratorBlock({
177
+ iteratorBlock: {
178
+ id: 'group-2',
179
+ type: 'group',
180
+ label: 'Basket Items',
181
+ value: undefined,
182
+ properties: {
183
+ iteratorDataPath: 'basket.items'
184
+ },
185
+ styles: {},
186
+ order: 0,
187
+ hidden: false,
188
+ isIterator: true,
189
+ iteratorDataPath: 'basket.items',
190
+ blocks: [
191
+ {
192
+ id: 'image-2',
193
+ type: 'image',
194
+ label: 'Basket Image',
195
+ value: '',
196
+ properties: {
197
+ dataBinding: 'item.image',
198
+ alt: ''
199
+ },
200
+ styles: {},
201
+ order: 0,
202
+ hidden: false
203
+ }
204
+ ]
205
+ },
206
+ sectionDataSource: {
207
+ type: 'page-context',
208
+ details: {
209
+ pageContext: {
210
+ pageType: 'basket',
211
+ rootPath: 'basket'
212
+ }
213
+ }
214
+ },
215
+ pageContext
216
+ });
217
+
218
+ expect(resolvedText.value).toBe('799.90');
219
+ expect(iteratorBlock.blocks).toHaveLength(1);
220
+ expect(iteratorBlock.blocks?.[0].value).toBe(
221
+ 'https://cdn.example.com/image-1.jpg'
222
+ );
223
+ });
224
+ });