@wix/ditto-codegen-public 1.0.274 → 1.0.276
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.
- package/dist/out.js +5 -5
- package/package.json +2 -2
- package/dist/examples-apps/ai-chatbot/.nvmrc +0 -1
- package/dist/examples-apps/ai-chatbot/README.md +0 -21
- package/dist/examples-apps/ai-chatbot/package-lock.json +0 -7266
- package/dist/examples-apps/ai-chatbot/package.json +0 -35
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/ProductChat.module.css +0 -3
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/ProductChat.tsx +0 -108
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/page.tsx +0 -100
- package/dist/examples-apps/ai-chatbot/src/dashboard/withProviders.tsx +0 -15
- package/dist/examples-apps/ai-chatbot/src/env.d.ts +0 -4
- package/dist/examples-apps/ai-chatbot/src/types.ts +0 -4
- package/dist/examples-apps/ai-chatbot/tsconfig.json +0 -8
- package/dist/examples-apps/ai-chatbot/wix.config.json +0 -5
- package/dist/examples-apps/contact-created-logger/package-lock.json +0 -15102
- package/dist/examples-apps/contact-created-logger/package.json +0 -37
- package/dist/examples-apps/contact-created-logger/src/backend/events/contact-created-logger/event.ts +0 -56
- package/dist/examples-apps/contact-created-logger/tsconfig.json +0 -5
- package/dist/examples-apps/contact-created-logger/wix.config.json +0 -4
- package/dist/examples-apps/coupon-popup/README.md +0 -13
- package/dist/examples-apps/coupon-popup/package.json +0 -43
- package/dist/examples-apps/coupon-popup/src/extensions.ts +0 -12
- package/dist/examples-apps/coupon-popup/src/index.ts +0 -2
- package/dist/examples-apps/coupon-popup/src/site/embedded-scripts/cart-coupon-popup/embedded.html +0 -562
- package/dist/examples-apps/coupon-popup/src/site/embedded-scripts/cart-coupon-popup/extensions.ts +0 -8
- package/dist/examples-apps/coupon-popup/tsconfig.json +0 -10
- package/dist/examples-apps/coupon-popup/wix.config.json +0 -4
- package/dist/examples-apps/custom-element/countdown-widget/components/ColorPickerField.tsx +0 -27
- package/dist/examples-apps/custom-element/countdown-widget/components/FontPickerField.tsx +0 -34
- package/dist/examples-apps/custom-element/countdown-widget/components/Separator.tsx +0 -10
- package/dist/examples-apps/custom-element/countdown-widget/components/TimeBlock.tsx +0 -23
- package/dist/examples-apps/custom-element/countdown-widget/extensions.ts +0 -18
- package/dist/examples-apps/custom-element/countdown-widget/panel.tsx +0 -146
- package/dist/examples-apps/custom-element/countdown-widget/styles.ts +0 -73
- package/dist/examples-apps/custom-element/countdown-widget/utils.ts +0 -46
- package/dist/examples-apps/custom-element/countdown-widget/widget.tsx +0 -97
- package/dist/examples-apps/product-created-logger/package-lock.json +0 -15102
- package/dist/examples-apps/product-created-logger/package.json +0 -37
- package/dist/examples-apps/product-created-logger/src/backend/events/product-created-logger/event.ts +0 -66
- package/dist/examples-apps/product-created-logger/tsconfig.json +0 -5
- package/dist/examples-apps/product-created-logger/wix.config.json +0 -4
- package/dist/examples-apps/react-builder/component.tsx +0 -123
- package/dist/examples-apps/react-builder/components/Badge.tsx +0 -14
- package/dist/examples-apps/react-builder/components/Button.tsx +0 -31
- package/dist/examples-apps/react-builder/components/Counter.tsx +0 -14
- package/dist/examples-apps/react-builder/components/FeaturedImage.tsx +0 -31
- package/dist/examples-apps/react-builder/components/SocialLinks.tsx +0 -61
- package/dist/examples-apps/react-builder/components/Subtitle.tsx +0 -11
- package/dist/examples-apps/react-builder/components/Tags.tsx +0 -25
- package/dist/examples-apps/react-builder/components/Title.tsx +0 -11
- package/dist/examples-apps/react-builder/components/index.ts +0 -8
- package/dist/examples-apps/react-builder/manifest.json +0 -345
- package/dist/examples-apps/react-builder/style.css +0 -197
- package/dist/examples-apps/react-builder/types.ts +0 -70
- package/dist/examples-apps/spis-examples/.nvmrc +0 -1
- package/dist/examples-apps/spis-examples/README.md +0 -21
- package/dist/examples-apps/spis-examples/package-lock.json +0 -6903
- package/dist/examples-apps/spis-examples/package.json +0 -32
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-additional-fees/additional-fees/plugin.ts +0 -66
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-discount-triggers/discount-triggers/plugin.ts +0 -42
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-gift-cards/gift-cards/plugin.ts +0 -38
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-shipping-rates/shipping-rates/plugin.ts +0 -34
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-validations/validations/plugin.ts +0 -24
- package/dist/examples-apps/spis-examples/src/env.d.ts +0 -4
- package/dist/examples-apps/spis-examples/tsconfig.json +0 -8
- package/dist/examples-apps/spis-examples/wix.config.json +0 -5
- package/dist/examples-apps/survey-manager/README.md +0 -21
- package/dist/examples-apps/survey-manager/package-lock.json +0 -14252
- package/dist/examples-apps/survey-manager/package.json +0 -36
- package/dist/examples-apps/survey-manager/src/dashboard/pages/apis.ts +0 -116
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/PageLoader.tsx +0 -23
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/QuestionModal.tsx +0 -84
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/QuestionsTable.tsx +0 -139
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/SurveyPageLayout.tsx +0 -99
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/SurveyStats.tsx +0 -50
- package/dist/examples-apps/survey-manager/src/dashboard/pages/page.tsx +0 -171
- package/dist/examples-apps/survey-manager/src/dashboard/pages/types.ts +0 -28
- package/dist/examples-apps/survey-manager/tsconfig.json +0 -8
- package/dist/examples-apps/survey-manager/wix.config.json +0 -4
- package/dist/opencode-tools/wds-lookup.ts +0 -134
package/dist/examples-apps/coupon-popup/src/site/embedded-scripts/cart-coupon-popup/embedded.html
DELETED
|
@@ -1,562 +0,0 @@
|
|
|
1
|
-
<div
|
|
2
|
-
id="popup-config"
|
|
3
|
-
data-coupon-code="{{couponCode}}"
|
|
4
|
-
data-popup-headline="{{popupHeadline}}"
|
|
5
|
-
data-popup-description="{{popupDescription}}"
|
|
6
|
-
data-minimum-cart-value="{{minimumCartValue}}"
|
|
7
|
-
data-enable-popup="{{enablePopup}}"
|
|
8
|
-
></div>
|
|
9
|
-
<div id="cart-coupon-popup-container"></div>
|
|
10
|
-
|
|
11
|
-
<style>
|
|
12
|
-
.cart-coupon-popup {
|
|
13
|
-
position: fixed;
|
|
14
|
-
top: 0;
|
|
15
|
-
left: 0;
|
|
16
|
-
right: 0;
|
|
17
|
-
bottom: 0;
|
|
18
|
-
z-index: 10000;
|
|
19
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
20
|
-
display: flex;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
align-items: center;
|
|
23
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
24
|
-
backdrop-filter: blur(4px);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.cart-coupon-popup.hidden {
|
|
28
|
-
display: none;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.popup-content {
|
|
32
|
-
max-width: 500px;
|
|
33
|
-
width: 90%;
|
|
34
|
-
max-height: 80vh;
|
|
35
|
-
overflow-y: auto;
|
|
36
|
-
border-radius: 12px;
|
|
37
|
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
|
38
|
-
position: relative;
|
|
39
|
-
animation: popupSlideIn 0.3s ease-out;
|
|
40
|
-
background-color: #FFFFFF;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@keyframes popupSlideIn {
|
|
44
|
-
from {
|
|
45
|
-
opacity: 0;
|
|
46
|
-
transform: scale(0.9) translateY(-20px);
|
|
47
|
-
}
|
|
48
|
-
to {
|
|
49
|
-
opacity: 1;
|
|
50
|
-
transform: scale(1) translateY(0);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.popup-header {
|
|
55
|
-
padding: 24px 24px 16px;
|
|
56
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
57
|
-
position: relative;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.close-button {
|
|
61
|
-
position: absolute;
|
|
62
|
-
top: 16px;
|
|
63
|
-
right: 16px;
|
|
64
|
-
background: none;
|
|
65
|
-
border: none;
|
|
66
|
-
font-size: 24px;
|
|
67
|
-
cursor: pointer;
|
|
68
|
-
color: #666;
|
|
69
|
-
padding: 4px;
|
|
70
|
-
border-radius: 4px;
|
|
71
|
-
transition: all 0.2s ease;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.close-button:hover {
|
|
75
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
76
|
-
color: #333;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.popup-headline {
|
|
80
|
-
margin: 0 0 8px 0;
|
|
81
|
-
font-size: 24px;
|
|
82
|
-
font-weight: 700;
|
|
83
|
-
color: #333;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.popup-description {
|
|
87
|
-
margin: 0;
|
|
88
|
-
font-size: 16px;
|
|
89
|
-
color: #666;
|
|
90
|
-
line-height: 1.5;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.cart-section {
|
|
94
|
-
padding: 20px 24px;
|
|
95
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.cart-title {
|
|
99
|
-
margin: 0 0 16px 0;
|
|
100
|
-
font-size: 18px;
|
|
101
|
-
font-weight: 600;
|
|
102
|
-
color: #333;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.cart-items {
|
|
106
|
-
max-height: 200px;
|
|
107
|
-
overflow-y: auto;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.cart-item {
|
|
111
|
-
display: flex;
|
|
112
|
-
align-items: center;
|
|
113
|
-
padding: 12px 0;
|
|
114
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.cart-item:last-child {
|
|
118
|
-
border-bottom: none;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.item-details {
|
|
122
|
-
flex: 1;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.item-name {
|
|
126
|
-
font-weight: 600;
|
|
127
|
-
color: #333;
|
|
128
|
-
margin: 0 0 4px 0;
|
|
129
|
-
font-size: 14px;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.item-price {
|
|
133
|
-
color: #666;
|
|
134
|
-
font-size: 14px;
|
|
135
|
-
margin: 0;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.item-quantity {
|
|
139
|
-
color: #888;
|
|
140
|
-
font-size: 12px;
|
|
141
|
-
margin-left: 12px;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.cart-total {
|
|
145
|
-
margin-top: 16px;
|
|
146
|
-
padding-top: 16px;
|
|
147
|
-
border-top: 2px solid rgba(0, 0, 0, 0.1);
|
|
148
|
-
text-align: right;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.total-label {
|
|
152
|
-
font-size: 18px;
|
|
153
|
-
font-weight: 700;
|
|
154
|
-
color: #333;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.empty-cart {
|
|
158
|
-
text-align: center;
|
|
159
|
-
color: #888;
|
|
160
|
-
font-style: italic;
|
|
161
|
-
padding: 20px 0;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.coupon-section {
|
|
165
|
-
padding: 20px 24px;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.coupon-code {
|
|
169
|
-
background-color: #f8f9fa;
|
|
170
|
-
border: 2px dashed #007bff;
|
|
171
|
-
border-radius: 8px;
|
|
172
|
-
padding: 16px;
|
|
173
|
-
text-align: center;
|
|
174
|
-
margin: 16px 0;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.coupon-code-text {
|
|
178
|
-
font-family: 'Courier New', monospace;
|
|
179
|
-
font-size: 20px;
|
|
180
|
-
font-weight: 700;
|
|
181
|
-
color: #007bff;
|
|
182
|
-
margin: 0 0 8px 0;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.coupon-hint {
|
|
186
|
-
font-size: 12px;
|
|
187
|
-
color: #666;
|
|
188
|
-
margin: 0;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.action-buttons {
|
|
192
|
-
display: flex;
|
|
193
|
-
gap: 12px;
|
|
194
|
-
margin-top: 20px;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.btn {
|
|
198
|
-
width: 100%;
|
|
199
|
-
padding: 12px 20px;
|
|
200
|
-
border: none;
|
|
201
|
-
border-radius: 6px;
|
|
202
|
-
font-size: 16px;
|
|
203
|
-
font-weight: 600;
|
|
204
|
-
cursor: pointer;
|
|
205
|
-
transition: all 0.2s ease;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.btn-primary {
|
|
209
|
-
background-color: #007bff;
|
|
210
|
-
color: white;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.btn-primary:hover {
|
|
214
|
-
background-color: #0056b3;
|
|
215
|
-
transform: translateY(-1px);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.footer-options {
|
|
219
|
-
padding: 16px 24px;
|
|
220
|
-
background-color: #f8f9fa;
|
|
221
|
-
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
222
|
-
border-radius: 0 0 12px 12px;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.dont-show-again {
|
|
226
|
-
display: flex;
|
|
227
|
-
align-items: center;
|
|
228
|
-
font-size: 14px;
|
|
229
|
-
color: #666;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.dont-show-again input {
|
|
233
|
-
margin-right: 8px;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.loading {
|
|
237
|
-
text-align: center;
|
|
238
|
-
padding: 40px 20px;
|
|
239
|
-
color: #666;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.error {
|
|
243
|
-
text-align: center;
|
|
244
|
-
padding: 20px;
|
|
245
|
-
color: #dc3545;
|
|
246
|
-
background-color: #f8d7da;
|
|
247
|
-
border-radius: 6px;
|
|
248
|
-
margin: 16px 0;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@media (max-width: 480px) {
|
|
252
|
-
.popup-content {
|
|
253
|
-
width: 95%;
|
|
254
|
-
margin: 20px;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.popup-header {
|
|
258
|
-
padding: 20px 20px 16px;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.cart-section,
|
|
262
|
-
.coupon-section {
|
|
263
|
-
padding: 16px 20px;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.action-buttons {
|
|
267
|
-
flex-direction: column;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
</style>
|
|
271
|
-
|
|
272
|
-
<script type="module">
|
|
273
|
-
import { currentCart } from '@wix/ecom';
|
|
274
|
-
|
|
275
|
-
// Get configuration from data attributes
|
|
276
|
-
const config = document.getElementById('popup-config');
|
|
277
|
-
if (!config) throw new Error('Config element not found');
|
|
278
|
-
|
|
279
|
-
const {
|
|
280
|
-
couponCode,
|
|
281
|
-
popupHeadline,
|
|
282
|
-
popupDescription,
|
|
283
|
-
minimumCartValue,
|
|
284
|
-
enablePopup
|
|
285
|
-
} = config.dataset;
|
|
286
|
-
|
|
287
|
-
// Exit early if popup is disabled
|
|
288
|
-
if (enablePopup !== 'true') {
|
|
289
|
-
throw new Error('Popup disabled');
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const container = document.getElementById('cart-coupon-popup-container');
|
|
293
|
-
if (!container) throw new Error('Container element not found');
|
|
294
|
-
|
|
295
|
-
let popupElement = null;
|
|
296
|
-
let cart = null;
|
|
297
|
-
let isLoading = false;
|
|
298
|
-
|
|
299
|
-
// Storage key for popup display control
|
|
300
|
-
const STORAGE_KEY_DONT_SHOW = 'cart-coupon-popup-dont-show';
|
|
301
|
-
|
|
302
|
-
// Check if popup should be shown
|
|
303
|
-
function shouldShowPopup() {
|
|
304
|
-
const dontShow = localStorage.getItem(STORAGE_KEY_DONT_SHOW);
|
|
305
|
-
console.log('dontShow',dontShow)
|
|
306
|
-
return dontShow !== 'true';
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// Create popup HTML structure
|
|
311
|
-
function createPopupElement() {
|
|
312
|
-
const popup = document.createElement('div');
|
|
313
|
-
popup.className = 'cart-coupon-popup hidden';
|
|
314
|
-
|
|
315
|
-
popup.innerHTML = `
|
|
316
|
-
<div class="popup-content">
|
|
317
|
-
<div class="popup-header">
|
|
318
|
-
<button class="close-button" id="close-popup">×</button>
|
|
319
|
-
<h2 class="popup-headline">${escapeHtml(popupHeadline || 'Special Offer!')}</h2>
|
|
320
|
-
<p class="popup-description">${escapeHtml(popupDescription || 'Apply this coupon to get a discount on your cart!')}</p>
|
|
321
|
-
</div>
|
|
322
|
-
|
|
323
|
-
<div class="cart-section">
|
|
324
|
-
<h3 class="cart-title">Your Cart</h3>
|
|
325
|
-
<div id="cart-content">
|
|
326
|
-
<div class="loading">Loading cart...</div>
|
|
327
|
-
</div>
|
|
328
|
-
</div>
|
|
329
|
-
|
|
330
|
-
<div class="coupon-section">
|
|
331
|
-
<div class="coupon-code">
|
|
332
|
-
<div class="coupon-code-text">${escapeHtml(couponCode)}</div>
|
|
333
|
-
<p class="coupon-hint">Click to copy this coupon code</p>
|
|
334
|
-
</div>
|
|
335
|
-
|
|
336
|
-
<div class="action-buttons">
|
|
337
|
-
<button class="btn btn-primary" id="dismiss-popup">Close</button>
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
|
|
341
|
-
<div class="footer-options">
|
|
342
|
-
<label class="dont-show-again">
|
|
343
|
-
<input type="checkbox" id="dont-show-again">
|
|
344
|
-
Don't show this popup again
|
|
345
|
-
</label>
|
|
346
|
-
</div>
|
|
347
|
-
</div>
|
|
348
|
-
`;
|
|
349
|
-
|
|
350
|
-
return popup;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// Escape HTML to prevent XSS
|
|
354
|
-
function escapeHtml(text) {
|
|
355
|
-
const div = document.createElement('div');
|
|
356
|
-
div.textContent = text;
|
|
357
|
-
return div.innerHTML;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Load current cart using Wix eCommerce API
|
|
361
|
-
async function loadCurrentCart() {
|
|
362
|
-
try {
|
|
363
|
-
isLoading = true;
|
|
364
|
-
|
|
365
|
-
// Get current cart
|
|
366
|
-
const currentCartData = await currentCart.getCurrentCart();
|
|
367
|
-
cart = currentCartData;
|
|
368
|
-
|
|
369
|
-
return currentCartData;
|
|
370
|
-
} catch (error) {
|
|
371
|
-
console.error('Failed to load cart:', error);
|
|
372
|
-
throw error;
|
|
373
|
-
} finally {
|
|
374
|
-
isLoading = false;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
// Render cart items in the popup
|
|
380
|
-
function renderCartContent(cartData) {
|
|
381
|
-
const cartContent = document.getElementById('cart-content');
|
|
382
|
-
if (!cartContent) return;
|
|
383
|
-
|
|
384
|
-
if (!cartData || !cartData.lineItems || cartData.lineItems.length === 0) {
|
|
385
|
-
cartContent.innerHTML = '<div class="empty-cart">Your cart is empty</div>';
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const cartItemsHtml = cartData.lineItems.map(item => {
|
|
390
|
-
const itemName = item.productName?.original || 'Unknown Item';
|
|
391
|
-
const itemPrice = item.price?.formattedAmount || '$0.00';
|
|
392
|
-
const quantity = item.quantity || 1;
|
|
393
|
-
|
|
394
|
-
return `
|
|
395
|
-
<div class="cart-item">
|
|
396
|
-
<div class="item-details">
|
|
397
|
-
<div class="item-name">${escapeHtml(itemName)}</div>
|
|
398
|
-
<div class="item-price">${escapeHtml(itemPrice)}</div>
|
|
399
|
-
</div>
|
|
400
|
-
<div class="item-quantity">Qty: ${quantity}</div>
|
|
401
|
-
</div>
|
|
402
|
-
`;
|
|
403
|
-
}).join('');
|
|
404
|
-
|
|
405
|
-
// Calculate total (use subtotal if available, otherwise sum line items)
|
|
406
|
-
const totalAmount = cartData.subtotal?.formattedAmount ||
|
|
407
|
-
cartData.lineItems.reduce((sum, item) => {
|
|
408
|
-
const price = parseFloat(item.price?.amount || '0');
|
|
409
|
-
return sum + (price * (item.quantity || 1));
|
|
410
|
-
}, 0).toFixed(2);
|
|
411
|
-
|
|
412
|
-
cartContent.innerHTML = `
|
|
413
|
-
<div class="cart-items">
|
|
414
|
-
${cartItemsHtml}
|
|
415
|
-
</div>
|
|
416
|
-
<div class="cart-total">
|
|
417
|
-
<div class="total-label">Total: ${typeof totalAmount === 'string' ? totalAmount : '$' + totalAmount}</div>
|
|
418
|
-
</div>
|
|
419
|
-
`;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// Check if cart meets minimum value requirement
|
|
423
|
-
function meetsMinimumValue(cartData) {
|
|
424
|
-
const minValue = parseFloat(minimumCartValue || '0');
|
|
425
|
-
if (minValue <= 0) return true;
|
|
426
|
-
|
|
427
|
-
if (!cartData || !cartData.lineItems || cartData.lineItems.length === 0) {
|
|
428
|
-
return false;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const cartValue = parseFloat(cartData.subtotal?.amount || '0');
|
|
432
|
-
return cartValue >= minValue;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// Show the popup
|
|
436
|
-
function showPopup() {
|
|
437
|
-
if (popupElement) {
|
|
438
|
-
popupElement.classList.remove('hidden');
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Hide the popup
|
|
443
|
-
function hidePopup(dontShowAgain = false) {
|
|
444
|
-
if (popupElement) {
|
|
445
|
-
popupElement.classList.add('hidden');
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (dontShowAgain) {
|
|
449
|
-
localStorage.setItem(STORAGE_KEY_DONT_SHOW, 'true');
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// Handle coupon code click (copy to clipboard)
|
|
454
|
-
function handleCouponCodeClick() {
|
|
455
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
456
|
-
navigator.clipboard.writeText(couponCode).then(() => {
|
|
457
|
-
// Show temporary feedback
|
|
458
|
-
const codeElement = document.querySelector('.coupon-code-text');
|
|
459
|
-
if (codeElement) {
|
|
460
|
-
const originalText = codeElement.textContent;
|
|
461
|
-
codeElement.textContent = 'Copied!';
|
|
462
|
-
setTimeout(() => {
|
|
463
|
-
codeElement.textContent = originalText;
|
|
464
|
-
}, 1500);
|
|
465
|
-
}
|
|
466
|
-
}).catch(err => {
|
|
467
|
-
console.warn('Failed to copy coupon code:', err);
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Set up event listeners
|
|
473
|
-
function setupEventListeners() {
|
|
474
|
-
if (!popupElement) return;
|
|
475
|
-
|
|
476
|
-
// Close button
|
|
477
|
-
const closeBtn = popupElement.querySelector('#close-popup');
|
|
478
|
-
if (closeBtn) {
|
|
479
|
-
closeBtn.addEventListener('click', () => hidePopup());
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// Dismiss button
|
|
483
|
-
const dismissBtn = popupElement.querySelector('#dismiss-popup');
|
|
484
|
-
if (dismissBtn) {
|
|
485
|
-
dismissBtn.addEventListener('click', () => {
|
|
486
|
-
const dontShowCheckbox = popupElement.querySelector('#dont-show-again');
|
|
487
|
-
const dontShow = dontShowCheckbox && dontShowCheckbox.checked;
|
|
488
|
-
hidePopup(dontShow);
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// Coupon code click to copy
|
|
493
|
-
const couponCodeElement = popupElement.querySelector('.coupon-code');
|
|
494
|
-
if (couponCodeElement) {
|
|
495
|
-
couponCodeElement.addEventListener('click', handleCouponCodeClick);
|
|
496
|
-
couponCodeElement.style.cursor = 'pointer';
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// Click outside to close
|
|
500
|
-
popupElement.addEventListener('click', (e) => {
|
|
501
|
-
if (e.target === popupElement) {
|
|
502
|
-
hidePopup();
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
// Escape key to close
|
|
507
|
-
document.addEventListener('keydown', (e) => {
|
|
508
|
-
if (e.key === 'Escape' && !popupElement.classList.contains('hidden')) {
|
|
509
|
-
hidePopup();
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// Initialize the popup
|
|
515
|
-
async function initializePopup() {
|
|
516
|
-
try {
|
|
517
|
-
// Check if popup should be shown
|
|
518
|
-
if (!shouldShowPopup()) {
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// Create popup element
|
|
523
|
-
popupElement = createPopupElement();
|
|
524
|
-
container.appendChild(popupElement);
|
|
525
|
-
|
|
526
|
-
// Set up event listeners
|
|
527
|
-
setupEventListeners();
|
|
528
|
-
|
|
529
|
-
// Load cart data
|
|
530
|
-
const cartData = await loadCurrentCart();
|
|
531
|
-
|
|
532
|
-
// Check if cart meets minimum value requirement
|
|
533
|
-
if (!meetsMinimumValue(cartData)) {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// Render cart content
|
|
538
|
-
renderCartContent(cartData);
|
|
539
|
-
|
|
540
|
-
// Show popup with a slight delay for better UX
|
|
541
|
-
setTimeout(() => {
|
|
542
|
-
showPopup();
|
|
543
|
-
}, 1000);
|
|
544
|
-
|
|
545
|
-
} catch (error) {
|
|
546
|
-
console.error('Failed to initialize cart coupon popup:', error);
|
|
547
|
-
|
|
548
|
-
// Show error state in popup if it exists
|
|
549
|
-
const cartContent = document.getElementById('cart-content');
|
|
550
|
-
if (cartContent) {
|
|
551
|
-
cartContent.innerHTML = '<div class="error">Failed to load cart. Please try again later.</div>';
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// Start initialization when DOM is ready
|
|
557
|
-
if (document.readyState === 'loading') {
|
|
558
|
-
document.addEventListener('DOMContentLoaded', initializePopup);
|
|
559
|
-
} else {
|
|
560
|
-
initializePopup();
|
|
561
|
-
}
|
|
562
|
-
</script>
|
package/dist/examples-apps/coupon-popup/src/site/embedded-scripts/cart-coupon-popup/extensions.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { extensions } from '@wix/astro/builders';
|
|
2
|
-
export const embeddedscriptcartCouponPopup = extensions.embeddedScript({
|
|
3
|
-
"id": "dbdbfc9a-23d0-45f8-9cb7-4b9c357d366f",
|
|
4
|
-
"name": "Cart & Coupon Popup",
|
|
5
|
-
"source": "./site/embedded-scripts/cart-coupon-popup/embedded.html",
|
|
6
|
-
"placement": "BODY_END",
|
|
7
|
-
"scriptType": "FUNCTIONAL"
|
|
8
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import { inputs } from '@wix/editor';
|
|
3
|
-
import { FormField, Box, FillPreview, SidePanel } from '@wix/design-system';
|
|
4
|
-
|
|
5
|
-
interface ColorPickerFieldProps {
|
|
6
|
-
label: string;
|
|
7
|
-
value: string;
|
|
8
|
-
onChange: (value: string) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const ColorPickerField: FC<ColorPickerFieldProps> = ({
|
|
12
|
-
label,
|
|
13
|
-
value,
|
|
14
|
-
onChange,
|
|
15
|
-
}) => (
|
|
16
|
-
<SidePanel.Field>
|
|
17
|
-
<FormField label={label}>
|
|
18
|
-
<Box width="30px" height="30px">
|
|
19
|
-
<FillPreview
|
|
20
|
-
fill={value}
|
|
21
|
-
onClick={() => inputs.selectColor(value, { onChange })}
|
|
22
|
-
/>
|
|
23
|
-
</Box>
|
|
24
|
-
</FormField>
|
|
25
|
-
</SidePanel.Field>
|
|
26
|
-
);
|
|
27
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import { inputs } from '@wix/editor';
|
|
3
|
-
import { FormField, Button, Text, SidePanel } from '@wix/design-system';
|
|
4
|
-
|
|
5
|
-
interface FontValue {
|
|
6
|
-
font: string;
|
|
7
|
-
textDecoration: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface FontPickerFieldProps {
|
|
11
|
-
label: string;
|
|
12
|
-
value: FontValue;
|
|
13
|
-
onChange: (value: FontValue) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const FontPickerField: FC<FontPickerFieldProps> = ({
|
|
17
|
-
label,
|
|
18
|
-
value,
|
|
19
|
-
onChange,
|
|
20
|
-
}) => (
|
|
21
|
-
<SidePanel.Field>
|
|
22
|
-
<FormField label={label}>
|
|
23
|
-
<Button
|
|
24
|
-
size="small"
|
|
25
|
-
priority="secondary"
|
|
26
|
-
onClick={() => inputs.selectFont(value, { onChange })}
|
|
27
|
-
fullWidth
|
|
28
|
-
>
|
|
29
|
-
<Text size="small" ellipsis>Change Font</Text>
|
|
30
|
-
</Button>
|
|
31
|
-
</FormField>
|
|
32
|
-
</SidePanel.Field>
|
|
33
|
-
);
|
|
34
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
|
|
3
|
-
interface TimeBlockProps {
|
|
4
|
-
value: string;
|
|
5
|
-
label: string;
|
|
6
|
-
numberStyle: React.CSSProperties;
|
|
7
|
-
labelStyle: React.CSSProperties;
|
|
8
|
-
blockStyle: React.CSSProperties;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const TimeBlock: FC<TimeBlockProps> = ({
|
|
12
|
-
value,
|
|
13
|
-
label,
|
|
14
|
-
numberStyle,
|
|
15
|
-
labelStyle,
|
|
16
|
-
blockStyle,
|
|
17
|
-
}) => (
|
|
18
|
-
<div style={blockStyle}>
|
|
19
|
-
<div style={numberStyle}>{value}</div>
|
|
20
|
-
<div style={labelStyle}>{label}</div>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { extensions } from '@wix/astro/builders';
|
|
2
|
-
export const sitewidgetcountdownWidget = extensions.customElement({
|
|
3
|
-
id: '54db089e-aa5b-436a-9dfa-074f2efad2ce',
|
|
4
|
-
name: 'Countdown Widget',
|
|
5
|
-
tagName: 'countdown-widget',
|
|
6
|
-
element: './site/widgets/custom-elements/countdown-widget/widget.tsx',
|
|
7
|
-
settings: './site/widgets/custom-elements/countdown-widget/panel.tsx',
|
|
8
|
-
installation: {
|
|
9
|
-
autoAdd: true
|
|
10
|
-
},
|
|
11
|
-
width: {
|
|
12
|
-
defaultWidth: 500,
|
|
13
|
-
allowStretch: true
|
|
14
|
-
},
|
|
15
|
-
height: {
|
|
16
|
-
defaultHeight: 500
|
|
17
|
-
}
|
|
18
|
-
})
|