@useinsider/guido 3.2.0-beta.479e47d → 3.2.0-beta.488f8eb
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 +117 -1
- package/dist/@types/config/schemas.js +153 -95
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +90 -88
- package/dist/components/organisms/AutoSaveController.vue.js +17 -0
- package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
- package/dist/components/organisms/header/RightSlot.vue.js +8 -8
- package/dist/components/organisms/header/RightSlot.vue2.js +9 -8
- package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
- package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
- package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
- package/dist/composables/useAutoSave.js +71 -0
- package/dist/composables/useHtmlValidator.js +41 -36
- package/dist/composables/useRecommendation.js +46 -26
- package/dist/composables/useRibbonOffset.js +21 -0
- package/dist/composables/useSave.js +19 -16
- package/dist/composables/useStripo.js +14 -16
- package/dist/composables/validators/useCouponBlockValidator.js +24 -0
- package/dist/config/compiler/recommendationCompilerRules.js +25 -25
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +104 -71
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/enums/onboarding.js +7 -2
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/Recommendation/block.js +35 -32
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +25 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +130 -81
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +19 -10
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +25 -15
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +33 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/package.json.js +1 -1
- package/dist/services/templateLibraryApi.js +5 -4
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +217 -0
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useAutoSave.d.ts +3 -0
- package/dist/src/composables/useConfig.d.ts +58 -0
- package/dist/src/composables/useRecommendation.d.ts +10 -1
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/composables/useRibbonOffset.d.ts +4 -0
- package/dist/src/composables/useSave.d.ts +1 -1
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/onboarding.d.ts +6 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +41 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +21 -0
- package/dist/src/library.d.ts +1 -1
- package/dist/src/stores/autosave.d.ts +12 -0
- package/dist/src/stores/config.d.ts +522 -0
- package/dist/src/stores/editor.d.ts +23 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/src/utils/timeUtil.d.ts +8 -0
- package/dist/stores/autosave.js +17 -0
- package/dist/stores/editor.js +3 -1
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/htmlEscape.js +13 -0
- package/dist/utils/pairProductVariables.js +89 -88
- package/dist/utils/templatePreparation.js +72 -32
- package/dist/utils/timeUtil.js +19 -0
- package/package.json +7 -3
- package/dist/enums/displayConditions.js +0 -80
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
- package/dist/src/enums/displayConditions.d.ts +0 -2
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
function y(
|
|
5
|
-
const n = `{{${s}${
|
|
1
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as S } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as _ } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
function y(r, c, e, o, s = "") {
|
|
5
|
+
const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
|
|
6
6
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
switch (
|
|
8
|
+
function f(r, c, e, o, s, n) {
|
|
9
|
+
switch (c) {
|
|
10
10
|
case "productImage": {
|
|
11
|
-
const t =
|
|
12
|
-
t && (t.setAttribute("src", `{{${n}${
|
|
13
|
-
const
|
|
14
|
-
|
|
11
|
+
const t = r.querySelector("img");
|
|
12
|
+
t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
|
|
13
|
+
const i = r.querySelector("a");
|
|
14
|
+
i && i.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
15
15
|
break;
|
|
16
16
|
}
|
|
17
17
|
case "productName": {
|
|
18
|
-
const t =
|
|
18
|
+
const t = r.querySelector("p");
|
|
19
19
|
if (t) {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const i = t.querySelector("strong") || t;
|
|
21
|
+
i.textContent = `{{${n}${e}_${o}_name}}`;
|
|
22
22
|
}
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productPrice": {
|
|
26
|
-
const t =
|
|
26
|
+
const t = r.querySelector("p");
|
|
27
27
|
if (t) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const i = t.querySelector("strong") || t;
|
|
29
|
+
i.textContent = y(e, o, "price", s, n);
|
|
30
30
|
}
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
case "productOldPrice": {
|
|
34
|
-
const t =
|
|
34
|
+
const t = r.querySelector("p");
|
|
35
35
|
if (t) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const i = t.querySelector("strong") || t;
|
|
37
|
+
i.textContent = y(
|
|
38
|
+
e,
|
|
39
39
|
o,
|
|
40
40
|
"original_price",
|
|
41
41
|
s,
|
|
@@ -45,94 +45,127 @@ function m(e, u, r, o, s, n) {
|
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
case "productButton": {
|
|
48
|
-
const t =
|
|
49
|
-
t && t.setAttribute("href", `{{${n}${
|
|
48
|
+
const t = r.querySelector("a");
|
|
49
|
+
t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
case "productOmnibusPrice": {
|
|
53
|
-
const t =
|
|
53
|
+
const t = r.querySelector(".omnibus-price-value");
|
|
54
54
|
if (t) {
|
|
55
|
-
t.textContent = `{{${n}${
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
|
|
56
|
+
const i = t.closest("p");
|
|
57
|
+
i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
case "productOmnibusDiscount": {
|
|
62
|
-
const t =
|
|
62
|
+
const t = r.querySelector(".omnibus-discount-value");
|
|
63
63
|
if (t) {
|
|
64
|
-
t.textContent = `{{${n}${
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
|
|
65
|
+
const i = t.closest("p");
|
|
66
|
+
i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
default: {
|
|
71
|
-
const t =
|
|
71
|
+
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
72
72
|
if (t) {
|
|
73
|
-
const
|
|
73
|
+
const i = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
74
74
|
if (a) {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const u = a.querySelector("strong") || a;
|
|
76
|
+
u.textContent = `{{${n}${e}_${o}_${i}}}`;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function q(
|
|
84
|
-
|
|
83
|
+
function q(r, c, e, o) {
|
|
84
|
+
r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
85
85
|
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}) :
|
|
86
|
+
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
87
|
+
p.length > 0 ? p.forEach((l) => {
|
|
88
|
+
f(l, u, c, t, e, o);
|
|
89
|
+
}) : f(a, u, c, t, e, o);
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const s =
|
|
93
|
+
function w(r, c, e, o) {
|
|
94
|
+
const s = r.querySelectorAll(".recommendation-product-row");
|
|
95
95
|
if (!s.length)
|
|
96
96
|
return;
|
|
97
|
-
const [n] = s, t = n.querySelector("[data-attribute-type]"),
|
|
98
|
-
s.forEach((a,
|
|
99
|
-
a.querySelectorAll("[data-attribute-type]").forEach((
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
97
|
+
const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
98
|
+
s.forEach((a, u) => {
|
|
99
|
+
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
100
|
+
const d = l.getAttribute("data-attribute-type") || "";
|
|
101
|
+
l.querySelectorAll(".attribute-cell").forEach((A, h) => {
|
|
102
|
+
const $ = u * i + h;
|
|
103
|
+
f(A, d, c, $, e, o);
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
function E(r, c, e, o) {
|
|
109
|
+
r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
110
|
+
w(n, c, e, o);
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
function C(
|
|
114
|
-
const o =
|
|
115
|
-
o === "list" ? q(
|
|
113
|
+
function C(r, c, e) {
|
|
114
|
+
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
115
|
+
o === "list" ? q(r, c, s, e) : E(r, c, s, e);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
` : "") + u.documentElement.outerHTML;
|
|
117
|
+
function b(r, c, e) {
|
|
118
|
+
const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
119
|
+
return s ? parseInt(s[1]) : e;
|
|
121
120
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
121
|
+
function P(r, c) {
|
|
122
|
+
let e = r.parentElement;
|
|
123
|
+
for (; e && e !== c; ) {
|
|
124
|
+
if (e.tagName === "TD") {
|
|
125
|
+
const o = e.getAttribute("width");
|
|
126
|
+
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
127
|
+
return e;
|
|
128
|
+
}
|
|
129
|
+
e = e.parentElement;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function R(r) {
|
|
134
|
+
const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
135
|
+
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
|
|
136
|
+
if (n.hasAttribute("width"))
|
|
137
|
+
return;
|
|
138
|
+
const t = P(n, r);
|
|
139
|
+
if (!t)
|
|
140
|
+
return;
|
|
141
|
+
const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
|
|
142
|
+
n.setAttribute("width", String(l));
|
|
143
|
+
const d = n.getAttribute("style") || "";
|
|
144
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
145
|
+
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
146
|
+
n.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function v(r, c) {
|
|
151
|
+
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
152
|
+
return (e ? `${e[0]}
|
|
153
|
+
` : "") + c.documentElement.outerHTML;
|
|
154
|
+
}
|
|
155
|
+
function O(r) {
|
|
156
|
+
const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
124
157
|
if (!o.length)
|
|
125
|
-
return
|
|
126
|
-
const { buildCampaignUrl: s } =
|
|
158
|
+
return r;
|
|
159
|
+
const { buildCampaignUrl: s } = S(), n = _();
|
|
127
160
|
n.recommendationCampaignUrls = {};
|
|
128
|
-
const { isFeatureEnabled: t } =
|
|
129
|
-
return o.forEach((
|
|
130
|
-
var
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
}),
|
|
161
|
+
const { isFeatureEnabled: t } = g(), i = t("liquidSyntax") ? "reco_" : "";
|
|
162
|
+
return o.forEach((u) => {
|
|
163
|
+
var l, d;
|
|
164
|
+
const p = u.getAttribute("recommendation-id");
|
|
165
|
+
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()), s(p), C(u, p, i), R(u));
|
|
166
|
+
}), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
134
167
|
}
|
|
135
168
|
export {
|
|
136
169
|
y as formatPriceVariable,
|
|
137
|
-
|
|
170
|
+
O as prepareRecommendationBlocks
|
|
138
171
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateRadioButton as
|
|
5
|
-
import { migrateRecommendation as
|
|
6
|
-
import { migrateUnsubscribe as
|
|
7
|
-
const
|
|
1
|
+
import { migrateCheckbox as o } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateRadioButton as a } from "./radioButtonMigrator.js";
|
|
5
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
6
|
+
import { migrateUnsubscribe as n } from "./unsubscribeMigrator.js";
|
|
7
|
+
const b = async (r, t = {}) => {
|
|
8
8
|
let m = r;
|
|
9
|
-
return m =
|
|
9
|
+
return m = o(m), m = a(m), m = await n(m), m = i(m), m = g(m, t), m = e(m), m;
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
b as migrate
|
|
13
13
|
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
|
+
import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
|
|
4
|
+
const C = "__title__", a = "product_attribute.";
|
|
5
|
+
function N(r) {
|
|
6
|
+
const t = r.variable ?? "";
|
|
7
|
+
switch (t) {
|
|
8
|
+
case "p_recommendation_title":
|
|
9
|
+
return { key: C, kind: "title" };
|
|
10
|
+
case "p_image":
|
|
11
|
+
return { key: y, kind: "image" };
|
|
12
|
+
case "p_name":
|
|
13
|
+
return { key: h, kind: "text" };
|
|
14
|
+
case "p_price":
|
|
15
|
+
return { key: R, kind: "text" };
|
|
16
|
+
case "p_original_price":
|
|
17
|
+
return { key: f, kind: "text" };
|
|
18
|
+
case "p_omnibus_price":
|
|
19
|
+
return { key: x, kind: "text" };
|
|
20
|
+
case "p_omnibus_discount":
|
|
21
|
+
return { key: A, kind: "text" };
|
|
22
|
+
case "p_button":
|
|
23
|
+
return { key: k, kind: "button" };
|
|
24
|
+
default:
|
|
25
|
+
if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
|
|
26
|
+
const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
|
|
27
|
+
return o ? {
|
|
28
|
+
key: `${l}${o}`,
|
|
29
|
+
kind: "custom",
|
|
30
|
+
customAttrName: o,
|
|
31
|
+
customAttrValue: s || `${a}${o}`
|
|
32
|
+
} : null;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function p(r) {
|
|
38
|
+
const t = d.indexOf(r);
|
|
39
|
+
return t === -1 ? Number.POSITIVE_INFINITY : t;
|
|
40
|
+
}
|
|
41
|
+
function S(r) {
|
|
42
|
+
const t = {
|
|
43
|
+
composition: [],
|
|
44
|
+
visibility: { ...I },
|
|
45
|
+
customAttributes: [],
|
|
46
|
+
customAttrValues: {},
|
|
47
|
+
perElementStyles: {},
|
|
48
|
+
anyTextTrimming: !1
|
|
49
|
+
};
|
|
50
|
+
if (!r || r.length === 0)
|
|
51
|
+
return t.composition = [...d], t;
|
|
52
|
+
const s = [];
|
|
53
|
+
r.forEach((e, i) => {
|
|
54
|
+
const n = N(e);
|
|
55
|
+
if (n) {
|
|
56
|
+
if (n.kind === "title") {
|
|
57
|
+
t.titleVariable = e;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
s.push({
|
|
61
|
+
key: n.key,
|
|
62
|
+
kind: n.kind,
|
|
63
|
+
hidden: e.hidden === !0,
|
|
64
|
+
positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
|
|
65
|
+
legacy: e,
|
|
66
|
+
customAttrName: n.customAttrName,
|
|
67
|
+
customAttrValue: n.customAttrValue,
|
|
68
|
+
originalIndex: i
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}), s.sort((e, i) => {
|
|
72
|
+
if (e.positionIdx !== i.positionIdx)
|
|
73
|
+
return e.positionIdx - i.positionIdx;
|
|
74
|
+
const n = p(e.key), u = p(i.key);
|
|
75
|
+
return n !== u ? n - u : e.originalIndex - i.originalIndex;
|
|
76
|
+
});
|
|
77
|
+
const o = {};
|
|
78
|
+
return s.forEach((e) => {
|
|
79
|
+
const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
|
|
80
|
+
switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
|
|
81
|
+
case "image":
|
|
82
|
+
o[i] = b(m.theme);
|
|
83
|
+
break;
|
|
84
|
+
case "button":
|
|
85
|
+
o[i] = O(m.theme);
|
|
86
|
+
break;
|
|
87
|
+
case "text":
|
|
88
|
+
case "custom": {
|
|
89
|
+
const _ = E(m.theme);
|
|
90
|
+
o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}), t.perElementStyles = o, t;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
S as mapComposition
|
|
98
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const i = "You May Also Like!";
|
|
2
|
+
function s(r) {
|
|
3
|
+
var e;
|
|
4
|
+
const o = r.querySelector(".ext-recommendation-title");
|
|
5
|
+
if (!o)
|
|
6
|
+
return i;
|
|
7
|
+
const t = (e = o.textContent) == null ? void 0 : e.trim();
|
|
8
|
+
return t && t.length > 0 ? t : i;
|
|
9
|
+
}
|
|
10
|
+
function u(r) {
|
|
11
|
+
const o = [
|
|
12
|
+
r,
|
|
13
|
+
...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
|
+
];
|
|
15
|
+
let t = "";
|
|
16
|
+
return o.some((e) => {
|
|
17
|
+
const n = e.getAttribute("bgcolor");
|
|
18
|
+
if (n && n.trim())
|
|
19
|
+
return t = n.trim(), !0;
|
|
20
|
+
const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
21
|
+
return c && c[1] ? (t = c[1].trim(), !0) : !1;
|
|
22
|
+
}), t;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
u as extractCardBgColor,
|
|
26
|
+
s as extractTitleText
|
|
27
|
+
};
|