@useinsider/guido 2.0.0-beta.117064 → 2.0.0-beta.13ba613

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 (36) hide show
  1. package/README.md +0 -2
  2. package/dist/@types/config/schemas.js +1 -3
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +17 -15
  5. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
  6. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  7. package/dist/composables/useStripo.js +40 -40
  8. package/dist/config/migrator/index.js +9 -8
  9. package/dist/config/migrator/itemsBlockMigrator.js +283 -0
  10. package/dist/extensions/Blocks/Items/block.js +39 -40
  11. package/dist/extensions/Blocks/Items/controls/cardComposition.js +46 -49
  12. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +28 -26
  13. package/dist/extensions/Blocks/Items/controls/settingsControl.js +132 -127
  14. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
  15. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -48
  16. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -58
  17. package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
  18. package/dist/extensions/Blocks/Items/template.js +296 -123
  19. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +172 -0
  20. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +11 -20
  21. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  22. package/dist/extensions/Blocks/common-control.js +64 -53
  23. package/dist/guido.css +1 -1
  24. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +366 -287
  25. package/dist/package.json.js +1 -1
  26. package/dist/services/stripoApi.js +10 -6
  27. package/dist/src/@types/config/schemas.d.ts +0 -4
  28. package/dist/src/composables/useConfig.d.ts +0 -2
  29. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
  30. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  31. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
  32. package/dist/src/extensions/Blocks/Items/template.d.ts +20 -1
  33. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +71 -0
  34. package/dist/src/extensions/Blocks/common-control.d.ts +13 -8
  35. package/dist/src/stores/config.d.ts +0 -17
  36. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- const o = { stripo: { version: "2.47.0" } }, s = {
1
+ const o = { stripo: { version: "2.52.0" } }, s = {
2
2
  guido: o
3
3
  };
4
4
  export {
@@ -1,8 +1,8 @@
1
1
  import { useHttp as m } from "../composables/useHttp.js";
2
- import { useToaster as i } from "../composables/useToaster.js";
3
- import { MAX_DEFAULT_TEMPLATE_ID as p } from "../enums/defaults.js";
2
+ import { useToaster as u } from "../composables/useToaster.js";
3
+ import { MAX_DEFAULT_TEMPLATE_ID as i } from "../enums/defaults.js";
4
4
  const y = () => {
5
- const { get: r } = m(), { handleError: o } = i();
5
+ const { get: r } = m(), { handleError: o } = u();
6
6
  return {
7
7
  getToken: async () => {
8
8
  try {
@@ -26,13 +26,17 @@ const y = () => {
26
26
  getDefaultTemplate: async () => {
27
27
  const t = {
28
28
  html: "",
29
- css: ""
29
+ css: "",
30
+ forceRecreate: !0
30
31
  };
31
32
  try {
32
- const c = new URLSearchParams(window.location.search).get("default-template"), s = c ? parseInt(c) : 0, l = s >= 1 && s <= p ? s : 0, { data: n } = await r(
33
+ const c = new URLSearchParams(window.location.search).get("default-template"), s = c ? parseInt(c) : 0, l = s >= 1 && s <= i ? s : 0, { data: n } = await r(
33
34
  `/stripo/default-template/${l}`
34
35
  ), a = typeof n == "string" ? JSON.parse(n) : n;
35
- return !a || typeof a != "object" || !("html" in a) || !("css" in a) ? t : a;
36
+ return !a || typeof a != "object" || !("html" in a) || !("css" in a) ? t : {
37
+ ...a,
38
+ forceRecreate: !0
39
+ };
36
40
  } catch (e) {
37
41
  return o(e, "Failed to fetch default template"), t;
38
42
  }
@@ -90,8 +90,6 @@ export declare const TemplateSchema: v.ObjectSchema<{
90
90
  }, undefined>, undefined>, readonly []>;
91
91
  /** Selected unsubscribe page IDs */
92
92
  readonly selectedUnsubscribePages: v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, readonly []>;
93
- /** Force recreate template in Stripo storage (use true when updating externally modified templates) */
94
- readonly forceRecreate: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
95
93
  }, undefined>;
96
94
  /**
97
95
  * Email header configuration (sender name and subject)
@@ -402,8 +400,6 @@ export declare const GuidoConfigSchema: v.ObjectSchema<{
402
400
  }, undefined>, undefined>, readonly []>;
403
401
  /** Selected unsubscribe page IDs */
404
402
  readonly selectedUnsubscribePages: v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, readonly []>;
405
- /** Force recreate template in Stripo storage (use true when updating externally modified templates) */
406
- readonly forceRecreate: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
407
403
  }, undefined>, {}>;
408
404
  /** Editor settings */
409
405
  readonly editor: v.OptionalSchema<v.ObjectSchema<{
@@ -31,7 +31,6 @@ export declare const useConfig: () => {
31
31
  } | undefined;
32
32
  }[];
33
33
  selectedUnsubscribePages: number[];
34
- forceRecreate: boolean;
35
34
  };
36
35
  editor: {
37
36
  locale: string;
@@ -117,7 +116,6 @@ export declare const useConfig: () => {
117
116
  } | undefined;
118
117
  }[];
119
118
  selectedUnsubscribePages: number[];
120
- forceRecreate: boolean;
121
119
  } | null>;
122
120
  editor: import("vue").ComputedRef<{
123
121
  locale: string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Migrates legacy ItemsBlock templates to v2 format
3
+ * @param html - HTML string containing legacy items blocks
4
+ * @returns Migrated HTML with replaced variables and cleaned conditionals
5
+ */
6
+ export declare function migrateItemsBlock(html: string): string;
@@ -9,7 +9,7 @@ export declare class PriceOrientationControl extends CommonControl {
9
9
  onRender(): void;
10
10
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
11
11
  _onPriceOrientationChange(value: string): void;
12
- private _updateHorizontalLayout;
13
12
  private _updateVerticalLayout;
13
+ private _updateHorizontalLayout;
14
14
  _getPriceOrientation(): string;
15
15
  }
@@ -31,10 +31,6 @@ export declare class ItemsBlockControl extends CommonControl {
31
31
  _updatePrice(price: string): void;
32
32
  _updateOriginalPrice(originalPrice: string): void;
33
33
  _updateQuantity(quantity: string): void;
34
- /**
35
- * @todo Optimize template reordering for performance.
36
- * @description Reorders the template structure based on current orientation and visibility settings.
37
- */
38
34
  _reOrderTemplate(): void;
39
35
  _updateDataTypeAttributes(itemsType: ProductType): void;
40
36
  _updateDataNumberAttributes(itemId: string): void;
@@ -1,6 +1,8 @@
1
+ import type { ItemsBlockConfig } from './utils/nodeConfigUtils';
1
2
  declare const migrationTemplate = "ADD YOUR MIGRATION HERE";
2
3
  type ProductType = 'CART_ITEMS' | 'BROWSED_ITEMS' | 'PURCHASED_ITEMS';
3
4
  type OrientationType = 'vertical' | 'horizontal';
5
+ type PriceOrientationType = 'vertical' | 'horizontal';
4
6
  type TemplateParameters = {
5
7
  orientation: OrientationType;
6
8
  itemsType: ProductType;
@@ -8,6 +10,23 @@ type TemplateParameters = {
8
10
  currencySymbol?: string;
9
11
  currencyLocation?: string;
10
12
  formattedPrice?: boolean;
13
+ migrate?: boolean;
14
+ /** Legacy config format (data-* attributes from esd-config-block) */
15
+ configBlockAttributes?: Record<string, string>;
16
+ /** New config format (Stripo V2 nodeConfig from esd-ext-config) */
17
+ nodeConfig?: Partial<ItemsBlockConfig>;
18
+ /** Extracted styles from a[product-attr="name"] for migration */
19
+ nameStyles?: string;
20
+ /** Extracted styles from a.es-button for migration */
21
+ buttonStyles?: string;
22
+ /** Extracted styles from p[product-attr="price"] for migration */
23
+ priceStyles?: string;
24
+ /** Extracted styles from p[product-attr="originalPrice"] for migration */
25
+ originalPriceStyles?: string;
26
+ /** Extracted styles from p[product-attr="quantity"] for migration */
27
+ quantityStyles?: string;
28
+ /** Price orientation within the card ('vertical' = stacked, 'horizontal' = side-by-side) */
29
+ priceOrientation?: PriceOrientationType;
11
30
  };
12
31
  /**
13
32
  * Generates the default template for the Items Block.
@@ -20,5 +39,5 @@ type TemplateParameters = {
20
39
  * @param params.formattedPrice - Whether to use formatted price display
21
40
  * @returns HTML template string for the Items Block
22
41
  */
23
- export declare function getDefaultTemplate({ orientation, itemsType, itemId, currencySymbol, currencyLocation, formattedPrice, }: TemplateParameters): string;
42
+ export declare function getDefaultTemplate({ orientation, itemsType, itemId, currencySymbol, currencyLocation, migrate, formattedPrice, configBlockAttributes, nodeConfig, nameStyles, buttonStyles, priceStyles, originalPriceStyles, quantityStyles, priceOrientation, }: TemplateParameters): string;
24
43
  export default migrationTemplate;
@@ -0,0 +1,71 @@
1
+ import { OrientationType, ProductType } from '@@/Types/extensions/items';
2
+ import { ImmutableHtmlNode, ImmutableHtmlElementNode, ControlApi, BlockApi } from '@stripoinc/ui-editor-extensions';
3
+ /**
4
+ * Typed configuration object for Items Block.
5
+ * Replaces the deprecated esd-config-block data-* attributes approach.
6
+ * Configuration is stored directly on the block node using Stripo V2's getNodeConfig/setNodeConfig API.
7
+ */
8
+ export interface ItemsBlockConfig {
9
+ initialized: boolean;
10
+ blockInstanceId: string;
11
+ source: ProductType;
12
+ type: ProductType;
13
+ itemsSelectValue: string;
14
+ orientation: OrientationType;
15
+ nameTrimming: boolean;
16
+ nameControlEnabled: boolean;
17
+ priceHideDiscount: boolean;
18
+ priceFormatted: boolean;
19
+ priceCurrencySymbol: string;
20
+ priceCurrencyLocation: string;
21
+ priceControlOpened: boolean;
22
+ priceOrientation: 'vertical' | 'horizontal';
23
+ quantityControlEnabled: boolean;
24
+ buttonLink: string;
25
+ imageLink: string;
26
+ buttonLabel: string;
27
+ imageVisible: boolean;
28
+ nameVisible: boolean;
29
+ quantityVisible: boolean;
30
+ priceVisible: boolean;
31
+ originalPriceVisible: boolean;
32
+ buttonVisible: boolean;
33
+ }
34
+ /**
35
+ * Generates a unique block instance ID.
36
+ */
37
+ export declare function generateBlockInstanceId(): string;
38
+ /**
39
+ * Returns default ItemsBlockConfig values.
40
+ * These are used when initializing a new block or when migrating from legacy format.
41
+ */
42
+ export declare function getDefaultItemsBlockConfig(): ItemsBlockConfig;
43
+ /**
44
+ * Gets the Items block container element from the current node.
45
+ * The container is identified by the `.items-block-v2` class (new) or `.esd-cart-items-block` (legacy).
46
+ * @param currentNode - The current node from the control (usually this.currentNode)
47
+ * @returns The container element or null if not found
48
+ */
49
+ export declare function getItemsBlockContainer(currentNode: ImmutableHtmlNode | undefined): ImmutableHtmlElementNode | null;
50
+ /**
51
+ * Gets the node configuration from the Items block.
52
+ * Uses Stripo V2's getNodeConfig() API.
53
+ * Falls back to migrating from legacy esd-config-block if nodeConfig is empty.
54
+ * @param currentNode - The current node from the control
55
+ * @returns The ItemsBlockConfig object or null if not found
56
+ */
57
+ export declare function getItemsBlockConfig(currentNode: ImmutableHtmlNode | undefined): ItemsBlockConfig | null;
58
+ /**
59
+ * Sets the node configuration on the Items block.
60
+ * Uses Stripo V2's setNodeConfig() API.
61
+ * @param currentNode - The current node from the control
62
+ * @param api - The API object (ControlApi or BlockApi)
63
+ * @param config - The configuration to set (partial update supported)
64
+ */
65
+ export declare function setItemsBlockConfig(currentNode: ImmutableHtmlNode | undefined, api: ControlApi | BlockApi, config: Partial<ItemsBlockConfig>): void;
66
+ /**
67
+ * Gets the block instance ID from the node config.
68
+ * @param currentNode - The current node from the control
69
+ * @returns The block instance ID or null if not found
70
+ */
71
+ export declare function getBlockInstanceIdFromConfig(currentNode: ImmutableHtmlNode | undefined): string | null;
@@ -56,25 +56,30 @@ export declare abstract class CommonControl extends Control {
56
56
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
57
57
  onDestroy(): void;
58
58
  /**
59
- * Gets the config block element from the current node.
59
+ * Gets the Items block container element from the current node.
60
+ * @returns The container element or null if not found
61
+ */
62
+ protected getItemsBlockContainer(): ImmutableHtmlElementNode | null;
63
+ /**
64
+ * Gets the config block element from the current node (legacy support).
65
+ * @deprecated Use getNodeConfig() from nodeConfigUtils instead for Stripo V2
60
66
  * @returns The config block element or null if not found
61
67
  */
62
68
  protected getConfigBlock(): ImmutableHtmlElementNode | null;
63
69
  /**
64
- * Gets the current block instance ID from the config block.
65
- * @param blockInstanceIdAttribute - The attribute name for block instance ID (default: 'data-block-instance-id')
70
+ * Gets the current block instance ID from the node config (Stripo V2) or legacy config block.
66
71
  * @returns The block instance ID or null if not found
67
72
  */
68
- protected getBlockInstanceId(blockInstanceIdAttribute?: string): string | null;
73
+ protected getBlockInstanceId(): string | null;
69
74
  /**
70
75
  * Handles block instance change detection and syncing.
71
- * This is a helper method for controls that need to sync attributes when switching between block instances.
72
- * @param syncFunction - Function to call when block instance changes (to sync from attributes)
76
+ * This is a helper method for controls that need to sync config when switching between block instances.
77
+ * Uses Stripo V2 nodeConfig API for block instance tracking.
78
+ * @param syncFunction - Function to call when block instance changes (to sync from node config)
73
79
  * @param updateUI - Function to call to update the UI (called both on change and when same block)
74
- * @param blockInstanceIdAttribute - The attribute name for block instance ID (default: 'data-block-instance-id')
75
80
  * @returns true if block instance changed, false otherwise
76
81
  */
77
- protected handleBlockInstanceChange(syncFunction: (node: ImmutableHtmlNode) => void, updateUI: () => void, blockInstanceIdAttribute?: string): boolean;
82
+ protected handleBlockInstanceChange(syncFunction: (node: ImmutableHtmlNode) => void, updateUI: () => void): boolean;
78
83
  _GuLabel({ text, name, position }: LabelProps): string;
79
84
  _GuToggle(name: string): string;
80
85
  _GuSelectItem({ text, value }: {
@@ -36,7 +36,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
36
36
  } | undefined;
37
37
  }[];
38
38
  selectedUnsubscribePages: number[];
39
- forceRecreate: boolean;
40
39
  };
41
40
  editor: {
42
41
  locale: string;
@@ -128,7 +127,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
128
127
  } | undefined;
129
128
  }[];
130
129
  selectedUnsubscribePages: number[];
131
- forceRecreate: boolean;
132
130
  };
133
131
  editor: {
134
132
  locale: string;
@@ -220,7 +218,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
220
218
  } | undefined;
221
219
  }[];
222
220
  selectedUnsubscribePages: number[];
223
- forceRecreate: boolean;
224
221
  };
225
222
  editor: {
226
223
  locale: string;
@@ -312,7 +309,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
312
309
  } | undefined;
313
310
  }[];
314
311
  selectedUnsubscribePages: number[];
315
- forceRecreate: boolean;
316
312
  };
317
313
  editor: {
318
314
  locale: string;
@@ -404,7 +400,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
404
400
  } | undefined;
405
401
  }[];
406
402
  selectedUnsubscribePages: number[];
407
- forceRecreate: boolean;
408
403
  };
409
404
  editor: {
410
405
  locale: string;
@@ -496,7 +491,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
496
491
  } | undefined;
497
492
  }[];
498
493
  selectedUnsubscribePages: number[];
499
- forceRecreate: boolean;
500
494
  };
501
495
  editor: {
502
496
  locale: string;
@@ -588,7 +582,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
588
582
  } | undefined;
589
583
  }[];
590
584
  selectedUnsubscribePages: number[];
591
- forceRecreate: boolean;
592
585
  };
593
586
  editor: {
594
587
  locale: string;
@@ -680,7 +673,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
680
673
  } | undefined;
681
674
  }[];
682
675
  selectedUnsubscribePages: number[];
683
- forceRecreate: boolean;
684
676
  };
685
677
  editor: {
686
678
  locale: string;
@@ -772,7 +764,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
772
764
  } | undefined;
773
765
  }[];
774
766
  selectedUnsubscribePages: number[];
775
- forceRecreate: boolean;
776
767
  };
777
768
  editor: {
778
769
  locale: string;
@@ -864,7 +855,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
864
855
  } | undefined;
865
856
  }[];
866
857
  selectedUnsubscribePages: number[];
867
- forceRecreate: boolean;
868
858
  };
869
859
  editor: {
870
860
  locale: string;
@@ -956,7 +946,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
956
946
  } | undefined;
957
947
  }[];
958
948
  selectedUnsubscribePages: number[];
959
- forceRecreate: boolean;
960
949
  };
961
950
  editor: {
962
951
  locale: string;
@@ -1048,7 +1037,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1048
1037
  } | undefined;
1049
1038
  }[];
1050
1039
  selectedUnsubscribePages: number[];
1051
- forceRecreate: boolean;
1052
1040
  };
1053
1041
  editor: {
1054
1042
  locale: string;
@@ -1140,7 +1128,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1140
1128
  } | undefined;
1141
1129
  }[];
1142
1130
  selectedUnsubscribePages: number[];
1143
- forceRecreate: boolean;
1144
1131
  };
1145
1132
  editor: {
1146
1133
  locale: string;
@@ -1232,7 +1219,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1232
1219
  } | undefined;
1233
1220
  }[];
1234
1221
  selectedUnsubscribePages: number[];
1235
- forceRecreate: boolean;
1236
1222
  };
1237
1223
  editor: {
1238
1224
  locale: string;
@@ -1324,7 +1310,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1324
1310
  } | undefined;
1325
1311
  }[];
1326
1312
  selectedUnsubscribePages: number[];
1327
- forceRecreate: boolean;
1328
1313
  };
1329
1314
  editor: {
1330
1315
  locale: string;
@@ -1416,7 +1401,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1416
1401
  } | undefined;
1417
1402
  }[];
1418
1403
  selectedUnsubscribePages: number[];
1419
- forceRecreate: boolean;
1420
1404
  };
1421
1405
  editor: {
1422
1406
  locale: string;
@@ -1508,7 +1492,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1508
1492
  } | undefined;
1509
1493
  }[];
1510
1494
  selectedUnsubscribePages: number[];
1511
- forceRecreate: boolean;
1512
1495
  };
1513
1496
  editor: {
1514
1497
  locale: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "2.0.0-beta.0117064",
3
+ "version": "2.0.0-beta.13ba613",
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",
@@ -31,7 +31,7 @@
31
31
  "author": "",
32
32
  "license": "ISC",
33
33
  "dependencies": {
34
- "@stripoinc/ui-editor-extensions": "3.3.0",
34
+ "@stripoinc/ui-editor-extensions": "3.5.0",
35
35
  "@useinsider/design-system-vue": "0.14.20",
36
36
  "@vueuse/core": "11.3.0",
37
37
  "lodash-es": "4.17.21",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "guido": {
87
87
  "stripo": {
88
- "version": "2.47.0"
88
+ "version": "2.52.0"
89
89
  }
90
90
  }
91
91
  }