@useinsider/guido 3.21.1-beta.7f84ba7 → 3.21.1

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.
@@ -7,13 +7,13 @@ function L(t, r, e, o, c = "") {
7
7
  const i = `{{${c}${t}_${r}_${e}}}`, n = `{{${c}${t}_${r}_currency}}`;
8
8
  return o === "before" ? `${n} ${i}` : `${i} ${n}`;
9
9
  }
10
- function A(t) {
10
+ function _(t) {
11
11
  let r = t;
12
12
  for (; r.children.length === 1; )
13
13
  [r] = r.children;
14
14
  return r;
15
15
  }
16
- function y(t, r, e, o, c, i) {
16
+ function A(t, r, e, o, c, i) {
17
17
  switch (r) {
18
18
  case "productImage": {
19
19
  const n = t.querySelector("img");
@@ -24,7 +24,7 @@ function y(t, r, e, o, c, i) {
24
24
  }
25
25
  case "productName": {
26
26
  const n = t.querySelector("p");
27
- n && (A(n).textContent = `{{${i}${e}_${o}_name}}`);
27
+ n && (_(n).textContent = `{{${i}${e}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  // Inline mode ("Move to next line" OFF) merges BOTH prices into one row
@@ -32,16 +32,16 @@ function y(t, r, e, o, c, i) {
32
32
  // substitute by cell content, not by the row's anchor (SD-145161).
33
33
  case "productPrice":
34
34
  case "productOldPrice": {
35
- const n = (a, l) => {
36
- a && (A(a).textContent = L(
35
+ const n = (l, d) => {
36
+ l && (_(l).textContent = L(
37
37
  e,
38
38
  o,
39
- l,
39
+ d,
40
40
  c,
41
41
  i
42
42
  ));
43
- }, s = t.querySelector(".product-price p"), d = t.querySelector(".product-old-price p"), u = !s && !d ? t.querySelector("p") : null;
44
- n(s ?? (r === "productPrice" ? u : null), "price"), n(d ?? (r === "productOldPrice" ? u : null), "original_price");
43
+ }, s = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !s && !a ? t.querySelector("p") : null;
44
+ n(s ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
45
45
  break;
46
46
  }
47
47
  case "productButton": {
@@ -70,8 +70,8 @@ function y(t, r, e, o, c, i) {
70
70
  default: {
71
71
  const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
72
72
  if (n) {
73
- const s = n.getAttribute("product-attr"), d = n.querySelector("p");
74
- d && (A(d).textContent = `{{${i}${e}_${o}_${s}}}`);
73
+ const s = n.getAttribute("product-attr"), a = n.querySelector("p");
74
+ a && (_(a).textContent = `{{${i}${e}_${o}_${s}}}`);
75
75
  }
76
76
  break;
77
77
  }
@@ -88,54 +88,54 @@ function b(t, r, e, o) {
88
88
  function R(t, r, e) {
89
89
  return b(t, r, 0, e);
90
90
  }
91
- function w(t, r, e, o) {
91
+ function D(t, r, e, o) {
92
92
  if (!t.innerHTML.includes("{{"))
93
93
  return;
94
94
  const { open: c, close: i } = b(t.ownerDocument, r, e, o);
95
95
  t.insertBefore(c, t.firstChild), t.appendChild(i);
96
96
  }
97
- function D(t, r, e, o) {
97
+ function w(t, r, e, o) {
98
98
  var n, s;
99
99
  if (!t.innerHTML.includes("{{"))
100
100
  return;
101
101
  const { open: c, close: i } = b(t.ownerDocument, r, e, o);
102
102
  (n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
103
103
  }
104
- function v(t, r, e, o) {
104
+ function W(t, r, e, o) {
105
105
  t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
106
- i.querySelectorAll("[data-attribute-type]").forEach((d) => {
107
- const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
108
- a.length > 0 ? a.forEach((l) => {
109
- y(l, u, r, n, e, o);
110
- }) : y(d, u, r, n, e, o);
111
- }), D(i, r, n, o);
106
+ i.querySelectorAll("[data-attribute-type]").forEach((a) => {
107
+ const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
108
+ l.length > 0 ? l.forEach((d) => {
109
+ A(d, u, r, n, e, o);
110
+ }) : A(a, u, r, n, e, o);
111
+ }), w(i, r, n, o);
112
112
  });
113
113
  }
114
- function H(t, r, e, o) {
114
+ function v(t, r, e, o) {
115
115
  const c = t.querySelectorAll(".recommendation-product-row");
116
116
  if (!c.length)
117
117
  return;
118
118
  const [i] = c, n = i.querySelector("[data-attribute-type]"), s = n ? n.querySelectorAll(".attribute-cell").length : 1;
119
- c.forEach((d, u) => {
120
- d.querySelectorAll("[data-attribute-type]").forEach((l) => {
121
- const p = l.getAttribute("data-attribute-type") || "";
122
- l.querySelectorAll(".attribute-cell").forEach((f, h) => {
123
- const S = u * s + h;
124
- y(f, p, r, S, e, o), w(f, r, S, o);
119
+ c.forEach((a, u) => {
120
+ a.querySelectorAll("[data-attribute-type]").forEach((d) => {
121
+ const p = d.getAttribute("data-attribute-type") || "";
122
+ d.querySelectorAll(".attribute-cell").forEach((f, m) => {
123
+ const h = u * s + m;
124
+ A(f, p, r, h, e, o), D(f, r, h, o);
125
125
  });
126
126
  });
127
127
  });
128
128
  }
129
- function W(t, r, e, o) {
129
+ function H(t, r, e, o) {
130
130
  t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
131
- H(i, r, e, o);
131
+ v(i, r, e, o);
132
132
  });
133
133
  }
134
134
  function F(t, r, e) {
135
135
  const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment") || "after";
136
- o === "list" ? v(t, r, c, e) : W(t, r, c, e);
136
+ o === "list" ? W(t, r, c, e) : H(t, r, c, e);
137
137
  }
138
- function _(t, r, e) {
138
+ function y(t, r, e) {
139
139
  const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
140
140
  return c ? parseInt(c[1]) : e;
141
141
  }
@@ -150,7 +150,7 @@ function C(t) {
150
150
  const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
151
151
  return e && $(e[1]) ? e[1] : null;
152
152
  }
153
- function x(t, r) {
153
+ function G(t, r) {
154
154
  let e = t.parentElement;
155
155
  for (; e && e !== r; ) {
156
156
  if (e.tagName === "TD" && C(e))
@@ -159,37 +159,35 @@ function x(t, r) {
159
159
  }
160
160
  return null;
161
161
  }
162
- function G(t) {
163
- const r = t.getAttribute("style") || "", e = _(r, "width", 600), o = _(r, "padding", 0) * 2, c = Math.max(0, e - o);
162
+ function V(t) {
163
+ const r = t.getAttribute("style") || "", e = y(r, "width", 600), o = y(r, "padding", 0) * 2, c = Math.max(0, e - o);
164
164
  c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
165
165
  if (i.hasAttribute("width"))
166
166
  return;
167
- const n = x(i, t);
167
+ const n = G(i, t);
168
168
  if (!n)
169
169
  return;
170
- const s = C(n), d = _(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
171
- if (p) {
172
- i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
173
- return;
174
- }
175
- if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
176
- const m = l && !l.trim().endsWith(";") ? "; " : "";
177
- i.setAttribute("style", `${l}${m}width: ${a}px`);
170
+ const s = C(n), a = y(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), l = Math.max(1, u - a);
171
+ i.setAttribute("width", String(l));
172
+ const d = i.getAttribute("style") || "";
173
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
174
+ const p = d && !d.trim().endsWith(";") ? "; " : "";
175
+ i.setAttribute("style", `${d}${p}width: ${l}px`);
178
176
  }
179
177
  });
180
178
  }
181
- const E = "MSO_MOBILE_HIDE_START", V = "MSO_MOBILE_HIDE_END";
182
- function U(t, r) {
179
+ const E = "MSO_MOBILE_HIDE_START", U = "MSO_MOBILE_HIDE_END";
180
+ function X(t, r) {
183
181
  t.querySelectorAll(q).forEach((e) => {
184
182
  var i, n;
185
183
  const o = e.querySelector(M);
186
184
  if (!o || o.children.length === 0)
187
185
  return;
188
186
  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(V), e.nextSibling));
187
+ (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(U), e.nextSibling));
190
188
  });
191
189
  }
192
- function X(t, r) {
190
+ function j(t, r) {
193
191
  const e = t.match(/<!DOCTYPE[^>]*>/i);
194
192
  return (e ? `${e[0]}
195
193
  ` : "") + r.documentElement.outerHTML;
@@ -202,17 +200,17 @@ function Q(t) {
202
200
  i.recommendationCampaignUrls = {};
203
201
  const { isFeatureEnabled: n } = g(), s = n("liquidSyntax") ? "reco_" : "";
204
202
  return o.forEach((u) => {
205
- var l, p, m, f;
206
- const a = u.getAttribute("recommendation-id");
207
- if (a) {
208
- if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
209
- F(u, a, s);
210
- const { open: h, close: S } = R(e, a, s);
211
- (m = u.parentNode) == null || m.insertBefore(h, u), (f = u.parentNode) == null || f.insertBefore(S, u.nextSibling);
203
+ var d, p, S, f;
204
+ const l = u.getAttribute("recommendation-id");
205
+ if (l) {
206
+ 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((m) => m.remove()), c(l), X(u, e), !T(u)) {
207
+ F(u, l, s);
208
+ const { open: m, close: h } = R(e, l, s);
209
+ (S = u.parentNode) == null || S.insertBefore(m, u), (f = u.parentNode) == null || f.insertBefore(h, u.nextSibling);
212
210
  }
213
- G(u);
211
+ V(u);
214
212
  }
215
- }), X(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
213
+ }), j(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
216
214
  }
217
215
  export {
218
216
  L as formatPriceVariable,
@@ -1,24 +1,23 @@
1
- var b = Object.defineProperty;
2
- var A = (m, c, e) => c in m ? b(m, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[c] = e;
3
- var u = (m, c, e) => A(m, typeof c != "symbol" ? c + "" : c, e);
1
+ var A = Object.defineProperty;
2
+ var D = (m, c, e) => c in m ? A(m, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[c] = e;
3
+ var u = (m, c, e) => D(m, typeof c != "symbol" ? c + "" : c, e);
4
4
  import { useConfig as g } from "../../../composables/useConfig.js";
5
- import { BlockId as D } from "../../../enums/block.js";
5
+ import { BlockId as b } from "../../../enums/block.js";
6
6
  import { getMigrationBannerHtml as E } from "../../../utils/migrationBannerHtml.js";
7
7
  import { Block as S, BlockCompositionType as v, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
- import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as M } from "./constants/defaultConfig.js";
8
+ import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as w } from "./constants/defaultConfig.js";
9
9
  import { RECOMMENDATION_ID_ATTR as f } from "./constants/selectors.js";
10
- import { ensureMobileFitRule as w, syncHeightBound as O } from "./controls/image/index.js";
11
- import { regenerateMobileProductRows as H } from "./controls/main/utils.js";
12
- import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as T } from "./controls/mobileLayout/cssRules.js";
10
+ import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
11
+ import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as O } from "./controls/mobileLayout/cssRules.js";
13
12
  import { RecommendationConfigService as a } from "./services/configService.js";
14
13
  import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
15
- import { getDefaultTemplate as x } from "./templates/grid/template.js";
16
- import { useRecommendationBlockWarning as F } from "./useRecommendationBlockWarning.js";
17
- import { registerNodeConfigWriter as y, readBlockNodeConfigs as $ } from "./utils/nodeConfigWriter.js";
18
- import { refreshArrivedStrategyBlocks as q, resolveSourceConfig as L, refreshDuplicatedStrategyBlocks as P } from "./utils/strategyCommit.js";
19
- const k = D.Recommendation, h = "recommendation-block-v2", C = "hide-price";
14
+ import { getDefaultTemplate as T } from "./templates/grid/template.js";
15
+ import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
16
+ import { registerNodeConfigWriter as k, readBlockNodeConfigs as $ } from "./utils/nodeConfigWriter.js";
17
+ import { refreshArrivedStrategyBlocks as q, resolveSourceConfig as H, refreshDuplicatedStrategyBlocks as F } from "./utils/strategyCommit.js";
18
+ const y = b.Recommendation, d = "recommendation-block-v2", C = "hide-price";
20
19
  let B = !1;
21
- class se extends S {
20
+ class te extends S {
22
21
  constructor() {
23
22
  super();
24
23
  /**
@@ -35,7 +34,7 @@ class se extends S {
35
34
  u(this, "_refreshClaims", /* @__PURE__ */ new Map());
36
35
  }
37
36
  getId() {
38
- return k;
37
+ return y;
39
38
  }
40
39
  getIcon() {
41
40
  return "recommendation-icon";
@@ -53,7 +52,7 @@ class se extends S {
53
52
  }
54
53
  getSettingsPanelTitleHtml() {
55
54
  return E(
56
- k,
55
+ y,
57
56
  this.api.translate("Recommendation Block"),
58
57
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
59
58
  );
@@ -76,7 +75,7 @@ class se extends S {
76
75
  */
77
76
  getTemplate() {
78
77
  const e = this._generateNextId();
79
- return this._pendingBlockId = e, x(e);
78
+ return this._pendingBlockId = e, T(e);
80
79
  }
81
80
  /**
82
81
  * Called when a new block is dropped into the template
@@ -88,7 +87,7 @@ class se extends S {
88
87
  onCreated(e) {
89
88
  const t = this._getRecommendationId(e);
90
89
  if (t !== null && t > 0) {
91
- if (this._pendingBlockId = null, this._ensureMobileFitRule(e), this._detectDuplicate(t)) {
90
+ if (this._pendingBlockId = null, this._detectDuplicate(t)) {
92
91
  this._handleDuplicate(e, t), this._scheduleArrivalReset(e);
93
92
  return;
94
93
  }
@@ -110,7 +109,7 @@ class se extends S {
110
109
  e,
111
110
  {
112
111
  recommendationId: i,
113
- configVersion: r ? N : M,
112
+ configVersion: r ? N : w,
114
113
  ...s ? { partnerName: g().partnerName.value } : {},
115
114
  // An RRS block picks a strategy, not an algorithm, and its algorithm control is
116
115
  // hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
@@ -120,8 +119,8 @@ class se extends S {
120
119
  ), l = p();
121
120
  if (l.setCurrentBlock(i), this._stampHidePrice(e, n.priceHideIfSameAsDiscounted), o) {
122
121
  I(this.api);
123
- const d = this._getBlockElement(e);
124
- d && (R(this.api, d, !0), H({
122
+ const h = this._getBlockElement(e);
123
+ h && (R(this.api, h, !0), M({
125
124
  currentNode: e,
126
125
  documentModifier: this.api.getDocumentModifier()
127
126
  }));
@@ -132,7 +131,7 @@ class se extends S {
132
131
  onDocumentInit() {
133
132
  try {
134
133
  const e = this.api.getDocumentRoot();
135
- e && "querySelectorAll" in e && e.querySelectorAll(`.${h}`).forEach((t) => this._queueArrivalRefresh(t));
134
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${d}`).forEach((t) => this._queueArrivalRefresh(t));
136
135
  } catch (e) {
137
136
  console.error("[recommendation] refreshing an opened strategy failed", e);
138
137
  }
@@ -155,13 +154,13 @@ class se extends S {
155
154
  "Assign recommendation ID to legacy block"
156
155
  );
157
156
  }
158
- this._healLingeringDuplicate(e), a.needsMigration(e) && this._migrateFromLegacy(e), this._healHidePriceAttr(e), this._ensureMobileFitRule(e), this._syncHeightBound(e);
157
+ this._healLingeringDuplicate(e), a.needsMigration(e) && this._migrateFromLegacy(e), this._healHidePriceAttr(e);
159
158
  try {
160
159
  B || (I(this.api), B = !0);
161
160
  const t = a.getConfig(e), i = this._getBlockElement(e);
162
161
  if (i) {
163
162
  const r = !t.mobileLayoutEnabled;
164
- T(i) !== r && R(this.api, i, r);
163
+ O(i) !== r && R(this.api, i, r);
165
164
  }
166
165
  } catch {
167
166
  }
@@ -177,20 +176,6 @@ class se extends S {
177
176
  const t = this._getRecommendationId(e);
178
177
  t && p().removeBlockState(t);
179
178
  }
180
- _ensureMobileFitRule(e) {
181
- try {
182
- w(this.api, e);
183
- } catch {
184
- }
185
- }
186
- _syncHeightBound(e) {
187
- const t = this._getBlockElement(e);
188
- if (t)
189
- try {
190
- O(this.api, t);
191
- } catch {
192
- }
193
- }
194
179
  /**
195
180
  * Warns (dark advisory toaster) when the design holds more than one live
196
181
  * recommendation block. Triggered from the user-add paths only (fresh drop
@@ -205,7 +190,7 @@ class se extends S {
205
190
  */
206
191
  _warnIfMultipleBlocks() {
207
192
  try {
208
- F().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
193
+ x().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
209
194
  } catch {
210
195
  }
211
196
  }
@@ -218,7 +203,7 @@ class se extends S {
218
203
  const t = /* @__PURE__ */ new Set();
219
204
  try {
220
205
  const i = this.api.getDocumentRoot();
221
- i && "querySelectorAll" in i && i.querySelectorAll(`.${h}`).forEach((s) => {
206
+ i && "querySelectorAll" in i && i.querySelectorAll(`.${d}`).forEach((s) => {
222
207
  if ("getAttribute" in s) {
223
208
  const n = s.getAttribute(f), o = n ? parseInt(n) : 0;
224
209
  t.add(o), o > e && (e = o);
@@ -259,7 +244,7 @@ class se extends S {
259
244
  }, 0));
260
245
  }
261
246
  _refreshArrivedBlocks(e) {
262
- y(this.api);
247
+ k(this.api);
263
248
  const t = /* @__PURE__ */ new Set(), i = e.flatMap(({ node: r, id: s }) => {
264
249
  const n = s ?? this._getRecommendationId(r), o = this._getBlockElement(r);
265
250
  if (!n || !o || t.has(n))
@@ -267,8 +252,8 @@ class se extends S {
267
252
  const l = a.getConfig(o);
268
253
  if (!this._canClaimRefresh(n, l.strategyId))
269
254
  return [];
270
- const d = { strategyId: l.strategyId };
271
- return t.add(n), this._refreshClaims.set(n, d), [{ id: n, config: l, claim: d }];
255
+ const h = { strategyId: l.strategyId };
256
+ return t.add(n), this._refreshClaims.set(n, h), [{ id: n, config: l, claim: h }];
272
257
  });
273
258
  i.length && q(i.map(({ id: r, config: s }) => ({ id: r, config: s }))).catch((r) => console.error("[recommendation] refreshing an arrived strategy failed", r)).finally(() => i.forEach(({ id: r, claim: s }) => this._releaseRefreshClaim(r, s)));
274
259
  }
@@ -307,7 +292,7 @@ class se extends S {
307
292
  if (!i || !("querySelectorAll" in i))
308
293
  return;
309
294
  const r = i.querySelectorAll(
310
- `.${h}[${f}="${t}"]`
295
+ `.${d}[${f}="${t}"]`
311
296
  );
312
297
  if (r.length <= 1)
313
298
  return;
@@ -332,7 +317,7 @@ class se extends S {
332
317
  const t = this.api.getDocumentRoot();
333
318
  if (t && "querySelectorAll" in t)
334
319
  return t.querySelectorAll(
335
- `.${h}[${f}="${e}"]`
320
+ `.${d}[${f}="${e}"]`
336
321
  ).length > 1;
337
322
  } catch {
338
323
  }
@@ -342,12 +327,12 @@ class se extends S {
342
327
  _handleDuplicate(e, t) {
343
328
  const i = this._reassignDuplicateId(e, t), r = p();
344
329
  if (r.cloneBlockState(t, i), r.setCurrentBlock(i), g().isFeatureEnabled("reusableRecommendationStrategy")) {
345
- this._resetSourceIds.add(t), y(this.api);
330
+ this._resetSourceIds.add(t), k(this.api);
346
331
  const s = a.getConfig(e), n = [
347
- { id: t, claim: { strategyId: L(t, s).strategyId } },
332
+ { id: t, claim: { strategyId: H(t, s).strategyId } },
348
333
  { id: i, claim: { strategyId: s.strategyId } }
349
334
  ].filter(({ id: o }) => !this._refreshClaims.has(o));
350
- n.forEach(({ id: o, claim: l }) => this._refreshClaims.set(o, l)), P(t, i, s).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o)).finally(() => n.forEach(({ id: o, claim: l }) => this._releaseRefreshClaim(o, l)));
335
+ n.forEach(({ id: o, claim: l }) => this._refreshClaims.set(o, l)), F(t, i, s).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o)).finally(() => n.forEach(({ id: o, claim: l }) => this._releaseRefreshClaim(o, l)));
351
336
  }
352
337
  this._warnIfMultipleBlocks();
353
338
  }
@@ -437,10 +422,10 @@ class se extends S {
437
422
  _getBlockElement(e) {
438
423
  if ("getAttribute" in e) {
439
424
  const t = e.getAttribute("class");
440
- if (t && t.includes(h))
425
+ if (t && t.includes(d))
441
426
  return e;
442
427
  }
443
- return "querySelector" in e ? e.querySelector(`.${h}`) ?? null : null;
428
+ return "querySelector" in e ? e.querySelector(`.${d}`) ?? null : null;
444
429
  }
445
430
  /**
446
431
  * Migrate configuration from legacy format
@@ -450,6 +435,6 @@ class se extends S {
450
435
  }
451
436
  }
452
437
  export {
453
- k as BLOCK_ID,
454
- se as RecommendationBlock
438
+ y as BLOCK_ID,
439
+ te as RecommendationBlock
455
440
  };
@@ -1,79 +1,19 @@
1
- import { EditorStatePropertyType as E, PreviewDeviceMode as I, ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { createImageMarginsControl as M, createImageSizeControl as C } from "../../../controlFactories.js";
3
- import { RecommendationBlockId as c } from "../../constants/blockIds.js";
4
- import { RecommendationControlId as g } from "../../constants/controlIds.js";
5
- import { BLOCK_ROOT_SELECTOR as l } from "../../constants/selectors.js";
6
- import { hasGetStyle as a, hasGetAttribute as O } from "../../utils/tagName.js";
7
- const R = { width: "", height: "auto", "max-height": "" }, f = `${l} img.adapt-img`, x = `*${l.slice(1)}`, p = `@media only screen and (max-width: 600px) { ${f} { max-height: none !important; } }`;
8
- function _(t) {
9
- return { width: "auto", height: "auto", "max-height": `${t}px` };
10
- }
11
- function A(t) {
12
- return t.querySelectorAll(x).some((e) => "getSelector" in e && e.getSelector() === f);
13
- }
14
- function T(t, e) {
15
- return a(t) && Object.entries(e).some(([o, n]) => (t.getStyle(o) ?? "") !== n);
16
- }
17
- function S(t) {
18
- const e = t.getDocumentRootCssNode();
19
- return e && !A(e) ? e : null;
20
- }
21
- function H(t, e) {
22
- const n = e.querySelectorAll("img").some((r) => a(r) && !!r.getStyle("max-height")) ? S(t) : null;
23
- if (!n)
24
- return;
25
- const i = t.getDocumentModifier();
26
- i.modifyCss(n).appendRule(p), i.apply(new h("Add the reco image mobile fit rule"));
27
- }
28
- const B = `[esd-extension-block-id="${c.IMAGE}"]`, L = /^\d+px$/;
29
- function y(t) {
30
- return O(t) && Number(t.getAttribute("height")) || 0;
31
- }
32
- function b(t) {
33
- const e = y(t), o = a(t) ? t.getStyle("max-height") ?? "" : "";
34
- return L.test(o) && e > 0 && o !== `${e}px`;
35
- }
36
- function U(t, e) {
37
- const o = e.querySelectorAll(B).map((i) => i.querySelector("img")).filter(b);
38
- if (!o.length)
39
- return;
40
- const n = t.getDocumentModifier();
41
- o.forEach((i) => n.modifyHtml(i).setStyle("max-height", `${y(i)}px`)), n.apply(new h("Sync the reco image height bound").asHidden());
42
- }
43
- class D extends C(
44
- g.IMAGE_SIZE,
45
- c.IMAGE,
46
- l
47
- ) {
48
- getAdditionalModifications(e) {
49
- if (this.api.getEditorState()[E.previewDeviceMode] === I.MOBILE)
50
- return;
51
- const o = this.getFitStyles(), n = this.getTargetNodes(e).map((s) => s.querySelector("img")).filter((s) => T(s, o)), i = o["max-height"] ? S(this.api) : null;
52
- if (!n.length && !i)
53
- return;
54
- const r = this.api.getDocumentModifier();
55
- return i && r.modifyCss(i).appendRule(p), n.forEach((s) => {
56
- const m = r.modifyHtml(s);
57
- Object.entries(o).forEach(([u, d]) => {
58
- d ? m.setStyle(u, d) : m.removeStyle(u);
59
- });
60
- }), r;
61
- }
62
- getFitStyles() {
63
- const { size: e } = this.api.getValues();
64
- return (e == null ? void 0 : e.type) === "height" && e.value ? _(e.value) : R;
65
- }
66
- }
67
- const F = M(
68
- g.IMAGE_MARGINS,
69
- c.IMAGE,
70
- l
71
- ), P = {
72
- size: D,
73
- margins: F
1
+ import { createImageMarginsControl as m, createImageSizeControl as n } from "../../../controlFactories.js";
2
+ import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
+ import { RecommendationControlId as r } from "../../constants/controlIds.js";
4
+ import { BLOCK_ROOT_SELECTOR as t } from "../../constants/selectors.js";
5
+ const e = n(
6
+ r.IMAGE_SIZE,
7
+ o.IMAGE,
8
+ t
9
+ ), i = m(
10
+ r.IMAGE_MARGINS,
11
+ o.IMAGE,
12
+ t
13
+ ), C = {
14
+ size: e,
15
+ margins: i
74
16
  };
75
17
  export {
76
- P as ImageControls,
77
- H as ensureMobileFitRule,
78
- U as syncHeightBound
18
+ C as ImageControls
79
19
  };
@@ -1,10 +1,10 @@
1
1
  import { extractWrapperTags as A } from "../../../../utils/preserveTextStyles.js";
2
2
  import { RecommendationBlockId as c } from "../constants/blockIds.js";
3
- import { DESKTOP_CONTAINER_SELECTOR as g, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as y, ATTR_PRODUCT_OLD_PRICE as p, ATTR_PRODUCT_OMNIBUS_PRICE as R, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as x, ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
3
+ import { DESKTOP_CONTAINER_SELECTOR as b, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as y, ATTR_PRODUCT_OLD_PRICE as p, ATTR_PRODUCT_OMNIBUS_PRICE as R, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as x, ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
4
4
  import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
5
5
  import { toCustomCompositionKey as U } from "../templates/utils.js";
6
6
  import { resolveRowVisibilityKeys as N, isMergedInlinePriceRow as C } from "./compositionKeys.js";
7
- import { hasQuerySelectorAll as I, hasGetAttribute as l, hasGetStyle as h, hasGetComputedStyle as M } from "./tagName.js";
7
+ import { hasQuerySelectorAll as I, hasGetAttribute as l, hasGetStyle as O, hasGetComputedStyle as M } from "./tagName.js";
8
8
  const s = [
9
9
  "font-size",
10
10
  "font-family",
@@ -37,10 +37,9 @@ const s = [
37
37
  "width",
38
38
  "height",
39
39
  "max-width",
40
- "max-height",
41
40
  "border-radius",
42
41
  "margin"
43
- ], b = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), L = [
42
+ ], g = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), L = [
44
43
  { attrKey: k, blockId: c.NAME, kind: "text" },
45
44
  { attrKey: y, blockId: c.PRICE, kind: "text" },
46
45
  { attrKey: p, blockId: c.OLD_PRICE, kind: "text" },
@@ -49,14 +48,14 @@ const s = [
49
48
  { attrKey: x, blockId: c.BUTTON, kind: "button" },
50
49
  { attrKey: q, blockId: c.IMAGE, kind: "image" }
51
50
  ];
52
- function O(t) {
51
+ function h(t) {
53
52
  return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
54
53
  }
55
54
  function K(t) {
56
55
  return t && "getInnerText" in t && typeof t.getInnerText == "function" ? t.getInnerText().trim() : "";
57
56
  }
58
57
  function a(t, e, r) {
59
- !e || !h(e) || r.forEach((n) => {
58
+ !e || !O(e) || r.forEach((n) => {
60
59
  const o = e.getStyle(n);
61
60
  o && o !== "inherit" && o !== "initial" && (t[n] = o);
62
61
  });
@@ -65,10 +64,10 @@ function E(t) {
65
64
  return Object.entries(t).map(([e, r]) => `${e}: ${r};`).join(" ");
66
65
  }
67
66
  function P(t) {
68
- if (!t || !h(t))
67
+ if (!t || !O(t))
69
68
  return;
70
69
  const e = t.getStyle("background-color") || t.getStyle("background");
71
- return e && !b.has(e) ? e : void 0;
70
+ return e && !g.has(e) ? e : void 0;
72
71
  }
73
72
  function S(t, e) {
74
73
  const r = {};
@@ -77,11 +76,11 @@ function S(t, e) {
77
76
  function $(t) {
78
77
  const e = t.querySelector("p"), r = {};
79
78
  a(r, t, s), a(r, e, s), a(r, t.querySelector("strong"), s), a(r, t.querySelector("em"), s), a(r, t.querySelector("s"), s);
80
- const n = E(r), { openTags: o, closeTags: i } = A(O(e));
79
+ const n = E(r), { openTags: o, closeTags: i } = A(h(e));
81
80
  return !n && !o ? null : { pStyle: n || void 0, openTags: o, closeTags: i };
82
81
  }
83
82
  function H(t) {
84
- const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = S(e, D), o = S(r, w), i = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(i), { openTags: T, closeTags: d } = A(O(r)), m = K(r);
83
+ const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = S(e, D), o = S(r, w), i = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(i), { openTags: T, closeTags: d } = A(h(r)), m = K(r);
85
84
  return !n && !o && !u && !T && !m ? null : {
86
85
  buttonBorderStyle: n || void 0,
87
86
  buttonAnchorStyle: o || void 0,
@@ -101,7 +100,7 @@ function j(t, e) {
101
100
  function f(t, e) {
102
101
  if (!t || !("querySelector" in t))
103
102
  return;
104
- const r = t.querySelector(g) ?? t;
103
+ const r = t.querySelector(b) ?? t;
105
104
  if (L.forEach(({ attrKey: i, blockId: u, kind: T }) => {
106
105
  const d = r.querySelector(`[esd-extension-block-id="${u}"]`);
107
106
  d && e(d, i, T);
@@ -127,20 +126,20 @@ function V(t) {
127
126
  function X(t) {
128
127
  if (!t || !("querySelector" in t))
129
128
  return;
130
- const e = t.querySelector(g) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
129
+ const e = t.querySelector(b) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
131
130
  return P(r);
132
131
  }
133
132
  function z(t) {
134
133
  if (!t)
135
134
  return;
136
135
  const e = l(t) ? t.getAttribute("bgcolor") : null;
137
- if (e && !b.has(e))
136
+ if (e && !g.has(e))
138
137
  return e;
139
138
  const r = P(t);
140
139
  if (r)
141
140
  return r;
142
141
  const n = M(t) ? t.getComputedStyle("background-color") : void 0;
143
- return n && !b.has(n) ? n : void 0;
142
+ return n && !g.has(n) ? n : void 0;
144
143
  }
145
144
  function Q(t) {
146
145
  const e = {};
@@ -171,7 +170,7 @@ function J(t) {
171
170
  function Z(t) {
172
171
  if (!t || !("querySelector" in t))
173
172
  return !1;
174
- const e = t.querySelector(g) ?? t;
173
+ const e = t.querySelector(b) ?? t;
175
174
  return C(e.querySelector(`[data-attribute-type="${y}"]`)) || C(e.querySelector(`[data-attribute-type="${p}"]`));
176
175
  }
177
176
  function tt(t) {
@@ -196,7 +195,7 @@ function rt(t) {
196
195
  const e = {};
197
196
  if (!t || !("querySelector" in t))
198
197
  return e;
199
- const r = t.querySelector(g) ?? t;
198
+ const r = t.querySelector(b) ?? t;
200
199
  return I(r) && r.querySelectorAll(".recommendation-attribute-row").forEach((n) => {
201
200
  if (!l(n))
202
201
  return;
@@ -64,8 +64,6 @@ export declare class RecommendationBlock extends Block {
64
64
  * @param node - The block node being deleted
65
65
  */
66
66
  onDelete(node: ImmutableHtmlNode): void;
67
- private _ensureMobileFitRule;
68
- private _syncHeightBound;
69
67
  /**
70
68
  * Warns (dark advisory toaster) when the design holds more than one live
71
69
  * recommendation block. Triggered from the user-add paths only (fresh drop
@@ -3,49 +3,35 @@
3
3
  *
4
4
  * Controls for styling the product image element in recommendation cards.
5
5
  */
6
- import type { CssNodeModifier, HtmlNodeModifier, ImmutableCssNode, ImmutableHtmlNode, TemplateModifier } from '@stripoinc/ui-editor-extensions';
7
- import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
8
- interface FitRuleApi {
9
- getDocumentRootCssNode: () => ImmutableCssNode | null;
10
- getDocumentModifier: () => TemplateModifier<HtmlNodeModifier, CssNodeModifier>;
11
- }
12
- export declare function ensureMobileFitRule(api: FitRuleApi, block: ImmutableHtmlNode): void;
13
- export declare function syncHeightBound(api: Pick<FitRuleApi, 'getDocumentModifier'>, block: ImmutableHtmlNode): void;
14
- declare const SizeControl_base: {
15
- new (): {
16
- getId(): string;
17
- getTargetNodes(root: ImmutableHtmlNode): ImmutableHtmlNode[];
18
- getParentControlId(): string;
19
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
20
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
21
- getModificationDescription(): ModificationDescription | undefined;
22
- getAdditionalModifications(_root: ImmutableHtmlNode): TemplateModifier<HtmlNodeModifier, CssNodeModifier> | undefined;
23
- isVisible(_node: ImmutableHtmlNode): boolean;
24
- getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
25
- };
26
- };
27
- declare class SizeControl extends SizeControl_base {
28
- getAdditionalModifications(root: ImmutableHtmlNode): TemplateModifier<HtmlNodeModifier, CssNodeModifier> | undefined;
29
- private getFitStyles;
30
- }
31
6
  /**
32
7
  * Grouped Image Controls
33
8
  * Use this object for cleaner imports in extension.ts
34
9
  */
35
10
  export declare const ImageControls: {
36
- readonly size: typeof SizeControl;
11
+ readonly size: {
12
+ new (): {
13
+ getId(): string;
14
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
15
+ getParentControlId(): string;
16
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
17
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
18
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
19
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
20
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
21
+ getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
22
+ };
23
+ };
37
24
  readonly margins: {
38
25
  new (): {
39
26
  getId(): string;
40
- getTargetNodes(root: ImmutableHtmlNode): ImmutableHtmlNode[];
27
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
41
28
  getParentControlId(): string;
42
29
  api: import("@stripoinc/ui-editor-extensions").ControlApi;
43
30
  getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
44
- getModificationDescription(): ModificationDescription | undefined;
45
- getAdditionalModifications(_root: ImmutableHtmlNode): TemplateModifier<HtmlNodeModifier, CssNodeModifier> | undefined;
46
- isVisible(_node: ImmutableHtmlNode): boolean;
31
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
32
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
33
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
47
34
  getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
48
35
  };
49
36
  };
50
37
  };
51
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.21.1-beta.7f84ba7",
3
+ "version": "3.21.1",
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",