@useinsider/guido 3.24.0-beta.0abeefe → 3.24.0-beta.0c16173
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 +7 -2
- package/dist/@types/config/schemas.js +40 -40
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +81 -85
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useBlocksConfig.js +20 -31
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/composables/useStripo.js +70 -70
- package/dist/composables/useTranslations.js +1 -2
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/enums/academy.js +0 -1
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/extension.js +15 -13
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/controlFactories.js +104 -104
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
- package/dist/node_modules/valibot/dist/index.js +261 -297
- package/dist/package.json.js +6 -6
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +4 -4
- package/dist/src/composables/useConfig.d.ts +2 -2
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
- package/dist/src/stores/config.d.ts +20 -167
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/src/utils/linkTrackingIds.d.ts +24 -22
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/stores/config.js +6 -13
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/linkTrackingIds.js +72 -72
- package/dist/utils/pairProductVariables.js +119 -100
- package/dist/utils/templatePreparation.js +59 -72
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
- package/dist/@types/display-condition.js +0 -25
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -17
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +0 -17
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +0 -45
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -36
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
- package/dist/composables/useDisplayConditions.js +0 -117
- package/dist/enums/display-condition.js +0 -12
- package/dist/extensions/DisplayConditions/bridge.js +0 -25
- package/dist/extensions/DisplayConditions/constants.js +0 -26
- package/dist/extensions/DisplayConditions/control.js +0 -215
- package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -226
- package/dist/extensions/DisplayConditions/extension.js +0 -28
- package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
- package/dist/extensions/DisplayConditions/library.js +0 -30
- package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
- package/dist/extensions/LinkTracking/extension.js +0 -17
- package/dist/extensions/LinkTracking/writer.js +0 -41
- package/dist/services/displayConditionApi.js +0 -39
- package/dist/src/@types/display-condition.d.ts +0 -60
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +0 -18
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
- package/dist/src/composables/useDisplayConditions.d.ts +0 -18
- package/dist/src/enums/display-condition.d.ts +0 -15
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
- package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -23
- package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
- package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
- package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
- package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
- package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
- package/dist/src/mock/api/display-conditions.d.ts +0 -2
- package/dist/src/services/displayConditionApi.d.ts +0 -8
- package/dist/src/stores/display-condition.d.ts +0 -84
- package/dist/src/utils/displayCondition.d.ts +0 -11
- package/dist/src/utils/protectTableText.d.ts +0 -2
- package/dist/stores/display-condition.js +0 -29
- package/dist/utils/displayCondition.js +0 -26
- package/dist/utils/protectTableText.js +0 -22
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
2
2
|
import { useRecommendation as O } from "../../../composables/useRecommendation.js";
|
|
3
|
-
import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function R(t, r, e, o, c = "") {
|
|
3
|
+
import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as B } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as N } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as T } from "./recommendationIgnoreUtils.js";
|
|
6
|
+
function L(t, r, e, o, c = "") {
|
|
8
7
|
const i = `{{${c}${t}_${r}_${e}}}`, n = `{{${c}${t}_${r}_currency}}`;
|
|
9
8
|
return o === "before" ? `${n} ${i}` : `${i} ${n}`;
|
|
10
9
|
}
|
|
11
|
-
function
|
|
10
|
+
function A(t) {
|
|
12
11
|
let r = t;
|
|
13
12
|
for (; r.children.length === 1; )
|
|
14
13
|
[r] = r.children;
|
|
@@ -20,12 +19,12 @@ function _(t, r, e, o, c, i) {
|
|
|
20
19
|
const n = t.querySelector("img");
|
|
21
20
|
n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
|
|
22
21
|
const s = t.querySelector("a");
|
|
23
|
-
s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(
|
|
22
|
+
s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(B));
|
|
24
23
|
break;
|
|
25
24
|
}
|
|
26
25
|
case "productName": {
|
|
27
26
|
const n = t.querySelector("p");
|
|
28
|
-
n && (
|
|
27
|
+
n && (A(n).textContent = `{{${i}${e}_${o}_name}}`);
|
|
29
28
|
break;
|
|
30
29
|
}
|
|
31
30
|
// Inline mode ("Move to next line" OFF) merges BOTH prices into one row
|
|
@@ -33,16 +32,16 @@ function _(t, r, e, o, c, i) {
|
|
|
33
32
|
// substitute by cell content, not by the row's anchor (SD-145161).
|
|
34
33
|
case "productPrice":
|
|
35
34
|
case "productOldPrice": {
|
|
36
|
-
const n = (
|
|
37
|
-
|
|
35
|
+
const n = (a, l) => {
|
|
36
|
+
a && (A(a).textContent = L(
|
|
38
37
|
e,
|
|
39
38
|
o,
|
|
40
|
-
|
|
39
|
+
l,
|
|
41
40
|
c,
|
|
42
41
|
i
|
|
43
42
|
));
|
|
44
|
-
}, s = t.querySelector(".product-price p"),
|
|
45
|
-
n(s ?? (r === "productPrice" ? u : null), "price"), n(
|
|
43
|
+
}, s = t.querySelector(".product-price p"), d = t.querySelector(".product-old-price p"), u = !s && !d ? t.querySelector("p") : null;
|
|
44
|
+
n(s ?? (r === "productPrice" ? u : null), "price"), n(d ?? (r === "productOldPrice" ? u : null), "original_price");
|
|
46
45
|
break;
|
|
47
46
|
}
|
|
48
47
|
case "productButton": {
|
|
@@ -71,72 +70,72 @@ function _(t, r, e, o, c, i) {
|
|
|
71
70
|
default: {
|
|
72
71
|
const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
73
72
|
if (n) {
|
|
74
|
-
const s = n.getAttribute("product-attr"),
|
|
75
|
-
|
|
73
|
+
const s = n.getAttribute("product-attr"), d = n.querySelector("p");
|
|
74
|
+
d && (A(d).textContent = `{{${i}${e}_${o}_${s}}}`);
|
|
76
75
|
}
|
|
77
76
|
break;
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
const
|
|
80
|
+
const P = "name";
|
|
82
81
|
function y(t, r, e, o) {
|
|
83
|
-
const c = `${o}${r}_${e}_${
|
|
82
|
+
const c = `${o}${r}_${e}_${P}`;
|
|
84
83
|
return {
|
|
85
84
|
open: t.createComment(`{% if ${c} and ${c} != "" %}`),
|
|
86
85
|
close: t.createComment("{% endif %}")
|
|
87
86
|
};
|
|
88
87
|
}
|
|
89
|
-
function
|
|
88
|
+
function R(t, r, e) {
|
|
90
89
|
return y(t, r, 0, e);
|
|
91
90
|
}
|
|
92
|
-
function
|
|
91
|
+
function w(t, r, e, o) {
|
|
93
92
|
if (!t.innerHTML.includes("{{"))
|
|
94
93
|
return;
|
|
95
94
|
const { open: c, close: i } = y(t.ownerDocument, r, e, o);
|
|
96
95
|
t.insertBefore(c, t.firstChild), t.appendChild(i);
|
|
97
96
|
}
|
|
98
|
-
function
|
|
97
|
+
function D(t, r, e, o) {
|
|
99
98
|
var n, s;
|
|
100
99
|
if (!t.innerHTML.includes("{{"))
|
|
101
100
|
return;
|
|
102
101
|
const { open: c, close: i } = y(t.ownerDocument, r, e, o);
|
|
103
102
|
(n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
|
|
104
103
|
}
|
|
105
|
-
function
|
|
104
|
+
function v(t, r, e, o) {
|
|
106
105
|
t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
|
|
107
|
-
i.querySelectorAll("[data-attribute-type]").forEach((
|
|
108
|
-
const u =
|
|
109
|
-
|
|
110
|
-
_(
|
|
111
|
-
}) : _(
|
|
112
|
-
}),
|
|
106
|
+
i.querySelectorAll("[data-attribute-type]").forEach((d) => {
|
|
107
|
+
const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
|
|
108
|
+
a.length > 0 ? a.forEach((l) => {
|
|
109
|
+
_(l, u, r, n, e, o);
|
|
110
|
+
}) : _(d, u, r, n, e, o);
|
|
111
|
+
}), D(i, r, n, o);
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
|
-
function
|
|
114
|
+
function H(t, r, e, o) {
|
|
116
115
|
const c = t.querySelectorAll(".recommendation-product-row");
|
|
117
116
|
if (!c.length)
|
|
118
117
|
return;
|
|
119
118
|
const [i] = c, n = i.querySelector("[data-attribute-type]"), s = n ? n.querySelectorAll(".attribute-cell").length : 1;
|
|
120
|
-
c.forEach((
|
|
121
|
-
|
|
122
|
-
const p =
|
|
123
|
-
|
|
119
|
+
c.forEach((d, u) => {
|
|
120
|
+
d.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
121
|
+
const p = l.getAttribute("data-attribute-type") || "";
|
|
122
|
+
l.querySelectorAll(".attribute-cell").forEach((m, h) => {
|
|
124
123
|
const S = u * s + h;
|
|
125
|
-
_(m, p, r, S, e, o),
|
|
124
|
+
_(m, p, r, S, e, o), w(m, r, S, o);
|
|
126
125
|
});
|
|
127
126
|
});
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
|
-
function
|
|
129
|
+
function W(t, r, e, o) {
|
|
131
130
|
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
132
|
-
|
|
131
|
+
H(i, r, e, o);
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
|
-
function
|
|
134
|
+
function F(t, r, e) {
|
|
136
135
|
const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment"), i = c === "0" || c === "before" ? "before" : "after";
|
|
137
|
-
o === "list" ?
|
|
136
|
+
o === "list" ? v(t, r, i, e) : W(t, r, i, e);
|
|
138
137
|
}
|
|
139
|
-
function
|
|
138
|
+
function b(t, r, e) {
|
|
140
139
|
const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
|
|
141
140
|
return c ? parseInt(c[1]) : e;
|
|
142
141
|
}
|
|
@@ -151,7 +150,7 @@ function g(t) {
|
|
|
151
150
|
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
152
151
|
return e && $(e[1]) ? e[1] : null;
|
|
153
152
|
}
|
|
154
|
-
function
|
|
153
|
+
function x(t, r) {
|
|
155
154
|
let e = t.parentElement;
|
|
156
155
|
for (; e && e !== r; ) {
|
|
157
156
|
if (e.tagName === "TD" && g(e))
|
|
@@ -160,64 +159,62 @@ function V(t, r) {
|
|
|
160
159
|
}
|
|
161
160
|
return null;
|
|
162
161
|
}
|
|
163
|
-
function
|
|
164
|
-
const r = t.getAttribute("style") || "", e =
|
|
162
|
+
function G(t) {
|
|
163
|
+
const r = t.getAttribute("style") || "", e = b(r, "width", 600), o = b(r, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
165
164
|
c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
166
165
|
if (i.hasAttribute("width"))
|
|
167
166
|
return;
|
|
168
|
-
const n =
|
|
167
|
+
const n = x(i, t);
|
|
169
168
|
if (!n)
|
|
170
169
|
return;
|
|
171
|
-
const s = g(n),
|
|
170
|
+
const s = g(n), d = b(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
|
|
172
171
|
if (p) {
|
|
173
|
-
i.setAttribute("width", String(Math.max(1, Math.min(
|
|
172
|
+
i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
|
|
174
173
|
return;
|
|
175
174
|
}
|
|
176
|
-
if (i.setAttribute("width", String(
|
|
177
|
-
const f =
|
|
178
|
-
i.setAttribute("style", `${
|
|
175
|
+
if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
|
|
176
|
+
const f = l && !l.trim().endsWith(";") ? "; " : "";
|
|
177
|
+
i.setAttribute("style", `${l}${f}width: ${a}px`);
|
|
179
178
|
}
|
|
180
179
|
});
|
|
181
180
|
}
|
|
182
|
-
const E = "MSO_MOBILE_HIDE_START",
|
|
183
|
-
function
|
|
181
|
+
const E = "MSO_MOBILE_HIDE_START", V = "MSO_MOBILE_HIDE_END";
|
|
182
|
+
function U(t, r) {
|
|
184
183
|
t.querySelectorAll(q).forEach((e) => {
|
|
185
184
|
var i, n;
|
|
186
185
|
const o = e.querySelector(M);
|
|
187
186
|
if (!o || o.children.length === 0)
|
|
188
187
|
return;
|
|
189
188
|
const c = e.previousSibling;
|
|
190
|
-
(c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === E || ((i = e.parentNode) == null || i.insertBefore(r.createComment(E), e), (n = e.parentNode) == null || n.insertBefore(r.createComment(
|
|
189
|
+
(c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === E || ((i = e.parentNode) == null || i.insertBefore(r.createComment(E), e), (n = e.parentNode) == null || n.insertBefore(r.createComment(V), e.nextSibling));
|
|
191
190
|
});
|
|
192
191
|
}
|
|
193
|
-
function
|
|
192
|
+
function X(t, r) {
|
|
194
193
|
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
195
194
|
return (e ? `${e[0]}
|
|
196
195
|
` : "") + r.documentElement.outerHTML;
|
|
197
196
|
}
|
|
198
|
-
function
|
|
199
|
-
const r =
|
|
197
|
+
function Q(t) {
|
|
198
|
+
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
200
199
|
if (!o.length)
|
|
201
200
|
return t;
|
|
202
|
-
const { buildCampaignUrl: c } = O(), i =
|
|
201
|
+
const { buildCampaignUrl: c } = O(), i = N();
|
|
203
202
|
i.recommendationCampaignUrls = {};
|
|
204
203
|
const { isFeatureEnabled: n } = C(), s = n("liquidSyntax") ? "reco_" : "";
|
|
205
|
-
o.forEach((u) => {
|
|
206
|
-
var
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
209
|
-
if ((
|
|
210
|
-
|
|
211
|
-
const { open: h, close: S } =
|
|
204
|
+
return o.forEach((u) => {
|
|
205
|
+
var l, p, f, m;
|
|
206
|
+
const a = u.getAttribute("recommendation-id");
|
|
207
|
+
if (a) {
|
|
208
|
+
if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
|
|
209
|
+
F(u, a, s);
|
|
210
|
+
const { open: h, close: S } = R(e, a, s);
|
|
212
211
|
(f = u.parentNode) == null || f.insertBefore(h, u), (m = u.parentNode) == null || m.insertBefore(S, u.nextSibling);
|
|
213
212
|
}
|
|
214
|
-
|
|
213
|
+
G(u);
|
|
215
214
|
}
|
|
216
|
-
});
|
|
217
|
-
const a = Y(r, e);
|
|
218
|
-
return L(a.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
215
|
+
}), X(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
219
216
|
}
|
|
220
217
|
export {
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
L as formatPriceVariable,
|
|
219
|
+
Q as prepareRecommendationBlocks
|
|
223
220
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateFullStoryScripts as
|
|
4
|
-
import { migrateItemsBlock as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { migrateCheckbox as e } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as a } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateFullStoryScripts as c } from "./fullStoryScriptMigrator.js";
|
|
4
|
+
import { migrateItemsBlock as g } from "./itemsBlockMigrator.js";
|
|
5
|
+
import { migrateItemsPriceFormat as n } from "./itemsPriceFormatMigrator.js";
|
|
6
|
+
import { migrateProductNameLink as p } from "./productNameLinkMigrator.js";
|
|
7
|
+
import { migrateRadioButton as f } from "./radioButtonMigrator.js";
|
|
8
|
+
import { migrateRecommendation as l } from "./recommendationMigrator.js";
|
|
9
|
+
import { migrateRecommendationPartnerScope as d } from "./recommendationPartnerMigrator.js";
|
|
10
|
+
import { migrateRecommendationTitle as s } from "./recommendationTitleMigrator.js";
|
|
11
|
+
import { migrateSocialIcons as k } from "./socialIconMigrator.js";
|
|
12
|
+
import { migrateUnsubscribe as P } from "./unsubscribeMigrator.js";
|
|
13
|
+
const H = async (t, i = {}, r, o) => {
|
|
14
|
+
let m = t;
|
|
15
|
+
return m = e(m), m = f(m), m = await P(m), m = a(m), m = l(m, i), r && (m = d(m, r)), m = s(m), m = g(m), o != null && o.itemsPriceFormatting && (m = n(m)), m = p(m), m = k(m), m = c(m), m;
|
|
15
16
|
};
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
H as migrate
|
|
18
19
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ITEMS_PRICE_FORMAT_ATTR as e } from "../../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { applyPriceFormatOpsToElement as o, planPriceFormatOps as n, snapshotPriceFormatFromElement as c } from "../../extensions/Blocks/Items/utils/priceFormatOps.js";
|
|
3
|
+
import { protectLiquid as i, restoreLiquid as s } from "../../utils/liquidProtection.js";
|
|
4
|
+
const m = `td.ins-product-td.items-block-v2:not([${e.DECIMAL_COUNT}])`, a = (r) => o(
|
|
5
|
+
r,
|
|
6
|
+
n(c(r), { convertLegacy: !0 })
|
|
7
|
+
);
|
|
8
|
+
function T(r) {
|
|
9
|
+
if (typeof r != "string" || !r.includes("ins-product-td"))
|
|
10
|
+
return r;
|
|
11
|
+
try {
|
|
12
|
+
const t = new DOMParser().parseFromString(i(r), "text/html");
|
|
13
|
+
return Array.from(t.querySelectorAll(m)).map(a).includes(!0) ? s(t.documentElement.outerHTML) : r;
|
|
14
|
+
} catch (t) {
|
|
15
|
+
return console.error("ItemsPriceFormatMigrator failed:", t), r;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
T as migrateItemsPriceFormat
|
|
20
|
+
};
|
package/dist/enums/academy.js
CHANGED
|
@@ -2,7 +2,6 @@ const e = "https://academy.insiderone.com", o = {
|
|
|
2
2
|
EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
|
|
3
3
|
GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
|
|
4
4
|
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
|
|
5
|
-
EMAIL_DISPLAY_CONDITIONS: `${e}/docs/new-editor-add-display-conditions-to-an-email`,
|
|
6
5
|
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
|
|
7
6
|
};
|
|
8
7
|
export {
|
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
var E = (h, d, t) => d in h ? k(h, d, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[d] = t;
|
|
3
|
+
var C = (h, d, t) => E(h, typeof d != "symbol" ? d + "" : d, t);
|
|
4
|
+
import { useConfig as P } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as H } from "../../../enums/block.js";
|
|
6
|
+
import { useOnboardingStore as N } from "../../../stores/onboarding.js";
|
|
7
|
+
import { getMigrationBannerHtml as R } from "../../../utils/migrationBannerHtml.js";
|
|
8
|
+
import { Block as M, BlockCompositionType as O, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
9
|
+
import { PRODUCT_WRAPPER_SELECTOR as w, isZeroWidthValue as g } from "./constants/cardWidth.js";
|
|
10
|
+
import { DEFAULT_ITEMS_PRICE_FORMAT as I, isNewPriceFormatRoot as v, currencyAttrTargets as B, ITEMS_CURRENCY_ATTR as y } from "./constants/currency.js";
|
|
11
|
+
import { ItemsBlockId as A } from "./enums/controlEnums.js";
|
|
12
|
+
import { SETTINGS_ENUMS as S, DefaultConfigValues as b } from "./enums/settingsEnums.js";
|
|
13
|
+
import { getDefaultTemplate as F } from "./template.js";
|
|
14
|
+
import { getItemsBlockContainer as T, getItemsBlockConfig as _, deriveItemNumber as L, generateBlockInstanceId as x, getDefaultItemsBlockConfig as V } from "./utils/nodeConfigUtils.js";
|
|
15
|
+
import { buildPriceFormatSnapshot as W, planPriceFormatOps as z, samePriceText as U, replacePriceText as Y, paragraphKindOf as j } from "./utils/priceFormatOps.js";
|
|
16
|
+
const D = H.Items, q = "Reconcile Items currency DOM attributes";
|
|
17
|
+
function K() {
|
|
18
|
+
return {
|
|
19
|
+
priceThousandSeparator: I.thousandSeparator,
|
|
20
|
+
priceDecimalSeparator: I.decimalSeparator,
|
|
21
|
+
priceDecimalCount: I.decimalCount
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
class at extends M {
|
|
16
25
|
constructor() {
|
|
17
26
|
super(...arguments);
|
|
18
27
|
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
19
|
-
|
|
28
|
+
C(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
20
29
|
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
21
|
-
|
|
30
|
+
C(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
|
|
22
31
|
}
|
|
23
32
|
getId() {
|
|
24
|
-
return
|
|
33
|
+
return D;
|
|
25
34
|
}
|
|
26
35
|
getIcon() {
|
|
27
36
|
return "items-icon";
|
|
28
37
|
}
|
|
29
38
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
39
|
+
return O.CONTAINER;
|
|
31
40
|
}
|
|
32
41
|
getName() {
|
|
33
42
|
return this.api.translate("Items");
|
|
@@ -36,20 +45,21 @@ class $ extends H {
|
|
|
36
45
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
37
46
|
}
|
|
38
47
|
getSettingsPanelTitleHtml() {
|
|
39
|
-
return
|
|
40
|
-
|
|
48
|
+
return R(
|
|
49
|
+
D,
|
|
41
50
|
this.api.translate("Items"),
|
|
42
51
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
43
52
|
);
|
|
44
53
|
}
|
|
45
54
|
getTemplate() {
|
|
46
|
-
return
|
|
47
|
-
orientation:
|
|
48
|
-
itemsType:
|
|
55
|
+
return F({
|
|
56
|
+
orientation: S.ORIENTATION.VERTICAL,
|
|
57
|
+
itemsType: S.ITEMS_TYPE.CART_ITEMS,
|
|
49
58
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
50
|
-
currencySymbol:
|
|
51
|
-
currencyLocation:
|
|
52
|
-
formattedPrice:
|
|
59
|
+
currencySymbol: b.productPriceCurrencySymbolControlValue,
|
|
60
|
+
currencyLocation: b.productPriceCurrencyLocationControlValue,
|
|
61
|
+
formattedPrice: b.productPriceFormattedControlValue === "1",
|
|
62
|
+
priceFormat: this._isPriceFormattingEnabled() ? I : void 0
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
allowInnerBlocksDND() {
|
|
@@ -59,26 +69,29 @@ class $ extends H {
|
|
|
59
69
|
return !0;
|
|
60
70
|
}
|
|
61
71
|
onCreated(t) {
|
|
62
|
-
const e = this.api.getDocumentModifier(),
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
72
|
+
const e = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
|
|
73
|
+
s.querySelector('[product-attr="imageSrc"] img') || e.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
74
|
+
const o = T(t);
|
|
75
|
+
if (!o)
|
|
66
76
|
return;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
if (!
|
|
70
|
-
const
|
|
71
|
-
|
|
77
|
+
const i = o.getNodeConfig(), c = i && Object.keys(i).length > 0, r = _(t);
|
|
78
|
+
if (r != null && r.initialized) {
|
|
79
|
+
if (!c) {
|
|
80
|
+
const l = this.api.getDocumentModifier();
|
|
81
|
+
l.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, l), this._healCollapsedWidths(o, l), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, l), l.apply(new p("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(r.blockInstanceId);
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
84
|
} else {
|
|
75
|
-
const
|
|
76
|
-
|
|
85
|
+
const l = {
|
|
86
|
+
...V(),
|
|
87
|
+
...this._isPriceFormattingEnabled() ? K() : {}
|
|
88
|
+
}, f = this.api.getDocumentModifier();
|
|
89
|
+
f.modifyHtml(o).setNodeConfig(l), this._stampProductTdDomAttributes(o, l, f, !0), f.apply(new p("Initialize Items block with default configuration")), N().startOnboarding("itemsOnboarding");
|
|
77
90
|
return;
|
|
78
91
|
}
|
|
79
|
-
const
|
|
80
|
-
let
|
|
81
|
-
|
|
92
|
+
const n = this._resolveInstanceId(r.blockInstanceId), a = { ...r, blockInstanceId: n }, u = this.api.getDocumentModifier();
|
|
93
|
+
let m = !1;
|
|
94
|
+
n !== r.blockInstanceId && (u.modifyHtml(o).setNodeConfig(a), m = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(o, a, u) && (m = !0), this._healCollapsedWidths(o, u) && (m = !0), m && u.apply(new p("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
82
95
|
}
|
|
83
96
|
/**
|
|
84
97
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -87,23 +100,23 @@ class $ extends H {
|
|
|
87
100
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
88
101
|
*/
|
|
89
102
|
onDocumentChanged(t) {
|
|
90
|
-
const e =
|
|
103
|
+
const e = T(t);
|
|
91
104
|
if (!e)
|
|
92
105
|
return;
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
this._reconcileCurrencyDomAttributes(e,
|
|
106
|
+
const s = e.getNodeConfig();
|
|
107
|
+
if (s && Object.keys(s).length > 0) {
|
|
108
|
+
const r = _(t);
|
|
109
|
+
if (r != null && r.initialized && this._shouldReconcileCurrency(r)) {
|
|
110
|
+
const n = this.api.getDocumentModifier();
|
|
111
|
+
this._reconcileCurrencyDomAttributes(e, r, n) && n.apply(new p(q)), this._markCurrencyHealed(r.blockInstanceId);
|
|
99
112
|
}
|
|
100
113
|
return;
|
|
101
114
|
}
|
|
102
|
-
const
|
|
103
|
-
if (!(
|
|
115
|
+
const i = _(t);
|
|
116
|
+
if (!(i != null && i.initialized))
|
|
104
117
|
return;
|
|
105
|
-
const
|
|
106
|
-
|
|
118
|
+
const c = this.api.getDocumentModifier();
|
|
119
|
+
c.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, c), this._healCollapsedWidths(e, c), this._shouldReconcileCurrency(i) && this._reconcileCurrencyDomAttributes(e, i, c), c.apply(new p("Recover Items block config from saved module")), this._markCurrencyHealed(i.blockInstanceId);
|
|
107
120
|
}
|
|
108
121
|
/**
|
|
109
122
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -113,21 +126,21 @@ class $ extends H {
|
|
|
113
126
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
114
127
|
* relies on this td-level fallback in pairProductVariables.
|
|
115
128
|
*/
|
|
116
|
-
_stampProductTdDomAttributes(t, e,
|
|
117
|
-
const
|
|
118
|
-
|
|
129
|
+
_stampProductTdDomAttributes(t, e, s, o = !1) {
|
|
130
|
+
const i = L(e.itemsSelectValue, e.type), c = (r, n) => {
|
|
131
|
+
o && t.getAttribute(r) || s.modifyHtml(t).setAttribute(r, n);
|
|
119
132
|
};
|
|
120
|
-
|
|
133
|
+
c("data-type", e.type), c("data-number", i), c("data-nodup", String(e.priceHideDiscount));
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
123
136
|
* Repairs a saved module's collapsed card into the state the load migrator produces. Acts only
|
|
124
137
|
* on a zero width, so Stripo's non-zero drop-time width never triggers it and a healed block no-ops.
|
|
125
138
|
*/
|
|
126
139
|
_healCollapsedWidths(t, e) {
|
|
127
|
-
const
|
|
128
|
-
return !
|
|
129
|
-
const
|
|
130
|
-
(
|
|
140
|
+
const o = t.querySelectorAll(w).filter((i) => g(i.getAttribute("width")) || g(i.getStyle("width")));
|
|
141
|
+
return !g(t.getAttribute("width")) && !o.length ? !1 : (t.hasClass("esd-container-frame") && e.modifyHtml(t).removeClass("esd-container-frame"), t.getAttribute("width") !== null && e.modifyHtml(t).removeAttribute("width"), o.forEach((i) => {
|
|
142
|
+
const c = i.getAttribute("width");
|
|
143
|
+
(c === null || g(c)) && e.modifyHtml(i).setAttribute("width", "100%"), g(i.getStyle("width")) && e.modifyHtml(i).setStyle("width", "100%");
|
|
131
144
|
}), !0);
|
|
132
145
|
}
|
|
133
146
|
/**
|
|
@@ -156,30 +169,55 @@ class $ extends H {
|
|
|
156
169
|
let e = t;
|
|
157
170
|
if (!e || this._seenInstanceIds.has(e))
|
|
158
171
|
do
|
|
159
|
-
e =
|
|
172
|
+
e = x();
|
|
160
173
|
while (this._seenInstanceIds.has(e));
|
|
161
174
|
return this._seenInstanceIds.add(e), e;
|
|
162
175
|
}
|
|
163
176
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* Config is the source of truth — never derive from visible text.
|
|
167
|
-
*
|
|
168
|
-
* Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
|
|
169
|
-
* is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
|
|
170
|
-
*
|
|
171
|
-
* Returns true only when an attr actually changed, so the caller can skip an empty apply that
|
|
172
|
-
* would otherwise re-trigger onDocumentChanged and loop.
|
|
177
|
+
* Single self-heal slot: the flag only decides whether a legacy root is converted; a root
|
|
178
|
+
* already in the new format is reconciled from config regardless. Returns whether anything was queued.
|
|
173
179
|
*/
|
|
174
|
-
_reconcileCurrencyDomAttributes(t, e,
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
_reconcileCurrencyDomAttributes(t, e, s) {
|
|
181
|
+
const o = this._isPriceFormattingEnabled();
|
|
182
|
+
if (!o && !v(t))
|
|
183
|
+
return this._reconcileLegacyCurrencyAttributes(t, e, s);
|
|
184
|
+
const i = this._priceParagraphs(t), c = W({
|
|
185
|
+
rootAttr: (n) => t.getAttribute(n),
|
|
186
|
+
config: e,
|
|
187
|
+
paragraphs: i.map(({ kind: n, node: a }) => ({
|
|
188
|
+
kind: n,
|
|
189
|
+
attr: (u) => a.getAttribute(u),
|
|
190
|
+
text: a.getInnerText()
|
|
191
|
+
}))
|
|
192
|
+
}), r = z(c, { convertLegacy: o });
|
|
193
|
+
return r.changed ? (Object.entries(r.rootSet).forEach(([n, a]) => {
|
|
194
|
+
s.modifyHtml(t).setAttribute(n, a);
|
|
195
|
+
}), i.forEach(({ kind: n, node: a }) => {
|
|
196
|
+
var l;
|
|
197
|
+
r.paragraphRemove.filter((f) => a.getAttribute(f) !== null).forEach((f) => s.modifyHtml(a).removeAttribute(f));
|
|
198
|
+
const u = (l = r.texts) == null ? void 0 : l[n], m = a.getInnerText();
|
|
199
|
+
u !== void 0 && !U(m, u) && s.modifyHtml(a).setInnerHtml(Y(a.getInnerHTML(), m, u));
|
|
200
|
+
}), r.configPatch && s.modifyHtml(t).setNodeConfig({ ...e, ...r.configPatch }), !0) : !1;
|
|
201
|
+
}
|
|
202
|
+
/** Legacy `<p>` contract via `currencyAttrTargets`: position when recorded, symbol only when custom. */
|
|
203
|
+
_reconcileLegacyCurrencyAttributes(t, e, s) {
|
|
204
|
+
const { position: o, symbol: i } = B(e), c = t.querySelectorAll(`.${A.PRICE} p`);
|
|
205
|
+
let r = !1;
|
|
206
|
+
return c.forEach((n) => {
|
|
207
|
+
o !== void 0 && n.getAttribute(y.POSITION) !== o && (s.modifyHtml(n).setAttribute(y.POSITION, o), r = !0), i !== void 0 && n.getAttribute(y.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(y.SYMBOL, i), r = !0);
|
|
208
|
+
}), r;
|
|
209
|
+
}
|
|
210
|
+
_priceParagraphs(t) {
|
|
211
|
+
return t.querySelectorAll(`.${A.PRICE} p`).flatMap((s) => {
|
|
212
|
+
const o = j(s.getAttribute("product-attr"));
|
|
213
|
+
return o ? [{ kind: o, node: s }] : [];
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
_isPriceFormattingEnabled() {
|
|
217
|
+
return P().isFeatureEnabled("itemsPriceFormatting");
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
221
|
+
D as BLOCK_ID,
|
|
222
|
+
at as ItemsBlock
|
|
185
223
|
};
|