@useinsider/guido 3.5.1-beta.ff14e7c → 3.5.2-beta.c2f8a2e

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.
@@ -1,127 +1,133 @@
1
- import { useConfig as S } from "../../../composables/useConfig.js";
2
- import { useRecommendation as g } from "../../../composables/useRecommendation.js";
3
- import { CSS_CLASS_RECO_BUTTON as _ } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as q } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- function y(r, c, e, o, s = "") {
6
- const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
7
- return o === "before" ? `${t} ${n}` : `${n} ${t}`;
1
+ import { useConfig as g } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
+ import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ function y(r, n, e, o, i = "") {
6
+ const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
7
+ return o === "before" ? `${t} ${c}` : `${c} ${t}`;
8
8
  }
9
- function f(r, c, e, o, s, n) {
10
- switch (c) {
9
+ function A(r) {
10
+ let n = r;
11
+ for (; n.children.length === 1; )
12
+ [n] = n.children;
13
+ return n;
14
+ }
15
+ function f(r, n, e, o, i, c) {
16
+ switch (n) {
11
17
  case "productImage": {
12
18
  const t = r.querySelector("img");
13
- t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
14
- const i = r.querySelector("a");
15
- i && (i.setAttribute("href", `{{${n}${e}_${o}_url}}`), i.classList.add(_));
19
+ t && (t.setAttribute("src", `{{${c}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${c}${e}_${o}_name}}`));
20
+ const s = r.querySelector("a");
21
+ s && (s.setAttribute("href", `{{${c}${e}_${o}_url}}`), s.classList.add(q));
16
22
  break;
17
23
  }
18
24
  case "productName": {
19
25
  const t = r.querySelector("p");
20
26
  if (t) {
21
- const i = t.querySelector("strong") || t;
22
- i.textContent = `{{${n}${e}_${o}_name}}`;
27
+ const s = t.querySelector("strong") || t;
28
+ s.textContent = `{{${c}${e}_${o}_name}}`;
23
29
  }
24
30
  break;
25
31
  }
26
32
  case "productPrice": {
27
33
  const t = r.querySelector("p");
28
- if (t) {
29
- const i = t.querySelector("strong") || t;
30
- i.textContent = y(e, o, "price", s, n);
31
- }
34
+ t && (A(t).textContent = y(
35
+ e,
36
+ o,
37
+ "price",
38
+ i,
39
+ c
40
+ ));
32
41
  break;
33
42
  }
34
43
  case "productOldPrice": {
35
44
  const t = r.querySelector("p");
36
- if (t) {
37
- const i = t.querySelector("strong") || t;
38
- i.textContent = y(
39
- e,
40
- o,
41
- "original_price",
42
- s,
43
- n
44
- ), t.setAttribute("product-attr", "discount");
45
- }
45
+ t && (A(t).textContent = y(
46
+ e,
47
+ o,
48
+ "original_price",
49
+ i,
50
+ c
51
+ ), t.setAttribute("product-attr", "discount"));
46
52
  break;
47
53
  }
48
54
  case "productButton": {
49
55
  const t = r.querySelector("a");
50
- t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
56
+ t && t.setAttribute("href", `{{${c}${e}_${o}_url}}`);
51
57
  break;
52
58
  }
53
59
  case "productOmnibusPrice": {
54
60
  const t = r.querySelector(".omnibus-price-value");
55
61
  if (t) {
56
- t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
57
- const i = t.closest("p");
58
- i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
62
+ t.textContent = `{{${c}${e}_${o}_omnibus_price}}`;
63
+ const s = t.closest("p");
64
+ s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
59
65
  }
60
66
  break;
61
67
  }
62
68
  case "productOmnibusDiscount": {
63
69
  const t = r.querySelector(".omnibus-discount-value");
64
70
  if (t) {
65
- t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
66
- const i = t.closest("p");
67
- i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
71
+ t.textContent = `{{${c}${e}_${o}_omnibus_discount}}`;
72
+ const s = t.closest("p");
73
+ s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
68
74
  }
69
75
  break;
70
76
  }
71
77
  default: {
72
78
  const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
73
79
  if (t) {
74
- const i = t.getAttribute("product-attr"), a = t.querySelector("p");
80
+ const s = t.getAttribute("product-attr"), a = t.querySelector("p");
75
81
  if (a) {
76
82
  const u = a.querySelector("strong") || a;
77
- u.textContent = `{{${n}${e}_${o}_${i}}}`;
83
+ u.textContent = `{{${c}${e}_${o}_${s}}}`;
78
84
  }
79
85
  }
80
86
  break;
81
87
  }
82
88
  }
83
89
  }
84
- function C(r, c, e, o) {
85
- r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
86
- n.querySelectorAll("[data-attribute-type]").forEach((a) => {
90
+ function w(r, n, e, o) {
91
+ r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
92
+ c.querySelectorAll("[data-attribute-type]").forEach((a) => {
87
93
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
88
94
  p.length > 0 ? p.forEach((l) => {
89
- f(l, u, c, t, e, o);
90
- }) : f(a, u, c, t, e, o);
95
+ f(l, u, n, t, e, o);
96
+ }) : f(a, u, n, t, e, o);
91
97
  });
92
98
  });
93
99
  }
94
- function E(r, c, e, o) {
95
- const s = r.querySelectorAll(".recommendation-product-row");
96
- if (!s.length)
100
+ function E(r, n, e, o) {
101
+ const i = r.querySelectorAll(".recommendation-product-row");
102
+ if (!i.length)
97
103
  return;
98
- const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
99
- s.forEach((a, u) => {
104
+ const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
105
+ i.forEach((a, u) => {
100
106
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
101
107
  const d = l.getAttribute("data-attribute-type") || "";
102
- l.querySelectorAll(".attribute-cell").forEach((A, h) => {
103
- const $ = u * i + h;
104
- f(A, d, c, $, e, o);
108
+ l.querySelectorAll(".attribute-cell").forEach((h, $) => {
109
+ const S = u * s + $;
110
+ f(h, d, n, S, e, o);
105
111
  });
106
112
  });
107
113
  });
108
114
  }
109
- function w(r, c, e, o) {
110
- r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
111
- E(n, c, e, o);
115
+ function R(r, n, e, o) {
116
+ r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
117
+ E(c, n, e, o);
112
118
  });
113
119
  }
114
- function R(r, c, e) {
115
- const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
116
- o === "list" ? C(r, c, s, e) : w(r, c, s, e);
120
+ function P(r, n, e) {
121
+ const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
122
+ o === "list" ? w(r, n, i, e) : R(r, n, i, e);
117
123
  }
118
- function b(r, c, e) {
119
- const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
120
- return s ? parseInt(s[1]) : e;
124
+ function b(r, n, e) {
125
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
126
+ return i ? parseInt(i[1]) : e;
121
127
  }
122
- function P(r, c) {
128
+ function T(r, n) {
123
129
  let e = r.parentElement;
124
- for (; e && e !== c; ) {
130
+ for (; e && e !== n; ) {
125
131
  if (e.tagName === "TD") {
126
132
  const o = e.getAttribute("width");
127
133
  if (o && o.endsWith("%") && parseFloat(o) < 100)
@@ -131,40 +137,40 @@ function P(r, c) {
131
137
  }
132
138
  return null;
133
139
  }
134
- function T(r) {
135
- const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
136
- s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
137
- if (n.hasAttribute("width"))
140
+ function v(r) {
141
+ const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
142
+ i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
143
+ if (c.hasAttribute("width"))
138
144
  return;
139
- const t = P(n, r);
145
+ const t = T(c, r);
140
146
  if (!t)
141
147
  return;
142
- const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
143
- n.setAttribute("width", String(l));
144
- const d = n.getAttribute("style") || "";
148
+ const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
149
+ c.setAttribute("width", String(l));
150
+ const d = c.getAttribute("style") || "";
145
151
  if (!/\bwidth\s*:\s*\d/i.test(d)) {
146
152
  const m = d && !d.trim().endsWith(";") ? "; " : "";
147
- n.setAttribute("style", `${d}${m}width: ${l}px`);
153
+ c.setAttribute("style", `${d}${m}width: ${l}px`);
148
154
  }
149
155
  });
150
156
  }
151
- function v(r, c) {
157
+ function O(r, n) {
152
158
  const e = r.match(/<!DOCTYPE[^>]*>/i);
153
159
  return (e ? `${e[0]}
154
- ` : "") + c.documentElement.outerHTML;
160
+ ` : "") + n.documentElement.outerHTML;
155
161
  }
156
162
  function N(r) {
157
- const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
163
+ const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
158
164
  if (!o.length)
159
165
  return r;
160
- const { buildCampaignUrl: s } = g(), n = q();
161
- n.recommendationCampaignUrls = {};
162
- const { isFeatureEnabled: t } = S(), i = t("liquidSyntax") ? "reco_" : "";
166
+ const { buildCampaignUrl: i } = _(), c = C();
167
+ c.recommendationCampaignUrls = {};
168
+ const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
163
169
  return o.forEach((u) => {
164
170
  var l, d;
165
171
  const p = u.getAttribute("recommendation-id");
166
- p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), R(u, p, i), T(u));
167
- }), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
172
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
173
+ }), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
168
174
  }
169
175
  export {
170
176
  y as formatPriceVariable,
@@ -1,85 +1,36 @@
1
- var x = Object.defineProperty;
2
- var y = (s, t, e) => t in s ? x(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var m = (s, t, e) => y(s, typeof t != "symbol" ? t + "" : t, e);
4
- import b from "../../extensions/Blocks/Checkbox/template.js";
5
- class f {
1
+ var h = Object.defineProperty;
2
+ var g = (r, t, e) => t in r ? h(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var l = (r, t, e) => g(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import f from "../../extensions/Blocks/Checkbox/template.js";
5
+ import { extractTextFromElement as m, buildTextBlock as p } from "./textBlockMigration.js";
6
+ class C {
6
7
  constructor() {
7
- m(this, "parser");
8
+ l(this, "parser");
8
9
  this.parser = new DOMParser();
9
10
  }
10
11
  migrate(t) {
11
12
  try {
12
- const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
13
- return i.length === 0 ? t : (i.forEach((r) => {
14
- if (r.classList.contains("checkbox-block-v2"))
13
+ const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.checkbox-block");
14
+ if (n.length === 0)
15
+ return t;
16
+ let i = !1;
17
+ return n.forEach((o) => {
18
+ if (o.classList.contains("checkbox-block-v2"))
15
19
  return;
16
- const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
17
- `<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
20
+ const b = o.getAttribute("id"), s = m(o, "ins-title"), a = m(o, "ins-description"), u = p(s, s.containerClass), x = p(a, a.containerClass), d = f.replace("{-{-TITLE-}-}", u).replace("{-{-DESCRIPTION-}-}", x), c = this.parser.parseFromString(
21
+ `<table id="tempDoc"><tbody><tr>${d}</tr></tbody></table>`,
18
22
  "text/html"
19
23
  ).querySelector(".checkbox-block-v2");
20
- o && r.parentNode && (o.setAttribute("id", n || ""), r.parentNode.replaceChild(o, r));
21
- }), e.documentElement.outerHTML);
24
+ c && o.parentNode && (c.setAttribute("id", b || ""), o.parentNode.replaceChild(c, o), i = !0);
25
+ }), i ? e.documentElement.outerHTML : t;
22
26
  } catch (e) {
23
27
  return console.error("CheckboxMigrator failed:", e), t;
24
28
  }
25
29
  }
26
- extractTextFromElement(t, e) {
27
- var o, d;
28
- const i = t.querySelector(`.${e}`);
29
- if (!i)
30
- return {
31
- text: e === "ins-title" ? "Title" : "Description",
32
- isBold: !1,
33
- isItalic: !1,
34
- align: "left",
35
- styles: ""
36
- };
37
- const r = i.querySelector("p");
38
- if (!r)
39
- return {
40
- text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
41
- isBold: !1,
42
- isItalic: !1,
43
- align: i.getAttribute("align") || "left",
44
- styles: ""
45
- };
46
- const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
47
- return {
48
- text: n,
49
- isBold: a,
50
- isItalic: p,
51
- align: c,
52
- styles: u
53
- };
54
- }
55
- buildTextBlock(t) {
56
- let e = t.text;
57
- t.isBold && t.isItalic ? e = `<strong path="1,0"><em path="1,0,0">${e}</em></strong>` : t.isBold ? e = `<strong path="1,0">${e}</strong>` : t.isItalic && (e = `<em path="1,0">${e}</em>`);
58
- const i = t.align ? ` align="${t.align}"` : "", r = t.styles ? ` style="${t.styles}"` : "";
59
- return `
60
- <td class="esd-block-text" ${i}>
61
- <p path="1" ${r}>
62
- ${e}
63
- </p>
64
- </td>
65
- `;
66
- }
67
- removeStyleProperties(t, e) {
68
- return t ? e.reduce((r, n) => {
69
- const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
70
- return r.replace(l, "");
71
- }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
72
- }
73
- convertInlineToBlock(t) {
74
- if (!t)
75
- return "";
76
- let e = t.replace(/display\s*:\s*inline/gi, "display: block");
77
- return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
78
- }
79
30
  }
80
- function k(s) {
81
- return new f().migrate(s);
31
+ function E(r) {
32
+ return new C().migrate(r);
82
33
  }
83
34
  export {
84
- k as migrateCheckbox
35
+ E as migrateCheckbox
85
36
  };
@@ -1,109 +1,54 @@
1
- var x = Object.defineProperty;
2
- var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
- import S from "../../extensions/Blocks/RadioButton/template.js";
5
- class B {
1
+ var q = Object.defineProperty;
2
+ var C = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var g = (o, t, e) => C(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import N from "../../extensions/Blocks/RadioButton/template.js";
5
+ import { extractTextFromElement as b, buildTextBlock as f } from "./textBlockMigration.js";
6
+ class R {
6
7
  constructor() {
7
- b(this, "parser");
8
+ g(this, "parser");
8
9
  this.parser = new DOMParser();
9
10
  }
10
- migrate(e) {
11
+ migrate(t) {
11
12
  try {
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 o = !1;
16
- return s.forEach((r) => {
13
+ const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.radio-button-block"), a = e.querySelectorAll("td.radio-button-v2");
14
+ if (n.length === 0 && a.length === 0)
15
+ return t;
16
+ let i = !1;
17
+ return n.forEach((r) => {
17
18
  if (r.classList.contains("radio-button-v2"))
18
19
  return;
19
- const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), p = this.buildTextBlock(a), d = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
20
- `<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
20
+ const s = r.getAttribute("id"), c = b(r, "ins-title"), d = b(r, "ins-description"), u = b(r, "ins-subscribe"), l = b(r, "ins-unsubscribe"), p = f(c, c.containerClass), m = f(d, d.containerClass), h = f(u), S = f(l), T = N.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", h).replace("{-{-NO-}-}", S), y = this.parser.parseFromString(
21
+ `<table id="tempDoc"><tbody><tr>${T}</tr></tbody></table>`,
21
22
  "text/html"
22
23
  ).querySelector(".radio-button-v2");
23
- m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
24
- }), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
25
- } catch (t) {
26
- return console.error("RadioButtonMigrator failed:", t), e;
24
+ y && r.parentNode && (y.setAttribute("id", s || ""), r.parentNode.replaceChild(y, r), i = !0);
25
+ }), i = this.healRadioButtonV2(e) || i, i ? e.documentElement.outerHTML : t;
26
+ } catch (e) {
27
+ return console.error("RadioButtonMigrator failed:", e), t;
27
28
  }
28
29
  }
29
- healRadioButtonV2(e) {
30
- let t = !1;
31
- return e.querySelectorAll("td.radio-button-v2").forEach((s) => {
32
- var d;
33
- s.classList.contains("radio-button-block") || (s.classList.add("radio-button-block"), t = !0);
34
- const i = s.querySelector("input#radioYes"), o = s.querySelector("input#radioNo");
35
- if (!i || !o)
30
+ healRadioButtonV2(t) {
31
+ let e = !1;
32
+ return t.querySelectorAll("td.radio-button-v2").forEach((n) => {
33
+ var m;
34
+ n.classList.contains("radio-button-block") || (n.classList.add("radio-button-block"), e = !0);
35
+ const a = n.querySelector("input#radioYes"), i = n.querySelector("input#radioNo");
36
+ if (!a || !i)
36
37
  return;
37
- const r = ((d = i.parentElement) == null ? void 0 : d.querySelector(":scope > p")) || null;
38
- if (!r && !i.hasAttribute("align"))
38
+ const r = ((m = a.parentElement) == null ? void 0 : m.querySelector(":scope > p")) || null;
39
+ if (!r && !a.hasAttribute("align"))
39
40
  return;
40
- const n = i.closest("tr"), a = o.closest("tr");
41
- if (!n || !a || n === a || !n.parentNode)
41
+ const s = a.closest("tr"), c = i.closest("tr");
42
+ if (!s || !c || s === c || !s.parentNode)
42
43
  return;
43
- const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), p = c.querySelector("p");
44
- u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), p && (p.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
45
- }), t;
46
- }
47
- extractTextFromElement(e, t) {
48
- var d, y;
49
- const s = e.querySelector(`.${t}`);
50
- if (!s)
51
- return {
52
- text: t === "ins-title" ? "Title" : "Description",
53
- isBold: !1,
54
- isItalic: !1,
55
- align: "left",
56
- styles: "",
57
- classList: ""
58
- };
59
- const i = s.querySelector("p");
60
- if (!i)
61
- return {
62
- text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
63
- isBold: !1,
64
- isItalic: !1,
65
- align: s.getAttribute("align") || "left",
66
- styles: "",
67
- classList: ""
68
- };
69
- const o = ((y = i.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", n = s.getAttribute("align") || i.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), p = s.getAttribute("class") || "";
70
- return {
71
- text: o,
72
- isBold: a,
73
- isItalic: g,
74
- align: n,
75
- styles: u,
76
- classList: p
77
- };
78
- }
79
- buildTextBlock(e) {
80
- let t = e.text;
81
- 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>`);
82
- const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
83
- return `
84
- <td class="esd-block-text ${e.classList}" ${s}>
85
- <p path="1" ${i}>
86
- ${t}
87
- </p>
88
- </td>
89
- `;
90
- }
91
- removeStyleProperties(e, t) {
92
- return e ? t.reduce((i, o) => {
93
- const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
94
- return i.replace(r, "");
95
- }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
96
- }
97
- convertInlineToBlock(e) {
98
- if (!e)
99
- return "";
100
- let t = e.replace(/display\s*:\s*inline/gi, "display: block");
101
- return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
44
+ const d = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", u = c.cloneNode(!0), l = u.querySelector("input#radioNo"), p = u.querySelector("p");
45
+ l && (l.setAttribute("id", "radioYes"), l.removeAttribute("align")), p && (p.innerHTML = d), s.parentNode.replaceChild(u, s), e = !0;
46
+ }), e;
102
47
  }
103
48
  }
104
- function L(l) {
105
- return new B().migrate(l);
49
+ function w(o) {
50
+ return new R().migrate(o);
106
51
  }
107
52
  export {
108
- L as migrateRadioButton
53
+ w as migrateRadioButton
109
54
  };
@@ -0,0 +1,65 @@
1
+ const I = {
2
+ "ins-title": "Title",
3
+ "ins-description": "Description",
4
+ "ins-subscribe": "Yes",
5
+ "ins-unsubscribe": "No"
6
+ }, y = /font-weight\s*:\s*[^;]*;?/gi, S = /font-style\s*:\s*[^;]*;?/gi, u = /;\s*;/g, T = /^;|;$/g, d = /display\s*:\s*inline/gi, m = /display\s*:/i, b = /font-weight\s*:\s*bold/i, A = /font-style\s*:\s*italic/i, R = /^<(?:strong|b)\b/i, $ = /^<(?:em|i)\b/i;
7
+ function L(t) {
8
+ return t ? t.replace(y, "").replace(S, "").replace(u, ";").replace(T, "").trim() : "";
9
+ }
10
+ function O(t) {
11
+ if (!t)
12
+ return "";
13
+ let e = t.replace(d, "display: block");
14
+ return m.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(u, ";").replace(T, "").trim();
15
+ }
16
+ function B(t, e) {
17
+ var c, a;
18
+ const o = I[e], l = t.querySelector(`.${e}`);
19
+ if (!l)
20
+ return {
21
+ paragraphs: [{ innerHtml: o, isBold: !1, isItalic: !1, styles: "" }],
22
+ align: "left",
23
+ containerClass: ""
24
+ };
25
+ const n = Array.from(l.querySelectorAll("p")), p = l.getAttribute("align") || ((c = n[0]) == null ? void 0 : c.getAttribute("align")) || "left", i = l.getAttribute("class") || "";
26
+ return n.length === 0 ? {
27
+ paragraphs: [{
28
+ innerHtml: ((a = l.textContent) == null ? void 0 : a.trim()) || o,
29
+ isBold: !1,
30
+ isItalic: !1,
31
+ styles: ""
32
+ }],
33
+ align: p,
34
+ containerClass: ""
35
+ } : { paragraphs: n.map((r) => {
36
+ const _ = r.getAttribute("style") || "", f = b.test(_) || !!r.querySelector("b, strong"), g = A.test(_) || !!r.querySelector("i, em"), E = L(_);
37
+ return {
38
+ // Legacy parity: empty <p> → fallback placeholder; <p><br></p> is not empty.
39
+ innerHtml: r.innerHTML.trim() || o,
40
+ isBold: f,
41
+ isItalic: g,
42
+ styles: O(E)
43
+ };
44
+ }), align: p, containerClass: i };
45
+ }
46
+ function C(t, e = "") {
47
+ const o = t.align ? ` align="${t.align}"` : "", l = t.paragraphs.map((n, p) => {
48
+ const i = p + 1;
49
+ let s = n.innerHtml;
50
+ const c = n.isBold && !R.test(s), a = n.isItalic && !$.test(s);
51
+ c && a ? s = `<strong path="${i},0"><em path="${i},0,0">${s}</em></strong>` : c ? s = `<strong path="${i},0">${s}</strong>` : a && (s = `<em path="${i},0">${s}</em>`);
52
+ const r = n.styles ? ` style="${n.styles.replaceAll('"', "'")}"` : "";
53
+ return `<p path="${i}"${r}>${s}</p>`;
54
+ }).join(`
55
+ `);
56
+ return `
57
+ <td class="esd-block-text ${e}" ${o}>
58
+ ${l}
59
+ </td>
60
+ `;
61
+ }
62
+ export {
63
+ C as buildTextBlock,
64
+ B as extractTextFromElement
65
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared text-block migration helpers used by both `radioButtonMigrator` and
3
+ * `checkboxMigrator`. Extracts a legacy v1 `.ins-title` / `.ins-description`
4
+ * cell into a paragraph descriptor and rebuilds it as a v2 `esd-block-text`
5
+ * cell — preserving every <p>, every inline tag (<u>, <a>, <br>, <strong>,
6
+ * <em>) and re-encoding bold/italic detection as canonical tags.
7
+ */
8
+ export type InsCellClass = 'ins-title' | 'ins-description' | 'ins-subscribe' | 'ins-unsubscribe';
9
+ type ParagraphContent = {
10
+ innerHtml: string;
11
+ isBold: boolean;
12
+ isItalic: boolean;
13
+ styles: string;
14
+ };
15
+ export type TextContent = {
16
+ paragraphs: ParagraphContent[];
17
+ align: string;
18
+ };
19
+ export type ExtractedTextContent = TextContent & {
20
+ containerClass: string;
21
+ };
22
+ export declare function extractTextFromElement(parent: Element, className: InsCellClass): ExtractedTextContent;
23
+ export declare function buildTextBlock(content: TextContent, extraClass?: string): string;
24
+ export {};
@@ -11,6 +11,11 @@ ue-description a {
11
11
  display: none;
12
12
  }
13
13
 
14
+ /* Override the rule above for the Gmail Promotions switcher docs link — remove with DT-28355. */
15
+ ue-lock-container.e2e-promotions-switcher ue-description a {
16
+ display: unset;
17
+ }
18
+
14
19
  .label {
15
20
  font-size: 13px;
16
21
  color: var(--guido-color-gray-800);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.5.1-beta.ff14e7c",
3
+ "version": "3.5.2-beta.c2f8a2e",
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",