@useinsider/guido 3.2.0-beta.a49c53c → 3.2.0-beta.a961c72

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 (63) hide show
  1. package/dist/@types/config/schemas.js +150 -94
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +88 -87
  4. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  5. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  6. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  7. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  8. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  9. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  10. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  11. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  12. package/dist/composables/useRibbonOffset.js +21 -0
  13. package/dist/composables/useStripo.js +39 -37
  14. package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
  15. package/dist/config/migrator/index.js +9 -9
  16. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  17. package/dist/config/migrator/recommendation/extractors.js +27 -0
  18. package/dist/config/migrator/recommendation/htmlBuilder.js +478 -0
  19. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  20. package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
  21. package/dist/config/migrator/recommendation/themeMapper.js +89 -0
  22. package/dist/config/migrator/recommendationMigrator.js +60 -290
  23. package/dist/enums/extensions/recommendationBlock.js +2 -1
  24. package/dist/enums/onboarding.js +7 -2
  25. package/dist/enums/unsubscribe.js +34 -27
  26. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  27. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  28. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  29. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  30. package/dist/guido.css +1 -1
  31. package/dist/node_modules/valibot/dist/index.js +450 -235
  32. package/dist/package.json.js +7 -0
  33. package/dist/src/@types/config/defaults.d.ts +5 -1
  34. package/dist/src/@types/config/index.d.ts +3 -3
  35. package/dist/src/@types/config/schemas.d.ts +213 -0
  36. package/dist/src/@types/config/types.d.ts +9 -1
  37. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  38. package/dist/src/composables/useConfig.d.ts +56 -0
  39. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  40. package/dist/src/config/migrator/index.d.ts +2 -1
  41. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +18 -0
  42. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  43. package/dist/src/config/migrator/recommendation/extractors.d.ts +23 -0
  44. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +31 -0
  45. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +28 -0
  46. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  47. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +29 -0
  48. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  49. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +28 -0
  50. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  51. package/dist/src/config/migrator/recommendation/types.d.ts +209 -0
  52. package/dist/src/config/migrator/recommendationMigrator.d.ts +28 -1
  53. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  54. package/dist/src/enums/onboarding.d.ts +6 -0
  55. package/dist/src/enums/unsubscribe.d.ts +5 -0
  56. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  57. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  58. package/dist/src/stores/config.d.ts +504 -0
  59. package/dist/src/stores/onboarding.d.ts +4 -0
  60. package/dist/static/templates/empty/style.css.js +1 -0
  61. package/dist/stores/onboarding.js +4 -0
  62. package/package.json +6 -2
  63. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Internal types for the legacy Recommendation block migrator.
3
+ *
4
+ * The legacy block stores its full state as a JSON blob inside the
5
+ * `esd-dev-product-config` HTML attribute. These interfaces describe
6
+ * the subset of that schema we depend on. All fields are optional —
7
+ * legacy data is heterogeneous and we use defensive optional chaining
8
+ * everywhere downstream.
9
+ */
10
+ /** Per-side numeric values used by border / padding theme fields. */
11
+ export interface LegacySides<T = number> {
12
+ left?: T;
13
+ right?: T;
14
+ top?: T;
15
+ bottom?: T;
16
+ }
17
+ /** Padding shape used for both desktop and mobile in legacy theme. */
18
+ export interface LegacyPaddingViewport {
19
+ all?: number;
20
+ top?: number;
21
+ right?: number;
22
+ bottom?: number;
23
+ left?: number;
24
+ }
25
+ /** Padding object covering both desktop and mobile breakpoints. */
26
+ export interface LegacyPadding {
27
+ desktop?: LegacyPaddingViewport;
28
+ mobile?: LegacyPaddingViewport;
29
+ }
30
+ /** Border-radius shape — observed in two flavours: shorthand or per-corner. */
31
+ export interface LegacyBorderRadius {
32
+ /** Single shorthand value (e.g. `radius: 4`). */
33
+ radius?: number;
34
+ /** Per-corner: top-left / top-right / bottom-right / bottom-left (in px). */
35
+ lt?: number;
36
+ rt?: number;
37
+ rb?: number;
38
+ lb?: number;
39
+ }
40
+ /** Theme attached to text-like variables (name, prices, omnibus, custom-attr). */
41
+ export interface LegacyTextTheme {
42
+ textStyle?: {
43
+ 'font-family'?: string;
44
+ 'font-size'?: string;
45
+ 'font-weight'?: string;
46
+ 'font-style'?: string;
47
+ };
48
+ textColor?: {
49
+ color?: string;
50
+ };
51
+ textBackgroundColor?: {
52
+ color?: string;
53
+ };
54
+ textPadding?: LegacyPadding;
55
+ textLineSpacing?: {
56
+ lineSpacing?: string;
57
+ 'font-lineSpacing'?: string;
58
+ };
59
+ textAlign?: {
60
+ align?: string;
61
+ };
62
+ textTrimming?: boolean;
63
+ }
64
+ /** Theme attached to image variables. */
65
+ export interface LegacyImageTheme {
66
+ imageSize?: {
67
+ width?: number;
68
+ height?: number;
69
+ };
70
+ }
71
+ /** Theme attached to the button variable. */
72
+ export interface LegacyButtonTheme {
73
+ buttonStyle?: {
74
+ 'font-family'?: string;
75
+ 'font-size'?: string;
76
+ 'font-weight'?: string;
77
+ 'font-style'?: string;
78
+ };
79
+ buttonStretch?: {
80
+ stretched?: boolean;
81
+ };
82
+ buttonInternalPadding?: LegacyPadding;
83
+ buttonExternalPadding?: LegacyPadding;
84
+ buttonText?: {
85
+ text?: string;
86
+ };
87
+ buttonColor?: {
88
+ color?: string;
89
+ };
90
+ textButtonColor?: {
91
+ color?: string;
92
+ };
93
+ buttonBorder?: {
94
+ width?: LegacySides<number>;
95
+ style?: LegacySides<string>;
96
+ color?: LegacySides<string>;
97
+ };
98
+ buttonBorderRadius?: LegacyBorderRadius;
99
+ buttonAlign?: {
100
+ align?: string;
101
+ };
102
+ }
103
+ /** Block-level theme. */
104
+ export interface LegacyBlockTheme {
105
+ blockAdapt?: {
106
+ adapt?: boolean;
107
+ };
108
+ blockPadding?: LegacyPadding;
109
+ }
110
+ /** Single composition.variable entry from `esd-dev-product-config`. */
111
+ export interface LegacyVariable {
112
+ /** e.g. `p_name`, `p_button`, `p_attribute_<ts>`. */
113
+ variable?: string;
114
+ /** Marker that distinguishes custom product attributes (`'p_attribute'`). */
115
+ variableType?: string;
116
+ /** Selector legacy used to address this element in the HTML. */
117
+ visibilityAreaSelector?: string;
118
+ /** Custom-attribute value (e.g. `product_attribute.brand`). */
119
+ value?: string;
120
+ /** Whether the element is hidden in the legacy block. */
121
+ hidden?: boolean;
122
+ /** Sort order across composition entries (lower = earlier). */
123
+ positionIdx?: number;
124
+ /** Element-kind-specific theme bag. */
125
+ theme?: LegacyTextTheme & LegacyImageTheme & LegacyButtonTheme & {
126
+ buttonText?: {
127
+ text?: string;
128
+ };
129
+ };
130
+ /** Custom attribute marker. */
131
+ custom?: boolean;
132
+ }
133
+ /** Full decoded `esd-dev-product-config` shape. */
134
+ export interface LegacyProductConfig {
135
+ rowCount?: number;
136
+ totalCount?: number;
137
+ orientation?: string;
138
+ composition?: {
139
+ variables?: LegacyVariable[];
140
+ };
141
+ theme?: LegacyBlockTheme;
142
+ }
143
+ /** Element kind dispatched from a legacy `variable` value. */
144
+ export type ElementKind = 'image' | 'text' | 'button' | 'custom' | 'title';
145
+ /** Mapping output from a single legacy variable. */
146
+ export interface MappedVariable {
147
+ /** Composition key (`productName`, `customAttr:brand`, …) or `__title__` for titles. */
148
+ key: string;
149
+ kind: ElementKind;
150
+ hidden: boolean;
151
+ positionIdx: number;
152
+ /** Original legacy variable (kept for downstream theme mapping). */
153
+ legacy: LegacyVariable;
154
+ /** For custom attrs: bare attribute name (e.g. `brand`). */
155
+ customAttrName?: string;
156
+ /** For custom attrs: full `product-attr` value (e.g. `product_attribute.brand`). */
157
+ customAttrValue?: string;
158
+ }
159
+ /** CSS style strings + attributes resolved from a single text-like theme. */
160
+ export interface MappedTextStyle {
161
+ /** Inline CSS for outer `<td>` (background, padding). */
162
+ tdStyle: string;
163
+ /** Inline CSS for inner `<p>` (typography, color, line-height, text-align). */
164
+ pStyle: string;
165
+ /** Value for `<td align>` attribute, if any. */
166
+ align?: string;
167
+ /** Whether to wrap content in `<strong>`. */
168
+ wrapBold: boolean;
169
+ /** Whether to wrap content in `<em>`. */
170
+ wrapItalic: boolean;
171
+ /** True if `textTrimming: true` in theme. */
172
+ textTrimming: boolean;
173
+ }
174
+ /** Resolved button styles. */
175
+ export interface MappedButtonStyle {
176
+ /** Inline CSS for outer `<td>` (external padding). */
177
+ tdStyle: string;
178
+ /** Value for `<td align>`, if any. */
179
+ align?: string;
180
+ /** Inline CSS for `<span class="es-button-border">`. */
181
+ spanStyle: string;
182
+ /** Inline CSS for `<a class="es-button">`. */
183
+ aStyle: string;
184
+ /** Button label text. */
185
+ text?: string;
186
+ }
187
+ /** Resolved image styles. */
188
+ export interface MappedImageStyle {
189
+ /** Width in pixels (number form) — applied as both `width=` attr and CSS. */
190
+ width?: number;
191
+ /** Height in pixels. */
192
+ height?: number;
193
+ }
194
+ /** Per-variable mapped style bag, keyed by composition key. */
195
+ export type PerElementStyles = Record<string, MappedTextStyle | MappedButtonStyle | MappedImageStyle | undefined>;
196
+ /** Composition mapper output. */
197
+ export interface MappedComposition {
198
+ composition: string[];
199
+ visibility: Record<string, boolean>;
200
+ customAttributes: string[];
201
+ /** Mapping of customAttr key → full `product-attr` value. */
202
+ customAttrValues: Record<string, string>;
203
+ /** Title variable, if present (for separate title rendering). */
204
+ titleVariable?: LegacyVariable;
205
+ /** Resolved styles per composition key. */
206
+ perElementStyles: PerElementStyles;
207
+ /** Whether *any* element had `textTrimming: true`. */
208
+ anyTextTrimming: boolean;
209
+ }
@@ -1 +1,28 @@
1
- export declare function migrateRecommendation(html: string): string;
1
+ /**
2
+ * Recommendation Block Migrator
3
+ *
4
+ * Migrates legacy Recommendation Blocks (composition stored in the
5
+ * `esd-dev-product-config` HTML attribute, plus runtime config in
6
+ * `Guido Config -> template.migration.recommendationConfigs[id]`)
7
+ * to the new container-style block structure.
8
+ *
9
+ * Each legacy block is migrated independently. If either input is
10
+ * missing for a given block, the migrator skips that block with a
11
+ * logged warning — no partial migration. After successful migration,
12
+ * the new HTML uses the `recommendation-block-v2` class and stamps a
13
+ * complete `RecommendationNodeConfig` into the `esd-ext-config`
14
+ * attribute, which Stripo's `node.getNodeConfig()` returns directly
15
+ * on first load.
16
+ *
17
+ * Re-running the migrator on the result is a no-op (idempotent): the
18
+ * selector matches only blocks that have `esd-dev-product-config`
19
+ * AND lack `recommendation-block-v2`.
20
+ */
21
+ import type { LegacyRecommendationConfig } from '@@/Types/config';
22
+ /**
23
+ * Migrate all legacy Recommendation Blocks in the given HTML string.
24
+ * @param html - Full template HTML.
25
+ * @param recommendationConfigs - Map of campaign-id → legacy config (`Record<string, LegacyRecommendationConfig>`).
26
+ * @returns Migrated HTML, or the original HTML if no legacy blocks exist.
27
+ */
28
+ export declare function migrateRecommendation(html: string, recommendationConfigs?: Record<string, LegacyRecommendationConfig>): string;
@@ -3,3 +3,9 @@ export declare const UI_EDITOR_SELECTOR = "ui-editor";
3
3
  export declare const CARD_COMPOSITION_TAB_SELECTOR = "button[role=\"tab\"][aria-label=\"Card Composition\"]";
4
4
  export declare const SETTINGS_TAB_SELECTOR = "button[role=\"tab\"][aria-label=\"Settings\"]";
5
5
  export declare const RIBBON_SELECTOR = ".in-ribbons-wrapper";
6
+ export declare const DYNAMIC_CONTENT_BUTTON_SELECTOR = "#guido__btn-add-dynamic-content";
7
+ export declare const AMP_TOGGLE_BUTTON_SELECTOR = ".guido__amp-toggle-html";
8
+ export declare const AMP_TOGGLE_WRAPPER_SELECTOR = ".in-segments-wrapper";
9
+ export declare const HEADER_SELECTOR = "[data-testid=\"guido-header\"]";
10
+ export declare const POPOVER_LEFT_OFFSET = 158;
11
+ export declare const POPOVER_TOP_GAP = 10;
@@ -12,6 +12,11 @@ export declare const URLS: {
12
12
  UNSUBSCRIBE_URL: string;
13
13
  PREFERENCES_URL: string;
14
14
  };
15
+ export declare const PRODUCT_TYPE_URL_SEGMENTS: {
16
+ readonly 60: "email";
17
+ readonly 49: "journey";
18
+ readonly 97: "email";
19
+ };
15
20
  export declare const INSIDER_ID = "iid";
16
21
  export declare const DEFAULT_UNSUBSCRIBE_GROUP: {
17
22
  readonly name: "Global Unsubscribe";
@@ -119,6 +119,16 @@ export declare class RecommendationConfigService {
119
119
  *
120
120
  * Reads existing data-attributes and creates a proper node config.
121
121
  * Used when loading templates created before node config was implemented.
122
+ *
123
+ * Sources, in priority order (later overrides earlier):
124
+ * 1. `esd-ext-config` JSON blob — emitted by the recommendation migrator and
125
+ * by hand-authored new templates. Carries the full RecommendationNodeConfig
126
+ * (strategy, language, currency, filters, productIds, etc.) which the
127
+ * discrete data-* attrs below cannot capture.
128
+ * 2. Discrete `data-*` attributes — runtime source of truth for
129
+ * layout/composition/spacing; controls keep these in sync as the user
130
+ * edits, so we let them override the JSON blob if they disagree.
131
+ * 3. `currency-*` attributes — durable currency source on the block element.
122
132
  * @param api - Stripo extension API with document modifier
123
133
  * @param node - The block node to migrate
124
134
  * @returns The migrated configuration
@@ -24,7 +24,7 @@ export interface CurrencyConfig {
24
24
  /** Number of decimal places (-1 for no formatting) */
25
25
  decimalCount: number;
26
26
  /** Character used for decimal separation */
27
- decimalSeparator: '.' | ',';
27
+ decimalSeparator: '.' | ',' | ' ';
28
28
  /** Character used for thousands separation */
29
29
  thousandSeparator: '.' | ',' | ' ' | '';
30
30
  }