@useinsider/guido 3.15.0-beta.0b5dc39 → 3.15.0-beta.0cbd17f

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.
@@ -3,20 +3,21 @@ import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommenda
3
3
  import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
4
  import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
5
  import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
6
- import { useConfigStore as x } from "../stores/config.js";
7
- const k = () => ({
6
+ import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
7
+ import { useConfigStore as P } from "../stores/config.js";
8
+ const B = () => ({
8
9
  calculateCardWidth: ({
9
10
  mobileLeftPadding: a,
10
11
  mobileRightPadding: s,
11
12
  cardsInRow: c,
12
- unresponsive: o
13
+ unresponsive: n
13
14
  }) => {
14
- const r = o ? c : 1, e = a + s + (r - 1) * b;
15
+ const r = n ? c : 1, e = a + s + (r - 1) * b;
15
16
  return (C - e) / r;
16
17
  },
17
18
  getRecommendationCampaignData: (a) => {
18
- const s = l(), c = Number(a), o = s.blockStates[c];
19
- if (!o)
19
+ const s = l(), c = Number(a), n = s.blockStates[c];
20
+ if (!n)
20
21
  return {
21
22
  textTrimming: !1,
22
23
  orientation: "vertical",
@@ -29,7 +30,7 @@ const k = () => ({
29
30
  discountBeforeTextValue: "",
30
31
  discountAfterTextValue: ""
31
32
  };
32
- const { recommendationConfigs: r } = o, e = r.orientation === "grid" ? "vertical" : "horizontal";
33
+ const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
33
34
  return {
34
35
  textTrimming: r.textTrimming,
35
36
  orientation: e,
@@ -45,7 +46,7 @@ const k = () => ({
45
46
  },
46
47
  buildCampaignUrl: (a, s) => {
47
48
  var m;
48
- const c = l(), o = x(), r = Number(a);
49
+ const c = l(), n = P(), r = Number(a);
49
50
  let e;
50
51
  if (s)
51
52
  e = s;
@@ -53,25 +54,25 @@ const k = () => ({
53
54
  const i = c.blockStates[r];
54
55
  if (!i)
55
56
  return "";
56
- const { recommendationConfigs: n } = i;
57
+ const { recommendationConfigs: o } = i;
57
58
  e = {
58
- strategy: n.strategy,
59
- language: n.language,
60
- currencyCode: n.currencySettings.value,
61
- size: n.size,
62
- productIds: n.productIds,
63
- filters: n.filters,
64
- shuffleProducts: n.shuffleProducts
59
+ strategy: o.strategy,
60
+ language: o.language,
61
+ currencyCode: o.currencySettings.value,
62
+ size: o.size,
63
+ productIds: o.productIds,
64
+ filters: o.filters,
65
+ shuffleProducts: o.shuffleProducts
65
66
  };
66
67
  }
67
68
  const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
68
- t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
69
+ t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
69
70
  const g = e.filters.filter((i) => i.isValid), d = h(g);
70
- d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(o.partnerName, e.strategy)).forEach(([i, n]) => t.set(i, n));
71
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
71
72
  const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
72
73
  return c.recommendationCampaignUrls[a] = u, u;
73
74
  }
74
75
  });
75
76
  export {
76
- k as useRecommendation
77
+ B as useRecommendation
77
78
  };
@@ -16,22 +16,22 @@ import { useEditorStore as b } from "../stores/editor.js";
16
16
  import { buildMergeTagEntries as W, flattenDynamicContentList as Y } from "../utils/genericUtil.js";
17
17
  import Z from "../package.json.js";
18
18
  let n = null;
19
- const Ce = () => {
20
- const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: M, getCustomFonts: T, getSyncModulesStatus: v } = K(), { handleEvent: B } = z(), { handleModuleAdd: F } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
19
+ const Ct = () => {
20
+ const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: T, getCustomFonts: v, getSyncModulesStatus: B } = K(), { handleEvent: F } = z(), { handleModuleAdd: M } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
21
21
  var l;
22
22
  if (document.getElementById("UiEditorScript")) {
23
23
  i();
24
24
  return;
25
25
  }
26
- const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(l = o == null ? void 0 : o.stripo) == null ? void 0 : l.version}/UIEditor.js`, e = document.createElement("script");
27
- e.id = "UiEditorScript", e.type = "module", e.src = r, e.onload = () => i(), e.onerror = () => {
28
- e.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${r}`));
29
- }, document.body.appendChild(e);
26
+ const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(l = o == null ? void 0 : o.stripo) == null ? void 0 : l.version}/UIEditor.js`, t = document.createElement("script");
27
+ t.id = "UiEditorScript", t.type = "module", t.src = r, t.onload = () => i(), t.onerror = () => {
28
+ t.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${r}`));
29
+ }, document.body.appendChild(t);
30
30
  }), n.catch(() => {
31
31
  n = null;
32
32
  }), n), _ = async (i, s, o, a = [], r = !1) => {
33
33
  var y, E, h, C;
34
- const e = b(), { html: l, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = ((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1;
34
+ const t = b(), { html: l, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = ((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1;
35
35
  await window.UIEditor.initEditor(
36
36
  document.querySelector("#guido-editor"),
37
37
  {
@@ -57,7 +57,6 @@ const Ce = () => {
57
57
  messageSettingsEnabled: !0,
58
58
  displayGmailAnnotations: !0,
59
59
  displayHiddenPreheader: !1,
60
- keepModuleStylesEnabled: !0,
61
60
  displayTitle: !1,
62
61
  displayUTM: !1,
63
62
  selectElementAfterDrop: !0,
@@ -78,38 +77,38 @@ const Ce = () => {
78
77
  )
79
78
  }
80
79
  ],
81
- async onTokenRefreshRequest(t) {
80
+ async onTokenRefreshRequest(e) {
82
81
  try {
83
- const d = await M();
84
- t(d);
82
+ const d = await T();
83
+ e(d);
85
84
  } catch (d) {
86
85
  p(d, "Failed to refresh token");
87
86
  }
88
87
  },
89
88
  onTemplateLoaded() {
90
89
  try {
91
- const { importCss: t } = H(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
92
- t(), d(), x(), I(), o.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
93
- e.hasChanges = !1;
90
+ const { importCss: e } = H(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
91
+ e(), d(), x(), I(), o.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
92
+ t.hasChanges = !1;
94
93
  }, 1e3);
95
- } catch (t) {
96
- p(t, "Failed to load custom interface appearance");
94
+ } catch (e) {
95
+ p(e, "Failed to load custom interface appearance");
97
96
  }
98
97
  },
99
- onCodeEditorVisibilityChanged(t) {
100
- e.isCodeEditorOpen = t;
98
+ onCodeEditorVisibilityChanged(e) {
99
+ t.isCodeEditorOpen = e;
101
100
  },
102
- onEditorVisualModeChanged(t) {
103
- e.editorVisualMode = t.toLowerCase();
101
+ onEditorVisualModeChanged(e) {
102
+ t.editorVisualMode = e.toLowerCase();
104
103
  },
105
- onVersionHistoryVisibilityChanged(t) {
106
- e.isVersionHistoryOpen = t;
104
+ onVersionHistoryVisibilityChanged(e) {
105
+ t.isVersionHistoryOpen = e;
107
106
  },
108
107
  onDataChanged() {
109
- e.hasChanges = !0;
108
+ t.hasChanges = !0;
110
109
  },
111
- onEvent: B,
112
- onModuleAdd: F,
110
+ onEvent: F,
111
+ onModuleAdd: M,
113
112
  notifications: V(),
114
113
  ignoreClickOutsideSelectors: [
115
114
  "#guido-dynamic-content-modal",
@@ -125,11 +124,11 @@ const Ce = () => {
125
124
  const a = b();
126
125
  try {
127
126
  await f();
128
- const [r, e] = await Promise.all([
129
- T(),
130
- v()
127
+ const [r, t] = await Promise.all([
128
+ v(),
129
+ B()
131
130
  ]);
132
- a.syncModulesEnabled = e, await _(i, s, o, r, e);
131
+ a.syncModulesEnabled = t, await _(i, s, o, r, t);
133
132
  } catch {
134
133
  a.loadingStatus = !1, k({
135
134
  type: X.Error,
@@ -146,5 +145,5 @@ const Ce = () => {
146
145
  } };
147
146
  };
148
147
  export {
149
- Ce as useStripo
148
+ Ct as useStripo
150
149
  };
@@ -1,12 +1,12 @@
1
- import { BlockId as f } from "../../../enums/block.js";
2
- import { useOnboardingStore as g } from "../../../stores/onboarding.js";
3
- import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
4
- import { Block as I, BlockCompositionType as C, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { SETTINGS_ENUMS as d, DefaultConfigValues as m } from "./enums/settingsEnums.js";
6
- import { getDefaultTemplate as b } from "./template.js";
7
- import { getItemsBlockContainer as l, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
- const p = f.Items;
9
- class O extends I {
1
+ import { BlockId as g } from "../../../enums/block.js";
2
+ import { useOnboardingStore as y } from "../../../stores/onboarding.js";
3
+ import { getMigrationBannerHtml as I } from "../../../utils/migrationBannerHtml.js";
4
+ import { Block as C, BlockCompositionType as b, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { SETTINGS_ENUMS as l, DefaultConfigValues as d } from "./enums/settingsEnums.js";
6
+ import { getDefaultTemplate as h } from "./template.js";
7
+ import { getItemsBlockContainer as u, getItemsBlockConfig as f, deriveItemNumber as D, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
+ const p = g.Items;
9
+ class E extends C {
10
10
  getId() {
11
11
  return p;
12
12
  }
@@ -14,7 +14,7 @@ class O extends I {
14
14
  return "items-icon";
15
15
  }
16
16
  getBlockCompositionType() {
17
- return C.CONTAINER;
17
+ return b.CONTAINER;
18
18
  }
19
19
  getName() {
20
20
  return this.api.translate("Items");
@@ -23,20 +23,20 @@ class O extends I {
23
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
24
  }
25
25
  getSettingsPanelTitleHtml() {
26
- return y(
26
+ return I(
27
27
  p,
28
28
  this.api.translate("Items"),
29
29
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
30
30
  );
31
31
  }
32
32
  getTemplate() {
33
- return b({
34
- orientation: d.ORIENTATION.VERTICAL,
35
- itemsType: d.ITEMS_TYPE.CART_ITEMS,
33
+ return h({
34
+ orientation: l.ORIENTATION.VERTICAL,
35
+ itemsType: l.ITEMS_TYPE.CART_ITEMS,
36
36
  itemId: "{{Abandoned Cart Item (1) Url}}",
37
- currencySymbol: m.productPriceCurrencySymbolControlValue,
38
- currencyLocation: m.productPriceCurrencyLocationControlValue,
39
- formattedPrice: m.productPriceFormattedControlValue === "1"
37
+ currencySymbol: d.productPriceCurrencySymbolControlValue,
38
+ currencyLocation: d.productPriceCurrencyLocationControlValue,
39
+ formattedPrice: d.productPriceFormattedControlValue === "1"
40
40
  });
41
41
  }
42
42
  allowInnerBlocksDND() {
@@ -45,23 +45,23 @@ class O extends I {
45
45
  canBeSavedAsModule() {
46
46
  return !0;
47
47
  }
48
- onCreated(e) {
49
- const t = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
50
- o.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
- const i = l(e);
52
- if (!i)
48
+ onCreated(n) {
49
+ const t = this.api.getDocumentModifier(), a = this.api.getDocumentRootCssNode();
50
+ a.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(a).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
+ const e = u(n);
52
+ if (!e)
53
53
  return;
54
- const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(e);
55
- if (n != null && n.initialized)
56
- if (s)
57
- n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(i).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
54
+ const o = e.getNodeConfig(), r = o && Object.keys(o).length > 0, i = f(n);
55
+ if (i != null && i.initialized)
56
+ if (r)
57
+ i.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...i, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
58
58
  else {
59
- const a = this.api.getDocumentModifier();
60
- a.modifyHtml(i).setNodeConfig(n), this._stampProductTdDomAttributes(i, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
59
+ const s = this.api.getDocumentModifier();
60
+ s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
61
61
  }
62
62
  else {
63
- const a = N();
64
- this.api.getDocumentModifier().modifyHtml(i).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
63
+ const s = N(), m = this.api.getDocumentModifier();
64
+ m.modifyHtml(e).setNodeConfig(s), this._stampProductTdDomAttributes(e, s, m, !0), m.apply(new c("Initialize Items block with default configuration")), y().startOnboarding("itemsOnboarding");
65
65
  }
66
66
  }
67
67
  /**
@@ -70,18 +70,18 @@ class O extends I {
70
70
  * into nodeConfig, so without this a reused module would reset to defaults.
71
71
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
72
72
  */
73
- onDocumentChanged(e) {
74
- const t = l(e);
73
+ onDocumentChanged(n) {
74
+ const t = u(n);
75
75
  if (!t)
76
76
  return;
77
- const o = t.getNodeConfig();
78
- if (o && Object.keys(o).length > 0)
77
+ const a = t.getNodeConfig();
78
+ if (a && Object.keys(a).length > 0)
79
79
  return;
80
- const r = u(e);
81
- if (!(r != null && r.initialized))
80
+ const o = f(n);
81
+ if (!(o != null && o.initialized))
82
82
  return;
83
- const s = this.api.getDocumentModifier();
84
- s.modifyHtml(t).setNodeConfig(r), this._stampProductTdDomAttributes(t, r, s), s.apply(new c("Recover Items block config from saved module"));
83
+ const r = this.api.getDocumentModifier();
84
+ r.modifyHtml(t).setNodeConfig(o), this._stampProductTdDomAttributes(t, o, r), r.apply(new c("Recover Items block config from saved module"));
85
85
  }
86
86
  /**
87
87
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -91,12 +91,14 @@ class O extends I {
91
91
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
92
92
  * relies on this td-level fallback in pairProductVariables.
93
93
  */
94
- _stampProductTdDomAttributes(e, t, o) {
95
- const i = h(t.itemsSelectValue, t.type);
96
- o.modifyHtml(e).setAttribute("data-type", t.type), o.modifyHtml(e).setAttribute("data-number", i), o.modifyHtml(e).setAttribute("data-nodup", String(t.priceHideDiscount));
94
+ _stampProductTdDomAttributes(n, t, a, e = !1) {
95
+ const o = D(t.itemsSelectValue, t.type), r = (i, s) => {
96
+ e && n.getAttribute(i) || a.modifyHtml(n).setAttribute(i, s);
97
+ };
98
+ r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
97
99
  }
98
100
  }
99
101
  export {
100
102
  p as BLOCK_ID,
101
- O as ItemsBlock
103
+ E as ItemsBlock
102
104
  };