@useinsider/guido 3.6.0-beta.7ca3ec5 → 3.6.0-beta.8307d2e

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,31 +1,32 @@
1
1
  import { useActionsApi as x } from "./useActionsApi.js";
2
2
  import { useConfig as y } from "./useConfig.js";
3
- import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as E } from "./useSyncModuleExtractor.js";
5
- import { useStripoApi as H } from "../services/stripoApi.js";
6
- import { useTemplatePreparation as b } from "../utils/templatePreparation.js";
7
- import { useHtmlValidator as q } from "./useHtmlValidator.js";
3
+ import { useSaveStart as w, useSaveComplete as H } from "./useGuidoActions.js";
4
+ import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
5
+ import { useStripoApi as C } from "../services/stripoApi.js";
6
+ import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
7
+ import { useHtmlValidator as k } from "./useHtmlValidator.js";
8
8
  import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
9
9
  import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
10
- const z = () => {
11
- const o = w(), s = C(), { validateHtml: r } = q(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = E(), { setSyncModuleUnsubscriptionPages: c } = H(), { editorSave: m } = x();
12
- return { save: async (p = !1, f = !1) => {
13
- var i;
10
+ import { useUnsubscribeBlockValidator as B } from "./validators/useUnsubscribeBlockValidator.js";
11
+ const J = () => {
12
+ const o = w(), s = H(), { validateHtml: r } = k(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { validateUnsubscribeBlockUniqueness: d } = B(), { callbacks: i, isFeatureEnabled: u } = y(), { extractSyncModuleData: c } = q(), { setSyncModuleUnsubscriptionPages: m } = C(), { editorSave: p } = x();
13
+ return { save: async (f = !1, v = !1) => {
14
+ var a;
14
15
  o();
15
- const { prepareTemplateDetails: v } = b(), t = await v();
16
- if (!l(t.compiledHtml))
16
+ const { prepareTemplateDetails: S } = E(), t = await S();
17
+ if (!l(t.compiledHtml) || !d(t.compiledHtml))
17
18
  return;
18
- if (d("liquidSyntax")) {
19
+ if (u("liquidSyntax")) {
19
20
  if (!await n(t.compiledHtml))
20
21
  return;
21
22
  } else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
22
23
  return;
23
- if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t) || !await m())
24
+ if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await p())
24
25
  return;
25
- const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
26
- return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
26
+ const { unsubscribePayload: V, stripoModules: b } = c(t.rawHtml);
27
+ return await m(V), t.modules = b, f || s({ ...t, silent: v }), t;
27
28
  } };
28
29
  };
29
30
  export {
30
- z as useSave
31
+ J as useSave
31
32
  };
@@ -0,0 +1,32 @@
1
+ import { ToasterTypeOptions as i } from "../../enums/toaster.js";
2
+ import { PAGE_TYPES as n } from "../../enums/unsubscribe.js";
3
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as u, DATA_ATTRIBUTES as l } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
+ import { useToaster as T } from "../useToaster.js";
5
+ import { useTranslations as E } from "../useTranslations.js";
6
+ const m = [
7
+ {
8
+ pageType: n.GLOBAL_UNSUBSCRIBE,
9
+ messageKey: "unsubscription-preference.duplicate-global-unsub"
10
+ },
11
+ {
12
+ pageType: n.SUBSCRIPTION_PREFERENCE_CENTER,
13
+ messageKey: "unsubscription-preference.duplicate-pref-center"
14
+ }
15
+ ], g = "unsubscription-preference.duplicate-both", y = () => {
16
+ const { showToaster: o } = T(), a = E();
17
+ return { validateUnsubscribeBlockUniqueness: (c) => {
18
+ const p = new DOMParser().parseFromString(c, "text/html"), t = /* @__PURE__ */ new Map();
19
+ p.querySelectorAll(u).forEach((e) => {
20
+ const r = Number(e.getAttribute(l.PAGE_TYPE));
21
+ t.set(r, (t.get(r) ?? 0) + 1);
22
+ });
23
+ const s = m.filter((e) => (t.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
24
+ return s.length ? (o({
25
+ type: i.Alert,
26
+ message: a(s.length > 1 ? g : s[0])
27
+ }), !1) : !0;
28
+ } };
29
+ };
30
+ export {
31
+ y as useUnsubscribeBlockValidator
32
+ };
@@ -1,6 +1,6 @@
1
- var p = Object.defineProperty;
2
- var A = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var r = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
1
+ var O = Object.defineProperty;
2
+ var p = (o, e, t) => e in o ? O(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var r = (o, e, t) => p(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as N } from "../../../common-control.js";
6
6
  import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
@@ -9,9 +9,9 @@ import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
9
9
  import { RecommendationConfigService as s } from "../../services/configService.js";
10
10
  import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
11
11
  import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
12
- const U = "recommendation-layout-orientation-control", O = "recommendationInfoBannerTest", a = {
12
+ const U = "recommendation-layout-orientation-control", A = "recommendationInfoBannerTest", a = {
13
13
  LAYOUT: "layout"
14
- }, y = "data-card-composition", n = {
14
+ }, y = "data-card-composition", i = {
15
15
  LAYOUT: "data-layout",
16
16
  COLUMN_SPACING: "data-column-spacing",
17
17
  ROW_SPACING: "data-row-spacing",
@@ -30,7 +30,7 @@ class Y extends N {
30
30
  getTemplate() {
31
31
  return `
32
32
  <div class="layout-control-container">
33
- ${this._GuOnPageMessage({ name: O })}
33
+ ${this._GuOnPageMessage({ name: A })}
34
34
 
35
35
  ${this._GuTwoColumns([
36
36
  this._GuLabel({ text: this.api.translate("Layout Orientation") }),
@@ -44,11 +44,10 @@ class Y extends N {
44
44
  }
45
45
  onRender() {
46
46
  this._setInfoMessageValue(
47
- O,
47
+ A,
48
48
  this.api.translate(
49
- `Note that updating the Layout Orientation, Number of Products,
50
- Products in One Row and Mobile Layout Optimization settings
51
- resets the style of your Recommendation block.`
49
+ `Note that updating the Layout Orientation, Number of Products and
50
+ Products in One Row settings resets the style of your Recommendation block.`
52
51
  )
53
52
  ), this._setFormValues(), this._listenToFormUpdates();
54
53
  }
@@ -84,8 +83,8 @@ class Y extends N {
84
83
  },
85
84
  `Changed layout to ${t}`
86
85
  ), this.store.patchCurrentBlockConfig({ orientation: t });
87
- const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
88
- t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.setAttribute(y, _.join(",")).setAttribute(L, "[]"), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
86
+ const n = this.api.getDocumentModifier().modifyHtml(c).setAttribute(i.LAYOUT, t).setAttribute(i.COLUMN_SPACING, g.toString()).setAttribute(i.ROW_SPACING, l.toString()).setAttribute(i.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(i.MOBILE_ROW_SPACING, m.toString());
87
+ t === "list" ? (n.setClass("es-m-p0"), n.setClass("ins-recommendation-list-layout")) : (n.removeClass("es-m-p0"), n.removeClass("ins-recommendation-list-layout")), n.setAttribute(y, _.join(",")).setAttribute(L, "[]"), n.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
89
88
  } finally {
90
89
  this.isChangingLayout = !1;
91
90
  }
@@ -115,10 +115,8 @@ const S = {
115
115
  class="esd-block-text product-old-price es-p15l es-p15r"
116
116
  align="center"
117
117
  esd-extension-block-id="${s.OLD_PRICE}">
118
- <p
119
- contenteditable="false"
120
- style="font-size: 14px; color: #999999;">
121
- <s><strong>${i(t, "original_price")}</strong></s>
118
+ <p contenteditable="false" style="font-size: 14px; color: #999999;">
119
+ <strong>${i(t, "original_price")}</strong>
122
120
  </p>
123
121
  </td>
124
122
  </tr>
@@ -14,10 +14,10 @@ function b() {
14
14
  thousandSeparator: e.thousandSeparator
15
15
  };
16
16
  }
17
- function r(t, e = "price") {
18
- const n = b(), s = t[e], a = (s == null ? void 0 : s[n.code]) ?? Object.values(s ?? {})[0] ?? 0;
17
+ function s(t, e = "price") {
18
+ const n = b(), a = t[e], r = (a == null ? void 0 : a[n.code]) ?? Object.values(a ?? {})[0] ?? 0;
19
19
  return R({
20
- price: a,
20
+ price: r,
21
21
  currency: n
22
22
  });
23
23
  }
@@ -69,7 +69,7 @@ const I = {
69
69
  esd-extension-block-id="${o.PRICE}"
70
70
  align="left">
71
71
  <p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: bold; margin: 0;">
72
- <strong>${r(t, "price")}</strong>
72
+ <strong>${s(t, "price")}</strong>
73
73
  </p>
74
74
  </td>
75
75
  </tr>
@@ -85,8 +85,8 @@ const I = {
85
85
  align="left">
86
86
  <p
87
87
  contenteditable="false"
88
- style="font-size: 14px; color: #999999; margin: 0;">
89
- <s><strong>${r(t, "original_price")}</strong></s>
88
+ style="font-size: 14px; color: #999999; text-decoration: line-through; margin: 0;">
89
+ <strong>${s(t, "original_price")}</strong>
90
90
  </p>
91
91
  </td>
92
92
  </tr>
@@ -104,7 +104,7 @@ const I = {
104
104
  align="left">
105
105
  <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
106
106
  <span class="omnibus-text-before">Lowest 30-day price: </span>
107
- <span class="omnibus-price-value">${r(t, "original_price")}</span>
107
+ <span class="omnibus-price-value">${s(t, "original_price")}</span>
108
108
  <span class="omnibus-text-after"></span>
109
109
  </p>
110
110
  </td>
@@ -115,7 +115,7 @@ const I = {
115
115
  */
116
116
  [g]: (t) => {
117
117
  var i, l;
118
- const e = b(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, s = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, a = n > 0 ? Math.round((n - s) / n * 100) : 0, m = a > 0 ? `-${a}%` : "0%";
118
+ const e = b(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, a = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - a) / n * 100) : 0, m = r > 0 ? `-${r}%` : "0%";
119
119
  return `
120
120
  <tr>
121
121
  <td
@@ -1,29 +1,29 @@
1
- function d(c, t) {
2
- const { thousandSeparator: i, decimalSeparator: e, decimalCount: r } = t, [u, o = ""] = String(c).split("."), n = o.slice(0, r).padEnd(r, "0"), a = u.replace(
1
+ function d(a, t) {
2
+ const { thousandSeparator: s, decimalSeparator: e, decimalCount: r } = t, u = Math.abs(a).toFixed(r), [c, o] = u.split("."), n = c.replace(
3
3
  /\B(?=(\d{3})+(?!\d))/g,
4
- i
5
- );
6
- return r > 0 && n ? `${a}${e}${n}` : a;
4
+ s
5
+ ), i = a < 0 ? "-" : "";
6
+ return r > 0 && o ? `${i}${n}${e}${o}` : `${i}${n}`;
7
7
  }
8
- function f(c) {
9
- const { price: t, currency: i } = c, {
8
+ function m(a) {
9
+ const { price: t, currency: s } = a, {
10
10
  symbol: e,
11
11
  alignment: r,
12
12
  thousandSeparator: u,
13
- decimalSeparator: o,
14
- decimalCount: n
15
- } = i;
13
+ decimalSeparator: c,
14
+ decimalCount: o
15
+ } = s;
16
16
  if (typeof t != "number" || Number.isNaN(t)) {
17
- const s = "0".repeat(n), m = `0${o}${s}`;
18
- return r === "before" ? `${e} ${m}` : `${m} ${e}`;
17
+ const i = "0".repeat(o), $ = `0${c}${i}`;
18
+ return r === "before" ? `${e} ${$}` : `${$} ${e}`;
19
19
  }
20
- const a = d(t, {
20
+ const n = d(t, {
21
21
  thousandSeparator: u,
22
- decimalSeparator: o,
23
- decimalCount: n
22
+ decimalSeparator: c,
23
+ decimalCount: o
24
24
  });
25
- return r === "before" ? `${e} ${a}` : `${a} ${e}`;
25
+ return r === "before" ? `${e} ${n}` : `${n} ${e}`;
26
26
  }
27
27
  export {
28
- f as formatPrice
28
+ m as formatPrice
29
29
  };
@@ -5,11 +5,11 @@ import { useToaster as B } from "../../../composables/useToaster.js";
5
5
  import { ToasterTypeOptions as S } from "../../../enums/toaster.js";
6
6
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
7
7
  import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
8
- import { Block as L, BlockCompositionType as f, ContextActionType as h, ModificationDescription as b, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
- import { getDefaultTemplate as A } from "./template.js";
10
- import { DATA_ATTRIBUTES as i, UNSUBSCRIBE_EVENTS as d } from "./utils/constants.js";
11
- import { parsePageList as p } from "./utils/utils.js";
12
- const y = "unsubscribe-block", m = 'a[data-unsubscribe-link="true"]', _ = ".unsubscribe-block-v2", I = "{{ins-unsubscribe-link}}", T = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", C = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", N = {
8
+ import { Block as L, BlockCompositionType as f, ContextActionType as h, ModificationDescription as b, BlockType as A } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
+ import { getDefaultTemplate as v } from "./template.js";
10
+ import { DATA_ATTRIBUTES as i, UNSUBSCRIBE_BLOCK_SELECTOR as p, UNSUBSCRIBE_EVENTS as d } from "./utils/constants.js";
11
+ import { parsePageList as m } from "./utils/utils.js";
12
+ const y = "unsubscribe-block", _ = 'a[data-unsubscribe-link="true"]', I = "{{ins-unsubscribe-link}}", T = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", C = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", N = {
13
13
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
14
14
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
15
15
  };
@@ -42,7 +42,7 @@ class F extends L {
42
42
  return this.api.translate("Unsubscribe Block Description");
43
43
  }
44
44
  getTemplate() {
45
- return A();
45
+ return v();
46
46
  }
47
47
  getContextActionsIds() {
48
48
  return [h.MOVE, h.REMOVE];
@@ -68,7 +68,7 @@ class F extends L {
68
68
  this._removeEventListeners(), this.currentNode = void 0, this.linkStateByBlockId.clear();
69
69
  }
70
70
  _hasUnsubscribeLink(e) {
71
- return "querySelector" in e ? !!e.querySelector(m) : !1;
71
+ return "querySelector" in e ? !!e.querySelector(_) : !1;
72
72
  }
73
73
  _readBlockId(e) {
74
74
  return "getAttribute" in e ? e.getAttribute(i.BLOCK_ID) : null;
@@ -102,7 +102,7 @@ class F extends L {
102
102
  let e = 0;
103
103
  try {
104
104
  const t = this.api.getDocumentRoot();
105
- t && "querySelectorAll" in t && t.querySelectorAll(_).forEach((s) => {
105
+ t && "querySelectorAll" in t && t.querySelectorAll(p).forEach((s) => {
106
106
  if ("getAttribute" in s) {
107
107
  const o = s.getAttribute(i.BLOCK_ID), u = o ? parseInt(o) : 0;
108
108
  u > e && (e = u);
@@ -150,7 +150,7 @@ class F extends L {
150
150
  try {
151
151
  if (!this.currentNode)
152
152
  return;
153
- this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${v.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
153
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${A.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
154
154
  } catch (e) {
155
155
  console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
156
156
  }
@@ -161,7 +161,7 @@ class F extends L {
161
161
  _updateBlock(e, t) {
162
162
  if (!this.currentNode || !("querySelector" in this.currentNode))
163
163
  return;
164
- const r = this.currentNode.querySelector(m);
164
+ const r = this.currentNode.querySelector(_);
165
165
  if (!r)
166
166
  return;
167
167
  const s = this._getMergeTag(e);
@@ -181,7 +181,7 @@ class F extends L {
181
181
  }
182
182
  _checkExistingBlocks() {
183
183
  const e = a();
184
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(_).forEach((r) => {
184
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(p).forEach((r) => {
185
185
  if ("getAttribute" in r) {
186
186
  const s = r.getAttribute(i.PAGE_TYPE);
187
187
  if (s) {
@@ -197,7 +197,7 @@ class F extends L {
197
197
  const t = e.getAttribute(i.PAGE_TYPE), r = e.getAttribute(i.PAGE_LIST);
198
198
  if (!t || !r)
199
199
  return;
200
- const s = a(), o = Number(t), u = p(r);
200
+ const s = a(), o = Number(t), u = m(r);
201
201
  await s.fetchTemplates(), s.setCollectionWithoutAutoSelection(o), s.loadSelectedTemplates(u);
202
202
  }
203
203
  _resetStoreState() {
@@ -209,7 +209,7 @@ class F extends L {
209
209
  const t = e.getAttribute(i.PAGE_LIST);
210
210
  if (!t)
211
211
  return;
212
- const r = a(), s = p(t);
212
+ const r = a(), s = m(t);
213
213
  r.removeUnsubscribePages(s);
214
214
  }
215
215
  }
@@ -1,12 +1,13 @@
1
1
  const s = {
2
2
  SELECT: "unsubscribe:select",
3
3
  CANCEL: "unsubscribe:cancel"
4
- }, e = {
4
+ }, b = {
5
5
  PAGE_TYPE: "data-unsubscribe-page-type",
6
6
  PAGE_LIST: "data-unsubscribe-page-list",
7
7
  BLOCK_ID: "data-unsubscribe-block-id"
8
- };
8
+ }, c = ".unsubscribe-block-v2";
9
9
  export {
10
- e as DATA_ATTRIBUTES,
10
+ b as DATA_ATTRIBUTES,
11
+ c as UNSUBSCRIBE_BLOCK_SELECTOR,
11
12
  s as UNSUBSCRIBE_EVENTS
12
13
  };
@@ -0,0 +1,3 @@
1
+ export declare const useUnsubscribeBlockValidator: () => {
2
+ validateUnsubscribeBlockUniqueness: (html: string) => boolean;
3
+ };
@@ -8,3 +8,4 @@ export declare const DATA_ATTRIBUTES: {
8
8
  readonly PAGE_LIST: "data-unsubscribe-page-list";
9
9
  readonly BLOCK_ID: "data-unsubscribe-block-id";
10
10
  };
11
+ export declare const UNSUBSCRIBE_BLOCK_SELECTOR = ".unsubscribe-block-v2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.6.0-beta.7ca3ec5",
3
+ "version": "3.6.0-beta.8307d2e",
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",