@useinsider/guido 2.0.0-beta.143201d → 2.0.0-beta.1ba7e26

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 (34) hide show
  1. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
  2. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  3. package/dist/config/migrator/index.js +9 -8
  4. package/dist/config/migrator/itemsBlockMigrator.js +283 -0
  5. package/dist/extensions/Blocks/Items/block.js +39 -40
  6. package/dist/extensions/Blocks/Items/controls/button/link.js +11 -11
  7. package/dist/extensions/Blocks/Items/controls/cardComposition.js +46 -49
  8. package/dist/extensions/Blocks/Items/controls/image/link.js +8 -8
  9. package/dist/extensions/Blocks/Items/controls/name/trimming.js +13 -15
  10. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +1 -1
  11. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
  12. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +15 -17
  13. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -15
  14. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +29 -27
  15. package/dist/extensions/Blocks/Items/controls/settingsControl.js +132 -127
  16. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
  17. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -48
  18. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -58
  19. package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
  20. package/dist/extensions/Blocks/Items/template.js +312 -125
  21. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +172 -0
  22. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +11 -20
  23. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  24. package/dist/extensions/Blocks/common-control.js +64 -53
  25. package/dist/guido.css +1 -1
  26. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +366 -287
  27. package/dist/package.json.js +1 -1
  28. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
  29. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  30. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
  31. package/dist/src/extensions/Blocks/Items/template.d.ts +20 -1
  32. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +71 -0
  33. package/dist/src/extensions/Blocks/common-control.d.ts +13 -8
  34. 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 {
@@ -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 }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "2.0.0-beta.143201d",
3
+ "version": "2.0.0-beta.1ba7e26",
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
  }