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