@useinsider/guido 2.1.0-beta.c1e85ba → 2.1.0-beta.c305789

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 +1 -3
  2. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
  3. package/dist/components/organisms/header/EditorActions.vue.js +10 -8
  4. package/dist/components/organisms/header/EditorActions.vue2.js +40 -31
  5. package/dist/components/organisms/header/MigrationConfirmModal.vue.js +17 -0
  6. package/dist/components/organisms/header/MigrationConfirmModal.vue2.js +41 -0
  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/composables/useHtmlValidator.js +114 -104
  10. package/dist/composables/useRecommendation.js +54 -21
  11. package/dist/composables/useSave.js +12 -16
  12. package/dist/composables/useStripo.js +57 -59
  13. package/dist/composables/useStripoEventHandler.js +12 -27
  14. package/dist/composables/useVersionHistoryApi.js +1 -1
  15. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  16. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  17. package/dist/config/i18n/en/index.js +11 -0
  18. package/dist/config/i18n/en/labels.json.js +12 -0
  19. package/dist/config/i18n/en/toasters.json.js +56 -0
  20. package/dist/config/i18n/en/tooltips.json.js +82 -0
  21. package/dist/config/i18n/index.js +7 -0
  22. package/dist/config/migrator/itemsBlockMigrator.js +131 -121
  23. package/dist/config/migrator/recommendationMigrator.js +45 -40
  24. package/dist/enums/extensions/recommendationBlock.js +1 -1
  25. package/dist/enums/recommendation.js +16 -15
  26. package/dist/enums/unsubscribe.js +21 -25
  27. package/dist/extensions/Blocks/Items/block.js +45 -25
  28. package/dist/extensions/Blocks/Items/iconsRegistry.js +6 -5
  29. package/dist/extensions/Blocks/Items/items.css.js +48 -0
  30. package/dist/extensions/Blocks/Recommendation/block.js +153 -9
  31. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  32. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  33. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +66 -0
  34. package/dist/extensions/Blocks/Recommendation/constants/layout.js +22 -0
  35. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -0
  36. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  37. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  38. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  39. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +92 -0
  41. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
  42. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +209 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
  44. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +250 -0
  45. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +160 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
  48. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +307 -0
  49. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  51. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
  52. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  53. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  54. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  55. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  56. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  57. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  58. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  59. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  60. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
  61. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  62. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -4
  63. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +61 -4
  64. package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
  65. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  66. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +254 -207
  67. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
  68. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  69. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
  70. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  71. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
  72. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  73. package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
  74. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  75. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  76. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
  77. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  78. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  79. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  80. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  81. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  82. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  83. package/dist/extensions/Blocks/common-control.js +12 -4
  84. package/dist/extensions/Blocks/common-icons.js +39 -0
  85. package/dist/extensions/Blocks/controlFactories.js +125 -93
  86. package/dist/guido.css +1 -1
  87. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +242 -186
  88. package/dist/services/recommendationApi.js +11 -8
  89. package/dist/services/stripoApi.js +19 -52
  90. package/dist/services/templateLibraryApi.js +16 -13
  91. package/dist/src/@types/events.d.ts +2 -38
  92. package/dist/src/components/Guido.vue.d.ts +1 -1
  93. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  94. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  95. package/dist/src/components/organisms/header/MigrationConfirmModal.vue.d.ts +6 -0
  96. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  97. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  98. package/dist/src/components/wrappers/WpModal.vue.d.ts +2 -2
  99. package/dist/src/composables/useRecommendation.d.ts +1 -0
  100. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  101. package/dist/src/config/i18n/en/index.d.ts +1 -0
  102. package/dist/src/config/i18n/index.d.ts +16 -0
  103. package/dist/src/enums/unsubscribe.d.ts +0 -3
  104. package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
  105. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +68 -0
  106. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  107. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  108. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  109. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  110. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +41 -0
  111. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +35 -0
  112. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  113. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  114. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  115. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  116. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  117. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  118. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  119. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
  120. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  121. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +79 -0
  122. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  123. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
  124. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  125. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +221 -0
  126. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  127. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  128. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
  129. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  130. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  131. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  132. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  133. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  134. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  135. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  136. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  137. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
  138. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  139. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  140. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  141. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -468
  142. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  143. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  144. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  145. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
  146. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  147. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  148. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  149. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
  150. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  151. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +166 -0
  152. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  153. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  154. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  155. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  156. package/dist/src/extensions/Blocks/common-control.d.ts +5 -0
  157. package/dist/src/extensions/Blocks/common-icons.d.ts +1 -0
  158. package/dist/src/services/stripoApi.d.ts +0 -5
  159. package/dist/src/stores/editor.d.ts +0 -23
  160. package/dist/src/stores/template.d.ts +3 -0
  161. package/dist/static/styles/components/notification.css.js +18 -0
  162. package/dist/static/styles/components/tools.css.js +6 -2
  163. package/dist/static/styles/customEditorStyle.css.js +35 -11
  164. package/dist/static/styles/variables.css.js +2 -0
  165. package/dist/static/templates/empty/index.html.js +74 -0
  166. package/dist/static/templates/empty/style.css.js +779 -0
  167. package/dist/stores/editor.js +1 -2
  168. package/dist/stores/template.js +9 -0
  169. package/dist/stores/unsubscribe.js +37 -34
  170. package/dist/utils/pairProductVariables.js +57 -56
  171. package/dist/utils/templatePreparation.js +15 -14
  172. package/package.json +1 -1
  173. package/dist/composables/useSyncModuleExtractor.js +0 -45
  174. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  175. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  176. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  177. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  178. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  179. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  180. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  181. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  182. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  183. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  184. package/dist/src/composables/useSyncModuleExtractor.d.ts +0 -4
  185. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  186. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
  187. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  188. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
  189. package/dist/src/mock/api/settings.d.ts +0 -2
@@ -1,27 +1,60 @@
1
- import { MinDeviceViewport as r, DefaultPadding as c } from "../enums/recommendation.js";
2
- const m = () => ({
1
+ import { RecommendationFeedSourceMaps as g, URLS as p } from "../enums/extensions/recommendationBlock.js";
2
+ import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
+ import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { generateCompleteFilterQuery as x } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { useConfigStore as C } from "../stores/config.js";
6
+ const N = () => ({
3
7
  calculateCardWidth: ({
4
- mobileLeftPadding: e,
5
- mobileRightPadding: a,
6
- cardsInRow: n,
7
- unresponsive: i
8
+ mobileLeftPadding: i,
9
+ mobileRightPadding: n,
10
+ cardsInRow: o,
11
+ unresponsive: a
8
12
  }) => {
9
- const t = i ? n : 1, o = e + a + (t - 1) * c;
10
- return (r - o) / t;
13
+ const r = a ? o : 1, e = i + n + (r - 1) * b;
14
+ return (R - e) / r;
11
15
  },
12
- getRecommendationCampaignData: (e) => (console.debug(e), {
13
- textTrimming: !1,
14
- orientation: "vertical",
15
- mobileLeftPadding: 0,
16
- mobileRightPadding: 0,
17
- cardsInRow: 2,
18
- unresponsive: !1,
19
- priceBeforeTextValue: "",
20
- priceAfterTextValue: "",
21
- discountBeforeTextValue: "",
22
- discountAfterTextValue: ""
23
- })
16
+ getRecommendationCampaignData: (i) => {
17
+ const n = l(), o = Number(i), a = n.blockStates[o];
18
+ if (!a)
19
+ return {
20
+ textTrimming: !1,
21
+ orientation: "vertical",
22
+ mobileLeftPadding: 0,
23
+ mobileRightPadding: 0,
24
+ cardsInRow: 2,
25
+ unresponsive: !1,
26
+ priceBeforeTextValue: "",
27
+ priceAfterTextValue: "",
28
+ discountBeforeTextValue: "",
29
+ discountAfterTextValue: ""
30
+ };
31
+ const { recommendationConfigs: r } = a, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
+ return {
33
+ textTrimming: r.textTrimming,
34
+ orientation: e,
35
+ mobileLeftPadding: 0,
36
+ mobileRightPadding: 0,
37
+ cardsInRow: r.cardsInRow,
38
+ unresponsive: r.unresponsive,
39
+ priceBeforeTextValue: "",
40
+ priceAfterTextValue: "",
41
+ discountBeforeTextValue: "",
42
+ discountAfterTextValue: ""
43
+ };
44
+ },
45
+ buildCampaignUrl: (i) => {
46
+ var d;
47
+ const n = l(), o = C(), a = Number(i), r = n.blockStates[a];
48
+ if (!r)
49
+ return "";
50
+ const { recommendationConfigs: e } = r, u = ((d = g.find((s) => s.key === e.strategy)) == null ? void 0 : d.path) || "", t = new URLSearchParams();
51
+ t.set("locale", e.language), t.set("currency", e.currencySettings.value), 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}");
52
+ const f = e.filters.filter((s) => s.isValid), c = x(f);
53
+ c && t.set("filter", c), e.shuffleProducts && t.set("shuffle", "true");
54
+ const m = `${p.RECOMMENDATION_API_URL}/v2/${u}?${t.toString()}`;
55
+ return n.recommendationCampaignUrls[i] = m, m;
56
+ }
24
57
  });
25
58
  export {
26
- m as useRecommendation
59
+ N as useRecommendation
27
60
  };
@@ -1,21 +1,17 @@
1
- import { useConfig as d } from "./useConfig.js";
2
- import { useSaveStart as p, useSaveComplete as f } from "./useGuidoActions.js";
3
- import { useSyncModuleExtractor as v } from "./useSyncModuleExtractor.js";
4
- import { useStripoApi as S } from "../services/stripoApi.js";
5
- import { useTemplatePreparation as x } from "../utils/templatePreparation.js";
6
- import { useHtmlValidator as V } from "./useHtmlValidator.js";
7
- const g = () => {
8
- const o = p(), s = f(), { validateHtml: i } = V(), { callbacks: a } = d(), { extractSyncModuleData: r } = v(), { setSyncModuleUnsubscriptionPages: n } = S();
9
- return { save: async (l = !1) => {
1
+ import { useConfig as l } from "./useConfig.js";
2
+ import { useSaveStart as m, useSaveComplete as c } from "./useGuidoActions.js";
3
+ import { useTemplatePreparation as d } from "../utils/templatePreparation.js";
4
+ import { useHtmlValidator as p } from "./useHtmlValidator.js";
5
+ const w = () => {
6
+ const i = m(), s = c(), { validateHtml: o } = p(), { callbacks: a } = l();
7
+ return { save: async (r = !1) => {
10
8
  var e;
11
- o();
12
- const { prepareTemplateDetails: c } = x(), t = await c();
13
- if (!await i(t.compiledHtml, t.dynamicContentList, !0) || (e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t))
14
- return;
15
- const { unsubscribePayload: m, stripoModules: u } = r(t.rawHtml);
16
- return await n(m), t.modules = u, l || s(t), t;
9
+ i();
10
+ const { prepareTemplateDetails: n } = d(), t = await n();
11
+ if (await o(t.compiledHtml, t.dynamicContentList, !0) && !((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)))
12
+ return r || s(t), t;
17
13
  } };
18
14
  };
19
15
  export {
20
- g as useSave
16
+ w as useSave
21
17
  };
@@ -1,26 +1,27 @@
1
- import { useActionsApi as M } from "./useActionsApi.js";
2
- import { useBlocksConfig as A } from "./useBlocksConfig.js";
3
- import { useConfig as F } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as D } from "./useCustomInterfaceAppearance.js";
5
- import { useStripoEventHandler as I } from "./useStripoEventHandler.js";
6
- import { useToaster as U } from "./useToaster.js";
7
- import { displayConditions as P } from "../enums/displayConditions.js";
8
- import { useStripoApi as R } from "../services/stripoApi.js";
9
- import H from "../static/styles/customEditorStyle.css.js";
10
- import { useEditorStore as S } from "../stores/editor.js";
11
- import { dynamicContentToMergeTags as O } from "../utils/genericUtil.js";
12
- import q from "../package.json.js";
1
+ import { useActionsApi as _ } from "./useActionsApi.js";
2
+ import { useBlocksConfig as B } from "./useBlocksConfig.js";
3
+ import { useConfig as v } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as A } from "./useCustomInterfaceAppearance.js";
5
+ import { useStripoEventHandler as F } from "./useStripoEventHandler.js";
6
+ import { useToaster as D } from "./useToaster.js";
7
+ import { localePatch as I } from "../config/i18n/index.js";
8
+ import { displayConditions as M } from "../enums/displayConditions.js";
9
+ import { useStripoApi as U } from "../services/stripoApi.js";
10
+ import P from "../static/styles/customEditorStyle.css.js";
11
+ import { useEditorStore as R } from "../stores/editor.js";
12
+ import { dynamicContentToMergeTags as H } from "../utils/genericUtil.js";
13
+ import O from "../package.json.js";
13
14
  const Z = (c) => {
14
- const { features: l, template: C } = F(), { handleError: u } = U(), { getToken: E, getCustomFonts: h, getSyncModulesStatus: w } = R(), { handleEvent: b } = I(), { getStripoBlocksConfig: k } = A(), T = async (i, n = [], r = !1) => {
15
- var g, f, y;
16
- const e = S(), { html: p, css: a } = i, { baseBlocks: t, extensions: d } = await k(), m = ((g = l.value) == null ? void 0 : g.displayConditions) ?? !0, _ = ((f = l.value) == null ? void 0 : f.modulesDisabled) ?? !1, B = ((y = C.value) == null ? void 0 : y.forceRecreate) ?? !1;
15
+ const { features: l, template: y } = v(), { handleError: u } = D(), { getToken: C, getCustomFonts: S } = U(), { handleEvent: E } = F(), { getStripoBlocksConfig: h } = B(), w = async (i, r = []) => {
16
+ var m, f, g;
17
+ const o = R(), { html: n, css: p } = i, { baseBlocks: s, extensions: t } = await h(), a = ((m = l.value) == null ? void 0 : m.displayConditions) ?? !0, k = ((f = l.value) == null ? void 0 : f.modulesDisabled) ?? !1, T = ((g = y.value) == null ? void 0 : g.forceRecreate) ?? !1;
17
18
  window.UIEditor.initEditor(
18
19
  document.querySelector("#guido-editor"),
19
20
  {
20
21
  metadata: c,
21
- html: p,
22
- css: a,
23
- forceRecreate: B,
22
+ html: n,
23
+ css: p,
24
+ forceRecreate: T,
24
25
  locale: "en",
25
26
  undoButtonSelector: "#guido__undo-button",
26
27
  redoButtonSelector: "#guido__redo-button",
@@ -30,89 +31,86 @@ const Z = (c) => {
30
31
  customAppearanceMergetags: !0,
31
32
  customAppearanceMergetagsBorderColor: "#f1f3fe",
32
33
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
33
- customViewStyles: H,
34
- conditionsEnabled: m,
35
- customConditionsEnabled: m,
36
- conditionCategories: P,
34
+ customViewStyles: P,
35
+ conditionsEnabled: a,
36
+ customConditionsEnabled: a,
37
+ conditionCategories: M,
37
38
  enableXSSSecurity: !0,
38
- modulesDisabled: _,
39
- syncModulesEnabled: r,
39
+ modulesDisabled: k,
40
40
  messageSettingsEnabled: !0,
41
41
  displayGmailAnnotations: !0,
42
42
  displayHiddenPreheader: !1,
43
43
  displayTitle: !1,
44
44
  displayUTM: !1,
45
45
  selectElementAfterDrop: !0,
46
- ...t ? { baseBlocks: t } : {},
46
+ ...s ? { baseBlocks: s } : {},
47
47
  editorFonts: {
48
48
  showDefaultStandardFonts: !0,
49
49
  showDefaultNotStandardFonts: !0,
50
- customFonts: n
50
+ customFonts: r
51
51
  },
52
52
  mergeTags: [
53
53
  {
54
- entries: O(c.preselectedDynamicContentList)
54
+ entries: H(c.preselectedDynamicContentList)
55
55
  }
56
56
  ],
57
- async onTokenRefreshRequest(o) {
57
+ async onTokenRefreshRequest(e) {
58
58
  try {
59
- const s = await E();
60
- o(s);
61
- } catch (s) {
62
- u(s, "Failed to refresh token");
59
+ const d = await C();
60
+ e(d);
61
+ } catch (d) {
62
+ u(d, "Failed to refresh token");
63
63
  }
64
64
  },
65
65
  onTemplateLoaded() {
66
66
  try {
67
- const { importCss: o } = D(), { activateCustomViewStyles: s, updateTimerInClonedTemplate: v } = M();
68
- o(), s(), v(), c.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
69
- e.hasChanges = !1;
67
+ const { importCss: e } = A(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: V } = _();
68
+ e(), d(), V(), c.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
69
+ o.hasChanges = !1;
70
70
  }, 1e3);
71
- } catch (o) {
72
- u(o, "Failed to load custom interface appearance");
71
+ } catch (e) {
72
+ u(e, "Failed to load custom interface appearance");
73
73
  }
74
74
  },
75
- onCodeEditorVisibilityChanged(o) {
76
- e.isCodeEditorOpen = o;
75
+ onCodeEditorVisibilityChanged(e) {
76
+ o.isCodeEditorOpen = e;
77
77
  },
78
- onEditorVisualModeChanged(o) {
79
- e.editorVisualMode = o.toLowerCase();
78
+ onEditorVisualModeChanged(e) {
79
+ o.editorVisualMode = e.toLowerCase();
80
80
  },
81
- onVersionHistoryVisibilityChanged(o) {
82
- e.isVersionHistoryOpen = o;
81
+ onVersionHistoryVisibilityChanged(e) {
82
+ o.isVersionHistoryOpen = e;
83
83
  },
84
84
  onDataChanged() {
85
- e.hasChanges = !0;
85
+ o.hasChanges = !0;
86
86
  },
87
- onEvent: b,
87
+ onEvent: E,
88
88
  ignoreClickOutsideSelectors: [
89
89
  "#guido-dynamic-content-modal",
90
90
  ".in-on-board-wrapper",
91
91
  ".in-drawer__container"
92
92
  ],
93
- extensions: d
93
+ extensions: t,
94
+ localePatch: I
94
95
  }
95
96
  );
96
- }, V = (i) => new Promise((n, r) => {
97
- var d;
97
+ }, b = (i) => new Promise((r, o) => {
98
+ var a;
98
99
  if (document.getElementById("UiEditorScript")) {
99
- i(), n();
100
+ i(), r();
100
101
  return;
101
102
  }
102
- const e = q.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
103
- t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
104
- i(), n();
103
+ const n = O.guido, s = `https://email-static.useinsider.com/guido/${(a = n == null ? void 0 : n.stripo) == null ? void 0 : a.version}/UIEditor.js`, t = document.createElement("script");
104
+ t.id = "UiEditorScript", t.type = "module", t.src = s, t.onload = () => {
105
+ i(), r();
105
106
  }, t.onerror = () => {
106
- r(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
107
+ o(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
107
108
  }, document.body.appendChild(t);
108
109
  });
109
110
  return { initPlugin: async (i) => {
110
- await V(async () => {
111
- const n = S(), [r, e] = await Promise.all([
112
- h(),
113
- w()
114
- ]);
115
- n.syncModulesEnabled = e, await T(i, r, e);
111
+ await b(async () => {
112
+ const r = await S();
113
+ await w(i, r);
116
114
  });
117
115
  } };
118
116
  };
@@ -1,35 +1,20 @@
1
- import { useStripoApi as i } from "../services/stripoApi.js";
2
- import { useEditorStore as u } from "../stores/editor.js";
3
- import { useOnboardingStore as l } from "../stores/onboarding.js";
4
- import { useUnsubscribeStore as b } from "../stores/unsubscribe.js";
5
- const v = () => {
6
- const { updateSyncModule: d, getSyncModule: r } = i(), n = u(), s = b(), a = {
7
- block_dropped: ({ blockName: e }) => {
8
- if (e === "BLOCK_TEXT") {
9
- const o = l(), t = !o.shouldShowOnboarding("textBlockOnboarding"), c = o.isActive("textBlockOnboarding");
10
- if (t || c)
1
+ import { useOnboardingStore as i } from "../stores/onboarding.js";
2
+ const c = () => {
3
+ const e = {
4
+ block_dropped: ({ blockName: t }) => {
5
+ if (t === "BLOCK_TEXT") {
6
+ const n = i(), o = !n.shouldShowOnboarding("textBlockOnboarding"), r = n.isActive("textBlockOnboarding");
7
+ if (o || r)
11
8
  return;
12
- o.start("textBlockOnboarding");
9
+ n.start("textBlockOnboarding");
13
10
  }
14
- },
15
- module_saved: async (e) => {
16
- n.syncModulesEnabled && (console.debug("[module_saved] Saved module data:", e), await d(e));
17
- },
18
- module_dropped: async (e) => {
19
- if (!n.syncModulesEnabled)
20
- return;
21
- const { moduleId: o } = e, t = await r(o);
22
- console.debug("[module_dropped] Sync module data:", t), t.unsubscriptionPreferencePages.length && await s.fetchTemplates();
23
- },
24
- module_updated: async (e) => {
25
- n.syncModulesEnabled && (console.debug("[module_updated] Updated module data:", e), await d(e));
26
11
  }
27
12
  };
28
- return { handleEvent: async (e, o) => {
29
- const t = a[e];
30
- console.debug("Stripo Event: ", e, o), t && await t(o);
13
+ return { handleEvent: async (t, n) => {
14
+ const o = e[t];
15
+ o && await o(n);
31
16
  } };
32
17
  };
33
18
  export {
34
- v as useStripoEventHandler
19
+ c as useStripoEventHandler
35
20
  };
@@ -35,7 +35,7 @@ const S = () => {
35
35
  () => {
36
36
  s({
37
37
  type: t.Success,
38
- message: `${e} patch restored successfully.`
38
+ message: "Your version has been restored successfully."
39
39
  });
40
40
  },
41
41
  (o) => {
@@ -1,15 +1,16 @@
1
- import { useRecommendation as u } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as P, REGEX as i, CSS as e, CONDITIONS as E, ATTRIBUTES as r, HTML as h } from "../../enums/recommendation.js";
3
- const H = [
1
+ import { useRecommendation as f } from "../../composables/useRecommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as P, REGEX as m, VerticalOrientation as g, CSS as e, ATTRIBUTES as a, CONDITIONS as A, HTML as h } from "../../enums/recommendation.js";
3
+ import { prepareRecommendationBlocks as D } from "./utils/recommendationCompilerUtils.js";
4
+ const G = [
4
5
  {
5
6
  id: "replace-images-with-variable-names",
6
7
  description: "Replacing dummy images with variable names in recommendation module",
7
8
  type: "custom",
8
- processor: (a) => {
9
- let t = a;
10
- return Object.entries(P).forEach(([, n]) => {
11
- Object.entries(n).forEach(([s, o]) => {
12
- t = t.replaceAll(o, `{{${s}}}`);
9
+ processor: (s) => {
10
+ let t = s;
11
+ return Object.entries(P).forEach(([, l]) => {
12
+ Object.entries(l).forEach(([n, o]) => {
13
+ t = t.replaceAll(o, `{{${n}}}`);
13
14
  });
14
15
  }), t;
15
16
  },
@@ -28,17 +29,17 @@ const H = [
28
29
  id: "add-recommendation-unresponsive-css",
29
30
  description: "Adding recommendation unresponsive css",
30
31
  type: "custom",
31
- processor: (a) => {
32
- const { getRecommendationCampaignData: t } = u();
33
- let n = a;
34
- const s = n.match(i.ID);
35
- if (s) {
36
- const o = [];
37
- if (s.forEach((c) => {
38
- const m = c.slice(35, c.length - 1).trim();
39
- t(m);
40
- }), o.length) {
41
- const c = `width:${Math.min(...o)}px!important;`;
32
+ processor: (s) => {
33
+ const { calculateCardWidth: t, getRecommendationCampaignData: l } = f();
34
+ let n = s;
35
+ const o = n.match(m.ID);
36
+ if (o) {
37
+ const d = [];
38
+ if (o.forEach((c) => {
39
+ const E = /recommendation-id="(.*?)"/i.exec(c), I = E ? E[1].trim() : "", p = l(I);
40
+ p.textTrimming && p.orientation === g && d.push(t(p));
41
+ }), d.length) {
42
+ const c = `width:${Math.min(...d)}px!important;`;
42
43
  n = n.replace(e.REGULAR_NAME_HEIGHT, `${e.TRIMMED_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.REGULAR_NAME_CONTAINER_HEIGHT, e.TRIMMED_NAME_CONTAINER_CSS).replace(e.RESPONSIVE_NAME_SIZE, `${e.RESPONSIVE_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.RESPONSIVE_NAME_CONTAINER_HEIGHT, e.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
43
44
  }
44
45
  }
@@ -46,32 +47,37 @@ const H = [
46
47
  },
47
48
  priority: 52
48
49
  },
49
- // TODO: prepareRecommendations
50
- // TODO: addRecommendationCustomFields
50
+ {
51
+ id: "prepare-recommendations",
52
+ description: "Replacing product data with template variables in recommendation blocks",
53
+ type: "custom",
54
+ processor: (s) => D(s),
55
+ priority: 48
56
+ },
51
57
  {
52
58
  id: "add-discount-conditions",
53
59
  description: "Adding discount conditions to the recommendation block",
54
60
  type: "custom",
55
- processor: (a) => {
56
- let t = a;
57
- const n = t.match(i.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: s } = u();
58
- return n !== null && n.forEach((o) => {
59
- const c = o.match(i.CUSTOM_FIELD);
60
- if (!c)
61
+ processor: (s) => {
62
+ let t = s;
63
+ const l = t.match(m.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = f();
64
+ return l !== null && l.forEach((o) => {
65
+ const d = o.match(m.CUSTOM_FIELD);
66
+ if (!d)
61
67
  return;
62
- const [m] = c, p = m.match(i.CUSTOM_FIELD_INDEXES_PART), A = m.match(i.CUSTOM_FIELD_NAME_PART), _ = o.match(i.ATTRIBUTE_PARAGRAPH_START_TAG);
63
- if (!p || !A || !_)
68
+ const [c] = d, E = c.match(m.CUSTOM_FIELD_INDEXES_PART), I = c.match(m.CUSTOM_FIELD_NAME_PART), p = o.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
69
+ if (!E || !I || !p)
64
70
  return;
65
- const [l] = p, [T] = A, [d] = _, N = T.substring(1, T.length - 2), R = d.match(i.COMPOSITION) !== null;
66
- let O = m;
67
- if (R) {
68
- const M = l.substring(2, l.length - 3);
69
- s(M);
71
+ const [u] = E, [R] = I, [_] = p, T = R.substring(1, R.length - 2), S = _.match(m.COMPOSITION) !== null;
72
+ let i = c;
73
+ if (S) {
74
+ const $ = u.substring(2, u.length - 3), r = n($);
75
+ T === a.OMNIBUS_PRICE && (r.priceBeforeTextValue && (i = `${r.priceBeforeTextValue}${i}`), r.priceAfterTextValue && (i = `${i}${r.priceAfterTextValue}`)), T === a.OMNIBUS_DISCOUNT && (r.discountBeforeTextValue && (i = `${r.discountBeforeTextValue}${i}`), r.discountAfterTextValue && (i = `${i}${r.discountAfterTextValue}`));
70
76
  }
71
- const I = l.substring(2);
72
- let S = "";
73
- N in E.IF && (S = E.IF[N].replaceAll(`{${r.DISCOUNT}}`, `${I}${r.DISCOUNT}`).replaceAll(`{${r.OMNIBUS_DISCOUNT}}`, `${I}${r.OMNIBUS_DISCOUNT}`).replaceAll(`{${r.OMNIBUS_PRICE}}`, `${I}${r.OMNIBUS_PRICE}`));
74
- const $ = `${d}${O}${h.PARAGRAPH_END_TAG}`, C = `${S}${R ? $ : o}${E.ELSE}${d}${h.PARAGRAPH_END_TAG}${E.END_IF}`;
77
+ const N = u.substring(2);
78
+ let M = "";
79
+ T in A.IF && (M = A.IF[T].replaceAll(`{${a.DISCOUNT}}`, `${N}${a.DISCOUNT}`).replaceAll(`{${a.OMNIBUS_DISCOUNT}}`, `${N}${a.OMNIBUS_DISCOUNT}`).replaceAll(`{${a.OMNIBUS_PRICE}}`, `${N}${a.OMNIBUS_PRICE}`));
80
+ const O = `${_}${i}${h.PARAGRAPH_END_TAG}`, C = `${M}${S ? O : o}${A.ELSE}${_}${h.PARAGRAPH_END_TAG}${A.END_IF}`;
75
81
  t = t.replace(o, C);
76
82
  }), t;
77
83
  },
@@ -79,5 +85,5 @@ const H = [
79
85
  }
80
86
  ];
81
87
  export {
82
- H as recommendationCompilerRules
88
+ G as recommendationCompilerRules
83
89
  };
@@ -0,0 +1,121 @@
1
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
2
+ function b(e, u, r, o) {
3
+ const n = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
4
+ return o === "before" ? `${t} ${n}` : `${n} ${t}`;
5
+ }
6
+ function p(e, u, r, o, n) {
7
+ switch (u) {
8
+ case "productImage": {
9
+ const t = e.querySelector("img");
10
+ t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
11
+ const c = e.querySelector("a");
12
+ c && c.setAttribute("href", `{{${r}_${o}_url}}`);
13
+ break;
14
+ }
15
+ case "productName": {
16
+ const t = e.querySelector("p");
17
+ if (t) {
18
+ const c = t.querySelector("strong") || t;
19
+ c.textContent = `{{${r}_${o}_name}}`;
20
+ }
21
+ break;
22
+ }
23
+ case "productPrice": {
24
+ const t = e.querySelector("p");
25
+ if (t) {
26
+ const c = t.querySelector("strong") || t;
27
+ c.textContent = b(r, o, "price", n);
28
+ }
29
+ break;
30
+ }
31
+ case "productOldPrice": {
32
+ const t = e.querySelector("p");
33
+ if (t) {
34
+ const c = t.querySelector("strong") || t;
35
+ c.textContent = b(
36
+ r,
37
+ o,
38
+ "original_price",
39
+ n
40
+ ), t.setAttribute("product-attr", "discount");
41
+ }
42
+ break;
43
+ }
44
+ case "productButton": {
45
+ const t = e.querySelector("a");
46
+ t && t.setAttribute("href", `{{${r}_${o}_url}}`);
47
+ break;
48
+ }
49
+ case "productOmnibusPrice": {
50
+ const t = e.querySelector(".omnibus-price-value");
51
+ if (t) {
52
+ t.textContent = `{{${r}_${o}_omnibus_price}}`;
53
+ const c = t.closest("p");
54
+ c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
55
+ }
56
+ break;
57
+ }
58
+ case "productOmnibusDiscount": {
59
+ const t = e.querySelector(".omnibus-discount-value");
60
+ if (t) {
61
+ t.textContent = `{{${r}_${o}_omnibus_discount}}`;
62
+ const c = t.closest("p");
63
+ c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
64
+ }
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ function $(e, u, r) {
70
+ e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
71
+ n.querySelectorAll("[data-attribute-type]").forEach((s) => {
72
+ const i = s.getAttribute("data-attribute-type") || "", a = s.querySelectorAll(".attribute-cell");
73
+ a.length > 0 ? a.forEach((l) => {
74
+ p(l, i, u, t, r);
75
+ }) : p(s, i, u, t, r);
76
+ });
77
+ });
78
+ }
79
+ function S(e, u, r) {
80
+ const o = e.querySelectorAll(".recommendation-product-row");
81
+ if (!o.length)
82
+ return;
83
+ const [n] = o, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
84
+ o.forEach((s, i) => {
85
+ s.querySelectorAll("[data-attribute-type]").forEach((l) => {
86
+ const f = l.getAttribute("data-attribute-type") || "";
87
+ l.querySelectorAll(".attribute-cell").forEach((y, m) => {
88
+ const A = i * c + m;
89
+ p(y, f, u, A, r);
90
+ });
91
+ });
92
+ });
93
+ }
94
+ function q(e, u, r) {
95
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
96
+ S(n, u, r);
97
+ });
98
+ }
99
+ function d(e, u) {
100
+ const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
101
+ r === "list" ? $(e, u, o) : q(e, u, o);
102
+ }
103
+ function h(e, u) {
104
+ const r = e.match(/<!DOCTYPE[^>]*>/i);
105
+ return (r ? `${r[0]}
106
+ ` : "") + u.documentElement.outerHTML;
107
+ }
108
+ function w(e) {
109
+ const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".ins-recommendation-v3-block-v2");
110
+ if (!o.length)
111
+ return e;
112
+ const { buildCampaignUrl: n } = _();
113
+ return o.forEach((c) => {
114
+ const s = c.getAttribute("recommendation-id");
115
+ s && (n(s), d(c, s));
116
+ }), h(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
117
+ }
118
+ export {
119
+ b as formatPriceVariable,
120
+ w as prepareRecommendationBlocks
121
+ };
@@ -0,0 +1,11 @@
1
+ import o from "./labels.json.js";
2
+ import t from "./toasters.json.js";
3
+ import r from "./tooltips.json.js";
4
+ const e = {
5
+ ...o,
6
+ ...r,
7
+ ...t
8
+ };
9
+ export {
10
+ e as en
11
+ };
@@ -0,0 +1,12 @@
1
+ const e = "Items", o = {
2
+ "Global Styles & Layout": "Global Styles and Layout",
3
+ "Structures & Modules": "Structures and Modules",
4
+ "Recommendation Block": "Recommendation",
5
+ Items: e,
6
+ "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.": "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.",
7
+ "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.": "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."
8
+ };
9
+ export {
10
+ e as Items,
11
+ o as default
12
+ };