@useinsider/guido 2.1.0-beta.d4a1ced → 2.1.0-beta.d770bbd

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.
Files changed (41) hide show
  1. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  2. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  3. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  5. package/dist/components/organisms/header/EditorActions.vue.js +8 -10
  6. package/dist/components/organisms/header/EditorActions.vue2.js +31 -40
  7. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  9. package/dist/config/i18n/en/labels.json.js +3 -8
  10. package/dist/config/migrator/itemsBlockMigrator.js +134 -136
  11. package/dist/config/migrator/recommendationMigrator.js +40 -42
  12. package/dist/extensions/Blocks/Items/block.js +25 -45
  13. package/dist/extensions/Blocks/Items/iconsRegistry.js +5 -6
  14. package/dist/extensions/Blocks/Items/items.css.js +0 -48
  15. package/dist/extensions/Blocks/Recommendation/block.js +29 -49
  16. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +3 -4
  17. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +0 -48
  18. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  19. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  20. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  21. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  22. package/dist/extensions/Blocks/common-control.js +4 -12
  23. package/dist/guido.css +1 -1
  24. package/dist/src/components/Guido.vue.d.ts +1 -1
  25. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  26. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  27. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  28. package/dist/src/components/wrappers/WpModal.vue.d.ts +2 -2
  29. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  30. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  31. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  32. package/dist/src/extensions/Blocks/common-control.d.ts +0 -5
  33. package/dist/stores/unsubscribe.js +37 -34
  34. package/package.json +2 -2
  35. package/dist/components/organisms/header/MigrationConfirmModal.vue.js +0 -17
  36. package/dist/components/organisms/header/MigrationConfirmModal.vue2.js +0 -41
  37. package/dist/extensions/Blocks/common-icons.js +0 -39
  38. package/dist/src/components/organisms/header/MigrationConfirmModal.vue.d.ts +0 -6
  39. package/dist/src/extensions/Blocks/common-icons.d.ts +0 -1
  40. package/dist/src/stores/template.d.ts +0 -3
  41. package/dist/stores/template.js +0 -9
@@ -1,19 +1,18 @@
1
- import { useOnboardingStore as g } from "../../../stores/onboarding.js";
2
- import { useTemplateStore as f } from "../../../stores/template.js";
3
- import { Block as u, BlockCompositionType as I, UIElementType as c, UEAttr as C, ModificationDescription as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
4
- import { SETTINGS_ENUMS as l, DefaultConfigValues as s } from "./enums/settingsEnums.js";
5
- import { getDefaultTemplate as y } from "./template.js";
6
- import { getItemsBlockContainer as b, getItemsBlockConfig as k, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
7
- const m = "items-block";
8
- class M extends u {
1
+ import { useOnboardingStore as d } from "../../../stores/onboarding.js";
2
+ import { Block as g, BlockCompositionType as f, ModificationDescription as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { SETTINGS_ENUMS as c, DefaultConfigValues as i } from "./enums/settingsEnums.js";
4
+ import { getDefaultTemplate as p } from "./template.js";
5
+ import { getItemsBlockContainer as u, getItemsBlockConfig as C, getDefaultItemsBlockConfig as I } from "./utils/nodeConfigUtils.js";
6
+ const y = "items-block";
7
+ class B extends g {
9
8
  getId() {
10
- return m;
9
+ return y;
11
10
  }
12
11
  getIcon() {
13
12
  return "items-icon";
14
13
  }
15
14
  getBlockCompositionType() {
16
- return I.CONTAINER;
15
+ return f.CONTAINER;
17
16
  }
18
17
  getName() {
19
18
  return this.api.translate("Items");
@@ -21,54 +20,35 @@ class M extends u {
21
20
  getDescription() {
22
21
  return this.api.translate("Items lets you display personalized products based on user behavior.");
23
22
  }
24
- getSettingsPanelTitleHtml() {
25
- if (f().migrations[m] === 0)
26
- return "";
27
- const n = this.api.translate("Items"), o = 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.");
28
- return `<div>
29
- <div style="display: flex; align-items: center;">
30
- <span>${n}</span>
31
- </div>
32
- <div class="items-migration-info">
33
- <${c.ICON}
34
- ${C.ICON.src}="migration-info-icon"
35
- class="items-migration-info__icon">
36
- </${c.ICON}>
37
- <p class="items-migration-info__text">
38
- ${o}
39
- </p>
40
- </div>
41
- </div>`;
42
- }
43
23
  getTemplate() {
44
- return y({
45
- orientation: l.ORIENTATION.VERTICAL,
46
- itemsType: l.ITEMS_TYPE.CART_ITEMS,
24
+ return p({
25
+ orientation: c.ORIENTATION.VERTICAL,
26
+ itemsType: c.ITEMS_TYPE.CART_ITEMS,
47
27
  itemId: "{{Abandoned Cart Item (1) Url}}",
48
- currencySymbol: s.productPriceCurrencySymbolControlValue,
49
- currencyLocation: s.productPriceCurrencyLocationControlValue,
50
- formattedPrice: s.productPriceFormattedControlValue === "1"
28
+ currencySymbol: i.productPriceCurrencySymbolControlValue,
29
+ currencyLocation: i.productPriceCurrencyLocationControlValue,
30
+ formattedPrice: i.productPriceFormattedControlValue === "1"
51
31
  });
52
32
  }
53
33
  allowInnerBlocksDND() {
54
34
  return !1;
55
35
  }
56
- onCreated(i) {
57
- const n = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
58
- o.querySelector('[product-attr="imageSrc"] img') || n.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
59
- const e = b(i);
36
+ onCreated(n) {
37
+ const s = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
38
+ r.querySelector('[product-attr="imageSrc"] img') || s.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
39
+ const e = u(n);
60
40
  if (!e)
61
41
  return;
62
- const a = e.getNodeConfig(), d = a && Object.keys(a).length > 0, t = k(i);
42
+ const a = e.getNodeConfig(), l = a && Object.keys(a).length > 0, t = C(n);
63
43
  if (t != null && t.initialized)
64
- d ? t.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...t, blockInstanceId: String(Date.now()) }).apply(new r("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(t).apply(new r("Migrate legacy config to nodeConfig"));
44
+ l ? t.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...t, blockInstanceId: String(Date.now()) }).apply(new o("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(t).apply(new o("Migrate legacy config to nodeConfig"));
65
45
  else {
66
- const p = N();
67
- this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(p).apply(new r("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
46
+ const m = I();
47
+ this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(m).apply(new o("Initialize Items block with default configuration")), d().startOnboarding("itemsOnboarding");
68
48
  }
69
49
  }
70
50
  }
71
51
  export {
72
- m as BLOCK_ID,
73
- M as ItemsBlock
52
+ y as BLOCK_ID,
53
+ B as ItemsBlock
74
54
  };
@@ -1,6 +1,5 @@
1
1
  import { IconsRegistry as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { MIGRATION_INFO_ICON as r } from "../common-icons.js";
3
- class s extends o {
2
+ class i extends o {
4
3
  registerIconsSvg(t) {
5
4
  t["items-icon"] = `
6
5
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -20,14 +19,14 @@ class s extends o {
20
19
  </svg>
21
20
  `, t["horizontal-orientation"] = `
22
21
  <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
23
- <path d="M10 19H4C3.44772 19 3 18.5523 3 18V2C3 1.44772 3.44772 1 4 1H10V19Z" stroke="currentColor"
22
+ <path d="M10 19H4C3.44772 19 3 18.5523 3 18V2C3 1.44772 3.44772 1 4 1H10V19Z" stroke="currentColor"
24
23
  stroke-width="2" fill="none"/>
25
- <path d="M17 2V18C17 18.5523 16.5523 19 16 19H10V1H16C16.5523 1 17 1.44772 17 2Z" stroke="currentColor"
24
+ <path d="M17 2V18C17 18.5523 16.5523 19 16 19H10V1H16C16.5523 1 17 1.44772 17 2Z" stroke="currentColor"
26
25
  stroke-width="2" fill="none"/>
27
26
  </svg>
28
- `, t["migration-info-icon"] = r;
27
+ `;
29
28
  }
30
29
  }
31
30
  export {
32
- s as ItemsIconsRegistry
31
+ i as ItemsIconsRegistry
33
32
  };
@@ -17,54 +17,6 @@ const n = `/* Utils */
17
17
  .container:has(.items-controls-container) {
18
18
  padding: 0
19
19
  }
20
-
21
- /* ─── Migration Info Box ─────────────────────────────────────────────── */
22
- /* Shown in the settings panel title when a block was migrated from legacy */
23
-
24
- /* Layout variables for positioning the absolutely-placed info box */
25
- :host {
26
- --items-migration-padding: 16px;
27
- --items-migration-title-height: 61px;
28
- --items-migration-box-height: 98px;
29
- }
30
-
31
- /* Push tabs down when info box is present inside the control panel header */
32
- .control-panel-header:has(.items-migration-info) {
33
- position: relative;
34
- margin-bottom: calc(2 * var(--items-migration-padding) + var(--items-migration-box-height));
35
- }
36
-
37
- /* Info box container */
38
- .items-migration-info {
39
- display: flex;
40
- align-items: flex-start;
41
- gap: 8px;
42
- padding: 12px;
43
- background: var(--guido-color-background-onpage-message-info);
44
- border: 1px solid var(--guido-color-border-onpage-message-info);
45
- border-radius: 4px;
46
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07);
47
- position: absolute;
48
- left: var(--items-migration-padding);
49
- right: var(--items-migration-padding);
50
- top: calc(var(--items-migration-padding) + var(--items-migration-title-height));
51
- }
52
-
53
- /* Icon — 18x19 icon inside a 24x24 bounding box (matches Figma) */
54
- .items-migration-info__icon {
55
- flex-shrink: 0;
56
- width: 24px;
57
- height: 24px;
58
- }
59
-
60
- /* Text content */
61
- .items-migration-info__text {
62
- margin: 4px 0;
63
- white-space: normal;
64
- font-size: 13px;
65
- font-weight: 400;
66
- line-height: 16px;
67
- }
68
20
  `;
69
21
  export {
70
22
  n as default
@@ -1,14 +1,13 @@
1
- var h = Object.defineProperty;
2
- var I = (r, o, t) => o in r ? h(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
3
- var g = (r, o, t) => I(r, typeof o != "symbol" ? o + "" : o, t);
4
- import { useTemplateStore as k } from "../../../stores/template.js";
5
- import { Block as _, BlockCompositionType as B, UIElementType as d, UEAttr as C, ModificationDescription as A } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { ensureMobileCssRulesExist as u } from "./controls/mobileLayout/cssRules.js";
1
+ var p = Object.defineProperty;
2
+ var f = (r, o, t) => o in r ? p(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
3
+ var g = (r, o, t) => f(r, typeof o != "symbol" ? o + "" : o, t);
4
+ import { Block as h, BlockCompositionType as I, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { ensureMobileCssRulesExist as d } from "./controls/mobileLayout/cssRules.js";
7
6
  import { RecommendationConfigService as s } from "./services/configService.js";
8
- import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
9
- import { getDefaultTemplate as R } from "./templates/grid/template.js";
10
- const f = "recommendation-block", c = "ins-recommendation-v3-block-v2", a = "recommendation-id";
11
- class E extends _ {
7
+ import { useRecommendationExtensionStore as u } from "./store/recommendation.js";
8
+ import { getDefaultTemplate as k } from "./templates/grid/template.js";
9
+ const B = "recommendation-block", c = "ins-recommendation-v3-block-v2", a = "recommendation-id";
10
+ class y extends h {
12
11
  constructor() {
13
12
  super();
14
13
  /**
@@ -18,13 +17,13 @@ class E extends _ {
18
17
  g(this, "_pendingBlockId", null);
19
18
  }
20
19
  getId() {
21
- return f;
20
+ return B;
22
21
  }
23
22
  getIcon() {
24
23
  return "recommendation-icon";
25
24
  }
26
25
  getBlockCompositionType() {
27
- return B.CONTAINER;
26
+ return I.CONTAINER;
28
27
  }
29
28
  getName() {
30
29
  return this.api.translate("Recommendation Block");
@@ -32,25 +31,6 @@ class E extends _ {
32
31
  getDescription() {
33
32
  return this.api.translate("Recommendation Block Title Description");
34
33
  }
35
- getSettingsPanelTitleHtml() {
36
- if (k().migrations[f] === 0)
37
- return "";
38
- const e = this.api.translate("Recommendation Block"), i = 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.");
39
- return `<div>
40
- <div style="display: flex; align-items: center;">
41
- <span>${e}</span>
42
- </div>
43
- <div class="recommendation-migration-info">
44
- <${d.ICON}
45
- ${C.ICON.src}="migration-info-icon"
46
- class="recommendation-migration-info__icon">
47
- </${d.ICON}>
48
- <p class="recommendation-migration-info__text">
49
- ${i}
50
- </p>
51
- </div>
52
- </div>`;
53
- }
54
34
  /**
55
35
  * Returns the template HTML for a new recommendation block.
56
36
  * Generates a unique recommendation ID and embeds the instance class
@@ -60,7 +40,7 @@ class E extends _ {
60
40
  */
61
41
  getTemplate() {
62
42
  const t = this._generateNextId();
63
- return this._pendingBlockId = t, R(t);
43
+ return this._pendingBlockId = t, k(t);
64
44
  }
65
45
  /**
66
46
  * Called when a new block is dropped into the template
@@ -72,8 +52,8 @@ class E extends _ {
72
52
  onCreated(t) {
73
53
  const e = this._pendingBlockId ?? this._generateNextId();
74
54
  this._pendingBlockId = null, this._assignRecommendationId(t, e);
75
- const i = s.initializeConfig(this.api, t, { recommendationId: e }), n = p();
76
- n.setCurrentBlock(e), u(this.api), n.patchCurrentBlockConfig({ language: i.language }, { triggerRefetch: !1 });
55
+ const n = s.initializeConfig(this.api, t, { recommendationId: e }), i = u();
56
+ i.setCurrentBlock(e), d(this.api), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
77
57
  }
78
58
  /**
79
59
  * Called when the document changes or template is loaded
@@ -93,7 +73,7 @@ class E extends _ {
93
73
  "Assign recommendation ID to legacy block"
94
74
  );
95
75
  }
96
- s.needsMigration(t) && this._migrateFromLegacy(t), u(this.api);
76
+ s.needsMigration(t) && this._migrateFromLegacy(t), d(this.api);
97
77
  }
98
78
  }
99
79
  /**
@@ -104,7 +84,7 @@ class E extends _ {
104
84
  */
105
85
  onDelete(t) {
106
86
  const e = this._getRecommendationId(t);
107
- e && p().removeBlockState(e);
87
+ e && u().removeBlockState(e);
108
88
  }
109
89
  /**
110
90
  * Generates the next unique recommendation ID by scanning all existing blocks
@@ -114,9 +94,9 @@ class E extends _ {
114
94
  let t = 0;
115
95
  try {
116
96
  const e = this.api.getDocumentRoot();
117
- e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((n) => {
118
- if ("getAttribute" in n) {
119
- const m = n.getAttribute(a), l = m ? parseInt(m) : 0;
97
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((i) => {
98
+ if ("getAttribute" in i) {
99
+ const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
120
100
  l > t && (t = l);
121
101
  }
122
102
  });
@@ -131,11 +111,11 @@ class E extends _ {
131
111
  * added classes via setAttribute.
132
112
  */
133
113
  _assignRecommendationId(t, e) {
134
- const i = this._getBlockElement(t);
135
- if (!i)
114
+ const n = this._getBlockElement(t);
115
+ if (!n)
136
116
  return;
137
- const n = this.api.getDocumentModifier();
138
- n.modifyHtml(i).setAttribute(a, e.toString()), n.apply(new A(`Assign recommendation ID ${e}`));
117
+ const i = this.api.getDocumentModifier();
118
+ i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new _(`Assign recommendation ID ${e}`));
139
119
  }
140
120
  /**
141
121
  * Gets the recommendation-id from a block node
@@ -144,11 +124,11 @@ class E extends _ {
144
124
  const e = this._getBlockElement(t);
145
125
  if (!e || !("getAttribute" in e))
146
126
  return null;
147
- const i = e.getAttribute(a);
148
- if (!i)
127
+ const n = e.getAttribute(a);
128
+ if (!n)
149
129
  return null;
150
- const n = parseInt(i);
151
- return Number.isNaN(n) ? null : n;
130
+ const i = parseInt(n);
131
+ return Number.isNaN(i) ? null : i;
152
132
  }
153
133
  /**
154
134
  * Gets the block element (the element with BLOCK_CLASS)
@@ -169,6 +149,6 @@ class E extends _ {
169
149
  }
170
150
  }
171
151
  export {
172
- f as BLOCK_ID,
173
- E as RecommendationBlock
152
+ B as BLOCK_ID,
153
+ y as RecommendationBlock
174
154
  };
@@ -1,6 +1,5 @@
1
1
  import { IconsRegistry as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { MIGRATION_INFO_ICON as t } from "../common-icons.js";
3
- class h extends r {
2
+ class o extends r {
4
3
  registerIconsSvg(C) {
5
4
  C["recommendation-icon"] = `
6
5
  <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
@@ -60,9 +59,9 @@ class h extends r {
60
59
  <circle cx="3" cy="16" r="1" stroke="currentColor" stroke-width="1"/>
61
60
  <rect x="7" y="15" width="11" height="2" rx="1"/>
62
61
  </svg>
63
- `, C["migration-info-icon"] = t;
62
+ `;
64
63
  }
65
64
  }
66
65
  export {
67
- h as RecommendationIconsRegistry
66
+ o as RecommendationIconsRegistry
68
67
  };
@@ -22,54 +22,6 @@ const n = `/* Utils */
22
22
  ue-orderable.orderable-disabled .droppable-icon {
23
23
  display: none;
24
24
  }
25
-
26
- /* ─── Migration Info Box ─────────────────────────────────────────────── */
27
- /* Shown in the settings panel title when a block was migrated from legacy */
28
-
29
- /* Layout variables for positioning the absolutely-placed info box */
30
- :host {
31
- --rec-migration-padding: 16px;
32
- --rec-migration-title-height: 61px;
33
- --rec-migration-box-height: 98px;
34
- }
35
-
36
- /* Push tabs down when info box is present inside the control panel header */
37
- .control-panel-header:has(.recommendation-migration-info) {
38
- position: relative;
39
- margin-bottom: calc(2 * var(--rec-migration-padding) + var(--rec-migration-box-height));
40
- }
41
-
42
- /* Info box container */
43
- .recommendation-migration-info {
44
- display: flex;
45
- align-items: flex-start;
46
- gap: 8px;
47
- padding: 12px;
48
- background: var(--guido-color-background-onpage-message-info);
49
- border: 1px solid var(--guido-color-border-onpage-message-info);
50
- border-radius: 4px;
51
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07);
52
- position: absolute;
53
- left: var(--rec-migration-padding);
54
- right: var(--rec-migration-padding);
55
- top: calc(var(--rec-migration-padding) + var(--rec-migration-title-height));
56
- }
57
-
58
- /* Icon — 18x19 icon inside a 24x24 bounding box (matches Figma) */
59
- .recommendation-migration-info__icon {
60
- flex-shrink: 0;
61
- width: 24px;
62
- height: 24px;
63
- }
64
-
65
- /* Text content */
66
- .recommendation-migration-info__text {
67
- margin: 4px 0;
68
- white-space: normal;
69
- font-size: 13px;
70
- font-weight: 400;
71
- line-height: 16px;
72
- }
73
25
  `;
74
26
  export {
75
27
  n as default
@@ -1,17 +1,17 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
2
+ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
5
  import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
- import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
7
  import { getDefaultTemplate as L } from "./template.js";
8
8
  import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
9
  import { parsePageList as p } from "./utils/utils.js";
10
- const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
10
+ const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
11
11
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
12
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
13
13
  };
14
- class R extends h {
14
+ class R extends _ {
15
15
  constructor() {
16
16
  super();
17
17
  u(this, "selectEventListener", null);
@@ -19,7 +19,7 @@ class R extends h {
19
19
  u(this, "currentNode");
20
20
  }
21
21
  getId() {
22
- return g;
22
+ return v;
23
23
  }
24
24
  getIcon() {
25
25
  return "unsubscribe-icon";
@@ -47,8 +47,8 @@ class R extends h {
47
47
  }
48
48
  _setupSelectEventListener() {
49
49
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
50
- const s = e, { collectionType: t, selectedPages: r } = s.detail;
51
- this._updateBlock(t, r.join(","));
50
+ const r = e, { collectionType: s, selectedPages: t } = r.detail;
51
+ this._updateBlock(s, t.join(","));
52
52
  }, document.addEventListener(a.SELECT, this.selectEventListener);
53
53
  }
54
54
  _removeSelectEventListener() {
@@ -74,17 +74,17 @@ class R extends h {
74
74
  _removeEventListeners() {
75
75
  this._removeSelectEventListener(), this._removeCancelEventListener();
76
76
  }
77
- _updateBlock(e, s) {
77
+ _updateBlock(e, r) {
78
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
79
  return;
80
- const t = this.currentNode.querySelector(v);
81
- if (!t)
80
+ const s = this.currentNode.querySelector(g);
81
+ if (!s)
82
82
  return;
83
- const r = this._getMergeTag(e);
84
- this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
83
+ const t = this._getMergeTag(e);
84
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
85
85
  }
86
86
  _getMergeTag(e) {
87
- return T[e] ?? B;
87
+ return B[e] ?? T;
88
88
  }
89
89
  _openDrawer() {
90
90
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
@@ -97,24 +97,24 @@ class R extends h {
97
97
  }
98
98
  _checkExistingBlocks() {
99
99
  const e = c();
100
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
101
- if ("getAttribute" in t) {
102
- const r = t.getAttribute(o.PAGE_TYPE);
103
- if (r) {
104
- const l = Number(r);
100
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
101
+ if ("getAttribute" in s) {
102
+ const t = s.getAttribute(o.PAGE_TYPE);
103
+ if (t) {
104
+ const l = Number(t);
105
105
  l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
106
106
  }
107
107
  }
108
108
  });
109
109
  }
110
- _loadBlockState(e) {
110
+ async _loadBlockState(e) {
111
111
  if (!("getAttribute" in e))
112
112
  return;
113
- const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
- if (!s || !t)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
115
115
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
116
+ const t = c(), l = Number(r), m = p(s);
117
+ await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
118
118
  }
119
119
  _resetStoreState() {
120
120
  c().$reset();
@@ -122,14 +122,14 @@ class R extends h {
122
122
  _removeBlockTemplatesFromStore(e) {
123
123
  if (!("getAttribute" in e))
124
124
  return;
125
- const s = e.getAttribute(o.PAGE_LIST);
126
- if (!s)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
127
127
  return;
128
- const t = c(), r = p(s);
129
- t.removeUnsubscribePages(r);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
130
130
  }
131
131
  }
132
132
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
133
+ v as UNSUBSCRIBE_BLOCK_ID,
134
134
  R as UnsubscribeBlock
135
135
  };
@@ -1,18 +1,18 @@
1
- var h = Object.defineProperty;
2
- var d = (a, s, e) => s in a ? h(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => d(a, typeof s != "symbol" ? s + "" : s, e);
1
+ var d = Object.defineProperty;
2
+ var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
+ var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
4
4
  import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
5
5
  import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
7
7
  import { parsePageList as _ } from "./utils/utils.js";
8
- const g = "ui-elements-unsubscribe", r = {
8
+ const v = "ui-elements-unsubscribe", r = {
9
9
  SELECT_BUTTON: "selectTemplateButton",
10
10
  PREV_BUTTON: "prevButton",
11
11
  NEXT_BUTTON: "nextButton",
12
12
  COUNTER_TEXT: "counterText",
13
13
  PREVIEW_IMAGE: "previewImage"
14
14
  };
15
- class N extends T {
15
+ class B extends T {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  u(this, "currentPreviewIndex", 0);
@@ -22,7 +22,7 @@ class N extends T {
22
22
  u(this, "lastParsedAttribute");
23
23
  }
24
24
  getId() {
25
- return g;
25
+ return v;
26
26
  }
27
27
  getTemplate() {
28
28
  return `
@@ -35,7 +35,7 @@ class N extends T {
35
35
  onTemplateNodeUpdated(e) {
36
36
  if (this.currentNode = e, "getAttribute" in this.currentNode) {
37
37
  const t = this.currentNode.getAttribute(p.PAGE_LIST);
38
- t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updatePreview(), this._updateCounter());
38
+ t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
39
39
  }
40
40
  }
41
41
  onRender() {
@@ -73,6 +73,9 @@ class N extends T {
73
73
  _onNextClick() {
74
74
  this.currentPreviewIndex < this.totalTemplates - 1 && (this.currentPreviewIndex++, this._updatePreview(), this._updateCounter());
75
75
  }
76
+ async _loadAndUpdatePreview() {
77
+ await l().fetchTemplates(), this._updatePreview(), this._updateCounter();
78
+ }
76
79
  _updatePreview() {
77
80
  var e;
78
81
  if ((e = this.currentPages) != null && e.length)
@@ -162,6 +165,6 @@ class N extends T {
162
165
  }
163
166
  }
164
167
  export {
165
- g as UNSUBSCRIBE_CONTROL_ID,
166
- N as UnsubscribeControl
168
+ v as UNSUBSCRIBE_CONTROL_ID,
169
+ B as UnsubscribeControl
167
170
  };
@@ -1,12 +1,12 @@
1
- var r = Object.defineProperty;
2
- var n = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var s = (i, t, e) => n(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { UIElement as m } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- const E = "unsubscribe-preview", l = "img", c = "Unsubscribe page preview";
6
- class o extends m {
1
+ var n = Object.defineProperty;
2
+ var m = (s, i, e) => i in s ? n(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
+ var r = (s, i, e) => m(s, typeof i != "symbol" ? i + "" : i, e);
4
+ import { UIElement as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ const E = "unsubscribe-preview", c = "img", a = "Unsubscribe page preview", g = "is-loaded";
6
+ class d extends l {
7
7
  constructor() {
8
8
  super(...arguments);
9
- s(this, "imgElement");
9
+ r(this, "imgElement");
10
10
  }
11
11
  getId() {
12
12
  return E;
@@ -14,19 +14,21 @@ class o extends m {
14
14
  getTemplate() {
15
15
  return `
16
16
  <div class="unsubscribe-preview-image-container">
17
+ <div class="unsubscribe-preview-loader"></div>
17
18
  <img
18
19
  src=""
19
- alt="${c}"
20
+ alt="${a}"
20
21
  class="unsubscribe-preview-image"
21
22
  />
22
23
  </div>
23
24
  `;
24
25
  }
25
26
  onRender(e) {
26
- this.imgElement = e.querySelector(l);
27
+ this.imgElement = e.querySelector(c);
27
28
  }
28
29
  setValue(e) {
29
- this.imgElement && (this.imgElement.src = e);
30
+ var t;
31
+ this.imgElement && (this.imgElement.src = e, (t = this.imgElement.parentElement) == null || t.classList.add(g));
30
32
  }
31
33
  getValue() {
32
34
  var e;
@@ -38,5 +40,5 @@ class o extends m {
38
40
  }
39
41
  export {
40
42
  E as PREVIEW_UI_ELEMENT_ID,
41
- o as PreviewUIElement
43
+ d as PreviewUIElement
42
44
  };