@useinsider/guido 3.20.1-beta.8a05319 → 3.20.1-beta.991508

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,34 +1,34 @@
1
- import { useRecommendation as C } from "./useRecommendation.js";
1
+ import { useRecommendation as S } from "./useRecommendation.js";
2
2
  import { useToaster as I } from "./useToaster.js";
3
3
  import { useTranslations as v } from "./useTranslations.js";
4
4
  import { ToasterTypeOptions as g } from "../enums/toaster.js";
5
5
  import "../extensions/Blocks/Recommendation/constants/selectors.js";
6
6
  import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
7
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
- import { resolveMigrationTarget as k, buildLegacyMigrationPayload as R } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
7
+ import { useRecommendationExtensionStore as R } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
+ import { resolveMigrationTarget as b, buildLegacyMigrationPayload as k } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
9
9
  import { commitBlockChangeOutsidePanel as T } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
10
10
  import { useConfigStore as h } from "../stores/config.js";
11
11
  const F = () => {
12
- const e = b(), r = h(), { buildCampaignUrl: m } = C(), { showToaster: c } = I(), a = v();
12
+ const e = R(), o = h(), { buildCampaignUrl: m } = S(), { showToaster: c } = I(), a = v();
13
13
  return { convertLegacyStrategy: async () => {
14
14
  const t = e.currentRecommendationId;
15
15
  if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
16
16
  return "";
17
- const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = k({
18
- campaignId: r.campaignId,
19
- templateLibraryId: r.templateLibraryId
20
- }), S = R({
17
+ const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = b({
18
+ campaignId: o.campaignId,
19
+ templateLibraryId: o.templateLibraryId
20
+ }), C = k({
21
21
  blockId: t,
22
22
  url: m(String(t)),
23
- campaignId: r.campaignId,
24
- variationId: r.variationId,
23
+ campaignId: o.campaignId,
24
+ variationId: o.variationId,
25
25
  strategy: d,
26
26
  productIds: y,
27
27
  target: s
28
28
  });
29
- let o;
29
+ let r;
30
30
  try {
31
- o = await e.convertLegacyStrategy(S, s);
31
+ r = await e.convertLegacyStrategy(C, s);
32
32
  } catch (i) {
33
33
  return console.error("[useLegacyStrategyConversion] migration failed", i), c({
34
34
  type: g.Error,
@@ -40,7 +40,7 @@ const F = () => {
40
40
  }), "";
41
41
  }
42
42
  try {
43
- await e.fetchStrategyProductsForBlock(t);
43
+ await e.fetchRecommendationProductsForBlock(t);
44
44
  } catch (i) {
45
45
  console.error("[useLegacyStrategyConversion] product refetch failed", i);
46
46
  }
@@ -48,16 +48,16 @@ const F = () => {
48
48
  return n ? T(
49
49
  t,
50
50
  {
51
- strategyId: o,
51
+ strategyId: r,
52
52
  size: n.recommendationConfigs.size,
53
53
  configVersion: L
54
54
  },
55
55
  n.recommendationProducts,
56
56
  "Converted legacy recommendation strategy"
57
- ) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
57
+ ) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), r) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
58
58
  type: g.Error,
59
59
  message: a("email-editor.legacy-strategy-update-failed")
60
- }), "") : o;
60
+ }), "") : r;
61
61
  } };
62
62
  };
63
63
  export {
@@ -1,6 +1,6 @@
1
1
  import { pairProductVariables as o } from "../../utils/pairProductVariables.js";
2
- import { normalizeItemsBlockWidths as r, wrapHiddenPriceTdsForOutlook as e, MSO_ITEMS_HIDE_START as t, MSO_ITEMS_HIDE_END as s } from "./utils/itemsCompilerUtils.js";
3
- const d = [
2
+ import { normalizeItemsBlockWidths as r, wrapHiddenPriceTdsForOutlook as t, lockHorizontalItemImageWidths as e, MSO_ITEMS_HIDE_START as s, MSO_ITEMS_HIDE_END as p } from "./utils/itemsCompilerUtils.js";
3
+ const c = [
4
4
  {
5
5
  id: "normalize-items-block-widths",
6
6
  // Runs before the other items rules so they see non-zero widths; not AMP-safe.
@@ -25,20 +25,27 @@ const d = [
25
25
  // with safe placeholder comments and collapse them inline for web-engine Outlook.
26
26
  description: "Mark hidden Items price tds for Outlook conditional hiding",
27
27
  type: "custom",
28
- processor: e,
28
+ processor: t,
29
29
  priority: 65
30
30
  // After pair-product-variables (60), before outlook rules (70+)
31
31
  },
32
+ {
33
+ id: "lock-horizontal-item-image-widths",
34
+ description: "Pin horizontal Items thumbnails to their width so narrow rows cannot collapse them",
35
+ type: "custom",
36
+ processor: e,
37
+ priority: 66
38
+ },
32
39
  {
33
40
  id: "swap-items-mso-markers",
34
41
  // Injecting the delicate `<!-- -->` ghost token LAST (after reco minify P99
35
42
  // and reco swap P100) keeps it out of every whitespace/comment-mangling pass.
36
43
  description: "Swap Items MSO markers into [if !mso] conditional comments",
37
44
  type: "custom",
38
- processor: (i) => i.replaceAll(`<!--${t}-->`, "<!--[if !mso]><!-- -->").replaceAll(`<!--${s}-->`, "<!--<![endif]-->"),
45
+ processor: (i) => i.replaceAll(`<!--${s}-->`, "<!--[if !mso]><!-- -->").replaceAll(`<!--${p}-->`, "<!--<![endif]-->"),
39
46
  priority: 101
40
47
  }
41
48
  ];
42
49
  export {
43
- d as itemsCompilerRules
50
+ c as itemsCompilerRules
44
51
  };
@@ -1,55 +1,75 @@
1
- import { PRODUCT_WRAPPER_SELECTOR as A, hasZeroWidthDeclaration as E, isZeroWidthValue as u, withWidthPin as h, PRODUCT_TD_SELECTOR as S, withoutZeroWidth as _ } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
2
- import { protectLiquid as m, restoreLiquid as y } from "../../../utils/liquidProtection.js";
3
- const f = "MSO_ITEMS_HIDE_START", D = "MSO_ITEMS_HIDE_END", T = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", M = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price";
4
- function g(e) {
5
- if (!e.includes("vertical-price") || !e.includes("ins-product-cart"))
6
- return e;
7
- const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(n, "text/html");
8
- let s = !1;
9
- if (r.querySelectorAll(M).forEach((t) => {
10
- var d, a;
11
- const o = t.getAttribute("style") || "";
12
- if (!/display\s*:\s*none/i.test(o))
1
+ import { PRODUCT_WRAPPER_SELECTOR as h, hasZeroWidthDeclaration as E, isZeroWidthValue as f, withWidthPin as T, PRODUCT_TD_SELECTOR as _, withoutZeroWidth as y } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
2
+ import { DefaultConfigValues as D } from "../../../extensions/Blocks/Items/enums/settingsEnums.js";
3
+ import { protectLiquid as p, restoreLiquid as A } from "../../../utils/liquidProtection.js";
4
+ const m = "MSO_ITEMS_HIDE_START", S = "MSO_ITEMS_HIDE_END", M = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", I = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price", O = ".ins-product-td td.product-image-class img[width]", g = Number(D.productImageWidth);
5
+ function C(t) {
6
+ if (!t.includes("vertical-price") || !t.includes("ins-product-cart"))
7
+ return t;
8
+ const s = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), o = new DOMParser().parseFromString(s, "text/html");
9
+ let n = !1;
10
+ if (o.querySelectorAll(I).forEach((e) => {
11
+ var d, u;
12
+ const r = e.getAttribute("style") || "";
13
+ if (!/display\s*:\s*none/i.test(r))
13
14
  return;
14
- const l = t.previousSibling;
15
- if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== f) && ((d = t.parentNode) == null || d.insertBefore(r.createComment(f), t), (a = t.parentNode) == null || a.insertBefore(r.createComment(D), t.nextSibling)), !/mso-hide/i.test(o)) {
16
- const p = o.trim().endsWith(";") ? " " : "; ";
17
- t.setAttribute("style", `${o}${p}${T}`);
15
+ const l = e.previousSibling;
16
+ if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== m) && ((d = e.parentNode) == null || d.insertBefore(o.createComment(m), e), (u = e.parentNode) == null || u.insertBefore(o.createComment(S), e.nextSibling)), !/mso-hide/i.test(r)) {
17
+ const a = r.trim().endsWith(";") ? " " : "; ";
18
+ e.setAttribute("style", `${r}${a}${M}`);
18
19
  }
19
- s = !0;
20
- }), !s)
21
- return e;
22
- const c = n.match(/<!DOCTYPE[^>]*>/i);
20
+ n = !0;
21
+ }), !n)
22
+ return t;
23
+ const c = s.match(/<!DOCTYPE[^>]*>/i);
23
24
  return ((c ? `${c[0]}
24
- ` : "") + r.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
25
+ ` : "") + o.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
25
26
  }
26
- function I(e) {
27
- if (!e.includes("ins-product-wrapper") && !e.includes("ins-product-td"))
28
- return e;
29
- const n = new DOMParser().parseFromString(m(e), "text/html");
30
- let r = !1;
31
- if (n.querySelectorAll(A).forEach((i) => {
32
- const t = i.getAttribute("style") || "";
33
- if (!E(t) && !u(i.getAttribute("width")))
27
+ function N(t) {
28
+ if (!t.includes("ins-product-wrapper") && !t.includes("ins-product-td"))
29
+ return t;
30
+ const s = new DOMParser().parseFromString(p(t), "text/html");
31
+ let o = !1;
32
+ if (s.querySelectorAll(h).forEach((i) => {
33
+ const e = i.getAttribute("style") || "";
34
+ if (!E(e) && !f(i.getAttribute("width")))
34
35
  return;
35
- const o = h(t);
36
- o !== t && (i.setAttribute("style", o), r = !0), u(i.getAttribute("width")) && (i.setAttribute("width", "100%"), r = !0);
37
- }), n.querySelectorAll(S).forEach((i) => {
38
- const t = i.getAttribute("style") || "";
39
- if (E(t)) {
40
- const o = _(t);
41
- o ? i.setAttribute("style", o) : i.removeAttribute("style"), r = !0;
36
+ const r = T(e);
37
+ r !== e && (i.setAttribute("style", r), o = !0), f(i.getAttribute("width")) && (i.setAttribute("width", "100%"), o = !0);
38
+ }), s.querySelectorAll(_).forEach((i) => {
39
+ const e = i.getAttribute("style") || "";
40
+ if (E(e)) {
41
+ const r = y(e);
42
+ r ? i.setAttribute("style", r) : i.removeAttribute("style"), o = !0;
42
43
  }
43
- u(i.getAttribute("width")) && (i.removeAttribute("width"), r = !0);
44
- }), !r)
45
- return e;
46
- const s = e.match(/<!DOCTYPE[^>]*>/i), c = s ? `${s[0]}
44
+ f(i.getAttribute("width")) && (i.removeAttribute("width"), o = !0);
45
+ }), !o)
46
+ return t;
47
+ const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
47
48
  ` : "";
48
- return y(c + n.documentElement.outerHTML);
49
+ return A(c + s.documentElement.outerHTML);
50
+ }
51
+ function L(t) {
52
+ if (!t.includes("product-image-class"))
53
+ return t;
54
+ const s = new DOMParser().parseFromString(p(t), "text/html");
55
+ let o = !1;
56
+ if (s.querySelectorAll(O).forEach((i) => {
57
+ var u, a;
58
+ const e = ((u = i.getAttribute("width")) == null ? void 0 : u.trim()) ?? "", r = ((a = i.getAttribute("style")) == null ? void 0 : a.trim()) ?? "";
59
+ if (!/^\d+$/.test(e) || /(^|;)\s*min-width\s*:/i.test(r))
60
+ return;
61
+ const l = r && !r.endsWith(";") ? ";" : "", d = Math.min(Number(e), g);
62
+ i.setAttribute("style", `${r}${l}min-width:${d}px;max-width:${e}px`), o = !0;
63
+ }), !o)
64
+ return t;
65
+ const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
66
+ ` : "";
67
+ return A(c + s.documentElement.outerHTML);
49
68
  }
50
69
  export {
51
- D as MSO_ITEMS_HIDE_END,
52
- f as MSO_ITEMS_HIDE_START,
53
- I as normalizeItemsBlockWidths,
54
- g as wrapHiddenPriceTdsForOutlook
70
+ S as MSO_ITEMS_HIDE_END,
71
+ m as MSO_ITEMS_HIDE_START,
72
+ L as lockHorizontalItemImageWidths,
73
+ N as normalizeItemsBlockWidths,
74
+ C as wrapHiddenPriceTdsForOutlook
55
75
  };