@useinsider/guido 3.18.1-beta.dea994d → 3.18.1-beta.e39fb14

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 (52) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +28 -26
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +53 -51
  5. package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
  6. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  7. package/dist/components/organisms/header/EditorActions.vue2.js +86 -56
  8. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  9. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
  10. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  11. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +48 -0
  12. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  13. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  14. package/dist/composables/useHtmlCompiler.js +37 -26
  15. package/dist/composables/useHtmlValidator.js +2 -0
  16. package/dist/composables/usePreviewMode.js +11 -12
  17. package/dist/composables/useSave.js +90 -45
  18. package/dist/composables/useSaveValidation.js +279 -0
  19. package/dist/composables/useSaveValidationRollout.js +9 -0
  20. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  21. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  22. package/dist/config/compiler/htmlCompilerRules.js +6 -14
  23. package/dist/enums/save-validation.js +4 -0
  24. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -34
  25. package/dist/guido.css +1 -1
  26. package/dist/src/@types/config/schemas.d.ts +4 -0
  27. package/dist/src/@types/save-validation.d.ts +19 -0
  28. package/dist/src/components/Guido.vue.d.ts +17 -1
  29. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  30. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  31. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  32. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  33. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  34. package/dist/src/composables/useConfig.d.ts +2 -0
  35. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  36. package/dist/src/composables/useSave.d.ts +6 -1
  37. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  38. package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
  39. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  40. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  41. package/dist/src/enums/save-validation.d.ts +27 -0
  42. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
  43. package/dist/src/stores/config.d.ts +30 -0
  44. package/dist/src/stores/save-validation.d.ts +22 -0
  45. package/dist/src/utils/templatePreparation.d.ts +30 -0
  46. package/dist/static/styles/customEditorStyle.css.js +0 -14
  47. package/dist/stores/config.js +39 -22
  48. package/dist/stores/save-validation.js +30 -0
  49. package/dist/utils/templatePreparation.js +28 -25
  50. package/package.json +1 -1
  51. package/dist/src/utils/appendMobileHiddenColumnCss.d.ts +0 -2
  52. package/dist/utils/appendMobileHiddenColumnCss.js +0 -11
@@ -1,8 +1,8 @@
1
- import "../@types/config/schemas.js";
1
+ import { MessageType as r } from "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
3
  import { parseConfig as o } from "../@types/config/validator.js";
4
- import { defineStore as r } from "pinia";
5
- const f = r("guido-config", {
4
+ import { defineStore as a } from "pinia";
5
+ const u = a("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -75,57 +75,74 @@ const f = r("guido-config", {
75
75
  * Get the template ID
76
76
  */
77
77
  templateId: (i) => {
78
- var e, n;
79
- return ((n = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : n.templateId) ?? "";
78
+ var e, t;
79
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.templateId) ?? "";
80
80
  },
81
81
  /**
82
82
  * Get the user ID
83
83
  */
84
84
  userId: (i) => {
85
- var e, n;
86
- return ((n = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : n.userId) ?? "";
85
+ var e, t;
86
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.userId) ?? "";
87
87
  },
88
88
  /**
89
89
  * Get the variation ID
90
90
  */
91
91
  variationId: (i) => {
92
- var e, n;
93
- return ((n = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : n.variationId) ?? "";
92
+ var e, t;
93
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.variationId) ?? "";
94
94
  },
95
95
  /**
96
96
  * Get the partner name
97
97
  */
98
98
  partnerName: (i) => {
99
- var e, n;
100
- return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.name) ?? "";
99
+ var e, t;
100
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.name) ?? "";
101
101
  },
102
102
  /**
103
103
  * Get the product type
104
104
  */
105
105
  productType: (i) => {
106
- var e, n;
107
- return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.productType) ?? 60;
106
+ var e, t;
107
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.productType) ?? 60;
108
108
  },
109
109
  /**
110
110
  * Get the message type
111
111
  */
112
112
  messageType: (i) => {
113
- var e, n;
114
- return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.messageType) ?? 1;
113
+ var e, t;
114
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) ?? 1;
115
+ },
116
+ /**
117
+ * Transactional campaigns keep the hard save block. Reactive getter, so
118
+ * consumers stay safe in setup where a raw config read snapshots null (SD-147945).
119
+ */
120
+ isTransactional() {
121
+ return this.messageType === r.TRANSACTIONAL;
122
+ },
123
+ /**
124
+ * Soft-save policy: may the editor persist a template with validation errors?
125
+ * Default true (host sets features.allowSaveWithErrors=false for transactional +
126
+ * unsub). Reactive getter defaulting true — reading via isFeatureEnabled would
127
+ * floor to false pre-init and momentarily hide the soft-save option (SD-147430).
128
+ */
129
+ allowSaveWithErrors() {
130
+ var i;
131
+ return ((i = this.features) == null ? void 0 : i.allowSaveWithErrors) ?? !0;
115
132
  },
116
133
  /**
117
134
  * Get the username
118
135
  */
119
136
  username: (i) => {
120
- var e, n;
121
- return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.username) ?? "Guido User";
137
+ var e, t;
138
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.username) ?? "Guido User";
122
139
  },
123
140
  /**
124
141
  * Check if header should be shown
125
142
  */
126
143
  showHeader: (i) => {
127
- var e, n;
128
- return ((n = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : n.showHeader) ?? !0;
144
+ var e, t;
145
+ return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
129
146
  },
130
147
  /**
131
148
  * Check if a specific feature is enabled.
@@ -134,8 +151,8 @@ const f = r("guido-config", {
134
151
  */
135
152
  // eslint-disable-next-line @stylistic/max-len
136
153
  isFeatureEnabled: (i) => (e) => {
137
- var n, t;
138
- return ((t = (n = i.config) == null ? void 0 : n.features) == null ? void 0 : t[e]) ?? !1;
154
+ var t, n;
155
+ return ((n = (t = i.config) == null ? void 0 : t.features) == null ? void 0 : n[e]) ?? !1;
139
156
  }
140
157
  },
141
158
  actions: {
@@ -155,5 +172,5 @@ const f = r("guido-config", {
155
172
  }
156
173
  });
157
174
  export {
158
- f as useConfigStore
175
+ u as useConfigStore
159
176
  };
@@ -0,0 +1,30 @@
1
+ import { defineStore as n } from "pinia";
2
+ function i(e) {
3
+ const t = /* @__PURE__ */ new Set();
4
+ return e.filter((r) => {
5
+ const s = JSON.stringify([r.rule, r.message, r.detail ?? ""]);
6
+ return t.has(s) ? !1 : (t.add(s), !0);
7
+ });
8
+ }
9
+ const o = n("guidoSaveValidation", {
10
+ state: () => ({
11
+ errors: [],
12
+ isDrawerOpen: !1,
13
+ intent: null
14
+ }),
15
+ getters: {
16
+ errorCount: (e) => e.errors.length
17
+ },
18
+ actions: {
19
+ open(e, t) {
20
+ this.errors = i(e), this.intent = t, this.isDrawerOpen = !0;
21
+ },
22
+ // Errors are retained so rows don't blank during the ~300ms close animation.
23
+ close() {
24
+ this.isDrawerOpen = !1;
25
+ }
26
+ }
27
+ });
28
+ export {
29
+ o as useSaveValidationStore
30
+ };
@@ -1,27 +1,27 @@
1
- import { useActionsApi as k } from "../composables/useActionsApi.js";
1
+ import { useActionsApi as R } from "../composables/useActionsApi.js";
2
2
  import { useConfig as U } from "../composables/useConfig.js";
3
3
  import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
4
4
  import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
- import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
6
  import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
7
  import { DATA_ATTRIBUTES as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
- import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
- import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
10
- import { useEditorStore as z } from "../stores/editor.js";
11
- import { useUnsubscribeStore as _ } from "../stores/unsubscribe.js";
12
- import { assignTrackingIds as v } from "./linkTrackingIds.js";
13
- function O(m) {
8
+ import { parsePageList as N } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
+ import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
10
+ import { useEditorStore as _ } from "../stores/editor.js";
11
+ import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
12
+ import { assignTrackingIds as O } from "./linkTrackingIds.js";
13
+ function M(m) {
14
14
  const i = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
15
15
  return i.forEach((s) => {
16
16
  const o = s.getAttribute(A.PAGE_LIST);
17
- o && t.push(...R(o));
17
+ o && t.push(...N(o));
18
18
  }), [...new Set(t)];
19
19
  }
20
- async function M(m) {
20
+ async function C(m) {
21
21
  const n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
22
22
  if (n.length === 0)
23
23
  return;
24
- const i = C();
24
+ const i = T();
25
25
  n.forEach((t) => {
26
26
  var r, l, g, f, c;
27
27
  const s = t.getAttribute("recommendation-id"), o = s ? Number(s) : NaN;
@@ -69,39 +69,39 @@ async function M(m) {
69
69
  }
70
70
  }
71
71
  const Z = () => {
72
- const m = N(), u = z(), n = _(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: s } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
72
+ const m = z(), u = _(), n = v(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: s } = R(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
73
73
  return {
74
74
  prepareTemplateDetails: async () => {
75
75
  let { html: r, css: l, syncModulesIds: g = [] } = await t();
76
76
  if (e("linkTrackingIds"))
77
77
  try {
78
- const { html: S, changed: F, nextSeq: H } = v(r, u.trackIdSessionFloor);
79
- u.trackIdSessionFloor = H, F && (r = S, await s(S, l));
78
+ const { html: S, changed: H, nextSeq: k } = O(r, u.trackIdSessionFloor);
79
+ u.trackIdSessionFloor = k, H && (r = S, await s(S, l));
80
80
  } catch (S) {
81
81
  console.error("Tracking-id step failed, saving anyway:", S);
82
82
  }
83
- const { html: f, ampHtml: c = "", ampErrors: T = [] } = await i({
83
+ const { html: f, ampHtml: c = "", ampErrors: I = [] } = await i({
84
84
  minimize: !0,
85
85
  resetDataSavedFlag: !1
86
86
  });
87
- n.selectedUnsubscribePages.length && await n.fetchTemplates(), await M(r);
88
- const { compiledHtml: I, stats: y, appliedRules: w } = o(f), D = c && p(c).compiledHtml, E = m.getSelectedDynamicContentList, P = C(), b = O(r);
87
+ n.selectedUnsubscribePages.length && await n.fetchTemplates(), await C(r);
88
+ const { compiledHtml: w, stats: y, appliedRules: D } = o(f), E = c && p(c).compiledHtml, P = m.getSelectedDynamicContentList, F = T(), b = M(r);
89
89
  return console.debug("HTML Compilation Stats:", {
90
90
  originalSize: y.originalSize,
91
91
  compiledSize: y.compiledSize,
92
92
  reduction: `${y.reductionPercentage.toFixed(2)}%`,
93
- appliedRules: w,
93
+ appliedRules: D,
94
94
  executionTime: `${y.executionTime.toFixed(2)}ms`
95
95
  }), {
96
- dynamicContentList: E,
97
- compiledHtml: I,
96
+ dynamicContentList: P,
97
+ compiledHtml: w,
98
98
  rawHtml: r,
99
99
  css: l,
100
- ampHtml: D,
101
- ampErrors: T,
100
+ ampHtml: E,
101
+ ampErrors: I,
102
102
  modules: g.map(Number),
103
103
  recommendation: {
104
- campaignUrls: P.recommendationCampaignUrls,
104
+ campaignUrls: F.recommendationCampaignUrls,
105
105
  configs: {}
106
106
  },
107
107
  unsubscribe: {
@@ -109,10 +109,13 @@ const Z = () => {
109
109
  config: b
110
110
  }
111
111
  };
112
- }
112
+ },
113
+ // Exposed so the back/test validate-only path can seed the reco store the
114
+ // same way a full save does (required-field findings depend on it).
115
+ hydrateRecommendationStore: C
113
116
  };
114
117
  };
115
118
  export {
116
- O as getHtmlReferencedUnsubscribePages,
119
+ M as getHtmlReferencedUnsubscribePages,
117
120
  Z as useTemplatePreparation
118
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.18.1-beta.dea994d",
3
+ "version": "3.18.1-beta.e39fb14",
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",
@@ -1,2 +0,0 @@
1
- /** Exported for the preview drawer, which takes its HTML from the backend and never runs the compiler. */
2
- export declare function appendMobileHiddenColumnCss(html: string): string;
@@ -1,11 +0,0 @@
1
- const s = "td.esdev-mso-td:has(> table > tbody > tr.es-mobile-hidden)", d = "table.esdev-mso-table:has(> tbody > tr > td.esdev-mso-td > table > tbody > tr.es-mobile-hidden)", t = `<style type="text/css">@media only screen and (max-width:600px){
2
- ${s}{display:none !important}
3
- ${d}{table-layout:fixed !important}
4
- ${d} > tbody > tr > td.es-m-w0{display:none !important}
5
- }</style>`;
6
- function n(e) {
7
- return !e || e.includes(t) ? e : /<\/head\s*>/i.test(e) ? e.replace(/<\/head\s*>/i, `${t}$&`) : `${t}${e}`;
8
- }
9
- export {
10
- n as appendMobileHiddenColumnCss
11
- };