@useinsider/guido 3.2.0-beta.caa22bf → 3.2.0-beta.ccaf9f5
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/README.md +0 -92
- package/dist/@types/config/schemas.js +94 -150
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +75 -75
- package/dist/composables/useCortexBlueprintBridge.js +38 -0
- package/dist/composables/useEmailTemplateApplier.js +41 -0
- package/dist/composables/useRecommendation.js +26 -46
- package/dist/composables/useSave.js +18 -21
- package/dist/composables/useStripo.js +16 -14
- package/dist/config/compiler/recommendationCompilerRules.js +27 -27
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/radioButtonMigrator.js +44 -64
- package/dist/config/migrator/recommendationMigrator.js +290 -74
- package/dist/enums/displayConditions.js +80 -0
- package/dist/enums/extensions/recommendationBlock.js +1 -2
- package/dist/extensions/Blocks/RadioButton/template.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +32 -35
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +24 -25
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +181 -228
- package/dist/extensions/Blocks/Recommendation/services/configService.js +29 -65
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +90 -130
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +22 -13
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +235 -450
- package/dist/src/@types/config/defaults.d.ts +1 -5
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +0 -213
- package/dist/src/@types/config/types.d.ts +1 -9
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +0 -56
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +17 -0
- package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -10
- package/dist/src/config/migrator/index.d.ts +1 -2
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -13
- package/dist/src/enums/displayConditions.d.ts +2 -0
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -34
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +3 -0
- package/dist/src/library.d.ts +1 -1
- package/dist/src/stores/config.d.ts +0 -504
- package/dist/utils/templatePreparation.js +32 -72
- package/package.json +1 -5
- package/dist/composables/validators/useCouponBlockValidator.js +0 -24
- package/dist/config/migrator/recommendation/compositionMapper.js +0 -98
- package/dist/config/migrator/recommendation/extractors.js +0 -27
- package/dist/config/migrator/recommendation/htmlBuilder.js +0 -496
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +0 -33
- package/dist/config/migrator/recommendation/settingsMapper.js +0 -70
- package/dist/config/migrator/recommendation/themeMapper.js +0 -93
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +0 -21
- package/dist/src/composables/useRecommendation.test.d.ts +0 -1
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +0 -2
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -7
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -11
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +0 -15
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +0 -7
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +0 -5
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/types.d.ts +0 -205
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +0 -1
- package/dist/src/utils/htmlEscape.d.ts +0 -5
- package/dist/src/utils/htmlEscape.test.d.ts +0 -1
- package/dist/utils/htmlEscape.js +0 -13
|
@@ -1,81 +1,297 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var T = (d, e, t) => e in d ? h(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var A = (d, e, t) => T(d, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { BLOCK_ID as S } from "../../extensions/Blocks/Recommendation/block.js";
|
|
5
|
+
import P, { prepareProductRows as q } from "../../extensions/Blocks/Recommendation/templates/grid/migration.js";
|
|
6
|
+
import { useTemplateStore as w } from "../../stores/template.js";
|
|
7
|
+
import { getDefaultProducts as $ } from "../../extensions/Blocks/Recommendation/templates/utils.js";
|
|
8
|
+
class B {
|
|
9
|
+
constructor() {
|
|
10
|
+
A(this, "parser");
|
|
11
|
+
this.parser = new DOMParser();
|
|
12
|
+
}
|
|
13
|
+
migrate(e) {
|
|
14
|
+
try {
|
|
15
|
+
const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll(
|
|
16
|
+
'td.ins-recommendation-v3-block-1:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"]:not(.recommendation-block-v2)'
|
|
17
|
+
);
|
|
18
|
+
return w().$patch((i) => {
|
|
19
|
+
i.migrations = { ...i.migrations, [S]: s.length };
|
|
20
|
+
}), s.length === 0 ? e : (s.forEach((i) => {
|
|
21
|
+
const r = i.getAttribute("id"), n = this.extractBgColor(i), u = this.extractTitle(i), c = this.extractProductRows(i), l = P.replace("{-{-TITLE-}-}", u).replace("{-{-PRODUCT_ROWS-}-}", c), a = this.parser.parseFromString(
|
|
22
|
+
`<table id="tempDoc"><tbody><tr>${l}</tr></tbody></table>`,
|
|
23
|
+
"text/html"
|
|
24
|
+
).querySelector(".recommendation-block-v2");
|
|
25
|
+
a && i.parentNode && (r && a.setAttribute("id", r), n && a.setAttribute("bgcolor", n), i.parentNode.replaceChild(a, i));
|
|
26
|
+
}), t.documentElement.outerHTML);
|
|
27
|
+
} catch (t) {
|
|
28
|
+
return console.error("RecommendationMigrator failed:", t), e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extracts background color from old block
|
|
33
|
+
* @param block - The old recommendation block element
|
|
34
|
+
* @returns The background color value or empty string
|
|
35
|
+
*/
|
|
36
|
+
extractBgColor(e) {
|
|
37
|
+
const t = e.getAttribute("bgcolor");
|
|
38
|
+
if (t)
|
|
39
|
+
return t.trim();
|
|
40
|
+
const s = e.getAttribute("style");
|
|
41
|
+
if (s) {
|
|
42
|
+
const o = s.match(/background-color\s*:\s*([^;]+)/i);
|
|
43
|
+
if (o && o[1])
|
|
44
|
+
return o[1].trim();
|
|
45
|
+
}
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Extracts background color from product card wrapper element
|
|
50
|
+
* @param cardElement - The product card TD element
|
|
51
|
+
* @returns The background color value or empty string
|
|
52
|
+
*/
|
|
53
|
+
extractCardBgColor(e) {
|
|
54
|
+
const t = e.getAttribute("bgcolor");
|
|
55
|
+
if (t)
|
|
56
|
+
return t.trim();
|
|
57
|
+
const s = e.getAttribute("style");
|
|
58
|
+
if (s) {
|
|
59
|
+
const o = s.match(/background-color\s*:\s*([^;]+)/i);
|
|
60
|
+
if (o && o[1])
|
|
61
|
+
return o[1].trim();
|
|
62
|
+
}
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extracts title from old block and converts to new structure
|
|
67
|
+
* @param block - The old recommendation block element
|
|
68
|
+
* @returns HTML string for the title block
|
|
69
|
+
*/
|
|
70
|
+
extractTitle(e) {
|
|
71
|
+
var g, a;
|
|
72
|
+
const t = e.querySelector(".ext-recommendation-title");
|
|
73
|
+
if (!t)
|
|
74
|
+
return this.buildTitleBlock({
|
|
75
|
+
text: "You May Also Like!",
|
|
76
|
+
isBold: !0,
|
|
77
|
+
isItalic: !1,
|
|
78
|
+
align: "center",
|
|
79
|
+
styles: "font-size: 28px; color: #333333;"
|
|
80
|
+
});
|
|
81
|
+
const s = t.querySelector("p");
|
|
82
|
+
if (!s) {
|
|
83
|
+
const p = ((g = t.textContent) == null ? void 0 : g.trim()) || "You May Also Like!", b = t.getAttribute("align") || "center";
|
|
84
|
+
return this.buildTitleBlock({
|
|
85
|
+
text: p,
|
|
86
|
+
isBold: !0,
|
|
87
|
+
isItalic: !1,
|
|
88
|
+
align: b,
|
|
89
|
+
styles: "font-size: 28px; color: #333333;"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const o = ((a = s.textContent) == null ? void 0 : a.trim()) || "You May Also Like!", i = t.getAttribute("align") || s.getAttribute("align") || "center", r = s.getAttribute("style") || "", n = /font-weight\s*:\s*bold/i.test(r) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(r) || !!s.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), l = this.convertInlineToBlock(c);
|
|
93
|
+
return this.buildTitleBlock({
|
|
94
|
+
text: o,
|
|
95
|
+
isBold: n,
|
|
96
|
+
isItalic: u,
|
|
97
|
+
align: i,
|
|
98
|
+
styles: l
|
|
65
99
|
});
|
|
66
|
-
} catch {
|
|
67
100
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Extracts product configuration from old block and generates new product rows
|
|
103
|
+
* @param block - The old recommendation block element
|
|
104
|
+
* @returns HTML string for product rows
|
|
105
|
+
*/
|
|
106
|
+
extractProductRows(e) {
|
|
107
|
+
const t = this.extractProductConfig(e);
|
|
108
|
+
if (!t)
|
|
109
|
+
return console.warn("[RecommendationMigrator] No product config found, using defaults"), this.generateProductRows(6, 3, {});
|
|
110
|
+
const { totalCount: s, productsPerRow: o } = t, i = this.extractProductStyles(e);
|
|
111
|
+
return this.generateProductRows(s, o, i);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Extracts Stripo padding/margin utility classes from a class string
|
|
115
|
+
* @param classString - Space-separated class string from element
|
|
116
|
+
* @returns Filtered Stripo utility classes as a space-separated string
|
|
117
|
+
*/
|
|
118
|
+
extractStripoClasses(e) {
|
|
119
|
+
return e ? e.split(/\s+/).filter((o) => /^es-(p\d+|m[-\d])/.test(o)).join(" ") : "";
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Extracts product configuration from old block
|
|
123
|
+
* @param block - The old recommendation block element
|
|
124
|
+
* @returns Object with totalCount and productsPerRow, or null if parsing fails
|
|
125
|
+
*/
|
|
126
|
+
extractProductConfig(e) {
|
|
127
|
+
const t = e.getAttribute("esd-dev-product-config");
|
|
128
|
+
if (!t)
|
|
129
|
+
return null;
|
|
72
130
|
try {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
131
|
+
const s = this.unescapeJsonString(t), o = JSON.parse(s);
|
|
132
|
+
return {
|
|
133
|
+
totalCount: o.totalCount ?? 6,
|
|
134
|
+
productsPerRow: o.rowCount ?? 3
|
|
135
|
+
};
|
|
136
|
+
} catch (s) {
|
|
137
|
+
return console.error("[RecommendationMigrator] Failed to parse product config:", s), console.error(
|
|
138
|
+
"[RecommendationMigrator] Error details:",
|
|
139
|
+
s instanceof Error ? s.message : String(s)
|
|
140
|
+
), null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Decodes HTML entities from JSON string
|
|
145
|
+
* @param text - The encoded string
|
|
146
|
+
* @returns Decoded string
|
|
147
|
+
*/
|
|
148
|
+
unescapeJsonString(e) {
|
|
149
|
+
return e.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/'/g, "'").replace(/"/g, '"').replace(/\\\\"/g, "'");
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Generates product rows using prepareProductRows with default product data
|
|
153
|
+
* @param totalCount - Total number of products to display
|
|
154
|
+
* @param productsPerRow - Number of products in each row
|
|
155
|
+
* @param extractedStyles - Styles extracted from old product elements
|
|
156
|
+
* @returns HTML string for product rows with applied styles
|
|
157
|
+
*/
|
|
158
|
+
generateProductRows(e, t, s) {
|
|
159
|
+
const o = $(), i = [];
|
|
160
|
+
for (let n = 0; n < e; n++) {
|
|
161
|
+
const u = o[n % o.length];
|
|
162
|
+
i.push({ ...u });
|
|
163
|
+
}
|
|
164
|
+
let r = q(i, t);
|
|
165
|
+
return r = this.applyExtractedStyles(r, s), r;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Extracts styles from old product elements
|
|
169
|
+
* @param block - The old recommendation block element
|
|
170
|
+
* @returns Object with extracted styles for each element type
|
|
171
|
+
*/
|
|
172
|
+
extractProductStyles(e) {
|
|
173
|
+
const t = {}, s = e.querySelector(".product-card");
|
|
174
|
+
if (!s)
|
|
175
|
+
return console.warn("[RecommendationMigrator] No product card found, using default styles"), t;
|
|
176
|
+
const o = this.extractCardBgColor(s);
|
|
177
|
+
o && (t.cardBgColor = o);
|
|
178
|
+
const i = s.querySelector(".ext-product-image");
|
|
179
|
+
if (i) {
|
|
180
|
+
const l = i.querySelector("img"), g = l == null ? void 0 : l.getAttribute("width"), a = i.getAttribute("style") || "", p = i.getAttribute("align") || "center", b = i.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
181
|
+
t.imageWidth = g || "120", t.imageAlign = p, t.imageTdStyle = a, t.imageClasses = m;
|
|
182
|
+
}
|
|
183
|
+
const r = s.querySelector(".ext-product-name");
|
|
184
|
+
if (r) {
|
|
185
|
+
const l = r.querySelector("p"), g = (l == null ? void 0 : l.getAttribute("style")) || "", a = r.getAttribute("align") || "center", p = r.getAttribute("style") || "", b = r.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
186
|
+
t.nameStyle = g, t.nameAlign = a, t.nameTdStyle = p, t.nameClasses = m;
|
|
187
|
+
}
|
|
188
|
+
const n = s.querySelector(".ext-product-price");
|
|
189
|
+
if (n) {
|
|
190
|
+
const l = n.querySelector("p"), g = (l == null ? void 0 : l.getAttribute("style")) || "", a = n.getAttribute("align") || "center", p = n.getAttribute("style") || "", b = n.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
191
|
+
t.priceStyle = g, t.priceAlign = a, t.priceTdStyle = p, t.priceClasses = m;
|
|
192
|
+
}
|
|
193
|
+
const u = s.querySelector(".ext-product-original-price");
|
|
194
|
+
if (u) {
|
|
195
|
+
const l = u.querySelector("p"), g = (l == null ? void 0 : l.getAttribute("style")) || "", a = u.getAttribute("align") || "center", p = u.getAttribute("style") || "", b = u.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
196
|
+
t.oldPriceStyle = g, t.oldPriceAlign = a, t.oldPriceTdStyle = p, t.oldPriceClasses = m;
|
|
197
|
+
}
|
|
198
|
+
const c = s.querySelector(".ext-product-button");
|
|
199
|
+
if (c) {
|
|
200
|
+
const l = c.querySelector(".es-button-border"), g = c.querySelector("a.es-button"), a = (l == null ? void 0 : l.getAttribute("style")) || "", p = (g == null ? void 0 : g.getAttribute("style")) || "", b = c.getAttribute("align") || "center", m = c.getAttribute("style") || "", f = c.getAttribute("class") || "", C = this.extractStripoClasses(f), y = ((c == null ? void 0 : c.textContent) || "").trim();
|
|
201
|
+
t.buttonBorderStyle = a, t.buttonLinkStyle = p, t.buttonAlign = b, t.buttonTdStyle = m, t.buttonClasses = C, t.buttonText = y;
|
|
76
202
|
}
|
|
77
|
-
|
|
203
|
+
return t;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Applies extracted styles to the generated HTML
|
|
207
|
+
* @param html - The generated HTML from prepareProductRows
|
|
208
|
+
* @param extractedStyles - Styles extracted from old product elements
|
|
209
|
+
* @returns HTML with applied styles
|
|
210
|
+
*/
|
|
211
|
+
applyExtractedStyles(e, t) {
|
|
212
|
+
if (!t || Object.keys(t).length === 0)
|
|
213
|
+
return e;
|
|
214
|
+
const s = this.parser.parseFromString(`<table>${e}</table>`, "text/html");
|
|
215
|
+
t.cardBgColor && s.querySelectorAll(".product-attribute-cell").forEach((r) => {
|
|
216
|
+
r.setAttribute("bgcolor", t.cardBgColor);
|
|
217
|
+
}), (t.imageWidth || t.imageAlign || t.imageTdStyle || t.imageClasses) && s.querySelectorAll(".product-image").forEach((r) => {
|
|
218
|
+
if (t.imageAlign && r.setAttribute("align", t.imageAlign), t.imageTdStyle && r.setAttribute("style", t.imageTdStyle), t.imageClasses) {
|
|
219
|
+
const c = `${r.getAttribute("class") || ""} ${t.imageClasses}`.trim();
|
|
220
|
+
r.setAttribute("class", c);
|
|
221
|
+
}
|
|
222
|
+
const n = r.querySelector("img");
|
|
223
|
+
n && t.imageWidth && n.setAttribute("width", t.imageWidth);
|
|
224
|
+
}), (t.nameStyle || t.nameAlign || t.nameTdStyle || t.nameClasses) && s.querySelectorAll(".product-name").forEach((r) => {
|
|
225
|
+
if (t.nameAlign && r.setAttribute("align", t.nameAlign), t.nameTdStyle && r.setAttribute("style", t.nameTdStyle), t.nameClasses) {
|
|
226
|
+
const c = `${r.getAttribute("class") || ""} ${t.nameClasses}`.trim();
|
|
227
|
+
r.setAttribute("class", c);
|
|
228
|
+
}
|
|
229
|
+
const n = r.querySelector("p");
|
|
230
|
+
n && t.nameStyle && n.setAttribute("style", t.nameStyle);
|
|
231
|
+
}), (t.priceStyle || t.priceAlign || t.priceTdStyle || t.priceClasses) && s.querySelectorAll(".product-price").forEach((r) => {
|
|
232
|
+
if (t.priceAlign && r.setAttribute("align", t.priceAlign), t.priceTdStyle && r.setAttribute("style", t.priceTdStyle), t.priceClasses) {
|
|
233
|
+
const c = `${r.getAttribute("class") || ""} ${t.priceClasses}`.trim();
|
|
234
|
+
r.setAttribute("class", c);
|
|
235
|
+
}
|
|
236
|
+
const n = r.querySelector("p");
|
|
237
|
+
n && t.priceStyle && n.setAttribute("style", t.priceStyle);
|
|
238
|
+
}), (t.oldPriceStyle || t.oldPriceAlign || t.oldPriceTdStyle || t.oldPriceClasses) && s.querySelectorAll(".product-old-price").forEach((r) => {
|
|
239
|
+
if (t.oldPriceAlign && r.setAttribute("align", t.oldPriceAlign), t.oldPriceTdStyle && r.setAttribute("style", t.oldPriceTdStyle), t.oldPriceClasses) {
|
|
240
|
+
const c = `${r.getAttribute("class") || ""} ${t.oldPriceClasses}`.trim();
|
|
241
|
+
r.setAttribute("class", c);
|
|
242
|
+
}
|
|
243
|
+
const n = r.querySelector("p");
|
|
244
|
+
n && t.oldPriceStyle && n.setAttribute("style", t.oldPriceStyle);
|
|
245
|
+
}), (t.buttonBorderStyle || t.buttonLinkStyle || t.buttonAlign || t.buttonTdStyle || t.buttonClasses) && s.querySelectorAll(".product-button").forEach((r) => {
|
|
246
|
+
if (t.buttonAlign && r.setAttribute("align", t.buttonAlign), t.buttonTdStyle && r.setAttribute("style", t.buttonTdStyle), t.buttonClasses) {
|
|
247
|
+
const l = `${r.getAttribute("class") || ""} ${t.buttonClasses}`.trim();
|
|
248
|
+
r.setAttribute("class", l);
|
|
249
|
+
}
|
|
250
|
+
const n = r.querySelector(".es-button-border");
|
|
251
|
+
n && t.buttonBorderStyle && n.setAttribute("style", t.buttonBorderStyle);
|
|
252
|
+
const u = r.querySelector("a.es-button");
|
|
253
|
+
u && (t.buttonLinkStyle && u.setAttribute("style", t.buttonLinkStyle), t.buttonText && (u.textContent = t.buttonText));
|
|
254
|
+
});
|
|
255
|
+
const o = s.querySelector("table");
|
|
256
|
+
return (o == null ? void 0 : o.innerHTML) || e;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Builds title block with proper structure
|
|
260
|
+
*/
|
|
261
|
+
buildTitleBlock(e) {
|
|
262
|
+
let t = e.text;
|
|
263
|
+
e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
|
|
264
|
+
const s = e.align ? ` align="${e.align}"` : "", o = e.styles ? ` style="${e.styles}"` : "";
|
|
265
|
+
return `
|
|
266
|
+
<td class="esd-block-text es-p10t es-p10b es-p20l es-p20r"${s}>
|
|
267
|
+
<p path="1"${o}>
|
|
268
|
+
${t}
|
|
269
|
+
</p>
|
|
270
|
+
</td>
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Removes specified style properties from a style string
|
|
275
|
+
*/
|
|
276
|
+
removeStyleProperties(e, t) {
|
|
277
|
+
return e ? t.reduce((o, i) => {
|
|
278
|
+
const r = new RegExp(`${i}\\s*:\\s*[^;]*;?`, "gi");
|
|
279
|
+
return o.replace(r, "");
|
|
280
|
+
}, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Converts inline display to block display
|
|
284
|
+
*/
|
|
285
|
+
convertInlineToBlock(e) {
|
|
286
|
+
if (!e)
|
|
287
|
+
return "";
|
|
288
|
+
let t = e.replace(/display\s*:\s*inline/gi, "display: block");
|
|
289
|
+
return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").replace(/"/g, "'").trim();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function v(d) {
|
|
293
|
+
return new B().migrate(d);
|
|
78
294
|
}
|
|
79
295
|
export {
|
|
80
|
-
|
|
296
|
+
v as migrateRecommendation
|
|
81
297
|
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const e = [
|
|
2
|
+
{
|
|
3
|
+
category: "Demographics",
|
|
4
|
+
conditions: [
|
|
5
|
+
{
|
|
6
|
+
id: 1,
|
|
7
|
+
name: "Language",
|
|
8
|
+
description: "Users who are in the English will see the banner",
|
|
9
|
+
beforeScript: '{% if language == "en_US" %}',
|
|
10
|
+
afterScript: "{% endif %}"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 2,
|
|
14
|
+
name: "Country",
|
|
15
|
+
description: "Only people who live in Australia will see the banner",
|
|
16
|
+
beforeScript: '{% if country == "Australia" %}',
|
|
17
|
+
afterScript: "{% endif %}"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 3,
|
|
21
|
+
name: "Country & City",
|
|
22
|
+
description: "Only people who are located in that country and city",
|
|
23
|
+
beforeScript: '{% if country == "United Kingdom" and city == "London" %}',
|
|
24
|
+
afterScript: "{% endif %}"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 4,
|
|
28
|
+
name: "Age (Less than operator)",
|
|
29
|
+
description: "Users whose age is less than 18",
|
|
30
|
+
beforeScript: "{% if age < 18 %}",
|
|
31
|
+
afterScript: "{% endif %}"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 5,
|
|
35
|
+
name: "Age (Equal and greater than operator)",
|
|
36
|
+
description: "Users whose age is equal or greater than 25",
|
|
37
|
+
beforeScript: "{% if age >= 25 %}",
|
|
38
|
+
afterScript: "{% endif %}"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 6,
|
|
42
|
+
name: "Age (Greater than & less than operators)",
|
|
43
|
+
description: "Users whose age is between 18 and 25",
|
|
44
|
+
beforeScript: "{% if age > 18 and age < 25 %}",
|
|
45
|
+
afterScript: "{% endif %}"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 7,
|
|
49
|
+
name: "Gender",
|
|
50
|
+
description: "Users whose gender is Female",
|
|
51
|
+
beforeScript: '{% if gender == "Female" %}',
|
|
52
|
+
afterScript: "{% endif %}"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 8,
|
|
56
|
+
name: "State",
|
|
57
|
+
description: "Users whose state is one of the followings. c_state is a custom attribute. Use this condition if you have the attribute with the same naming. ",
|
|
58
|
+
beforeScript: '{% if c_state == "VIC" or c_state == "NSW" or c_state == "QLD" %}',
|
|
59
|
+
afterScript: "{% endif %}"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 9,
|
|
63
|
+
name: "VIP User",
|
|
64
|
+
description: "Users who are VIP users for that brand. c_is_vip_user = true. c_is_vip_user is a custom attribute. Use this condition if you have the attribute with the same naming.",
|
|
65
|
+
beforeScript: "{% if c_is_vip_user %}",
|
|
66
|
+
afterScript: "{% endif %}"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 10,
|
|
70
|
+
name: "Membership Type",
|
|
71
|
+
description: "Users who belong to gold or silver membership type. c_is_gold_member = true, c_is_silver_member = true. These are custom attributes. Use this condition if you have the attribute with the same naming.",
|
|
72
|
+
beforeScript: "{% if c_is_gold_member or c_is_silver_member %}",
|
|
73
|
+
afterScript: "{% endif %}"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
export {
|
|
79
|
+
e as displayConditions
|
|
80
|
+
};
|
|
@@ -18,8 +18,7 @@ const s = {
|
|
|
18
18
|
{ text: "after the amount", value: "1" }
|
|
19
19
|
], d = [
|
|
20
20
|
{ text: "dot(.)", value: "." },
|
|
21
|
-
{ text: "comma(,)", value: "," }
|
|
22
|
-
{ text: "space( )", value: " " }
|
|
21
|
+
{ text: "comma(,)", value: "," }
|
|
23
22
|
], p = [
|
|
24
23
|
{ text: "0", value: "0" },
|
|
25
24
|
{ text: "1", value: "1" },
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (r, n, t) =>
|
|
4
|
-
import { BlockId as
|
|
5
|
-
import { getMigrationBannerHtml as
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var I = (r, n, t) => n in r ? k(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
|
|
3
|
+
var u = (r, n, t) => I(r, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { BlockId as B } from "../../../enums/block.js";
|
|
5
|
+
import { getMigrationBannerHtml as _ } from "../../../utils/migrationBannerHtml.js";
|
|
6
6
|
import { Block as b, BlockCompositionType as R, ModificationDescription as y } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
7
|
import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
|
|
8
8
|
import { ensureMobileCssRulesExist as g, setMobileLayoutOptOut as d, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
|
|
9
9
|
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
|
|
11
11
|
import { getDefaultTemplate as E } from "./templates/grid/template.js";
|
|
12
|
-
const f =
|
|
12
|
+
const f = B.Recommendation, a = "recommendation-block-v2", l = "recommendation-id";
|
|
13
13
|
let h = !1;
|
|
14
14
|
class q extends b {
|
|
15
15
|
constructor() {
|
|
@@ -38,7 +38,7 @@ class q extends b {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
getSettingsPanelTitleHtml() {
|
|
41
|
-
return
|
|
41
|
+
return _(
|
|
42
42
|
f,
|
|
43
43
|
this.api.translate("Recommendation Block"),
|
|
44
44
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
@@ -66,18 +66,15 @@ class q extends b {
|
|
|
66
66
|
* @param node - The newly created block node
|
|
67
67
|
*/
|
|
68
68
|
onCreated(t) {
|
|
69
|
-
const e = this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
s.setCurrentBlock(i), g(this.api);
|
|
76
|
-
const a = this._getBlockElement(t);
|
|
77
|
-
a && (d(this.api, a, !0), C({
|
|
69
|
+
const e = this._pendingBlockId ?? this._generateNextId();
|
|
70
|
+
this._pendingBlockId = null, this._assignRecommendationId(t, e);
|
|
71
|
+
const o = c.initializeConfig(this.api, t, { recommendationId: e }), i = p();
|
|
72
|
+
i.setCurrentBlock(e), g(this.api);
|
|
73
|
+
const s = this._getBlockElement(t);
|
|
74
|
+
s && (d(this.api, s, !0), C({
|
|
78
75
|
currentNode: t,
|
|
79
76
|
documentModifier: this.api.getDocumentModifier()
|
|
80
|
-
})),
|
|
77
|
+
})), i.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
80
|
* Called when the document changes or template is loaded
|
|
@@ -100,10 +97,10 @@ class q extends b {
|
|
|
100
97
|
c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
101
98
|
try {
|
|
102
99
|
h || (g(this.api), h = !0);
|
|
103
|
-
const e = c.getConfig(t),
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
A(
|
|
100
|
+
const e = c.getConfig(t), o = this._getBlockElement(t);
|
|
101
|
+
if (o) {
|
|
102
|
+
const i = !e.mobileLayoutEnabled;
|
|
103
|
+
A(o) !== i && d(this.api, o, i);
|
|
107
104
|
}
|
|
108
105
|
} catch {
|
|
109
106
|
}
|
|
@@ -127,10 +124,10 @@ class q extends b {
|
|
|
127
124
|
let t = 0;
|
|
128
125
|
try {
|
|
129
126
|
const e = this.api.getDocumentRoot();
|
|
130
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
131
|
-
if ("getAttribute" in
|
|
132
|
-
const s =
|
|
133
|
-
|
|
127
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${a}`).forEach((i) => {
|
|
128
|
+
if ("getAttribute" in i) {
|
|
129
|
+
const s = i.getAttribute(l), m = s ? parseInt(s) : 0;
|
|
130
|
+
m > t && (t = m);
|
|
134
131
|
}
|
|
135
132
|
});
|
|
136
133
|
} catch {
|
|
@@ -144,11 +141,11 @@ class q extends b {
|
|
|
144
141
|
* added classes via setAttribute.
|
|
145
142
|
*/
|
|
146
143
|
_assignRecommendationId(t, e) {
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
144
|
+
const o = this._getBlockElement(t);
|
|
145
|
+
if (!o)
|
|
149
146
|
return;
|
|
150
|
-
const
|
|
151
|
-
|
|
147
|
+
const i = this.api.getDocumentModifier();
|
|
148
|
+
i.modifyHtml(o).setAttribute(l, e.toString()), i.apply(new y(`Assign recommendation ID ${e}`));
|
|
152
149
|
}
|
|
153
150
|
/**
|
|
154
151
|
* Gets the recommendation-id from a block node
|
|
@@ -157,11 +154,11 @@ class q extends b {
|
|
|
157
154
|
const e = this._getBlockElement(t);
|
|
158
155
|
if (!e || !("getAttribute" in e))
|
|
159
156
|
return null;
|
|
160
|
-
const
|
|
161
|
-
if (!
|
|
157
|
+
const o = e.getAttribute(l);
|
|
158
|
+
if (!o)
|
|
162
159
|
return null;
|
|
163
|
-
const
|
|
164
|
-
return Number.isNaN(
|
|
160
|
+
const i = parseInt(o);
|
|
161
|
+
return Number.isNaN(i) ? null : i;
|
|
165
162
|
}
|
|
166
163
|
/**
|
|
167
164
|
* Gets the block element (the element with BLOCK_CLASS)
|
|
@@ -169,10 +166,10 @@ class q extends b {
|
|
|
169
166
|
_getBlockElement(t) {
|
|
170
167
|
if ("getAttribute" in t) {
|
|
171
168
|
const e = t.getAttribute("class");
|
|
172
|
-
if (e && e.includes(
|
|
169
|
+
if (e && e.includes(a))
|
|
173
170
|
return t;
|
|
174
171
|
}
|
|
175
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
172
|
+
return "querySelector" in t ? t.querySelector(`.${a}`) ?? null : null;
|
|
176
173
|
}
|
|
177
174
|
/**
|
|
178
175
|
* Migrate configuration from legacy format
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_MOBILE_ROW_SPACING as R, DEFAULT_MOBILE_COLUMN_SPACING as U, DEFAULT_ROW_SPACING as i, DEFAULT_COLUMN_SPACING as s, DEFAULT_MOBILE_CARDS_IN_ROW as o, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
|
|
2
2
|
import { ATTR_PRODUCT_IMAGE as _, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as t, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as r, ATTR_PRODUCT_OMNIBUS_DISCOUNT as I, ATTR_PRODUCT_BUTTON as n } from "./selectors.js";
|
|
3
3
|
const O = {
|
|
4
4
|
code: "USD",
|
|
@@ -44,10 +44,10 @@ const O = {
|
|
|
44
44
|
mobileCardsInRow: o,
|
|
45
45
|
mobileLayoutEnabled: !1,
|
|
46
46
|
previousMobileCardsInRow: o,
|
|
47
|
-
columnSpacing:
|
|
48
|
-
rowSpacing:
|
|
49
|
-
mobileColumnSpacing:
|
|
50
|
-
mobileRowSpacing:
|
|
47
|
+
columnSpacing: s,
|
|
48
|
+
rowSpacing: i,
|
|
49
|
+
mobileColumnSpacing: U,
|
|
50
|
+
mobileRowSpacing: R,
|
|
51
51
|
// Composition
|
|
52
52
|
composition: a,
|
|
53
53
|
visibility: E,
|