@useinsider/guido 3.7.2-beta.13c9a35 → 3.7.2-beta.1489585
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/@types/config/schemas.js +66 -70
- package/dist/composables/usePreviewMode.js +14 -15
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +78 -92
- package/dist/config/migrator/recommendation/htmlBuilder.js +58 -59
- package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
- package/dist/extensions/Blocks/Recommendation/block.js +41 -60
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -10
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +288 -369
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +82 -96
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +30 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +28 -34
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +288 -338
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +5 -7
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +155 -215
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -31
- package/dist/extensions/Blocks/Recommendation/templates/index.js +29 -10
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +145 -133
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +43 -22
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +109 -92
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +216 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
- package/dist/extensions/Blocks/controlFactories.js +159 -133
- package/dist/src/@types/config/schemas.d.ts +0 -16
- package/dist/src/composables/useConfig.d.ts +0 -4
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +20 -47
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -13
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +163 -41
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
- package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
- package/dist/src/stores/config.d.ts +0 -36
- package/package.json +1 -1
- package/dist/composables/useRecommendationPreview.js +0 -100
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
- package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleFolderDefaults as S } from "../../enums/defaults.js";
|
|
2
|
-
import { object as
|
|
2
|
+
import { object as o, number as n, optional as e, string as t, picklist as l, pipe as p, minLength as b, custom as h, boolean as a, array as c, record as k, literal as i, looseObject as y, variant as g, union as f, unknown as s } from "../../node_modules/valibot/dist/index.js";
|
|
3
3
|
const d = {
|
|
4
4
|
/** Promotional/marketing emails */
|
|
5
5
|
PROMOTIONAL: 1,
|
|
@@ -12,7 +12,7 @@ const d = {
|
|
|
12
12
|
ARCHITECT: 49,
|
|
13
13
|
/** Unsubscribe page builder */
|
|
14
14
|
UNSUBSCRIBE_PAGES: 97
|
|
15
|
-
}, R =
|
|
15
|
+
}, R = o({
|
|
16
16
|
/** Unique identifier for the template being edited */
|
|
17
17
|
templateId: p(
|
|
18
18
|
t(),
|
|
@@ -25,12 +25,12 @@ const d = {
|
|
|
25
25
|
),
|
|
26
26
|
/** Optional variation ID for A/B testing */
|
|
27
27
|
variationId: e(t())
|
|
28
|
-
}),
|
|
28
|
+
}), C = o({
|
|
29
29
|
/** Fallback font name (e.g., "Georgia") */
|
|
30
30
|
name: t(),
|
|
31
31
|
/** Fallback font family (e.g., "serif" or "sans-serif") */
|
|
32
32
|
family: t()
|
|
33
|
-
}),
|
|
33
|
+
}), T = o({
|
|
34
34
|
/** Partner/organization name (required) */
|
|
35
35
|
name: p(
|
|
36
36
|
t(),
|
|
@@ -53,8 +53,8 @@ const d = {
|
|
|
53
53
|
/** Display name for the current user */
|
|
54
54
|
username: e(t(), "Guido User"),
|
|
55
55
|
/** Fallback font settings from partner settings — used to match backend size calculation */
|
|
56
|
-
fallbackFont: e(
|
|
57
|
-
}), A =
|
|
56
|
+
fallbackFont: e(C)
|
|
57
|
+
}), A = o({
|
|
58
58
|
/** Display text for the dynamic content */
|
|
59
59
|
text: t(),
|
|
60
60
|
/** Template variable value (e.g., {{username}}) */
|
|
@@ -63,57 +63,53 @@ const d = {
|
|
|
63
63
|
fallback: e(t()),
|
|
64
64
|
/** Optional formatting options */
|
|
65
65
|
format: e(
|
|
66
|
-
|
|
66
|
+
o({
|
|
67
67
|
key: t(),
|
|
68
68
|
value: t()
|
|
69
69
|
})
|
|
70
70
|
)
|
|
71
71
|
}), I = y({
|
|
72
72
|
/** Block ID (matches the dictionary key and the legacy HTML element id) */
|
|
73
|
-
id: e(
|
|
73
|
+
id: e(n()),
|
|
74
74
|
/** Decimal places for price display (legacy data may use string or number) */
|
|
75
|
-
decimalCount: e(f([t(),
|
|
75
|
+
decimalCount: e(f([t(), n()])),
|
|
76
76
|
/** Pinned product IDs (empty array when filter-driven) */
|
|
77
|
-
productIds: e(c(
|
|
77
|
+
productIds: e(c(s())),
|
|
78
78
|
/** Whether the block requested live products at send time */
|
|
79
|
-
sendProductRequestFlag: e(
|
|
79
|
+
sendProductRequestFlag: e(a()),
|
|
80
80
|
/** Whether to randomize product order */
|
|
81
|
-
shuffleProducts: e(
|
|
81
|
+
shuffleProducts: e(a()),
|
|
82
82
|
/** Filter rules driving product selection */
|
|
83
|
-
filters: e(c(
|
|
83
|
+
filters: e(c(s())),
|
|
84
84
|
/** Currency code (e.g. 'EUR') — sometimes absent in legacy data */
|
|
85
85
|
currency: e(t()),
|
|
86
86
|
/** Currency display settings (separators, alignment, decimals) */
|
|
87
|
-
currencySettings: e(
|
|
87
|
+
currencySettings: e(s()),
|
|
88
88
|
/** Locale (e.g. 'nl_NL') */
|
|
89
89
|
language: e(t()),
|
|
90
90
|
/** Recommendation strategy key (e.g. 'newArrivals') */
|
|
91
91
|
strategy: e(t()),
|
|
92
92
|
/** Snapshot of products as rendered by the legacy block */
|
|
93
|
-
recommendedProducts: e(c(
|
|
93
|
+
recommendedProducts: e(c(s())),
|
|
94
94
|
/** Number of product cards per row */
|
|
95
|
-
cardsInRow: e(
|
|
95
|
+
cardsInRow: e(n()),
|
|
96
96
|
/** Mobile-only padding (right) */
|
|
97
|
-
mobileRightPadding: e(
|
|
97
|
+
mobileRightPadding: e(n()),
|
|
98
98
|
/** Mobile-only padding (left) */
|
|
99
|
-
mobileLeftPadding: e(
|
|
99
|
+
mobileLeftPadding: e(n()),
|
|
100
100
|
/** Disable responsive scaling */
|
|
101
|
-
unresponsive: e(
|
|
101
|
+
unresponsive: e(a()),
|
|
102
102
|
/** Layout orientation ('vertical' | 'horizontal') */
|
|
103
103
|
orientation: e(t()),
|
|
104
104
|
/** Whether long text is trimmed */
|
|
105
|
-
textTrimming: e(
|
|
105
|
+
textTrimming: e(a()),
|
|
106
106
|
/** Block type marker used by some legacy variants */
|
|
107
107
|
blockType: e(t()),
|
|
108
108
|
/** Size variant marker (legacy data may use string or number) */
|
|
109
|
-
size: e(f([t(),
|
|
109
|
+
size: e(f([t(), n()])),
|
|
110
110
|
/** Vertical responsiveness flag (legacy size=1 variants) */
|
|
111
|
-
verticalResponsiveness: e(
|
|
112
|
-
|
|
113
|
-
isPriceMovedToNextLine: e(o()),
|
|
114
|
-
/** Legacy "Hide if same as discounted" / delete-price-for-zero-sale toggle */
|
|
115
|
-
isPriceDeletedForZeroSale: e(o())
|
|
116
|
-
}), L = a({
|
|
111
|
+
verticalResponsiveness: e(a())
|
|
112
|
+
}), E = o({
|
|
117
113
|
/**
|
|
118
114
|
* Legacy recommendation block configs keyed by block ID.
|
|
119
115
|
* Pass this when loading a template authored with the v1
|
|
@@ -124,7 +120,7 @@ const d = {
|
|
|
124
120
|
k(t(), I),
|
|
125
121
|
{}
|
|
126
122
|
)
|
|
127
|
-
}),
|
|
123
|
+
}), L = o({
|
|
128
124
|
/** Initial HTML content */
|
|
129
125
|
html: e(t(), ""),
|
|
130
126
|
/** Initial CSS content */
|
|
@@ -137,53 +133,53 @@ const d = {
|
|
|
137
133
|
/** Valid custom field attribute names from the partner's categorized fields */
|
|
138
134
|
customFieldAttributes: e(c(t()), []),
|
|
139
135
|
/** Selected unsubscribe page IDs */
|
|
140
|
-
selectedUnsubscribePages: e(c(
|
|
136
|
+
selectedUnsubscribePages: e(c(n()), []),
|
|
141
137
|
/** Force recreate template in Stripo storage (use true when updating externally modified templates) */
|
|
142
|
-
forceRecreate: e(
|
|
138
|
+
forceRecreate: e(a(), !1),
|
|
143
139
|
/** Migration-only inputs (legacy block configs) */
|
|
144
|
-
migration: e(
|
|
145
|
-
}),
|
|
140
|
+
migration: e(E, {})
|
|
141
|
+
}), O = o({
|
|
146
142
|
/** Sender display name */
|
|
147
143
|
senderName: e(t(), ""),
|
|
148
144
|
/** Email subject line */
|
|
149
145
|
subject: e(t(), "")
|
|
150
|
-
}),
|
|
146
|
+
}), v = o({
|
|
151
147
|
/** Locale for the editor UI */
|
|
152
148
|
locale: e(t(), "en"),
|
|
153
149
|
/** Path to translations object */
|
|
154
150
|
translationsPath: e(t(), "window.trans[Object.keys(window.trans)[0]]"),
|
|
155
151
|
/** Migration date for template compatibility */
|
|
156
|
-
migrationDate: e(
|
|
152
|
+
migrationDate: e(n(), 1759696858),
|
|
157
153
|
/** Email header settings */
|
|
158
|
-
emailHeader: e(
|
|
154
|
+
emailHeader: e(O, { senderName: "", subject: "" }),
|
|
159
155
|
/** Folder name for user-saved modules (used by Stripo plugin panel for path construction) */
|
|
160
156
|
savedModulesFolderName: e(t(), S.SAVED_MODULES),
|
|
161
157
|
/** Folder name for default/prebuilt modules (used by Stripo plugin panel for path construction) */
|
|
162
158
|
defaultModulesFolderName: e(t(), S.DEFAULT_MODULES)
|
|
163
|
-
}), M =
|
|
159
|
+
}), M = o({
|
|
164
160
|
/** Whether to show the header bar */
|
|
165
|
-
showHeader: e(
|
|
161
|
+
showHeader: e(a(), !0),
|
|
166
162
|
/** Custom label for back button (if shown) */
|
|
167
163
|
backButtonLabel: e(t())
|
|
168
|
-
}),
|
|
164
|
+
}), P = o({
|
|
169
165
|
/** Enable dynamic content insertion */
|
|
170
|
-
dynamicContent: e(
|
|
166
|
+
dynamicContent: e(a(), !0),
|
|
171
167
|
/** Enable save as template functionality */
|
|
172
|
-
saveAsTemplate: e(
|
|
168
|
+
saveAsTemplate: e(a(), !0),
|
|
173
169
|
/** Enable version history */
|
|
174
|
-
versionHistory: e(
|
|
170
|
+
versionHistory: e(a(), !0),
|
|
175
171
|
/** Enable test message sending */
|
|
176
|
-
testMessage: e(
|
|
172
|
+
testMessage: e(a(), !0),
|
|
177
173
|
/** Enable display conditions */
|
|
178
|
-
displayConditions: e(
|
|
174
|
+
displayConditions: e(a(), !0),
|
|
179
175
|
/** Enable unsubscribe block */
|
|
180
|
-
unsubscribe: e(
|
|
176
|
+
unsubscribe: e(a(), !0),
|
|
181
177
|
/** Disable modules panel in the editor */
|
|
182
|
-
modulesDisabled: e(
|
|
178
|
+
modulesDisabled: e(a(), !1),
|
|
183
179
|
/** Enable Liquid template syntax */
|
|
184
|
-
liquidSyntax: e(
|
|
180
|
+
liquidSyntax: e(a(), !1),
|
|
185
181
|
/** Enable autosave (3-min interval + tab-hide). User toggles on/off from the header. */
|
|
186
|
-
autosave: e(
|
|
182
|
+
autosave: e(a(), !1)
|
|
187
183
|
}), N = l([
|
|
188
184
|
"amp-accordion",
|
|
189
185
|
"amp-carousel",
|
|
@@ -206,7 +202,7 @@ const d = {
|
|
|
206
202
|
"unsubscribe-block",
|
|
207
203
|
"coupon-block",
|
|
208
204
|
"items-block"
|
|
209
|
-
]), x =
|
|
205
|
+
]), x = o({
|
|
210
206
|
/** Default blocks to exclude from the editor */
|
|
211
207
|
excludeDefaults: e(
|
|
212
208
|
c(N),
|
|
@@ -217,14 +213,14 @@ const d = {
|
|
|
217
213
|
c(D),
|
|
218
214
|
[]
|
|
219
215
|
)
|
|
220
|
-
}), m =
|
|
216
|
+
}), m = o({
|
|
221
217
|
/** Unique identifier for the rule */
|
|
222
218
|
id: t(),
|
|
223
219
|
/** Human-readable description */
|
|
224
220
|
description: e(t()),
|
|
225
221
|
/** Priority for rule ordering (lower = earlier) */
|
|
226
|
-
priority:
|
|
227
|
-
}), F =
|
|
222
|
+
priority: n()
|
|
223
|
+
}), F = o({
|
|
228
224
|
...m.entries,
|
|
229
225
|
type: i("replace"),
|
|
230
226
|
/** String to search for */
|
|
@@ -232,8 +228,8 @@ const d = {
|
|
|
232
228
|
/** Replacement string */
|
|
233
229
|
replacement: t(),
|
|
234
230
|
/** Replace all occurrences (default: false) */
|
|
235
|
-
replaceAll: e(
|
|
236
|
-
}), U =
|
|
231
|
+
replaceAll: e(a())
|
|
232
|
+
}), U = o({
|
|
237
233
|
...m.entries,
|
|
238
234
|
type: i("regex"),
|
|
239
235
|
/** Regex pattern string */
|
|
@@ -242,12 +238,12 @@ const d = {
|
|
|
242
238
|
replacement: t(),
|
|
243
239
|
/** Regex flags (e.g., 'gi') */
|
|
244
240
|
flags: e(t())
|
|
245
|
-
}), B =
|
|
241
|
+
}), B = o({
|
|
246
242
|
...m.entries,
|
|
247
243
|
type: i("remove"),
|
|
248
244
|
/** Strings or patterns to remove */
|
|
249
245
|
targets: c(t())
|
|
250
|
-
}), w =
|
|
246
|
+
}), w = o({
|
|
251
247
|
...m.entries,
|
|
252
248
|
type: i("custom"),
|
|
253
249
|
/** Custom processor function */
|
|
@@ -260,12 +256,12 @@ const d = {
|
|
|
260
256
|
U,
|
|
261
257
|
B,
|
|
262
258
|
w
|
|
263
|
-
]), j =
|
|
259
|
+
]), j = o({
|
|
264
260
|
/** Custom compiler rules to apply */
|
|
265
261
|
customRules: e(c(H), []),
|
|
266
262
|
/** Skip default compiler rules */
|
|
267
|
-
ignoreDefaultRules: e(
|
|
268
|
-
}), q =
|
|
263
|
+
ignoreDefaultRules: e(a(), !1)
|
|
264
|
+
}), q = o({
|
|
269
265
|
/**
|
|
270
266
|
* External validation handler called before save completes.
|
|
271
267
|
* Return false to cancel the save operation.
|
|
@@ -276,21 +272,21 @@ const d = {
|
|
|
276
272
|
"externalValidation must be a function"
|
|
277
273
|
)
|
|
278
274
|
)
|
|
279
|
-
}), V =
|
|
275
|
+
}), V = o({
|
|
280
276
|
// Required sections
|
|
281
277
|
/** Identity configuration (required) */
|
|
282
278
|
identity: R,
|
|
283
279
|
/** Partner configuration (required) */
|
|
284
|
-
partner:
|
|
280
|
+
partner: T,
|
|
285
281
|
// Optional sections (with defaults)
|
|
286
282
|
/** Template content and presets */
|
|
287
|
-
template: e(
|
|
283
|
+
template: e(L, {}),
|
|
288
284
|
/** Editor settings */
|
|
289
|
-
editor: e(
|
|
285
|
+
editor: e(v, {}),
|
|
290
286
|
/** UI configuration */
|
|
291
287
|
ui: e(M, {}),
|
|
292
288
|
/** Feature toggles */
|
|
293
|
-
features: e(
|
|
289
|
+
features: e(P, {}),
|
|
294
290
|
/** Block configuration */
|
|
295
291
|
blocks: e(x, {}),
|
|
296
292
|
/** Compiler configuration */
|
|
@@ -307,20 +303,20 @@ export {
|
|
|
307
303
|
w as CustomRuleSchema,
|
|
308
304
|
N as DefaultBlockTypeSchema,
|
|
309
305
|
A as DynamicContentSchema,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
306
|
+
v as EditorSchema,
|
|
307
|
+
O as EmailHeaderSchema,
|
|
308
|
+
C as FallbackFontSchema,
|
|
309
|
+
P as FeaturesSchema,
|
|
314
310
|
V as GuidoConfigSchema,
|
|
315
311
|
R as IdentitySchema,
|
|
316
312
|
I as LegacyRecommendationConfigSchema,
|
|
317
313
|
d as MessageType,
|
|
318
|
-
|
|
314
|
+
T as PartnerSchema,
|
|
319
315
|
r as ProductType,
|
|
320
316
|
U as RegexRuleSchema,
|
|
321
317
|
B as RemoveRuleSchema,
|
|
322
318
|
F as ReplaceRuleSchema,
|
|
323
|
-
|
|
324
|
-
|
|
319
|
+
E as TemplateMigrationSchema,
|
|
320
|
+
L as TemplateSchema,
|
|
325
321
|
M as UISchema
|
|
326
322
|
};
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { useEditorStore as
|
|
2
|
-
import { usePreviewStore as
|
|
3
|
-
import { useActionsApi as
|
|
4
|
-
import { useCodeEditorApi as
|
|
5
|
-
import { useHtmlCompiler as
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const t = n(), e = p(), { closeCodeEditor: a } = u(), { getPreviewData: m, getCompiledEmail: s } = c(), { compileHtml: l } = v(), { substituteRecommendationPreview: r } = w(), i = () => {
|
|
1
|
+
import { useEditorStore as d } from "../stores/editor.js";
|
|
2
|
+
import { usePreviewStore as n } from "../stores/preview.js";
|
|
3
|
+
import { useActionsApi as p } from "./useActionsApi.js";
|
|
4
|
+
import { useCodeEditorApi as c } from "./useCodeEditorApi.js";
|
|
5
|
+
import { useHtmlCompiler as u } from "./useHtmlCompiler.js";
|
|
6
|
+
const g = () => {
|
|
7
|
+
const t = d(), e = n(), { closeCodeEditor: i } = c(), { getPreviewData: a, getCompiledEmail: s } = p(), { compileHtml: m } = u(), r = () => {
|
|
9
8
|
t.isPreviewModeOpen = !1, e.$reset();
|
|
10
9
|
};
|
|
11
10
|
return {
|
|
12
|
-
closePreviewMode:
|
|
11
|
+
closePreviewMode: r,
|
|
13
12
|
openPreviewMode: () => {
|
|
14
|
-
t.isCodeEditorOpen &&
|
|
13
|
+
t.isCodeEditorOpen && i(), t.isPreviewModeOpen = !0;
|
|
15
14
|
},
|
|
16
15
|
loadPreviewData: async () => {
|
|
17
16
|
if (!(t.loadingStatus || e.isLoaded)) {
|
|
18
17
|
t.loadingStatus = !0;
|
|
19
18
|
try {
|
|
20
|
-
const [o,
|
|
21
|
-
|
|
19
|
+
const [o, l] = await Promise.all([
|
|
20
|
+
a(),
|
|
22
21
|
s({ minimize: !0, resetDataSavedFlag: !1 })
|
|
23
22
|
]);
|
|
24
|
-
e.templateHtml =
|
|
23
|
+
e.templateHtml = o.html || "", e.ampHtml = o.ampHtml || "", e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = m(l.html).estimatedSizeKB, e.isLoaded = !0;
|
|
25
24
|
} catch (o) {
|
|
26
|
-
console.error("Failed to load preview data:", o),
|
|
25
|
+
console.error("Failed to load preview data:", o), r();
|
|
27
26
|
} finally {
|
|
28
27
|
t.loadingStatus = !1;
|
|
29
28
|
}
|
|
@@ -32,5 +31,5 @@ const C = () => {
|
|
|
32
31
|
};
|
|
33
32
|
};
|
|
34
33
|
export {
|
|
35
|
-
|
|
34
|
+
g as usePreviewMode
|
|
36
35
|
};
|
|
@@ -2,158 +2,144 @@ import { useConfig as _ } from "../../../composables/useConfig.js";
|
|
|
2
2
|
import { useRecommendation as g } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
function
|
|
6
|
-
const c = `{{${
|
|
7
|
-
return o === "before" ? `${
|
|
5
|
+
function h(r, n, e, o, i = "") {
|
|
6
|
+
const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
|
|
7
|
+
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function b(r) {
|
|
10
10
|
let n = r;
|
|
11
11
|
for (; n.children.length === 1; )
|
|
12
12
|
[n] = n.children;
|
|
13
13
|
return n;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function A(r, n, e, o, i, c) {
|
|
16
16
|
switch (n) {
|
|
17
17
|
case "productImage": {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
18
|
+
const t = r.querySelector("img");
|
|
19
|
+
t && (t.setAttribute("src", `{{${c}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${c}${e}_${o}_name}}`));
|
|
20
|
+
const s = r.querySelector("a");
|
|
21
|
+
s && (s.setAttribute("href", `{{${c}${e}_${o}_url}}`), s.classList.add(q));
|
|
22
22
|
break;
|
|
23
23
|
}
|
|
24
24
|
case "productName": {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const i = e.querySelector("strong") || e;
|
|
28
|
-
i.textContent = `{{${c}${t}_${o}_name}}`;
|
|
29
|
-
}
|
|
25
|
+
const t = r.querySelector("p");
|
|
26
|
+
t && (b(t).textContent = `{{${c}${e}_${o}_name}}`);
|
|
30
27
|
break;
|
|
31
28
|
}
|
|
32
29
|
case "productPrice": {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const t = r.querySelector("p");
|
|
31
|
+
t && (b(t).textContent = h(
|
|
32
|
+
e,
|
|
36
33
|
o,
|
|
37
34
|
"price",
|
|
38
|
-
|
|
39
|
-
c
|
|
40
|
-
));
|
|
41
|
-
const i = r.querySelector(".product-old-price p");
|
|
42
|
-
i && (f(i).textContent = b(
|
|
43
|
-
t,
|
|
44
|
-
o,
|
|
45
|
-
"original_price",
|
|
46
|
-
s,
|
|
35
|
+
i,
|
|
47
36
|
c
|
|
48
37
|
));
|
|
49
38
|
break;
|
|
50
39
|
}
|
|
51
40
|
case "productOldPrice": {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
const t = r.querySelector("p");
|
|
42
|
+
t && (b(t).textContent = h(
|
|
43
|
+
e,
|
|
55
44
|
o,
|
|
56
45
|
"original_price",
|
|
57
|
-
|
|
46
|
+
i,
|
|
58
47
|
c
|
|
59
|
-
));
|
|
48
|
+
), t.setAttribute("product-attr", "discount"));
|
|
60
49
|
break;
|
|
61
50
|
}
|
|
62
51
|
case "productButton": {
|
|
63
|
-
const
|
|
64
|
-
|
|
52
|
+
const t = r.querySelector("a");
|
|
53
|
+
t && t.setAttribute("href", `{{${c}${e}_${o}_url}}`);
|
|
65
54
|
break;
|
|
66
55
|
}
|
|
67
56
|
case "productOmnibusPrice": {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
57
|
+
const t = r.querySelector(".omnibus-price-value");
|
|
58
|
+
if (t) {
|
|
59
|
+
t.textContent = `{{${c}${e}_${o}_omnibus_price}}`;
|
|
60
|
+
const s = t.closest("p");
|
|
61
|
+
s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
|
|
73
62
|
}
|
|
74
63
|
break;
|
|
75
64
|
}
|
|
76
65
|
case "productOmnibusDiscount": {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
66
|
+
const t = r.querySelector(".omnibus-discount-value");
|
|
67
|
+
if (t) {
|
|
68
|
+
t.textContent = `{{${c}${e}_${o}_omnibus_discount}}`;
|
|
69
|
+
const s = t.closest("p");
|
|
70
|
+
s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
|
|
82
71
|
}
|
|
83
72
|
break;
|
|
84
73
|
}
|
|
85
74
|
default: {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
const u = a.querySelector("strong") || a;
|
|
91
|
-
u.textContent = `{{${c}${t}_${o}_${i}}}`;
|
|
92
|
-
}
|
|
75
|
+
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
76
|
+
if (t) {
|
|
77
|
+
const s = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
78
|
+
a && (b(a).textContent = `{{${c}${e}_${o}_${s}}}`);
|
|
93
79
|
}
|
|
94
80
|
break;
|
|
95
81
|
}
|
|
96
82
|
}
|
|
97
83
|
}
|
|
98
|
-
function w(r, n,
|
|
99
|
-
r.querySelectorAll(".recommendation-product-row").forEach((c,
|
|
84
|
+
function w(r, n, e, o) {
|
|
85
|
+
r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
|
|
100
86
|
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
101
87
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
102
88
|
p.length > 0 ? p.forEach((l) => {
|
|
103
|
-
|
|
104
|
-
}) :
|
|
89
|
+
A(l, u, n, t, e, o);
|
|
90
|
+
}) : A(a, u, n, t, e, o);
|
|
105
91
|
});
|
|
106
92
|
});
|
|
107
93
|
}
|
|
108
|
-
function E(r, n,
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
94
|
+
function E(r, n, e, o) {
|
|
95
|
+
const i = r.querySelectorAll(".recommendation-product-row");
|
|
96
|
+
if (!i.length)
|
|
111
97
|
return;
|
|
112
|
-
const [c] =
|
|
113
|
-
|
|
98
|
+
const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
99
|
+
i.forEach((a, u) => {
|
|
114
100
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
115
101
|
const d = l.getAttribute("data-attribute-type") || "";
|
|
116
|
-
l.querySelectorAll(".attribute-cell").forEach((
|
|
117
|
-
const S = u *
|
|
118
|
-
|
|
102
|
+
l.querySelectorAll(".attribute-cell").forEach((y, $) => {
|
|
103
|
+
const S = u * s + $;
|
|
104
|
+
A(y, d, n, S, e, o);
|
|
119
105
|
});
|
|
120
106
|
});
|
|
121
107
|
});
|
|
122
108
|
}
|
|
123
|
-
function
|
|
109
|
+
function R(r, n, e, o) {
|
|
124
110
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
125
|
-
E(c, n,
|
|
111
|
+
E(c, n, e, o);
|
|
126
112
|
});
|
|
127
113
|
}
|
|
128
|
-
function
|
|
129
|
-
const o = r.getAttribute("data-layout") || "grid",
|
|
130
|
-
o === "list" ? w(r, n,
|
|
114
|
+
function P(r, n, e) {
|
|
115
|
+
const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
|
|
116
|
+
o === "list" ? w(r, n, i, e) : R(r, n, i, e);
|
|
131
117
|
}
|
|
132
|
-
function
|
|
133
|
-
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"),
|
|
134
|
-
return
|
|
118
|
+
function f(r, n, e) {
|
|
119
|
+
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
|
|
120
|
+
return i ? parseInt(i[1]) : e;
|
|
135
121
|
}
|
|
136
|
-
function
|
|
137
|
-
let
|
|
138
|
-
for (;
|
|
139
|
-
if (
|
|
140
|
-
const o =
|
|
122
|
+
function T(r, n) {
|
|
123
|
+
let e = r.parentElement;
|
|
124
|
+
for (; e && e !== n; ) {
|
|
125
|
+
if (e.tagName === "TD") {
|
|
126
|
+
const o = e.getAttribute("width");
|
|
141
127
|
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
142
|
-
return
|
|
128
|
+
return e;
|
|
143
129
|
}
|
|
144
|
-
|
|
130
|
+
e = e.parentElement;
|
|
145
131
|
}
|
|
146
132
|
return null;
|
|
147
133
|
}
|
|
148
|
-
function
|
|
149
|
-
const n = r.getAttribute("style") || "",
|
|
150
|
-
|
|
134
|
+
function v(r) {
|
|
135
|
+
const n = r.getAttribute("style") || "", e = f(n, "width", 600), o = f(n, "padding", 0) * 2, i = Math.max(0, e - o);
|
|
136
|
+
i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
151
137
|
if (c.hasAttribute("width"))
|
|
152
138
|
return;
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
139
|
+
const t = T(c, r);
|
|
140
|
+
if (!t)
|
|
155
141
|
return;
|
|
156
|
-
const
|
|
142
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = f(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
|
|
157
143
|
c.setAttribute("width", String(l));
|
|
158
144
|
const d = c.getAttribute("style") || "";
|
|
159
145
|
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
@@ -162,25 +148,25 @@ function T(r) {
|
|
|
162
148
|
}
|
|
163
149
|
});
|
|
164
150
|
}
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
return (
|
|
151
|
+
function O(r, n) {
|
|
152
|
+
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
153
|
+
return (e ? `${e[0]}
|
|
168
154
|
` : "") + n.documentElement.outerHTML;
|
|
169
155
|
}
|
|
170
156
|
function N(r) {
|
|
171
|
-
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"),
|
|
157
|
+
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
172
158
|
if (!o.length)
|
|
173
159
|
return r;
|
|
174
|
-
const { buildCampaignUrl:
|
|
160
|
+
const { buildCampaignUrl: i } = g(), c = C();
|
|
175
161
|
c.recommendationCampaignUrls = {};
|
|
176
|
-
const { isFeatureEnabled:
|
|
162
|
+
const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
|
|
177
163
|
return o.forEach((u) => {
|
|
178
164
|
var l, d;
|
|
179
165
|
const p = u.getAttribute("recommendation-id");
|
|
180
|
-
p && ((l = u.parentNode) == null || l.insertBefore(
|
|
181
|
-
}),
|
|
166
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
|
|
167
|
+
}), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
182
168
|
}
|
|
183
169
|
export {
|
|
184
|
-
|
|
170
|
+
h as formatPriceVariable,
|
|
185
171
|
N as prepareRecommendationBlocks
|
|
186
172
|
};
|