@useinsider/guido 3.2.0-beta.4345b1b → 3.2.0-beta.51460b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useActionsApi.js +4 -4
- package/dist/composables/useSave.js +1 -1
- package/dist/config/compiler/recommendationCompilerRules.js +67 -72
- package/dist/config/migrator/radioButtonMigrator.js +60 -49
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
- package/dist/extensions/Blocks/Items/enums/productEnums.js +7 -19
- package/dist/extensions/Blocks/RadioButton/template.js +1 -1
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/package.json +1 -1
|
@@ -89,11 +89,11 @@ const v = () => {
|
|
|
89
89
|
updateHtmlAndCss: (t, e) => {
|
|
90
90
|
window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
|
|
91
91
|
},
|
|
92
|
-
editorSave: () =>
|
|
93
|
-
window.StripoEditorApi.actionsApi.save((
|
|
94
|
-
|
|
92
|
+
editorSave: () => {
|
|
93
|
+
window.StripoEditorApi.actionsApi.save((t) => {
|
|
94
|
+
t && n(t, "Failed to save template");
|
|
95
95
|
});
|
|
96
|
-
}
|
|
96
|
+
}
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
export {
|
|
@@ -19,7 +19,7 @@ const F = () => {
|
|
|
19
19
|
return;
|
|
20
20
|
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
|
|
21
21
|
return;
|
|
22
|
-
|
|
22
|
+
c();
|
|
23
23
|
const { unsubscribePayload: f, stripoModules: v } = d(t.rawHtml);
|
|
24
24
|
return await u(f), t.modules = v, m || s(t), t;
|
|
25
25
|
} };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
1
|
+
import { useRecommendation as N } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as C, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as R, CONDITIONS as $, HTML as h } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
4
4
|
const w = [
|
|
5
5
|
{
|
|
6
6
|
id: "replace-images-with-variable-names",
|
|
7
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
8
8
|
type: "custom",
|
|
9
|
-
processor: (
|
|
10
|
-
let e =
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
e = e.replaceAll(
|
|
9
|
+
processor: (i) => {
|
|
10
|
+
let e = i;
|
|
11
|
+
return Object.entries(C).forEach(([, p]) => {
|
|
12
|
+
Object.entries(p).forEach(([c, n]) => {
|
|
13
|
+
e = e.replaceAll(n, `{{${c}}}`);
|
|
14
14
|
});
|
|
15
15
|
}), e;
|
|
16
16
|
},
|
|
@@ -29,21 +29,21 @@ const w = [
|
|
|
29
29
|
id: "add-recommendation-unresponsive-css",
|
|
30
30
|
description: "Adding recommendation unresponsive css",
|
|
31
31
|
type: "custom",
|
|
32
|
-
processor: (
|
|
33
|
-
const { calculateCardWidth: e, getRecommendationCampaignData:
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
32
|
+
processor: (i) => {
|
|
33
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: p } = N();
|
|
34
|
+
let c = i;
|
|
35
|
+
const n = c.match(T.ID);
|
|
36
|
+
if (n) {
|
|
37
37
|
const a = [];
|
|
38
|
-
if (
|
|
39
|
-
const d = /recommendation-id="(.*?)"/i.exec(
|
|
40
|
-
|
|
38
|
+
if (n.forEach((s) => {
|
|
39
|
+
const d = /recommendation-id="(.*?)"/i.exec(s), _ = d ? d[1].trim() : "", A = p(_);
|
|
40
|
+
A.textTrimming && A.orientation === M && a.push(e(A));
|
|
41
41
|
}), a.length) {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const s = `width:${Math.min(...a)}px!important;`;
|
|
43
|
+
c = c.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return c;
|
|
47
47
|
},
|
|
48
48
|
priority: 52
|
|
49
49
|
},
|
|
@@ -51,34 +51,34 @@ const w = [
|
|
|
51
51
|
id: "prepare-recommendations",
|
|
52
52
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
53
53
|
type: "custom",
|
|
54
|
-
processor: (
|
|
54
|
+
processor: (i) => x(i),
|
|
55
55
|
priority: 48
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
id: "add-discount-conditions",
|
|
59
59
|
description: "Adding discount conditions to the recommendation block",
|
|
60
60
|
type: "custom",
|
|
61
|
-
processor: (
|
|
62
|
-
let e =
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
const a =
|
|
61
|
+
processor: (i) => {
|
|
62
|
+
let e = i;
|
|
63
|
+
const p = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: c } = N();
|
|
64
|
+
return p !== null && p.forEach((n) => {
|
|
65
|
+
const a = n.match(T.CUSTOM_FIELD);
|
|
66
66
|
if (!a)
|
|
67
67
|
return;
|
|
68
|
-
const [
|
|
69
|
-
if (!d || !_ || !
|
|
68
|
+
const [s] = a, d = s.match(T.CUSTOM_FIELD_INDEXES_PART), _ = s.match(T.CUSTOM_FIELD_NAME_PART), A = n.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
|
+
if (!d || !_ || !A)
|
|
70
70
|
return;
|
|
71
|
-
const [
|
|
72
|
-
let t =
|
|
71
|
+
const [I] = d, [S] = _, [m] = A, o = S.substring(1, S.length - 2), r = m.match(T.COMPOSITION) !== null;
|
|
72
|
+
let t = s;
|
|
73
73
|
if (r) {
|
|
74
|
-
const
|
|
75
|
-
o ===
|
|
74
|
+
const b = I.substring(2, I.length - 3), l = c(b);
|
|
75
|
+
o === R.OMNIBUS_PRICE && (l.priceBeforeTextValue && (t = `${l.priceBeforeTextValue}${t}`), l.priceAfterTextValue && (t = `${t}${l.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (t = `${l.discountBeforeTextValue}${t}`), l.discountAfterTextValue && (t = `${t}${l.discountAfterTextValue}`));
|
|
76
76
|
}
|
|
77
|
-
const u =
|
|
77
|
+
const u = I.substring(2);
|
|
78
78
|
let f = "";
|
|
79
|
-
o in
|
|
80
|
-
const
|
|
81
|
-
e = e.replace(
|
|
79
|
+
o in $.IF && (f = $.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${u}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${u}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${u}${R.OMNIBUS_PRICE}`));
|
|
80
|
+
const g = `${m}${t}${h.PARAGRAPH_END_TAG}`, y = `${f}${r ? g : n}${$.ELSE}${m}${h.PARAGRAPH_END_TAG}${$.END_IF}`;
|
|
81
|
+
e = e.replace(n, y);
|
|
82
82
|
}), e;
|
|
83
83
|
},
|
|
84
84
|
priority: 53
|
|
@@ -95,24 +95,19 @@ const w = [
|
|
|
95
95
|
{
|
|
96
96
|
id: "strip-recommendation-editor-attributes",
|
|
97
97
|
description: "Strip editor-only attributes from compiled recommendation output",
|
|
98
|
-
type: "
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return c.replace(
|
|
104
|
-
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
105
|
-
(l, n) => `<!--REC_START-->${n.replace(e, "")}<!--REC_END-->`
|
|
106
|
-
);
|
|
107
|
-
},
|
|
98
|
+
type: "regex",
|
|
99
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
100
|
+
pattern: '\\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"',
|
|
101
|
+
replacement: "",
|
|
102
|
+
flags: "g",
|
|
108
103
|
priority: 55
|
|
109
104
|
},
|
|
110
105
|
{
|
|
111
106
|
id: "strip-unused-recommendation-classes",
|
|
112
107
|
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
113
108
|
type: "custom",
|
|
114
|
-
processor: (
|
|
115
|
-
let e =
|
|
109
|
+
processor: (i) => {
|
|
110
|
+
let e = i.replace(
|
|
116
111
|
/ class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
|
|
117
112
|
""
|
|
118
113
|
);
|
|
@@ -124,8 +119,8 @@ const w = [
|
|
|
124
119
|
id: "remove-empty-mobile-layout-artifacts",
|
|
125
120
|
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
126
121
|
type: "custom",
|
|
127
|
-
processor: (
|
|
128
|
-
let e =
|
|
122
|
+
processor: (i) => {
|
|
123
|
+
let e = i;
|
|
129
124
|
return e = e.replace(
|
|
130
125
|
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
131
126
|
""
|
|
@@ -134,9 +129,9 @@ const w = [
|
|
|
134
129
|
""
|
|
135
130
|
), e = e.replace(
|
|
136
131
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
137
|
-
(
|
|
138
|
-
const
|
|
139
|
-
return
|
|
132
|
+
(p, c) => {
|
|
133
|
+
const n = c.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
134
|
+
return n.every((d) => a.test(d)) ? "" : p;
|
|
140
135
|
}
|
|
141
136
|
)), e;
|
|
142
137
|
},
|
|
@@ -146,38 +141,38 @@ const w = [
|
|
|
146
141
|
id: "deduplicate-inline-styles",
|
|
147
142
|
description: "Replace repeated inline styles with CSS class references within recommendation blocks",
|
|
148
143
|
type: "custom",
|
|
149
|
-
processor: (
|
|
150
|
-
const e =
|
|
144
|
+
processor: (i) => {
|
|
145
|
+
const e = i.replace(
|
|
151
146
|
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
152
147
|
(o) => o.replace(
|
|
153
148
|
/([;"]color:)([^;"]+)/g,
|
|
154
149
|
(r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
|
|
155
150
|
)
|
|
156
|
-
),
|
|
157
|
-
let a =
|
|
151
|
+
), p = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, c = / style="([^"]*)"/g, n = /* @__PURE__ */ new Map();
|
|
152
|
+
let a = p.exec(e);
|
|
158
153
|
for (; a !== null; ) {
|
|
159
|
-
let o =
|
|
154
|
+
let o = c.exec(a[1]);
|
|
160
155
|
for (; o !== null; ) {
|
|
161
156
|
const [, r] = o;
|
|
162
|
-
|
|
157
|
+
n.set(r, (n.get(r) || 0) + 1), o = c.exec(a[1]);
|
|
163
158
|
}
|
|
164
|
-
|
|
159
|
+
c.lastIndex = 0, a = p.exec(e);
|
|
165
160
|
}
|
|
166
|
-
const
|
|
161
|
+
const s = /* @__PURE__ */ new Map(), d = [];
|
|
167
162
|
let _ = 0;
|
|
168
|
-
if (
|
|
163
|
+
if (n.forEach((o, r) => {
|
|
169
164
|
if (o >= 6) {
|
|
170
165
|
const t = `rc${_++}`;
|
|
171
|
-
|
|
166
|
+
s.set(r, t), d.push(`.${t}{${r}}`);
|
|
172
167
|
}
|
|
173
|
-
}),
|
|
168
|
+
}), s.size === 0) {
|
|
174
169
|
let o = e;
|
|
175
170
|
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
176
171
|
}
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const t =
|
|
180
|
-
|
|
172
|
+
const A = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), I = (o, r) => `${o.slice(0, -1)} ${r}"`, S = /* @__PURE__ */ new Map();
|
|
173
|
+
s.forEach((o, r) => {
|
|
174
|
+
const t = A(r);
|
|
175
|
+
S.set(r, {
|
|
181
176
|
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
182
177
|
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
183
178
|
});
|
|
@@ -187,14 +182,14 @@ const w = [
|
|
|
187
182
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
188
183
|
(o, r) => {
|
|
189
184
|
let t = r;
|
|
190
|
-
return
|
|
191
|
-
const
|
|
185
|
+
return s.forEach((u, f) => {
|
|
186
|
+
const g = S.get(f);
|
|
192
187
|
t = t.replace(
|
|
193
|
-
|
|
194
|
-
(y,
|
|
188
|
+
g.caseA,
|
|
189
|
+
(y, b, l) => I(b, u) + l
|
|
195
190
|
), t = t.replace(
|
|
196
|
-
|
|
197
|
-
(y,
|
|
191
|
+
g.caseB,
|
|
192
|
+
(y, b, l) => b + I(l, u)
|
|
198
193
|
), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
|
|
199
194
|
}), t;
|
|
200
195
|
}
|
|
@@ -1,88 +1,99 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
class
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var T = (l, e, t) => e in l ? h(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var y = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import S from "../../extensions/Blocks/RadioButton/template.js";
|
|
5
|
+
class B {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
7
|
+
y(this, "parser");
|
|
8
8
|
this.parser = new DOMParser();
|
|
9
9
|
}
|
|
10
|
-
migrate(
|
|
10
|
+
migrate(e) {
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.radio-button-block"), i = t.querySelectorAll("td.radio-button-v2");
|
|
13
|
+
if (s.length === 0 && i.length === 0)
|
|
14
|
+
return e;
|
|
15
|
+
let n = !1;
|
|
16
|
+
return s.forEach((r) => {
|
|
17
|
+
if (r.classList.contains("radio-button-v2"))
|
|
15
18
|
return;
|
|
16
|
-
const
|
|
17
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
19
|
+
const c = r.getAttribute("id"), o = this.extractTextFromElement(r, "ins-title"), a = this.extractTextFromElement(r, "ins-description"), p = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), m = this.buildTextBlock(o), d = this.buildTextBlock(a), g = this.buildTextBlock({ ...p, classList: "" }), x = this.buildTextBlock({ ...u, classList: "" }), f = S.replace("{-{-TITLE-}-}", m).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", g).replace("{-{-NO-}-}", x), b = this.parser.parseFromString(
|
|
20
|
+
`<table id="tempDoc"><tbody><tr>${f}</tr></tbody></table>`,
|
|
18
21
|
"text/html"
|
|
19
22
|
).querySelector(".radio-button-v2");
|
|
20
|
-
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
b && r.parentNode && (b.setAttribute("id", c || ""), r.parentNode.replaceChild(b, r), n = !0);
|
|
24
|
+
}), t.querySelectorAll('td.radio-button-v2 input[type="radio"]').forEach((r) => {
|
|
25
|
+
var p, u;
|
|
26
|
+
const c = (p = r.parentElement) == null ? void 0 : p.querySelector(":scope > p"), o = (u = r.parentElement) == null ? void 0 : u.parentElement;
|
|
27
|
+
if (!c || (o == null ? void 0 : o.tagName) !== "TR")
|
|
28
|
+
return;
|
|
29
|
+
r.removeAttribute("esd-block-text"), r.removeAttribute("align");
|
|
30
|
+
const a = t.createElement("td");
|
|
31
|
+
a.className = "esd-block-text", a.appendChild(c), o.appendChild(a), n = !0;
|
|
32
|
+
}), n ? t.documentElement.outerHTML : e;
|
|
33
|
+
} catch (t) {
|
|
34
|
+
return console.error("RadioButtonMigrator failed:", t), e;
|
|
24
35
|
}
|
|
25
36
|
}
|
|
26
|
-
extractTextFromElement(
|
|
27
|
-
var
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
37
|
+
extractTextFromElement(e, t) {
|
|
38
|
+
var d, g;
|
|
39
|
+
const s = e.querySelector(`.${t}`);
|
|
40
|
+
if (!s)
|
|
30
41
|
return {
|
|
31
|
-
text:
|
|
42
|
+
text: t === "ins-title" ? "Title" : "Description",
|
|
32
43
|
isBold: !1,
|
|
33
44
|
isItalic: !1,
|
|
34
45
|
align: "left",
|
|
35
46
|
styles: "",
|
|
36
47
|
classList: ""
|
|
37
48
|
};
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
49
|
+
const i = s.querySelector("p");
|
|
50
|
+
if (!i)
|
|
40
51
|
return {
|
|
41
|
-
text: ((
|
|
52
|
+
text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
|
|
42
53
|
isBold: !1,
|
|
43
54
|
isItalic: !1,
|
|
44
|
-
align:
|
|
55
|
+
align: s.getAttribute("align") || "left",
|
|
45
56
|
styles: "",
|
|
46
57
|
classList: ""
|
|
47
58
|
};
|
|
48
|
-
const n = ((
|
|
59
|
+
const n = ((g = i.textContent) == null ? void 0 : g.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", c = s.getAttribute("align") || i.getAttribute("align") || "left", o = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), a = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), p = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(p), m = s.getAttribute("class") || "";
|
|
49
60
|
return {
|
|
50
61
|
text: n,
|
|
51
|
-
isBold:
|
|
52
|
-
isItalic:
|
|
53
|
-
align:
|
|
54
|
-
styles:
|
|
62
|
+
isBold: o,
|
|
63
|
+
isItalic: a,
|
|
64
|
+
align: c,
|
|
65
|
+
styles: u,
|
|
55
66
|
classList: m
|
|
56
67
|
};
|
|
57
68
|
}
|
|
58
|
-
buildTextBlock(
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const
|
|
69
|
+
buildTextBlock(e) {
|
|
70
|
+
let t = e.text;
|
|
71
|
+
e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
|
|
72
|
+
const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
|
|
62
73
|
return `
|
|
63
|
-
<td class="esd-block-text ${
|
|
64
|
-
<p path="1" ${
|
|
65
|
-
${
|
|
74
|
+
<td class="esd-block-text ${e.classList}" ${s}>
|
|
75
|
+
<p path="1" ${i}>
|
|
76
|
+
${t}
|
|
66
77
|
</p>
|
|
67
78
|
</td>
|
|
68
79
|
`;
|
|
69
80
|
}
|
|
70
|
-
removeStyleProperties(
|
|
71
|
-
return
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
},
|
|
81
|
+
removeStyleProperties(e, t) {
|
|
82
|
+
return e ? t.reduce((i, n) => {
|
|
83
|
+
const r = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
84
|
+
return i.replace(r, "");
|
|
85
|
+
}, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
75
86
|
}
|
|
76
|
-
convertInlineToBlock(
|
|
77
|
-
if (!
|
|
87
|
+
convertInlineToBlock(e) {
|
|
88
|
+
if (!e)
|
|
78
89
|
return "";
|
|
79
|
-
let
|
|
80
|
-
return /display\s*:/i.test(
|
|
90
|
+
let t = e.replace(/display\s*:\s*inline/gi, "display: block");
|
|
91
|
+
return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
|
-
function
|
|
84
|
-
return new
|
|
94
|
+
function k(l) {
|
|
95
|
+
return new B().migrate(l);
|
|
85
96
|
}
|
|
86
97
|
export {
|
|
87
|
-
|
|
98
|
+
k as migrateRadioButton
|
|
88
99
|
};
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { getItemsBlockConfig as I, setItemsBlockConfig as
|
|
6
|
-
const
|
|
1
|
+
import { ModificationDescription as m, UIElementType as _, UEAttr as A } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as h } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as L, ItemsBlockId as R } from "../../enums/controlEnums.js";
|
|
4
|
+
import { productPairs as T } from "../../enums/productEnums.js";
|
|
5
|
+
import { getItemsBlockConfig as I, setItemsBlockConfig as u, escapeReplacement as N } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const D = L.PRICE_SINGLE_PRICE, l = {
|
|
7
7
|
SINGLE_PRICE: "singlePrice"
|
|
8
8
|
};
|
|
9
|
-
class
|
|
9
|
+
class y extends h {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return D;
|
|
12
12
|
}
|
|
13
13
|
getTemplate() {
|
|
14
14
|
return `
|
|
15
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${L.PRICE_SINGLE_PRICE}">
|
|
16
16
|
${this._getSinglePrice()}
|
|
17
17
|
</div>
|
|
18
18
|
`;
|
|
19
19
|
}
|
|
20
20
|
onRender() {
|
|
21
21
|
const e = I(this.currentNode);
|
|
22
|
-
this.api.updateValues({ [l.SINGLE_PRICE]: (e == null ? void 0 : e.priceSinglePrice) ?? !1 }), this.api.onValueChanged(l.SINGLE_PRICE, (
|
|
23
|
-
this._onSinglePriceChange(
|
|
22
|
+
this.api.updateValues({ [l.SINGLE_PRICE]: (e == null ? void 0 : e.priceSinglePrice) ?? !1 }), this.api.onValueChanged(l.SINGLE_PRICE, (t) => {
|
|
23
|
+
this._onSinglePriceChange(t);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
onTemplateNodeUpdated(e) {
|
|
27
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const
|
|
29
|
-
this.api.updateValues({ [l.SINGLE_PRICE]: (
|
|
28
|
+
const t = I(this.currentNode);
|
|
29
|
+
this.api.updateValues({ [l.SINGLE_PRICE]: (t == null ? void 0 : t.priceSinglePrice) ?? !1 });
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
_onSinglePriceChange(e) {
|
|
33
|
-
if (console.debug("Single price changed to: ", e), !this.currentNode)
|
|
33
|
+
if (console.debug("Single price changed to: ", e), u(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
|
|
34
34
|
return;
|
|
35
|
-
const
|
|
36
|
-
r ?
|
|
37
|
-
r ?
|
|
35
|
+
const t = I(this.currentNode), o = (t == null ? void 0 : t.type) ?? "CART_ITEMS", r = (t == null ? void 0 : t.priceFormatted) ?? !1, i = T.PAIRS_FOR_EXTENSION.price[o], c = T.PAIRS_FOR_EXTENSION.originalPrice[o], [P, p] = e ? [
|
|
36
|
+
r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
|
|
37
|
+
r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
|
|
38
38
|
] : [
|
|
39
|
-
r ?
|
|
40
|
-
r ?
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
((
|
|
45
|
-
|
|
39
|
+
r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
|
|
40
|
+
r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
|
|
41
|
+
], s = r ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, d = r ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, [g, C] = e ? [s, d] : [d, s], n = this.currentNode.closest(".items-block"), S = (n == null ? void 0 : n.querySelectorAll(
|
|
42
|
+
`[esd-extension-block-id="${R.PRICE}"]`
|
|
43
|
+
)) || [], E = this.api.getDocumentModifier();
|
|
44
|
+
S.forEach((a) => {
|
|
45
|
+
this._updatePriceBlock(E, a, P, p, e);
|
|
46
|
+
}), ((n == null ? void 0 : n.querySelectorAll(
|
|
47
|
+
`[esd-extension-block-id="${R.ORIGINAL_PRICE}"]`
|
|
46
48
|
)) || []).forEach((a) => {
|
|
47
|
-
this._updatePriceBlock(
|
|
48
|
-
}), (
|
|
49
|
-
`[esd-extension-block-id="${p.ORIGINAL_PRICE}"]`
|
|
50
|
-
)) || []).forEach((a) => {
|
|
51
|
-
this._updatePriceBlock(s, a, L, C, e);
|
|
52
|
-
}), s.apply(new S(
|
|
49
|
+
this._updatePriceBlock(E, a, g, C, e);
|
|
50
|
+
}), E.apply(new m(
|
|
53
51
|
`Updated price to ${e ? "single" : "total"} price`
|
|
54
52
|
));
|
|
55
53
|
}
|
|
56
|
-
_updatePriceBlock(e,
|
|
57
|
-
const
|
|
58
|
-
e.modifyHtml(
|
|
54
|
+
_updatePriceBlock(e, t, o, r, i) {
|
|
55
|
+
const c = t.getInnerHTML().trim().replace(o, N(r));
|
|
56
|
+
e.modifyHtml(t).setInnerHtml(c), t.querySelectorAll('[product-attr="price"], [product-attr="originalPrice"]').forEach((s) => {
|
|
57
|
+
e.modifyHtml(s).setAttribute("data-single_price", i ? "true" : "false");
|
|
58
|
+
});
|
|
59
59
|
}
|
|
60
60
|
_getSinglePrice() {
|
|
61
61
|
return `
|
|
62
62
|
<div class="display-flex align-items-center justify-content-between">
|
|
63
|
-
<${
|
|
64
|
-
${
|
|
63
|
+
<${_.LABEL}
|
|
64
|
+
${A.LABEL.text}="${this.api.translate("Show Single Product Price")}"
|
|
65
65
|
>
|
|
66
|
-
</${
|
|
66
|
+
</${_.LABEL}>
|
|
67
67
|
${this._GuToggle(l.SINGLE_PRICE)}
|
|
68
68
|
</div>
|
|
69
69
|
`;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
D as CONTROL_BLOCK_ID,
|
|
74
|
+
y as PriceSinglePriceControl
|
|
75
75
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from "../../../../node_modules/lodash-es/flatMap.js";
|
|
2
|
-
import
|
|
3
|
-
const T = '<td align="center" class="ins-product-td items-block items-block-v2">',
|
|
2
|
+
import a from "../../../../node_modules/lodash-es/range.js";
|
|
3
|
+
const T = '<td align="center" class="ins-product-td items-block items-block-v2">', E = { PAIRS_FOR_EXTENSION: {
|
|
4
4
|
imageSrc: {
|
|
5
5
|
CART_ITEMS: {
|
|
6
6
|
ATTR: "ins_apr_img",
|
|
@@ -212,10 +212,10 @@ const T = '<td align="center" class="ins-product-td items-block items-block-v2">
|
|
|
212
212
|
}
|
|
213
213
|
} };
|
|
214
214
|
function m(e, s = 8) {
|
|
215
|
-
return
|
|
215
|
+
return a(1, s + 1).map((i) => `${e}_${i}`);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
const { PAIRS_FOR_EXTENSION: e } =
|
|
217
|
+
function t() {
|
|
218
|
+
const { PAIRS_FOR_EXTENSION: e } = E, s = [];
|
|
219
219
|
return s.push(
|
|
220
220
|
e.imageSrc.CART_ITEMS.ATTR,
|
|
221
221
|
e.imageSrc.BROWSED_ITEMS.ATTR,
|
|
@@ -234,34 +234,22 @@ function r() {
|
|
|
234
234
|
), s.push(
|
|
235
235
|
e.price.CART_ITEMS.PRICE,
|
|
236
236
|
e.price.CART_ITEMS.PRICE_FORMATTED,
|
|
237
|
-
e.price.CART_ITEMS.SINGLE_PRICE,
|
|
238
|
-
e.price.CART_ITEMS.SINGLE_PRICE_FORMATTED,
|
|
239
237
|
e.price.CART_ITEMS.CURRENCY,
|
|
240
238
|
e.price.BROWSED_ITEMS.PRICE,
|
|
241
239
|
e.price.BROWSED_ITEMS.PRICE_FORMATTED,
|
|
242
|
-
e.price.BROWSED_ITEMS.SINGLE_PRICE,
|
|
243
|
-
e.price.BROWSED_ITEMS.SINGLE_PRICE_FORMATTED,
|
|
244
240
|
e.price.BROWSED_ITEMS.CURRENCY,
|
|
245
241
|
e.price.PURCHASED_ITEMS.PRICE,
|
|
246
242
|
e.price.PURCHASED_ITEMS.PRICE_FORMATTED,
|
|
247
|
-
e.price.PURCHASED_ITEMS.SINGLE_PRICE,
|
|
248
|
-
e.price.PURCHASED_ITEMS.SINGLE_PRICE_FORMATTED,
|
|
249
243
|
e.price.PURCHASED_ITEMS.CURRENCY
|
|
250
244
|
), s.push(
|
|
251
245
|
e.originalPrice.CART_ITEMS.PRICE,
|
|
252
246
|
e.originalPrice.CART_ITEMS.PRICE_FORMATTED,
|
|
253
|
-
e.originalPrice.CART_ITEMS.SINGLE_PRICE,
|
|
254
|
-
e.originalPrice.CART_ITEMS.SINGLE_PRICE_FORMATTED,
|
|
255
247
|
e.originalPrice.CART_ITEMS.CURRENCY,
|
|
256
248
|
e.originalPrice.BROWSED_ITEMS.PRICE,
|
|
257
249
|
e.originalPrice.BROWSED_ITEMS.PRICE_FORMATTED,
|
|
258
|
-
e.originalPrice.BROWSED_ITEMS.SINGLE_PRICE,
|
|
259
|
-
e.originalPrice.BROWSED_ITEMS.SINGLE_PRICE_FORMATTED,
|
|
260
250
|
e.originalPrice.BROWSED_ITEMS.CURRENCY,
|
|
261
251
|
e.originalPrice.PURCHASED_ITEMS.PRICE,
|
|
262
252
|
e.originalPrice.PURCHASED_ITEMS.PRICE_FORMATTED,
|
|
263
|
-
e.originalPrice.PURCHASED_ITEMS.SINGLE_PRICE,
|
|
264
|
-
e.originalPrice.PURCHASED_ITEMS.SINGLE_PRICE_FORMATTED,
|
|
265
253
|
e.originalPrice.PURCHASED_ITEMS.CURRENCY
|
|
266
254
|
), s.push(
|
|
267
255
|
e.button.CART_ITEMS.HREF,
|
|
@@ -274,11 +262,11 @@ function r() {
|
|
|
274
262
|
), s;
|
|
275
263
|
}
|
|
276
264
|
const o = _(
|
|
277
|
-
|
|
265
|
+
t(),
|
|
278
266
|
(e) => m(e)
|
|
279
267
|
);
|
|
280
268
|
export {
|
|
281
269
|
o as itemsBlockDynamicVariables,
|
|
282
|
-
|
|
270
|
+
E as productPairs,
|
|
283
271
|
T as templateFirstLine
|
|
284
272
|
};
|
|
@@ -3,15 +3,15 @@ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
5
|
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as _, BlockCompositionType as S,
|
|
7
|
-
import { getDefaultTemplate as
|
|
6
|
+
import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as L } from "./template.js";
|
|
8
8
|
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
9
|
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
-
const
|
|
10
|
+
const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
|
|
11
11
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
12
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class R extends _ {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
u(this, "selectEventListener", null);
|
|
@@ -19,7 +19,7 @@ class I extends _ {
|
|
|
19
19
|
u(this, "currentNode");
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return v;
|
|
23
23
|
}
|
|
24
24
|
getIcon() {
|
|
25
25
|
return "unsubscribe-icon";
|
|
@@ -34,7 +34,7 @@ class I extends _ {
|
|
|
34
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
35
35
|
}
|
|
36
36
|
getTemplate() {
|
|
37
|
-
return
|
|
37
|
+
return L();
|
|
38
38
|
}
|
|
39
39
|
onSelect(e) {
|
|
40
40
|
this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
@@ -66,7 +66,7 @@ class I extends _ {
|
|
|
66
66
|
try {
|
|
67
67
|
if (!this.currentNode)
|
|
68
68
|
return;
|
|
69
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).
|
|
69
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
|
|
70
70
|
} catch (e) {
|
|
71
71
|
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
72
72
|
}
|
|
@@ -77,14 +77,14 @@ class I extends _ {
|
|
|
77
77
|
_updateBlock(e, r) {
|
|
78
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
79
79
|
return;
|
|
80
|
-
const s = this.currentNode.querySelector(
|
|
80
|
+
const s = this.currentNode.querySelector(g);
|
|
81
81
|
if (!s)
|
|
82
82
|
return;
|
|
83
83
|
const t = this._getMergeTag(e);
|
|
84
84
|
this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
|
|
85
85
|
}
|
|
86
86
|
_getMergeTag(e) {
|
|
87
|
-
return
|
|
87
|
+
return B[e] ?? T;
|
|
88
88
|
}
|
|
89
89
|
_openDrawer() {
|
|
90
90
|
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
@@ -130,6 +130,6 @@ class I extends _ {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
v as UNSUBSCRIBE_BLOCK_ID,
|
|
134
|
+
R as UnsubscribeBlock
|
|
135
135
|
};
|
|
@@ -7,5 +7,5 @@ export declare const useActionsApi: () => {
|
|
|
7
7
|
getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
|
|
8
8
|
updateTimerInClonedTemplate: () => Promise<string | null>;
|
|
9
9
|
updateHtmlAndCss: (html: string, css: string) => void;
|
|
10
|
-
editorSave: () =>
|
|
10
|
+
editorSave: () => void;
|
|
11
11
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const migrationTemplate = "\n <td\n align=\"left\"\n esd-extension-block-id=\"radio-button-block\"\n esd-handler-name=\"esd-extension-RadioButtonBlock\"\n class=\"\n radio-button\n radio-button-v2\n esd-block-ra\n esd-radio-button-block\n esd-extension-block\n es-p10t\n es-p10b\n es-p30r\n es-p30l\"\n >\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td align=\"left\" width=\"70%\" style=\"vertical-align: top;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n <tr>\n {-{-DESCRIPTION-}-}\n </tr>\n </tbody>\n </table>\n </td>\n <td align=\"right\" width=\"30%\" style=\"vertical-align: middle;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioYes\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle
|
|
1
|
+
declare const migrationTemplate = "\n <td\n align=\"left\"\n esd-extension-block-id=\"radio-button-block\"\n esd-handler-name=\"esd-extension-RadioButtonBlock\"\n class=\"\n radio-button\n radio-button-v2\n esd-block-ra\n esd-radio-button-block\n esd-extension-block\n es-p10t\n es-p10b\n es-p30r\n es-p30l\"\n >\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td align=\"left\" width=\"70%\" style=\"vertical-align: top;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n <tr>\n {-{-DESCRIPTION-}-}\n </tr>\n </tbody>\n </table>\n </td>\n <td align=\"right\" width=\"30%\" style=\"vertical-align: middle;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioYes\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;\">\n </td>\n {-{-YES-}-}\n </tr>\n </table>\n </td>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioNo\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;\">\n </td>\n {-{-NO-}-}\n </tr>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n";
|
|
2
2
|
/**
|
|
3
3
|
* @returns The template for the default checkbox block
|
|
4
4
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.2.0-beta.
|
|
3
|
+
"version": "3.2.0-beta.51460b4",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|