@useinsider/guido 3.17.0-beta.db80c84 → 3.17.0-beta.dc7f4d2

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 (76) hide show
  1. package/dist/components/Guido.vue.js +8 -8
  2. package/dist/components/Guido.vue2.js +78 -76
  3. package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
  4. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  5. package/dist/components/organisms/header/EditorActions.vue2.js +74 -43
  6. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  7. package/dist/components/organisms/header/LeftSlot.vue2.js +46 -23
  8. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  9. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +48 -0
  10. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  11. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  12. package/dist/composables/useHtmlCompiler.js +37 -26
  13. package/dist/composables/useHtmlValidator.js +2 -0
  14. package/dist/composables/useSave.js +84 -41
  15. package/dist/composables/useSaveValidation.js +279 -0
  16. package/dist/composables/useSaveValidationRollout.js +9 -0
  17. package/dist/composables/useStripo.js +14 -14
  18. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  19. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  20. package/dist/config/migrator/index.js +8 -9
  21. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  22. package/dist/config/migrator/recommendation/extractors.js +24 -29
  23. package/dist/config/migrator/recommendation/htmlBuilder.js +130 -116
  24. package/dist/config/migrator/recommendationMigrator.js +15 -18
  25. package/dist/enums/save-validation.js +4 -0
  26. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  27. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  28. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +22 -23
  29. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +28 -34
  30. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +238 -306
  31. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +8 -9
  32. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -1
  33. package/dist/extensions/Blocks/Recommendation/extension.js +29 -31
  34. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -23
  35. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +33 -26
  36. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  37. package/dist/extensions/Blocks/Recommendation/templates/utils.js +107 -85
  38. package/dist/guido.css +1 -1
  39. package/dist/src/@types/save-validation.d.ts +19 -0
  40. package/dist/src/components/Guido.vue.d.ts +17 -1
  41. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  42. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  43. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  44. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  45. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  46. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  47. package/dist/src/composables/useSave.d.ts +6 -1
  48. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  49. package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
  50. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  51. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  52. package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -8
  53. package/dist/src/enums/save-validation.d.ts +27 -0
  54. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +1 -2
  55. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +0 -7
  56. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -1
  57. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  58. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -10
  59. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -10
  60. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +0 -1
  61. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -1
  62. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
  63. package/dist/src/stores/config.d.ts +5 -0
  64. package/dist/src/stores/save-validation.d.ts +22 -0
  65. package/dist/src/utils/templatePreparation.d.ts +30 -0
  66. package/dist/static/styles/customEditorStyle.css.js +1 -3
  67. package/dist/stores/config.js +13 -6
  68. package/dist/stores/save-validation.js +30 -0
  69. package/dist/utils/templatePreparation.js +28 -25
  70. package/package.json +1 -1
  71. package/dist/config/migrator/recommendationTitleMigrator.js +0 -119
  72. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +0 -44
  73. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +0 -33
  74. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +0 -5
  75. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -86
  76. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +0 -13
@@ -65,12 +65,5 @@ export declare enum RecommendationControlId {
65
65
  CUSTOM_ATTR_SIZE = "recommendation-block-custom-attr-size-control",
66
66
  CUSTOM_ATTR_STYLE = "recommendation-block-custom-attr-style-control",
67
67
  CUSTOM_ATTR_TEXT_TRIM = "recommendation-block-custom-attr-text-trim-control",
68
- TITLE_ALIGN = "recommendation-block-title-align-control",
69
- TITLE_BACKGROUND = "recommendation-block-title-background-control",
70
- TITLE_COLOR = "recommendation-block-title-color-control",
71
- TITLE_FONT_FAMILY = "recommendation-block-title-font-family-control",
72
- TITLE_PADDINGS = "recommendation-block-title-paddings-control",
73
- TITLE_SIZE = "recommendation-block-title-size-control",
74
- TITLE_STYLE = "recommendation-block-title-style-control",
75
68
  SYNC_INFO_MESSAGE = "recommendation-block-sync-info-message"
76
69
  }
@@ -32,7 +32,6 @@ export declare const DEFAULT_COMPOSITION: string[];
32
32
  /**
33
33
  * Default visibility settings for card elements
34
34
  * Omnibus elements are hidden by default (not all regions require them)
35
- * The block-level title is visible on a fresh drop.
36
35
  */
37
36
  export declare const DEFAULT_VISIBILITY: Record<string, boolean>;
38
37
  /**
@@ -8,6 +8,6 @@
8
8
  */
9
9
  export { RecommendationBlockId } from './blockIds';
10
10
  export { RecommendationControlId } from './controlIds';
11
- export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CSS_CLASS_RECO_BUTTON, CSS_CLASS_SKIP_COMPILE, RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, ATTR_RECOMMENDATION_TITLE, SELECTOR_TITLE_CELL, ATTR_CUSTOM_PREFIX, ATTR_DATA_CARD_COMPOSITION, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, CSS_CLASS_ATTRIBUTE_ROW, CSS_CLASS_SPACER, SELECTOR_ATTRIBUTE_ROW, ATTR_DATA_ATTRIBUTE_TYPE, ATTR_DATA_VISIBILITY, PRODUCT_ATTRIBUTE_PREFIX, BUILT_IN_DEFAULT_ATTRIBUTES, } from './selectors';
11
+ export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CSS_CLASS_RECO_BUTTON, CSS_CLASS_SKIP_COMPILE, RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, ATTR_CUSTOM_PREFIX, ATTR_DATA_CARD_COMPOSITION, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, SELECTOR_ATTRIBUTE_ROW, ATTR_DATA_ATTRIBUTE_TYPE, PRODUCT_ATTRIBUTE_PREFIX, BUILT_IN_DEFAULT_ATTRIBUTES, } from './selectors';
12
12
  export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, DEFAULT_MOBILE_COLUMN_SPACING, DEFAULT_MOBILE_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
13
13
  export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, EXCLUDED_ALGORITHM_IDS, } from './defaultConfig';
@@ -58,10 +58,6 @@ export declare const ATTR_PRODUCT_OLD_PRICE = "productOldPrice";
58
58
  export declare const ATTR_PRODUCT_OMNIBUS_PRICE = "productOmnibusPrice";
59
59
  export declare const ATTR_PRODUCT_OMNIBUS_DISCOUNT = "productOmnibusDiscount";
60
60
  export declare const ATTR_PRODUCT_BUTTON = "productButton";
61
- export declare const ATTR_RECOMMENDATION_TITLE = "recommendationTitle";
62
- export declare const CSS_CLASS_TITLE_CELL = "ins-recommendation-title";
63
- /** Title cell — the only `esd-block-text` living outside the product containers. */
64
- export declare const SELECTOR_TITLE_CELL = ".ins-recommendation-title";
65
61
  /**
66
62
  * Custom attribute constants
67
63
  * Used for dynamically added product attributes in Card Composition
@@ -74,16 +70,10 @@ export declare const ATTR_DATA_CUSTOM_ATTRIBUTES = "data-custom-attributes";
74
70
  export declare const ATTR_DATA_CARD_COMPOSITION = "data-card-composition";
75
71
  /** HTML attribute on <td> elements identifying the product attribute for compiler template variable generation */
76
72
  export declare const ATTR_PRODUCT_ATTR = "product-attr";
77
- /** Class every composition attribute row carries — the visibility toggle and the compiler both key on it */
78
- export declare const CSS_CLASS_ATTRIBUTE_ROW = "recommendation-attribute-row";
79
73
  /** Row wrapper of one composition entry inside a product card */
80
74
  export declare const SELECTOR_ATTRIBUTE_ROW = ".recommendation-attribute-row";
81
75
  /** HTML attribute on an attribute row holding its composition key */
82
76
  export declare const ATTR_DATA_ATTRIBUTE_TYPE = "data-attribute-type";
83
- /** HTML attribute on an attribute row holding its visibility (`1` / `0`) */
84
- export declare const ATTR_DATA_VISIBILITY = "data-visibility";
85
- /** Class on the spacer cell of the row that trails a title */
86
- export declare const CSS_CLASS_SPACER = "spacer";
87
77
  /** Prefix `resolveProductAttrValue` puts on custom (non-default) product attributes in `product-attr` values */
88
78
  export declare const PRODUCT_ATTRIBUTE_PREFIX = "product_attribute.";
89
79
  /**
@@ -33,8 +33,6 @@ export declare class RecommendationCardCompositionControl extends CommonControl
33
33
  private _normalizeComposition;
34
34
  private _readCustomAttributesFromNode;
35
35
  private _readVisibilityFromRows;
36
- private _withTitlePresence;
37
- private _hasTitle;
38
36
  private _getDefaultVisibilities;
39
37
  private _extractVisibilityFromRows;
40
38
  private _parseVisibilityValue;
@@ -189,14 +187,6 @@ export declare class RecommendationCardCompositionControl extends CommonControl
189
187
  */
190
188
  private _buildCompositionHtml;
191
189
  private _applyVisibilityToBlock;
192
- private _applyTitleVisibilityToBlock;
193
- private _resolveTitleInjection;
194
- private _findTitleRows;
195
- private _findTitleRowsByClass;
196
- private _isSpacerRow;
197
- private _findTitleContainerBody;
198
- private _readInnerHtml;
199
- private _defaultTitleParagraph;
200
190
  /**
201
191
  * Finds the composition array index for the Nth custom attribute (0-based).
202
192
  * Scans left-to-right, counting only entries with the custom prefix.
@@ -11,7 +11,6 @@
11
11
  */
12
12
  export { RecommendationBlockControl, CONTROL_BLOCK_ID, AlgorithmControl, ALGORITHM_CONTROL_ID, LocaleControl, LOCALE_CONTROL_ID, CurrencyControl, CURRENCY_CONTROL_ID, ProductCountControl, PRODUCT_COUNT_CONTROL_ID, ProductLayoutControl, PRODUCT_LAYOUT_CONTROL_ID, FiltersControl, FILTERS_CONTROL_ID, ShuffleControl, SHUFFLE_CONTROL_ID, LayoutOrientationControl, LAYOUT_ORIENTATION_CONTROL_ID, PricePlacementControl, PRICE_PLACEMENT_CONTROL_ID, } from './main';
13
13
  export * from './main/utils';
14
- export { TitleControls } from './title';
15
14
  export { NameControls } from './name';
16
15
  export { PriceControls } from './price';
17
16
  export { OldPriceControls } from './oldPrice';
@@ -70,7 +70,6 @@ export interface RegenerateProductRowsOptions {
70
70
  /** Optional: pass composition directly to avoid stale DOM reads after setAttribute */
71
71
  composition?: string[];
72
72
  }
73
- export declare function getMainContainerTbody(currentNode: ImmutableHtmlNode): ImmutableHtmlNode | null;
74
73
  /**
75
74
  * Regenerates only the mobile product container rows and commits in a single apply().
76
75
  * Standalone entry point for callers that change mobile-only settings
@@ -286,6 +286,11 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
286
286
  * every block's recommendationConfigs across user edits.
287
287
  */
288
288
  hasInvalidBlock(): boolean;
289
+ /**
290
+ * Per-instance counterpart to `hasInvalidBlock`: the ids of every block
291
+ * that fails required-field validation, one drawer row each (SD-147430).
292
+ */
293
+ invalidBlockIds(): string[];
289
294
  fetchRecommendationProducts(): Promise<void>;
290
295
  _doFetchProducts(): Promise<void>;
291
296
  }>;
@@ -2106,6 +2106,11 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2106
2106
  };
2107
2107
  } | null;
2108
2108
  } & import("pinia").PiniaCustomStateProperties<ConfigStoreState>) => number;
2109
+ /**
2110
+ * Transactional campaigns keep the hard save block. Reactive getter, so
2111
+ * consumers stay safe in setup where a raw config read snapshots null (SD-147945).
2112
+ */
2113
+ isTransactional(): boolean;
2109
2114
  /**
2110
2115
  * Get the username
2111
2116
  */
@@ -0,0 +1,22 @@
1
+ import type { SaveValidationError, SaveValidationIntent } from '@@/Types/save-validation';
2
+ interface SaveValidationState {
3
+ errors: SaveValidationError[];
4
+ isDrawerOpen: boolean;
5
+ intent: SaveValidationIntent | null;
6
+ }
7
+ export declare const useSaveValidationStore: import("pinia").StoreDefinition<"guidoSaveValidation", SaveValidationState, {
8
+ errorCount: (state: {
9
+ errors: {
10
+ rule: import("../enums/save-validation").SaveValidationRule;
11
+ message: string;
12
+ detail?: string | undefined;
13
+ type: import("../enums/toaster").ToasterTypeOptions;
14
+ }[];
15
+ isDrawerOpen: boolean;
16
+ intent: SaveValidationIntent | null;
17
+ } & import("pinia").PiniaCustomStateProperties<SaveValidationState>) => number;
18
+ }, {
19
+ open(errors: SaveValidationError[], intent: SaveValidationIntent): void;
20
+ close(): void;
21
+ }>;
22
+ export {};
@@ -15,6 +15,36 @@ import type { SavedTemplateDetails } from '@@/Types/stripo';
15
15
  * same source), so it is reliably present regardless of how the block was added.
16
16
  */
17
17
  export declare function getHtmlReferencedUnsubscribePages(html: string): number[];
18
+ /**
19
+ * Hydrates the recommendation extension store from the persisted `esd-ext-config`
20
+ * JSON blob on each `.recommendation-block-v2` element in the raw editor HTML.
21
+ *
22
+ * Why this runs before `compileHtml`:
23
+ * The HTML compiler's `prepareRecommendationBlocks` rule asks
24
+ * `useRecommendation.buildCampaignUrl(id)` to assemble each block's API URL
25
+ * from `blockStates[id].recommendationConfigs`. That Pinia entry is normally
26
+ * populated by `RecommendationBlockControl._syncNodeConfigToStore`, which
27
+ * only fires when the user *selects* the block. Saving without ever
28
+ * selecting a migrated block would otherwise build the URL from empty/
29
+ * default state and the campaign URL would not be saved.
30
+ *
31
+ * Why we read raw HTML, not compiled HTML:
32
+ * Stripo's `compileEmail()` strips editor-only attributes (`esd-*`) from the
33
+ * compiled output, so `esd-ext-config` is gone by the time the compiler
34
+ * pipeline sees the HTML. The raw HTML from `getTemplateData()` preserves
35
+ * the attribute as the migrator wrote it.
36
+ *
37
+ * Reference data pre-load:
38
+ * When the template has recommendation blocks, this also pre-loads the
39
+ * shared reference data (languages / currency list) so the save-time
40
+ * required-fields validator can check each block's locale and currency
41
+ * against the partner's real options. Best-effort — on a fetch failure the
42
+ * validator degrades to its empty-list guard (`requiredFields.ts`) instead
43
+ * of blocking the save or stranding the Save button.
44
+ */
45
+ declare function hydrateRecommendationStoreFromRawHtml(rawHtml: string): Promise<void>;
18
46
  export declare const useTemplatePreparation: () => {
19
47
  prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
48
+ hydrateRecommendationStore: typeof hydrateRecommendationStoreFromRawHtml;
20
49
  };
50
+ export {};
@@ -43,9 +43,7 @@ const n = `.esd-x,
43
43
  .recommendation-block-v2 .product-omnibus-discount ue-node-actions,
44
44
  .recommendation-block-v2 .product-omnibus-discount ue-node-panel,
45
45
  .recommendation-block-v2 .product-button ue-node-actions,
46
- .recommendation-block-v2 .product-button ue-node-panel,
47
- .recommendation-block-v2 .ins-recommendation-title ue-node-actions,
48
- .recommendation-block-v2 .ins-recommendation-title ue-node-panel {
46
+ .recommendation-block-v2 .product-button ue-node-panel {
49
47
  display: none !important;
50
48
  }
51
49
 
@@ -1,8 +1,8 @@
1
- import "../@types/config/schemas.js";
1
+ import { MessageType as o } from "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
- import { parseConfig as o } from "../@types/config/validator.js";
4
- import { defineStore as r } from "pinia";
5
- const f = r("guido-config", {
3
+ import { parseConfig as r } from "../@types/config/validator.js";
4
+ import { defineStore as a } from "pinia";
5
+ const g = a("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -113,6 +113,13 @@ const f = r("guido-config", {
113
113
  var e, n;
114
114
  return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.messageType) ?? 1;
115
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 === o.TRANSACTIONAL;
122
+ },
116
123
  /**
117
124
  * Get the username
118
125
  */
@@ -143,7 +150,7 @@ const f = r("guido-config", {
143
150
  * Initialize the config store with validated configuration
144
151
  */
145
152
  init(i) {
146
- const e = o(i);
153
+ const e = r(i);
147
154
  this.config = e, this.initialized = !0;
148
155
  },
149
156
  /**
@@ -155,5 +162,5 @@ const f = r("guido-config", {
155
162
  }
156
163
  });
157
164
  export {
158
- f as useConfigStore
165
+ g as useConfigStore
159
166
  };
@@ -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 s } 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 n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
15
15
  return n.forEach((i) => {
16
16
  const o = i.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 a = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
22
22
  if (a.length === 0)
23
23
  return;
24
- const n = C();
24
+ const n = T();
25
25
  a.forEach((t) => {
26
26
  var r, l, g, f, c;
27
27
  const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
@@ -68,39 +68,39 @@ async function M(m) {
68
68
  }
69
69
  }
70
70
  const Z = () => {
71
- const m = N(), u = z(), a = _(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
71
+ const m = z(), u = _(), a = v(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = R(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
72
72
  return {
73
73
  prepareTemplateDetails: async () => {
74
74
  let { html: r, css: l, syncModulesIds: g = [] } = await t();
75
75
  if (e("linkTrackingIds"))
76
76
  try {
77
- const { html: y, changed: H, nextSeq: I } = v(r, u.trackIdSessionFloor);
78
- u.trackIdSessionFloor = I, H && (r = y, await i(y, l));
77
+ const { html: y, changed: I, nextSeq: k } = O(r, u.trackIdSessionFloor);
78
+ u.trackIdSessionFloor = k, I && (r = y, await i(y, l));
79
79
  } catch (y) {
80
80
  console.error("Tracking-id step failed, saving anyway:", y);
81
81
  }
82
- const { html: f, ampHtml: c = "", ampErrors: T = [] } = await n({
82
+ const { html: f, ampHtml: c = "", ampErrors: w = [] } = await n({
83
83
  minimize: !0,
84
84
  resetDataSavedFlag: !1
85
85
  });
86
- a.selectedUnsubscribePages.length && await a.fetchTemplates(), await M(r);
87
- const { compiledHtml: w, stats: S, appliedRules: D } = o(f), E = c && p(c).compiledHtml, P = m.getSelectedDynamicContentList, F = C(), b = O(r);
86
+ a.selectedUnsubscribePages.length && await a.fetchTemplates(), await C(r);
87
+ const { compiledHtml: D, stats: S, appliedRules: E } = o(f), P = c && p(c).compiledHtml, F = m.getSelectedDynamicContentList, H = T(), b = M(r);
88
88
  return console.debug("HTML Compilation Stats:", {
89
89
  originalSize: S.originalSize,
90
90
  compiledSize: S.compiledSize,
91
91
  reduction: `${S.reductionPercentage.toFixed(2)}%`,
92
- appliedRules: D,
92
+ appliedRules: E,
93
93
  executionTime: `${S.executionTime.toFixed(2)}ms`
94
94
  }), {
95
- dynamicContentList: P,
96
- compiledHtml: w,
95
+ dynamicContentList: F,
96
+ compiledHtml: D,
97
97
  rawHtml: r,
98
98
  css: l,
99
- ampHtml: E,
100
- ampErrors: T,
99
+ ampHtml: P,
100
+ ampErrors: w,
101
101
  modules: g.map(Number),
102
102
  recommendation: {
103
- campaignUrls: F.recommendationCampaignUrls,
103
+ campaignUrls: H.recommendationCampaignUrls,
104
104
  configs: {}
105
105
  },
106
106
  unsubscribe: {
@@ -108,10 +108,13 @@ const Z = () => {
108
108
  config: b
109
109
  }
110
110
  };
111
- }
111
+ },
112
+ // Exposed so the back/test validate-only path can seed the reco store the
113
+ // same way a full save does (required-field findings depend on it).
114
+ hydrateRecommendationStore: C
112
115
  };
113
116
  };
114
117
  export {
115
- O as getHtmlReferencedUnsubscribePages,
118
+ M as getHtmlReferencedUnsubscribePages,
116
119
  Z as useTemplatePreparation
117
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.17.0-beta.db80c84",
3
+ "version": "3.17.0-beta.dc7f4d2",
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,119 +0,0 @@
1
- var R = Object.defineProperty;
2
- var f = (s, t, e) => t in s ? R(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var a = (s, t, e) => f(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { RecommendationBlockId as d } from "../../extensions/Blocks/Recommendation/constants/blockIds.js";
5
- import { BLOCK_ROOT_SELECTOR as u, CSS_CLASS_SKIP_COMPILE as m, ATTR_DATA_ATTRIBUTE_TYPE as S, ATTR_RECOMMENDATION_TITLE as l, CONTAINER_SELECTOR as E, CSS_CLASS_TITLE_CELL as c, CSS_CLASS_SPACER as C, CSS_CLASS_ATTRIBUTE_ROW as A, ATTR_DATA_VISIBILITY as L } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
6
- const p = u.slice(1), g = `${u}:not(.${m})`, O = `[${S}="${l}"]`, h = "td.esd-block-text", _ = "table.container > tbody", T = "esd-ext-config";
7
- class y {
8
- constructor() {
9
- a(this, "parser");
10
- this.parser = new DOMParser();
11
- }
12
- migrate(t) {
13
- try {
14
- if (!t.includes(p))
15
- return t;
16
- const e = this.parser.parseFromString(t, "text/html");
17
- return Array.from(e.querySelectorAll(g)).reduce(
18
- (n, o) => this._migrateBlock(o) || n,
19
- !1
20
- ) ? e.documentElement.outerHTML : t;
21
- } catch (e) {
22
- return console.error("RecommendationTitleMigrator failed:", e), t;
23
- }
24
- }
25
- /** Migrates one block. Returns `true` when the block was changed. */
26
- _migrateBlock(t) {
27
- if (t.querySelector(O) || this._hasRecordedTitleState(t))
28
- return !1;
29
- const e = this._findTitleCell(t), i = e !== null && (e.textContent ?? "").trim().length > 0;
30
- return i ? this._tagExistingTitle(t, e) : this._removeTitleRemnants(t, e), this._writeVisibility(t, i), !0;
31
- }
32
- /** The only `esd-block-text` cell outside the product containers is the title. */
33
- _findTitleCell(t) {
34
- return Array.from(t.querySelectorAll(h)).find((e) => !e.closest(E) && this._isTitlePosition(t, e)) ?? null;
35
- }
36
- _isTitlePosition(t, e) {
37
- var r;
38
- const i = this._wrapperRowOf(t, e);
39
- return e.classList.contains(c) || i !== null && i === ((r = i.parentElement) == null ? void 0 : r.firstElementChild);
40
- }
41
- /**
42
- * Stamps the attribute-row tagging onto the title's wrapper row and the spacer
43
- * below it, so one toggle governs the pair and the compiler drops both when off.
44
- */
45
- _tagExistingTitle(t, e) {
46
- e.classList.add(c), e.setAttribute("esd-extension-block-id", d.TITLE);
47
- const i = this._wrapperRowOf(t, e);
48
- if (!i)
49
- return;
50
- this._tagRow(i);
51
- const r = i.nextElementSibling;
52
- r && this._isSpacerRow(r) && this._tagRow(r);
53
- }
54
- /** The `<tr>` inside `table.container > tbody` that wraps the title's own table. */
55
- _wrapperRowOf(t, e) {
56
- if (!e)
57
- return null;
58
- const i = t.querySelector(_);
59
- return Array.from((i == null ? void 0 : i.children) ?? []).find((r) => r.contains(e)) ?? null;
60
- }
61
- /**
62
- * Direct children only — a product-container row holds spacer cells further down,
63
- * and `querySelector` would happily reach them. (`:scope >` is unsupported in happy-dom.)
64
- */
65
- _isSpacerRow(t) {
66
- return Array.from(t.children).some((e) => e.classList.contains(C));
67
- }
68
- _tagRow(t) {
69
- t.classList.add(A), t.setAttribute(S, l), t.setAttribute(L, "1");
70
- }
71
- /**
72
- * A deleted title leaves nothing to tag — the toggle re-injects the markup only
73
- * when the user switches it back on. Its leftovers (an emptied wrapper row, the
74
- * spacer that trailed it) would otherwise render as blank padding on top.
75
- */
76
- _removeTitleRemnants(t, e) {
77
- var o;
78
- const i = this._wrapperRowOf(t, e), r = i == null ? void 0 : i.nextElementSibling;
79
- if (r && this._isSpacerRow(r) && r.remove(), i) {
80
- i.remove();
81
- return;
82
- }
83
- const n = (o = t.querySelector(_)) == null ? void 0 : o.firstElementChild;
84
- n && this._isSpacerRow(n) && n.remove();
85
- }
86
- /**
87
- * Mirrors the resolved state into the persisted config blob, so a saved module
88
- * whose `data-*` attributes Stripo strips on re-drop still restores the toggle.
89
- */
90
- _writeVisibility(t, e) {
91
- const i = this._readConfig(t);
92
- if (!i)
93
- return;
94
- const r = typeof i.visibility == "object" && i.visibility !== null ? i.visibility : {};
95
- i.visibility = { ...r, [l]: e }, t.setAttribute(T, JSON.stringify(i));
96
- }
97
- _hasRecordedTitleState(t) {
98
- var i;
99
- const e = (i = this._readConfig(t)) == null ? void 0 : i.visibility;
100
- return typeof e == "object" && e !== null && l in e;
101
- }
102
- _readConfig(t) {
103
- const e = t.getAttribute(T);
104
- if (!e)
105
- return null;
106
- try {
107
- const i = JSON.parse(e);
108
- return typeof i == "object" && i !== null ? i : null;
109
- } catch {
110
- return null;
111
- }
112
- }
113
- }
114
- function v(s) {
115
- return new y().migrate(s);
116
- }
117
- export {
118
- v as migrateRecommendationTitle
119
- };
@@ -1,44 +0,0 @@
1
- import { createPaddingsControl as r, createTextBackgroundColorControl as T, createTextFontFamilyControl as e, createTextStyleControl as l, createTextSizeControl as C, createTextColorControl as c, createTextAlignControl as I } from "../../../controlFactories.js";
2
- import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
- import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
- import { BLOCK_ROOT_SELECTOR as n } from "../../constants/selectors.js";
5
- const L = I(
6
- t.TITLE_ALIGN,
7
- o.TITLE,
8
- n
9
- ), a = c(
10
- t.TITLE_COLOR,
11
- o.TITLE,
12
- n
13
- ), i = C(
14
- t.TITLE_SIZE,
15
- o.TITLE,
16
- n
17
- ), E = l(
18
- t.TITLE_STYLE,
19
- o.TITLE,
20
- n
21
- ), m = e(
22
- t.TITLE_FONT_FAMILY,
23
- o.TITLE,
24
- n
25
- ), s = T(
26
- t.TITLE_BACKGROUND,
27
- o.TITLE,
28
- n
29
- ), d = r(
30
- t.TITLE_PADDINGS,
31
- o.TITLE,
32
- n
33
- ), x = {
34
- align: L,
35
- color: a,
36
- size: i,
37
- style: E,
38
- fontFamily: m,
39
- background: s,
40
- paddings: d
41
- };
42
- export {
43
- x as TitleControls
44
- };
@@ -1,33 +0,0 @@
1
- import { RecommendationBlockId as r } from "../constants/blockIds.js";
2
- import { DEFAULT_ROW_SPACING as l } from "../constants/layout.js";
3
- import { CSS_CLASS_ATTRIBUTE_ROW as d, ATTR_RECOMMENDATION_TITLE as n, ATTR_DATA_VISIBILITY as A, CSS_CLASS_TITLE_CELL as _, CSS_CLASS_SPACER as c } from "../constants/selectors.js";
4
- const a = "You May Also Like!", i = '<p style="font-size: 28px; color: #333333;"><strong>{-{-TITLE-}-}</strong></p>';
5
- function E(s = i, t = !0, T = l) {
6
- const e = `class="${d}" data-attribute-type="${n}" ${A}="${t ? "1" : "0"}"`, o = t ? "" : ' style="display: none;"';
7
- return `
8
- <tr ${e}${o}>
9
- <td>
10
- <table width="100%" cellpadding="0" cellspacing="0" border="0">
11
- <tbody>
12
- <tr>
13
- <td
14
- class="esd-block-text ${_} es-p10t es-p10b es-p20l es-p20r"
15
- align="center"
16
- esd-extension-block-id="${r.TITLE}">
17
- ${s}
18
- </td>
19
- </tr>
20
- </tbody>
21
- </table>
22
- </td>
23
- </tr>
24
- <tr ${e}${o}>
25
- <td class="${c}" style="height: ${T}px;"></td>
26
- </tr>
27
- `;
28
- }
29
- export {
30
- i as DEFAULT_TITLE_PARAGRAPH,
31
- a as DEFAULT_TITLE_TEXT,
32
- E as buildTitleRows
33
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Runs before the document reaches the editor, so a legacy title is already a
3
- * composition item on the first render — no post-load adoption pass.
4
- */
5
- export declare function migrateRecommendationTitle(html: string): string;