@useinsider/guido 3.1.1 → 3.2.0-beta.080341b

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 (189) hide show
  1. package/README.md +117 -0
  2. package/dist/@types/config/schemas.js +166 -96
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +92 -80
  5. package/dist/components/organisms/AutoSaveController.vue.js +17 -0
  6. package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  9. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  10. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  11. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  12. package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
  13. package/dist/components/organisms/header/RightSlot.vue.js +11 -11
  14. package/dist/components/organisms/header/RightSlot.vue2.js +17 -13
  15. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  16. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  17. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  18. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  19. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  20. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  21. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  22. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  23. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
  24. package/dist/composables/useActionsApi.js +4 -4
  25. package/dist/composables/useAutoSave.js +71 -0
  26. package/dist/composables/useFullStoryBridge.js +14 -0
  27. package/dist/composables/useHtmlCompiler.js +23 -21
  28. package/dist/composables/useHtmlValidator.js +40 -38
  29. package/dist/composables/usePreviewMode.js +20 -16
  30. package/dist/composables/useRecommendation.js +46 -26
  31. package/dist/composables/useRibbonOffset.js +21 -0
  32. package/dist/composables/useSave.js +26 -15
  33. package/dist/composables/useStripo.js +48 -45
  34. package/dist/composables/validators/useCouponBlockValidator.js +24 -0
  35. package/dist/composables/validators/useLiquidValidator.js +42 -0
  36. package/dist/config/compiler/liquidCompilerRules.js +15 -0
  37. package/dist/config/compiler/recommendationCompilerRules.js +162 -43
  38. package/dist/config/compiler/unsubscribeCompilerRules.js +48 -45
  39. package/dist/config/compiler/utils/recommendationCompilerUtils.js +110 -71
  40. package/dist/config/i18n/en/tooltips.json.js +2 -1
  41. package/dist/config/migrator/checkboxMigrator.js +5 -3
  42. package/dist/config/migrator/index.js +9 -9
  43. package/dist/config/migrator/radioButtonMigrator.js +66 -44
  44. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  45. package/dist/config/migrator/recommendation/extractors.js +27 -0
  46. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  47. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  48. package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
  49. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  50. package/dist/config/migrator/recommendationMigrator.js +74 -290
  51. package/dist/enums/extensions/recommendationBlock.js +16 -12
  52. package/dist/enums/onboarding.js +7 -2
  53. package/dist/enums/recommendation.js +2 -2
  54. package/dist/enums/unsubscribe.js +34 -27
  55. package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
  56. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
  57. package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
  58. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  59. package/dist/extensions/Blocks/Recommendation/block.js +60 -50
  60. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  61. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  62. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  63. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  64. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
  65. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
  66. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +27 -26
  67. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
  68. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +211 -162
  69. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
  70. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
  71. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  72. package/dist/extensions/Blocks/Recommendation/services/configService.js +76 -33
  73. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
  74. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -79
  75. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +24 -13
  76. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  77. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  78. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +27 -15
  79. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  80. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  81. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
  82. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
  83. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  84. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  85. package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
  86. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  87. package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
  88. package/dist/guido.css +1 -1
  89. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
  90. package/dist/node_modules/valibot/dist/index.js +450 -235
  91. package/dist/package.json.js +1 -1
  92. package/dist/services/recommendationApi.js +15 -15
  93. package/dist/services/stripoApi.js +9 -9
  94. package/dist/services/templateLibraryApi.js +49 -46
  95. package/dist/src/@types/config/defaults.d.ts +5 -1
  96. package/dist/src/@types/config/index.d.ts +3 -3
  97. package/dist/src/@types/config/schemas.d.ts +245 -0
  98. package/dist/src/@types/config/types.d.ts +11 -1
  99. package/dist/src/@types/generic.d.ts +0 -1
  100. package/dist/src/@types/save-as-template.d.ts +1 -0
  101. package/dist/src/components/Guido.vue.d.ts +1 -1
  102. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
  103. package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
  104. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  105. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  106. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  107. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  108. package/dist/src/composables/useActionsApi.d.ts +1 -1
  109. package/dist/src/composables/useAutoSave.d.ts +3 -0
  110. package/dist/src/composables/useConfig.d.ts +70 -0
  111. package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
  112. package/dist/src/composables/useRecommendation.d.ts +10 -1
  113. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  114. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  115. package/dist/src/composables/useSave.d.ts +1 -1
  116. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  117. package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
  118. package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
  119. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  120. package/dist/src/config/migrator/index.d.ts +2 -1
  121. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  122. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  123. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  124. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  125. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  126. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  127. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  128. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  129. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  130. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  131. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  132. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  133. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  134. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  135. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  136. package/dist/src/enums/onboarding.d.ts +6 -0
  137. package/dist/src/enums/unsubscribe.d.ts +5 -0
  138. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
  139. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  140. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  141. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  142. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  143. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  144. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
  145. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
  146. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  147. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
  148. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
  149. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +21 -3
  150. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  151. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
  152. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  153. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  154. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  155. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  156. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
  157. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
  158. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  159. package/dist/src/library.d.ts +1 -1
  160. package/dist/src/services/templateLibraryApi.d.ts +1 -1
  161. package/dist/src/stores/autosave.d.ts +12 -0
  162. package/dist/src/stores/config.d.ts +630 -0
  163. package/dist/src/stores/editor.d.ts +23 -0
  164. package/dist/src/stores/onboarding.d.ts +4 -0
  165. package/dist/src/stores/preview.d.ts +3 -0
  166. package/dist/src/utils/genericUtil.d.ts +1 -1
  167. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  168. package/dist/src/utils/htmlEscape.d.ts +5 -0
  169. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  170. package/dist/src/utils/timeUtil.d.ts +8 -0
  171. package/dist/static/styles/base.css.js +7 -2
  172. package/dist/static/styles/components/button.css.js +16 -9
  173. package/dist/static/styles/components/loader.css.js +4 -0
  174. package/dist/static/styles/components/narrow-panel.css.js +52 -0
  175. package/dist/stores/autosave.js +17 -0
  176. package/dist/stores/editor.js +3 -1
  177. package/dist/stores/onboarding.js +4 -0
  178. package/dist/stores/preview.js +4 -3
  179. package/dist/utils/genericUtil.js +42 -20
  180. package/dist/utils/htmlCompiler.js +48 -41
  181. package/dist/utils/htmlEscape.js +13 -0
  182. package/dist/utils/pairProductVariables.js +89 -88
  183. package/dist/utils/templatePreparation.js +75 -24
  184. package/dist/utils/timeUtil.js +19 -0
  185. package/dist/utils/tooltipUtils.js +4 -5
  186. package/package.json +8 -4
  187. package/dist/enums/displayConditions.js +0 -80
  188. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  189. package/dist/src/enums/displayConditions.d.ts +0 -2
@@ -1,84 +1,85 @@
1
- import { productPairs as P } from "../extensions/Blocks/Items/enums/productEnums.js";
2
- function L(F) {
3
- const R = F.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), $ = new DOMParser().parseFromString(R, "text/html"), y = P.PAIRS_FOR_EXTENSION;
4
- Object.entries(y).forEach(([n, l]) => {
5
- $.querySelectorAll(".ins-product-td").forEach((c) => {
6
- const E = c.getAttribute("data-number") || "1", T = c.getAttribute("data-type") || "CART_ITEMS";
7
- c.querySelectorAll(`[product-attr="${n}"]`).forEach((e) => {
8
- var H;
9
- const b = e.getAttribute("data-type") || T, u = e.getAttribute("data-number") || E, p = l[b];
10
- if (p)
11
- switch (n) {
1
+ import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ function q(w) {
3
+ const y = w.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), T = new DOMParser().parseFromString(y, "text/html"), C = L.PAIRS_FOR_EXTENSION;
4
+ Object.entries(C).forEach(([r, f]) => {
5
+ T.querySelectorAll(".ins-product-td").forEach((o) => {
6
+ const A = o.getAttribute("data-number") || "1", b = o.getAttribute("data-type") || "CART_ITEMS";
7
+ o.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
8
+ var k, F, I;
9
+ const $ = e.getAttribute("data-type") || b, d = e.getAttribute("data-number") || A, u = f[$];
10
+ if (u)
11
+ switch (r) {
12
12
  case "imageSrc": {
13
- let t = null, o = null;
14
- if (e.tagName === "IMG" ? (t = e, o = t.closest("a")) : (t = e.querySelector("img"), o = e.querySelector("a") || e.closest("a")), !t)
13
+ let t = null, i = null;
14
+ if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
15
15
  break;
16
- const i = p.DEFAULT, a = p.ATTR;
17
- if (i && t.src) {
18
- const r = t.src;
19
- i.some((f) => {
20
- const s = f.split("/").pop() || "", _ = r.split("/").pop() || "";
21
- return r.includes(f) || r.includes(s) || _ === s;
22
- }) && (t.src = `{{${a}_${u}}}`);
16
+ const a = u.DEFAULT, s = u.ATTR;
17
+ if (a && t.src) {
18
+ const c = t.src;
19
+ a.some((h) => {
20
+ const l = h.split("/").pop() || "", g = c.split("/").pop() || "";
21
+ return c.includes(h) || c.includes(l) || g === l;
22
+ }) && (t.src = `{{${s}_${d}}}`);
23
23
  }
24
- if (o) {
25
- const r = (H = y.itemLink) == null ? void 0 : H[b];
26
- if (r) {
27
- const d = r.HREF, f = r.DEFAULT_HREF || "#!", s = o.href;
28
- (s === "#" || s === "" || s.endsWith("#!") || s.endsWith(f) || s === `${window.location.href}${f}` || !s || s === window.location.href) && (o.href = `{{${d}_${u}}}`);
24
+ const n = (F = (k = C.name) == null ? void 0 : k[$]) == null ? void 0 : F.ATTR;
25
+ if (n && t.setAttribute("alt", `{{${n}_${d}}}`), i) {
26
+ const c = (I = C.itemLink) == null ? void 0 : I[$];
27
+ if (c) {
28
+ const E = c.HREF, h = c.DEFAULT_HREF || "#!", l = i.href;
29
+ (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${d}}}`);
29
30
  }
30
31
  }
31
32
  break;
32
33
  }
33
34
  case "name": {
34
- const t = p, o = t.ATTR, i = t.DEFAULT_HREF || "#!", a = t.HREF;
35
- e.textContent && (e.textContent = `{{${o}_${u}}}`);
36
- const r = e.closest("a") || (e.tagName === "A" ? e : null);
37
- if (r && a) {
38
- const d = r.href, f = `${window.location.href}${i}`;
39
- (d === f || d.endsWith(i)) && (r.href = `{{${a}_${u}}}`);
35
+ const t = u, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
36
+ e.textContent && (e.textContent = `{{${i}_${d}}}`);
37
+ const n = e.closest("a") || (e.tagName === "A" ? e : null);
38
+ if (n && s) {
39
+ const c = n.href, E = `${window.location.href}${a}`;
40
+ (c === E || c.endsWith(a)) && (n.href = `{{${s}_${d}}}`);
40
41
  }
41
42
  break;
42
43
  }
43
44
  case "price":
44
45
  case "originalPrice": {
45
- const t = p, o = e.getAttribute("data-formated"), i = e.getAttribute("data-single_price"), a = o === "true", r = i === "true", d = e.getAttribute("data-curency") || "before";
46
- let f;
47
- r ? f = a ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : f = a ? t.PRICE_FORMATTED : t.PRICE;
48
- const s = t.CURRENCY;
49
- let _ = `{{${f}_${u}}}`;
50
- if (s) {
51
- const k = `{{${s}_${u}}}`;
52
- _ = d === "after" ? `${_} ${k}` : `${k} ${_}`;
46
+ const t = u, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", c = e.getAttribute("data-curency") || "before";
47
+ let E;
48
+ n ? E = s ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : E = s ? t.PRICE_FORMATTED : t.PRICE;
49
+ const h = t.CURRENCY;
50
+ let l = `{{${E}_${d}}}`;
51
+ if (h) {
52
+ const g = `{{${h}_${d}}}`;
53
+ l = c === "after" ? `${l} ${g}` : `${g} ${l}`;
53
54
  }
54
- e.textContent = _;
55
+ e.textContent = l;
55
56
  break;
56
57
  }
57
58
  case "quantity": {
58
- const t = p, o = t.ATTR, i = t.DEFAULT;
59
- e.textContent && e.textContent.trim() === i && (e.textContent = `{{${o}_${u}}}`);
59
+ const t = u, i = t.ATTR, a = t.DEFAULT;
60
+ e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${d}}}`);
60
61
  break;
61
62
  }
62
63
  case "button": {
63
- const t = p, o = t.HREF, i = t.DEFAULT_HREF || "#!", a = e.tagName === "A" ? e : e.querySelector("a");
64
- if (a) {
65
- const r = a.href || "", d = `${window.location.href}${i}`;
66
- (r === "" || r === "#" || r === d || r.endsWith(i) || r.endsWith("#!") || r === window.location.href) && (a.href = `{{${o}_${u}}}`);
64
+ const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
65
+ if (s) {
66
+ const n = s.href || "", c = `${window.location.href}${a}`;
67
+ (n === "" || n === "#" || n === c || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${d}}}`);
67
68
  }
68
69
  break;
69
70
  }
70
71
  case "itemLink": {
71
- const t = p, o = t.HREF, i = t.DEFAULT_HREF || "#!", a = e;
72
- if (a.href) {
73
- const r = a.href, d = `${window.location.href}${i}`;
74
- (r === d || r.endsWith(i)) && (a.href = `{{${o}_${u}}}`);
72
+ const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
73
+ if (s.href) {
74
+ const n = s.href, c = `${window.location.href}${a}`;
75
+ (n === c || n.endsWith(a)) && (s.href = `{{${i}_${d}}}`);
75
76
  }
76
77
  break;
77
78
  }
78
79
  default: {
79
- if ("ATTR" in p) {
80
- const t = p.ATTR;
81
- e.textContent && (e.textContent = `{{${t}_${u}}}`);
80
+ if ("ATTR" in u) {
81
+ const t = u.ATTR;
82
+ e.textContent && (e.textContent = `{{${t}_${d}}}`);
82
83
  }
83
84
  break;
84
85
  }
@@ -86,55 +87,55 @@ function L(F) {
86
87
  });
87
88
  });
88
89
  });
89
- const S = R.match(/<!DOCTYPE[^>]*>/i), I = S ? `${S[0]}
90
- ` : "", w = $.querySelectorAll(".ins-product-td"), m = [];
91
- w.forEach((n) => {
92
- const l = n.getAttribute("data-type") || "CART_ITEMS", A = n.getAttribute("data-number") || "1", c = n.getAttribute("data-nodup"), E = n.outerHTML;
93
- m.push({
94
- element: n,
95
- outerHtml: E,
96
- type: l,
97
- number: A,
98
- nodup: c || void 0
90
+ const S = y.match(/<!DOCTYPE[^>]*>/i), M = S ? `${S[0]}
91
+ ` : "", P = T.querySelectorAll(".ins-product-td"), H = [];
92
+ P.forEach((r) => {
93
+ const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", o = r.getAttribute("data-nodup"), A = r.outerHTML;
94
+ H.push({
95
+ element: r,
96
+ outerHtml: A,
97
+ type: f,
98
+ number: p,
99
+ nodup: o || void 0
99
100
  });
100
101
  });
101
- let h = I + $.documentElement.outerHTML;
102
- m.reverse().forEach(({ outerHtml: n, type: l, number: A }) => {
103
- let c = "";
104
- switch (l) {
102
+ let _ = M + T.documentElement.outerHTML;
103
+ H.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
104
+ let o = "";
105
+ switch (f) {
105
106
  case "CART_ITEMS":
106
- c = "ins_apr_total_product_kind";
107
+ o = "ins_apr_total_product_kind";
107
108
  break;
108
109
  case "BROWSED_ITEMS":
109
- c = "browsed_item_total_product_kind";
110
+ o = "browsed_item_total_product_kind";
110
111
  break;
111
112
  case "PURCHASED_ITEMS":
112
- c = "purchased_item_total_product_kind";
113
+ o = "purchased_item_total_product_kind";
113
114
  break;
114
115
  }
115
- if (c) {
116
- const T = parseInt(A) - 1, b = `${`{% if ${c} > ${T} %}`}${n}{% endif %}`;
117
- h = h.replace(n, b);
116
+ if (o) {
117
+ const b = parseInt(p) - 1, $ = `${`{% if ${o} > ${b} %}`}${r}{% endif %}`;
118
+ _ = _.replace(r, $);
118
119
  }
119
120
  });
120
- const M = $.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), g = [];
121
- return M.forEach((n) => {
122
- const l = n.getAttribute("data-number"), A = n.getAttribute("data-type");
123
- if (!l || A !== "CART_ITEMS")
121
+ const D = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
122
+ return D.forEach((r) => {
123
+ const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
124
+ if (!f || p !== "CART_ITEMS")
124
125
  return;
125
- const c = n.closest(".product-original-price-class");
126
- if (c) {
127
- const E = c.outerHTML;
128
- g.some((C) => C.tdOuterHtml === E) || g.push({ tdOuterHtml: E, number: l });
126
+ const o = r.closest(".product-original-price-class");
127
+ if (o) {
128
+ const A = o.outerHTML;
129
+ R.some((m) => m.tdOuterHtml === A) || R.push({ tdOuterHtml: A, number: f });
129
130
  }
130
- }), g.reverse().forEach(({ tdOuterHtml: n, number: l }) => {
131
- const A = `{% if ins_apr_price_${l} != ins_apr_originalprice_${l} %}`;
132
- if (!h.includes(A) && !n.includes("{% if")) {
133
- const E = `${A}${n}{% endif %}`;
134
- h = h.replace(n, E);
131
+ }), R.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
132
+ const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
133
+ if (!_.includes(p) && !r.includes("{% if")) {
134
+ const A = `${p}${r}{% endif %}`;
135
+ _ = _.replace(r, A);
135
136
  }
136
- }), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
137
+ }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
137
138
  }
138
139
  export {
139
- L as pairProductVariables
140
+ q as pairProductVariables
140
141
  };
@@ -1,42 +1,93 @@
1
- import { useActionsApi as f } from "../composables/useActionsApi.js";
1
+ import { useActionsApi as T } from "../composables/useActionsApi.js";
2
2
  import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
- import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { useDynamicContentStore as x } from "../stores/dynamic-content.js";
5
- import { useUnsubscribeStore as y } from "../stores/unsubscribe.js";
6
- const E = () => {
7
- const o = x(), t = y(), { getCompiledEmail: i, getTemplateData: n, editorSave: s } = f(), { compileHtml: m } = C();
3
+ import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as D } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
+ function U(i, r) {
10
+ const s = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), c = [];
11
+ return s.forEach((t) => {
12
+ const o = t.getAttribute(y.PAGE_LIST);
13
+ o && c.push(...P(o));
14
+ }), r.filter((t) => c.includes(t));
15
+ }
16
+ function F(i) {
17
+ const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
+ if (m.length === 0)
19
+ return;
20
+ const d = b();
21
+ m.forEach((s) => {
22
+ var g, f, u, n, S;
23
+ const c = s.getAttribute("recommendation-id"), t = c ? Number(c) : NaN;
24
+ if (!Number.isFinite(t))
25
+ return;
26
+ const o = s.getAttribute("esd-ext-config");
27
+ if (!o)
28
+ return;
29
+ let e;
30
+ try {
31
+ e = JSON.parse(o);
32
+ } catch {
33
+ return;
34
+ }
35
+ if (!e || typeof e != "object" || Array.isArray(e))
36
+ return;
37
+ const p = {
38
+ strategy: e.strategy ?? a.strategy,
39
+ language: e.language ?? a.language,
40
+ size: e.size ?? a.size,
41
+ // Spread the default arrays so each block gets a fresh reference
42
+ // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
+ productIds: e.productIds ?? [...a.productIds],
44
+ filters: e.filters ?? [...a.filters],
45
+ shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
+ currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? l.code,
47
+ currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? l.alignment,
48
+ currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? l.decimalCount,
49
+ currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? l.decimalSeparator,
50
+ currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? l.thousandSeparator
51
+ };
52
+ d.seedBlockUrlConfig(t, p);
53
+ });
54
+ }
55
+ const _ = () => {
56
+ const i = D(), r = E(), { getCompiledEmail: m, getTemplateData: d } = T(), { compileHtml: s } = C();
8
57
  return {
9
58
  prepareTemplateDetails: async () => {
10
- const { html: a, ampHtml: r = "", ampErrors: c = [] } = await i({
59
+ const { html: t, ampHtml: o = "", ampErrors: e = [] } = await m({
11
60
  minimize: !0,
12
61
  resetDataSavedFlag: !1
13
- }), { html: l, css: p, syncModulesIds: u = [] } = await n(), { compiledHtml: d, stats: e, appliedRules: S } = m(a), g = o.getSelectedDynamicContentList, b = T();
14
- return s(), console.debug("HTML Compilation Stats:", {
15
- originalSize: e.originalSize,
16
- compiledSize: e.compiledSize,
17
- reduction: `${e.reductionPercentage.toFixed(2)}%`,
62
+ }), { html: p, css: g, syncModulesIds: f = [] } = await d();
63
+ r.selectedUnsubscribePages.length && await r.fetchTemplates(), F(p);
64
+ const { compiledHtml: u, stats: n, appliedRules: S } = s(t), h = i.getSelectedDynamicContentList, A = b();
65
+ return console.debug("HTML Compilation Stats:", {
66
+ originalSize: n.originalSize,
67
+ compiledSize: n.compiledSize,
68
+ reduction: `${n.reductionPercentage.toFixed(2)}%`,
18
69
  appliedRules: S,
19
- executionTime: `${e.executionTime.toFixed(2)}ms`
70
+ executionTime: `${n.executionTime.toFixed(2)}ms`
20
71
  }), {
21
- dynamicContentList: g,
22
- compiledHtml: d,
23
- rawHtml: l,
24
- css: p,
25
- ampHtml: r,
26
- ampErrors: c,
27
- modules: u.map(Number),
72
+ dynamicContentList: h,
73
+ compiledHtml: u,
74
+ rawHtml: p,
75
+ css: g,
76
+ ampHtml: o,
77
+ ampErrors: e,
78
+ modules: f.map(Number),
28
79
  recommendation: {
29
- campaignUrls: b.recommendationCampaignUrls,
80
+ campaignUrls: A.recommendationCampaignUrls,
30
81
  configs: {}
31
82
  },
32
83
  unsubscribe: {
33
- status: t.unsubscribePagesStatus,
34
- config: t.selectedUnsubscribePages
84
+ status: r.unsubscribePagesStatus,
85
+ config: U(u, r.selectedUnsubscribePages)
35
86
  }
36
87
  };
37
88
  }
38
89
  };
39
90
  };
40
91
  export {
41
- E as useTemplatePreparation
92
+ _ as useTemplatePreparation
42
93
  };
@@ -0,0 +1,19 @@
1
+ const r = (t) => {
2
+ const e = -t.getTimezoneOffset(), o = e >= 0 ? "+" : "-", n = Math.abs(e), s = Math.floor(n / 60), i = n % 60;
3
+ return i === 0 ? `UTC${o}${s}` : `UTC${o}${s}:${String(i).padStart(2, "0")}`;
4
+ }, a = () => {
5
+ var e;
6
+ const { timeZone: t } = new Intl.DateTimeFormat().resolvedOptions();
7
+ return ((e = t.split("/").pop()) == null ? void 0 : e.replace(/_/g, " ")) ?? t;
8
+ }, c = (t, e = !1) => {
9
+ const o = t.toLocaleTimeString([], {
10
+ hour: "2-digit",
11
+ hour12: !1,
12
+ minute: "2-digit",
13
+ second: "2-digit"
14
+ });
15
+ return e ? `${o} (${r(t)} ${a()})` : o;
16
+ };
17
+ export {
18
+ c as formatLocalTime
19
+ };
@@ -1,11 +1,10 @@
1
- const e = (s, t = {}) => ({
2
- id: s,
1
+ const o = (i, t = {}) => ({
2
+ id: i,
3
3
  dynamicPosition: t.dynamicPosition ?? !1,
4
4
  staticPosition: t.staticPosition ?? "bottom center",
5
5
  iconStatus: t.iconStatus ?? !1,
6
- offset: t.offset,
7
- preventXss: t.preventXss
6
+ offset: t.offset
8
7
  });
9
8
  export {
10
- e as getTooltipOptions
9
+ o as getTooltipOptions
11
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.1.1",
3
+ "version": "3.2.0-beta.080341b",
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",
@@ -24,6 +24,8 @@
24
24
  "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
25
25
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
26
26
  "type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest",
27
29
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
28
30
  "prepare": "husky",
29
31
  "preinstall": "rm -rf ./node_modules/.vite"
@@ -32,8 +34,8 @@
32
34
  "author": "",
33
35
  "license": "ISC",
34
36
  "dependencies": {
35
- "@stripoinc/ui-editor-extensions": "3.5.0",
36
- "@useinsider/design-system-vue": "0.14.28",
37
+ "@stripoinc/ui-editor-extensions": "3.8.0",
38
+ "@useinsider/design-system-vue": "1.1.0-beta.73ec2fa",
37
39
  "@vueuse/core": "11.3.0",
38
40
  "lodash-es": "4.17.21",
39
41
  "pinia": "2.3.1",
@@ -69,12 +71,14 @@
69
71
  "eslint-plugin-vue": "10.1.0",
70
72
  "eslint-plugin-vue-scoped-css": "2.6.1",
71
73
  "globals": "16.0.0",
74
+ "happy-dom": "15.11.7",
72
75
  "husky": "9.1.7",
73
76
  "msw": "2.10.3",
74
77
  "sass": "1.69.7",
75
78
  "typescript": "5.5.4",
76
79
  "typescript-eslint": "8.26.0",
77
80
  "vite-plugin-dts": "4.5.4",
81
+ "vitest": "2.1.9",
78
82
  "vue-tsc": "2.2.10"
79
83
  },
80
84
  "overrides": {
@@ -86,7 +90,7 @@
86
90
  },
87
91
  "guido": {
88
92
  "stripo": {
89
- "version": "2.54.0"
93
+ "version": "2.62.0"
90
94
  }
91
95
  }
92
96
  }
@@ -1,80 +0,0 @@
1
- const e = [
2
- {
3
- category: "Demographics",
4
- conditions: [
5
- {
6
- id: 1,
7
- name: "Language",
8
- description: "Users who are in the English will see the banner",
9
- beforeScript: '{% if language == "en_US" %}',
10
- afterScript: "{% endif %}"
11
- },
12
- {
13
- id: 2,
14
- name: "Country",
15
- description: "Only people who live in Australia will see the banner",
16
- beforeScript: '{% if country == "Australia" %}',
17
- afterScript: "{% endif %}"
18
- },
19
- {
20
- id: 3,
21
- name: "Country & City",
22
- description: "Only people who are located in that country and city",
23
- beforeScript: '{% if country == "United Kingdom" and city == "London" %}',
24
- afterScript: "{% endif %}"
25
- },
26
- {
27
- id: 4,
28
- name: "Age (Less than operator)",
29
- description: "Users whose age is less than 18",
30
- beforeScript: "{% if age < 18 %}",
31
- afterScript: "{% endif %}"
32
- },
33
- {
34
- id: 5,
35
- name: "Age (Equal and greater than operator)",
36
- description: "Users whose age is equal or greater than 25",
37
- beforeScript: "{% if age >= 25 %}",
38
- afterScript: "{% endif %}"
39
- },
40
- {
41
- id: 6,
42
- name: "Age (Greater than & less than operators)",
43
- description: "Users whose age is between 18 and 25",
44
- beforeScript: "{% if age > 18 and age < 25 %}",
45
- afterScript: "{% endif %}"
46
- },
47
- {
48
- id: 7,
49
- name: "Gender",
50
- description: "Users whose gender is Female",
51
- beforeScript: '{% if gender == "Female" %}',
52
- afterScript: "{% endif %}"
53
- },
54
- {
55
- id: 8,
56
- name: "State",
57
- description: "Users whose state is one of the followings. c_state is a custom attribute. Use this condition if you have the attribute with the same naming. ",
58
- beforeScript: '{% if c_state == "VIC" or c_state == "NSW" or c_state == "QLD" %}',
59
- afterScript: "{% endif %}"
60
- },
61
- {
62
- id: 9,
63
- name: "VIP User",
64
- description: "Users who are VIP users for that brand. c_is_vip_user = true. c_is_vip_user is a custom attribute. Use this condition if you have the attribute with the same naming.",
65
- beforeScript: "{% if c_is_vip_user %}",
66
- afterScript: "{% endif %}"
67
- },
68
- {
69
- id: 10,
70
- name: "Membership Type",
71
- description: "Users who belong to gold or silver membership type. c_is_gold_member = true, c_is_silver_member = true. These are custom attributes. Use this condition if you have the attribute with the same naming.",
72
- beforeScript: "{% if c_is_gold_member or c_is_silver_member %}",
73
- afterScript: "{% endif %}"
74
- }
75
- ]
76
- }
77
- ];
78
- export {
79
- e as displayConditions
80
- };