@useinsider/guido 3.7.0-beta.24bdfa3 → 3.7.0-beta.340a6d3

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 (40) hide show
  1. package/dist/@types/config/schemas.js +66 -70
  2. package/dist/composables/usePreviewMode.js +14 -15
  3. package/dist/config/compiler/utils/recommendationCompilerUtils.js +82 -90
  4. package/dist/config/migrator/recommendation/htmlBuilder.js +58 -59
  5. package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
  6. package/dist/extensions/Blocks/Recommendation/block.js +43 -59
  7. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
  8. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +313 -377
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +72 -84
  10. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +66 -68
  11. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
  12. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
  13. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +5 -7
  14. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +72 -101
  15. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -31
  16. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -9
  17. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +59 -74
  18. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  19. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -88
  20. package/dist/src/@types/config/schemas.d.ts +0 -16
  21. package/dist/src/composables/useConfig.d.ts +0 -4
  22. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  23. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
  24. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
  25. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
  27. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
  28. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -16
  29. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  30. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -13
  31. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
  32. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -33
  33. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
  34. package/dist/src/stores/config.d.ts +0 -36
  35. package/package.json +1 -1
  36. package/dist/composables/useRecommendationPreview.js +0 -100
  37. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
  38. package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
  39. package/dist/src/composables/useRecommendationPreview.test.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
@@ -9,7 +9,7 @@
9
9
  * // Or individual imports
10
10
  * import { NameAlignControl, ButtonColorControl } from './controls';
11
11
  */
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';
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, } from './main';
13
13
  export * from './main/utils';
14
14
  export { NameControls } from './name';
15
15
  export { PriceControls } from './price';
@@ -5,12 +5,11 @@ import { CurrencyControl, CURRENCY_CONTROL_ID } from './currency';
5
5
  import { FiltersControl, FILTERS_CONTROL_ID } from './filters';
6
6
  import { LayoutOrientationControl, LAYOUT_ORIENTATION_CONTROL_ID } from './layoutOrientation';
7
7
  import { LocaleControl, LOCALE_CONTROL_ID } from './locale';
8
- import { PricePlacementControl, PRICE_PLACEMENT_CONTROL_ID } from './pricePlacement';
9
8
  import { ProductCountControl, PRODUCT_COUNT_CONTROL_ID } from './productCount';
10
9
  import { ProductLayoutControl, PRODUCT_LAYOUT_CONTROL_ID } from './productLayout';
11
10
  import { ShuffleControl, SHUFFLE_CONTROL_ID } from './shuffle';
12
11
  export declare const CONTROL_BLOCK_ID = "ui-elements-recommendation-block";
13
- export { 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, };
12
+ export { 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, };
14
13
  export * from './utils';
15
14
  /**
16
15
  * Main recommendation block control that composes all sub-controls
@@ -26,7 +25,6 @@ export declare class RecommendationBlockControl extends CommonControl {
26
25
  private productLayoutControl;
27
26
  private filtersControl;
28
27
  private shuffleControl;
29
- private pricePlacementControl;
30
28
  private layoutOrientationControl;
31
29
  getId(): string;
32
30
  getTemplate(): string;
@@ -24,8 +24,6 @@ export interface PerBlockConfigs {
24
24
  unresponsive: boolean;
25
25
  size: string;
26
26
  customAttributes: string[];
27
- priceMovedToNextLine: boolean;
28
- priceHideIfSameAsDiscounted: boolean;
29
27
  }
30
28
  interface PerBlockState {
31
29
  recommendationConfigs: PerBlockConfigs;
@@ -1,4 +1,3 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
2
1
  import { type ElementRenderer } from '../utils';
3
2
  /**
4
3
  * Grid element renderer
@@ -25,19 +24,4 @@ export declare const ATTRIBUTE_CELL_CLASS = "attribute-cell";
25
24
  * card-composition control so both render identical filler markup.
26
25
  */
27
26
  export declare function buildFillerCell(columnWidth: string, padding?: string): string;
28
- /**
29
- * Renders the inline price cell used when "Move to next line" is OFF: the sale
30
- * price and original price sit side by side in a single attribute cell, each
31
- * keeping its own `esd-extension-block-id` + `product-*` class so the per-element
32
- * style controls and the compiler keep working.
33
- *
34
- * `originalFirst` preserves the card-composition order (original before sale when
35
- * `productOldPrice` precedes `productPrice` in the composition) so the side-by-side
36
- * order matches the stacked order.
37
- */
38
- export declare function renderInlineGridPriceCell(product: RecommendationProduct, originalFirst?: boolean): string;
39
- /**
40
- * Standalone (stacked) original-price cell.
41
- */
42
- export declare function renderGridOldPriceCell(product: RecommendationProduct): string;
43
27
  export declare const gridElementRenderer: ElementRenderer;
@@ -1,5 +1,5 @@
1
1
  import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
2
- import { type ElementRenderer, type PricePlacementFlags } from '../utils';
2
+ import { type ElementRenderer } from '../utils';
3
3
  /**
4
4
  * Generates attribute-aligned product rows for grid layout.
5
5
  * Creates rows where each row contains one attribute type from all products.
@@ -9,7 +9,7 @@ import { type ElementRenderer, type PricePlacementFlags } from '../utils';
9
9
  * @param composition - Array defining order of card elements
10
10
  * @returns HTML string for attribute-aligned rows
11
11
  */
12
- export declare function prepareGridAttributeRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[], filterList?: FiltersResponse, flags?: PricePlacementFlags): string;
12
+ export declare function prepareGridAttributeRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[], filterList?: FiltersResponse): string;
13
13
  /**
14
14
  * Prepares grid product rows with attribute-aligned structure
15
15
  * Groups products into rows, then generates attribute-aligned HTML for each group
@@ -19,7 +19,7 @@ export declare function prepareGridAttributeRows(products: RecommendationProduct
19
19
  * @param composition - Array defining order of card elements
20
20
  * @returns HTML string for all product rows
21
21
  */
22
- export declare function prepareGridProductRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[], filterList?: FiltersResponse, flags?: PricePlacementFlags): string;
22
+ export declare function prepareGridProductRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[], filterList?: FiltersResponse): string;
23
23
  /**
24
24
  * Prepares grid product rows with attribute-aligned structure.
25
25
  * Uses row-based rendering where each attribute type forms a single row across all products.
@@ -28,6 +28,6 @@ export declare function prepareGridProductRows(products: RecommendationProduct[]
28
28
  * @param composition - Array defining element order
29
29
  * @returns HTML string for product rows
30
30
  */
31
- export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[], filterList?: FiltersResponse, flags?: PricePlacementFlags): string;
31
+ export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[], filterList?: FiltersResponse): string;
32
32
  export declare function getDefaultTemplate(recommendationId?: number): string;
33
33
  export declare function generateBlockTemplate(products: RecommendationProduct[], productsPerRow: number, title?: string, composition?: string[], mobileProductsPerRow?: number): string;
@@ -1,4 +1,3 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
2
1
  import { type ElementRenderer } from '../utils';
3
2
  /**
4
3
  * List element renderer
@@ -6,16 +5,4 @@ import { type ElementRenderer } from '../utils';
6
5
  * - Name and Prices return `<tr><td>` rows for the info cell table
7
6
  * All elements have esd-block-* classes for Stripo selection
8
7
  */
9
- /**
10
- * Standalone (stacked) original-price info row.
11
- */
12
- export declare function renderListOldPriceRow(product: RecommendationProduct): string;
13
- /**
14
- * Inline price info row used when "Move to next line" is OFF: the sale price and
15
- * original price sit in two cells of one row. Each keeps its block id + class so
16
- * style controls and the compiler keep working. `originalFirst` preserves the
17
- * card-composition order (original before sale by default) so it matches the
18
- * stacked order.
19
- */
20
- export declare function renderInlineListPriceRow(product: RecommendationProduct, originalFirst?: boolean): string;
21
8
  export declare const listElementRenderer: ElementRenderer;
@@ -1,5 +1,4 @@
1
1
  import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
2
- import { type PricePlacementFlags } from '../utils';
3
2
  /**
4
3
  * Generates a list product card with 3-column layout
5
4
  * Uses buildElementRenderer to render Image, Info content, and Button
@@ -12,7 +11,7 @@ import { type PricePlacementFlags } from '../utils';
12
11
  * @param composition - Array defining order of card elements
13
12
  * @returns HTML string for a single product card row
14
13
  */
15
- export declare function getListProductCard(product: RecommendationProduct, composition?: string[], filterList?: FiltersResponse, flags?: PricePlacementFlags): string;
14
+ export declare function getListProductCard(product: RecommendationProduct, composition?: string[], filterList?: FiltersResponse): string;
16
15
  /**
17
16
  * Prepares list product rows
18
17
  * Each product is a full-width row with 3-column layout
@@ -20,6 +19,6 @@ export declare function getListProductCard(product: RecommendationProduct, compo
20
19
  * @param composition - Array defining order of card elements
21
20
  * @returns HTML string for product rows
22
21
  */
23
- export declare function prepareProductRows(products: RecommendationProduct[], composition?: string[], filterList?: FiltersResponse, flags?: PricePlacementFlags): string;
22
+ export declare function prepareProductRows(products: RecommendationProduct[], composition?: string[], filterList?: FiltersResponse): string;
24
23
  export declare function getDefaultTemplate(): string;
25
24
  export declare function generateBlockTemplate(products: RecommendationProduct[], title?: string, composition?: string[]): string;
@@ -1,33 +1,10 @@
1
- import type { CurrencyConfig } from '../types/nodeConfig';
2
1
  import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
3
2
  import { ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON } from '../constants';
4
- type PriceKey = 'price' | 'original_price' | 'discount';
5
- /**
6
- * Current currency configuration from the store, in CurrencyConfig shape.
7
- */
8
- export declare function getCurrentCurrencyConfig(): CurrencyConfig;
9
- /**
10
- * Formats a product price using current currency settings. Falls back to the
11
- * first available currency, then 0, when the active currency has no value.
12
- */
13
- export declare function formatProductPrice(product: RecommendationProduct, priceKey?: PriceKey): string;
14
3
  /**
15
4
  * Converts a snake_case attribute name to Title Case display name.
16
5
  * e.g., "rating_star" → "Rating Star"
17
6
  */
18
7
  export declare function toDisplayName(attrName: string): string;
19
- /**
20
- * Resolves the inline (side-by-side) price layout from the composition order so
21
- * it matches the stacked order. `anchor` is whichever of price / original price
22
- * comes first in the composition (the merged cell renders there); `skip` is the
23
- * other (dropped, since it's merged in); `originalFirst` puts the original price
24
- * on the left when it precedes the sale price (the default composition order).
25
- */
26
- export declare function resolveInlinePriceOrder(composition: string[]): {
27
- originalFirst: boolean;
28
- anchor: string;
29
- skip: string;
30
- };
31
8
  /**
32
9
  * Reduces a raw product-attribute value to a displayable scalar string.
33
10
  * Array-type attributes (filter types `Strings`/`Numbers`) are substituted with
@@ -80,15 +57,7 @@ export type Orientation = 'list' | 'grid';
80
57
  /**
81
58
  * Options for prepareProductRows unified function
82
59
  */
83
- /**
84
- * Block-level price placement flags threaded into the row builders.
85
- * - `priceInline`: render sale + original price on one line (skip the standalone
86
- * original-price row).
87
- */
88
- export interface PricePlacementFlags {
89
- priceInline?: boolean;
90
- }
91
- export interface PrepareProductRowsOptions extends PricePlacementFlags {
60
+ export interface PrepareProductRowsOptions {
92
61
  /** Number of products per row (only for grid layout, defaults to 3) */
93
62
  productsPerRow?: number;
94
63
  /** Number of products per row on mobile (only for grid layout, defaults to 1) */
@@ -155,4 +124,3 @@ export declare function getDefaultProducts(count?: number): RecommendationProduc
155
124
  * @returns HTML template string with {-{-TITLE-}-}, {-{-PRODUCT_ROWS-}-}, and {-{-MOBILE_PRODUCT_ROWS-}-} (grid only) placeholders
156
125
  */
157
126
  export declare function createBlockTemplate(layout?: Orientation, instanceClass?: string): string;
158
- export {};
@@ -152,21 +152,6 @@ export interface RecommendationNodeConfig {
152
152
  * Whether to trim long product names with ellipsis
153
153
  */
154
154
  textTrimming: boolean;
155
- /**
156
- * Whether the price and original price render on separate stacked lines.
157
- * - true (default): each on its own attribute row (current Guido look)
158
- * - false: both rendered inline on the same line, and Card Composition
159
- * collapses them into a single "Product Prices" entry
160
- * Ported from the legacy product block's `isPriceMovedToNextLine`.
161
- */
162
- priceMovedToNextLine: boolean;
163
- /**
164
- * Whether to hide the redundant original price when it equals the sale
165
- * price (no real discount). Enforced in the real email via a liquid
166
- * condition and mirrored in the editor on mock data.
167
- * Ported from the legacy product block's `isPriceDeletedForZeroSale`.
168
- */
169
- priceHideIfSameAsDiscounted: boolean;
170
155
  /**
171
156
  * Configuration version for future migrations
172
157
  * Increment when making breaking changes to schema
@@ -65,8 +65,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
65
65
  blockType?: string | undefined;
66
66
  size?: string | number | undefined;
67
67
  verticalResponsiveness?: boolean | undefined;
68
- isPriceMovedToNextLine?: boolean | undefined;
69
- isPriceDeletedForZeroSale?: boolean | undefined;
70
68
  } & {
71
69
  [key: string]: unknown;
72
70
  };
@@ -199,8 +197,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
199
197
  blockType?: string | undefined;
200
198
  size?: string | number | undefined;
201
199
  verticalResponsiveness?: boolean | undefined;
202
- isPriceMovedToNextLine?: boolean | undefined;
203
- isPriceDeletedForZeroSale?: boolean | undefined;
204
200
  } & {
205
201
  [key: string]: unknown;
206
202
  };
@@ -333,8 +329,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
333
329
  blockType?: string | undefined;
334
330
  size?: string | number | undefined;
335
331
  verticalResponsiveness?: boolean | undefined;
336
- isPriceMovedToNextLine?: boolean | undefined;
337
- isPriceDeletedForZeroSale?: boolean | undefined;
338
332
  } & {
339
333
  [key: string]: unknown;
340
334
  };
@@ -467,8 +461,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
467
461
  blockType?: string | undefined;
468
462
  size?: string | number | undefined;
469
463
  verticalResponsiveness?: boolean | undefined;
470
- isPriceMovedToNextLine?: boolean | undefined;
471
- isPriceDeletedForZeroSale?: boolean | undefined;
472
464
  } & {
473
465
  [key: string]: unknown;
474
466
  };
@@ -601,8 +593,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
601
593
  blockType?: string | undefined;
602
594
  size?: string | number | undefined;
603
595
  verticalResponsiveness?: boolean | undefined;
604
- isPriceMovedToNextLine?: boolean | undefined;
605
- isPriceDeletedForZeroSale?: boolean | undefined;
606
596
  } & {
607
597
  [key: string]: unknown;
608
598
  };
@@ -735,8 +725,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
735
725
  blockType?: string | undefined;
736
726
  size?: string | number | undefined;
737
727
  verticalResponsiveness?: boolean | undefined;
738
- isPriceMovedToNextLine?: boolean | undefined;
739
- isPriceDeletedForZeroSale?: boolean | undefined;
740
728
  } & {
741
729
  [key: string]: unknown;
742
730
  };
@@ -869,8 +857,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
869
857
  blockType?: string | undefined;
870
858
  size?: string | number | undefined;
871
859
  verticalResponsiveness?: boolean | undefined;
872
- isPriceMovedToNextLine?: boolean | undefined;
873
- isPriceDeletedForZeroSale?: boolean | undefined;
874
860
  } & {
875
861
  [key: string]: unknown;
876
862
  };
@@ -1003,8 +989,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1003
989
  blockType?: string | undefined;
1004
990
  size?: string | number | undefined;
1005
991
  verticalResponsiveness?: boolean | undefined;
1006
- isPriceMovedToNextLine?: boolean | undefined;
1007
- isPriceDeletedForZeroSale?: boolean | undefined;
1008
992
  } & {
1009
993
  [key: string]: unknown;
1010
994
  };
@@ -1137,8 +1121,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1137
1121
  blockType?: string | undefined;
1138
1122
  size?: string | number | undefined;
1139
1123
  verticalResponsiveness?: boolean | undefined;
1140
- isPriceMovedToNextLine?: boolean | undefined;
1141
- isPriceDeletedForZeroSale?: boolean | undefined;
1142
1124
  } & {
1143
1125
  [key: string]: unknown;
1144
1126
  };
@@ -1271,8 +1253,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1271
1253
  blockType?: string | undefined;
1272
1254
  size?: string | number | undefined;
1273
1255
  verticalResponsiveness?: boolean | undefined;
1274
- isPriceMovedToNextLine?: boolean | undefined;
1275
- isPriceDeletedForZeroSale?: boolean | undefined;
1276
1256
  } & {
1277
1257
  [key: string]: unknown;
1278
1258
  };
@@ -1405,8 +1385,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1405
1385
  blockType?: string | undefined;
1406
1386
  size?: string | number | undefined;
1407
1387
  verticalResponsiveness?: boolean | undefined;
1408
- isPriceMovedToNextLine?: boolean | undefined;
1409
- isPriceDeletedForZeroSale?: boolean | undefined;
1410
1388
  } & {
1411
1389
  [key: string]: unknown;
1412
1390
  };
@@ -1539,8 +1517,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1539
1517
  blockType?: string | undefined;
1540
1518
  size?: string | number | undefined;
1541
1519
  verticalResponsiveness?: boolean | undefined;
1542
- isPriceMovedToNextLine?: boolean | undefined;
1543
- isPriceDeletedForZeroSale?: boolean | undefined;
1544
1520
  } & {
1545
1521
  [key: string]: unknown;
1546
1522
  };
@@ -1673,8 +1649,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1673
1649
  blockType?: string | undefined;
1674
1650
  size?: string | number | undefined;
1675
1651
  verticalResponsiveness?: boolean | undefined;
1676
- isPriceMovedToNextLine?: boolean | undefined;
1677
- isPriceDeletedForZeroSale?: boolean | undefined;
1678
1652
  } & {
1679
1653
  [key: string]: unknown;
1680
1654
  };
@@ -1807,8 +1781,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1807
1781
  blockType?: string | undefined;
1808
1782
  size?: string | number | undefined;
1809
1783
  verticalResponsiveness?: boolean | undefined;
1810
- isPriceMovedToNextLine?: boolean | undefined;
1811
- isPriceDeletedForZeroSale?: boolean | undefined;
1812
1784
  } & {
1813
1785
  [key: string]: unknown;
1814
1786
  };
@@ -1941,8 +1913,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1941
1913
  blockType?: string | undefined;
1942
1914
  size?: string | number | undefined;
1943
1915
  verticalResponsiveness?: boolean | undefined;
1944
- isPriceMovedToNextLine?: boolean | undefined;
1945
- isPriceDeletedForZeroSale?: boolean | undefined;
1946
1916
  } & {
1947
1917
  [key: string]: unknown;
1948
1918
  };
@@ -2075,8 +2045,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2075
2045
  blockType?: string | undefined;
2076
2046
  size?: string | number | undefined;
2077
2047
  verticalResponsiveness?: boolean | undefined;
2078
- isPriceMovedToNextLine?: boolean | undefined;
2079
- isPriceDeletedForZeroSale?: boolean | undefined;
2080
2048
  } & {
2081
2049
  [key: string]: unknown;
2082
2050
  };
@@ -2209,8 +2177,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2209
2177
  blockType?: string | undefined;
2210
2178
  size?: string | number | undefined;
2211
2179
  verticalResponsiveness?: boolean | undefined;
2212
- isPriceMovedToNextLine?: boolean | undefined;
2213
- isPriceDeletedForZeroSale?: boolean | undefined;
2214
2180
  } & {
2215
2181
  [key: string]: unknown;
2216
2182
  };
@@ -2343,8 +2309,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2343
2309
  blockType?: string | undefined;
2344
2310
  size?: string | number | undefined;
2345
2311
  verticalResponsiveness?: boolean | undefined;
2346
- isPriceMovedToNextLine?: boolean | undefined;
2347
- isPriceDeletedForZeroSale?: boolean | undefined;
2348
2312
  } & {
2349
2313
  [key: string]: unknown;
2350
2314
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.7.0-beta.24bdfa3",
3
+ "version": "3.7.0-beta.340a6d3",
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,100 +0,0 @@
1
- import { BLOCK_ROOT_SELECTOR as S, CURRENCY_ATTR as d, CONTAINER_SELECTOR as f } from "../extensions/Blocks/Recommendation/constants/selectors.js";
2
- import { useRecommendationExtensionStore as O } from "../extensions/Blocks/Recommendation/store/recommendation.js";
3
- import { formatPrice as g } from "../extensions/Blocks/Recommendation/utils/priceFormatter.js";
4
- const p = `${S}[recommendation-id]`, R = ".product-old-price", C = /\{\{(?:reco_)?(\d+_\d+_[a-zA-Z0-9_.]+)\}\}/g, h = new RegExp(
5
- "\\{%\\s*if\\s+([\\s\\S]+?)\\s*%\\}([\\s\\S]*?)(?:\\{%\\s*else\\s*%\\}([\\s\\S]*?))?\\{%\\s*endif\\s*%\\}",
6
- "g"
7
- );
8
- function T(e) {
9
- const t = e.getAttribute(d.CURRENCY) || "USD", i = e.getAttribute(d.DECIMAL_SEPARATOR) || ".", s = e.getAttribute(d.THOUSAND_SEPARATOR) || ",";
10
- return {
11
- code: t,
12
- symbol: e.getAttribute(d.SYMBOL) || t,
13
- alignment: e.getAttribute(d.ALIGNMENT) === "0" ? "before" : "after",
14
- decimalCount: parseInt(e.getAttribute(d.DECIMAL_COUNT) || "2") || 2,
15
- decimalSeparator: i,
16
- thousandSeparator: s
17
- };
18
- }
19
- function _(e, t) {
20
- return (e == null ? void 0 : e[t]) ?? Object.values(e ?? {})[0] ?? 0;
21
- }
22
- function b(e, t) {
23
- const i = _(e.original_price, t), s = _(e.price, t), n = i > 0 ? Math.round((i - s) / i * 100) : 0;
24
- return n > 0 ? `${n}%` : "0%";
25
- }
26
- function N(e, t, i, s, n, a) {
27
- s.forEach((o, c) => {
28
- const r = (m) => `${i}_${c}_${m}`, u = g({ price: _(o.price, n.code), currency: n }), l = g({ price: _(o.original_price, n.code), currency: n }), A = b(o, n.code);
29
- e.set(r("name"), o.name ?? ""), e.set(r("image_url"), o.image_url ?? ""), e.set(r("url"), o.url ?? ""), e.set(r("item_id"), o.item_id ?? ""), e.set(r("currency"), ""), e.set(r("price"), u), e.set(r("original_price"), l), e.set(r("discount"), A), e.set(r("omnibus_price"), l), e.set(r("omnibus_discount"), A), a && u === l && t.add(`${i}_${c}`), Object.entries(o.product_attributes ?? {}).forEach(([m, E]) => {
30
- e.set(r(`product_attribute.${m}`), String(E)), e.set(r(m), String(E));
31
- });
32
- });
33
- }
34
- function L(e, t) {
35
- const i = e.match(/^(.+?)\s*(!=|==)\s*"([^"]*)"$/);
36
- if (!i)
37
- return !0;
38
- const [, s, n, a] = i, o = t.get(s.trim()) ?? "";
39
- return n === "!=" ? o !== a : o === a;
40
- }
41
- function P(e, t) {
42
- return e.replace(
43
- h,
44
- (i, s, n, a) => s.split(/\s+and\s+/).every((c) => L(c.trim(), t)) ? n : a ?? ""
45
- );
46
- }
47
- function $(e) {
48
- let t = e;
49
- for (; t.children.length === 1; )
50
- [t] = t.children;
51
- return t;
52
- }
53
- function D(e, t) {
54
- var o;
55
- if (!t.size)
56
- return e;
57
- const i = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), s = new DOMParser().parseFromString(i, "text/html");
58
- s.querySelectorAll(p).forEach((c) => {
59
- const r = Number(c.getAttribute("recommendation-id"));
60
- if (!Number.isFinite(r))
61
- return;
62
- const u = c.querySelectorAll(f);
63
- (u.length ? Array.from(u) : [c]).forEach((A) => {
64
- A.querySelectorAll(R).forEach((m, E) => {
65
- t.has(`${r}_${E}`) && ($(m).textContent = "");
66
- });
67
- });
68
- });
69
- const n = (o = e.match(/<!DOCTYPE[^>]*>/i)) == null ? void 0 : o[0];
70
- return ((n ? `${n}
71
- ` : "") + s.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
72
- }
73
- function I(e) {
74
- if (!e || !e.includes("recommendation-block-v2"))
75
- return e;
76
- const t = O(), i = new DOMParser().parseFromString(e, "text/html"), s = Array.from(i.querySelectorAll(p)), n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
77
- if (s.forEach((c) => {
78
- var l;
79
- const r = Number(c.getAttribute("recommendation-id"));
80
- if (!Number.isFinite(r))
81
- return;
82
- const u = ((l = t.blockStates[r]) == null ? void 0 : l.recommendationProducts) ?? [];
83
- u.length && N(
84
- n,
85
- a,
86
- r,
87
- u,
88
- T(c),
89
- c.getAttribute("hide-price") === "true"
90
- );
91
- }), !n.size)
92
- return e;
93
- let o = D(e, a);
94
- return o = o.replace(C, (c, r) => n.has(r) ? n.get(r) : c), o = P(o, n), o;
95
- }
96
- const x = () => ({ substituteRecommendationPreview: I });
97
- export {
98
- I as substituteRecommendationPreview,
99
- x as useRecommendationPreview
100
- };
@@ -1,133 +0,0 @@
1
- var m = Object.defineProperty;
2
- var p = (i, o, e) => o in i ? m(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
- var d = (i, o, e) => p(i, typeof o != "symbol" ? o + "" : o, e);
4
- import { UEAttr as u, ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as f } from "../../../common-control.js";
6
- import { ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OLD_PRICE as I } from "../../constants/selectors.js";
7
- import { RecommendationConfigService as n } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
9
- import { getBlockElement as l, regenerateProductRowsWithStyles as g } from "./utils.js";
10
- const E = "recommendation-price-placement-control", N = "hide-price", r = {
11
- ORIENTATION: "priceOrientation",
12
- HIDE_IF_SAME: "priceHideIfSameAsDiscounted"
13
- }, A = [
14
- { icon: "vertical-orientation", value: "vertical" },
15
- { icon: "horizontal-orientation", value: "horizontal" }
16
- ], C = (i) => i ? "vertical" : "horizontal";
17
- class P extends f {
18
- constructor() {
19
- super(...arguments);
20
- d(this, "store", T());
21
- }
22
- getId() {
23
- return E;
24
- }
25
- getTemplate() {
26
- return `
27
- <div class="price-placement-control-container" style="border-bottom: 1px solid #e0e0e0;">
28
- ${this._GuTwoColumns([
29
- this._GuLabel({ text: this.api.translate("Product Price Orientation") }),
30
- this._GuRadioButton({
31
- name: r.ORIENTATION,
32
- buttons: A
33
- })
34
- ])}
35
- ${this._GuTwoColumns([
36
- this._GuLabel({ text: this.api.translate("Hide if same as discounted") }),
37
- this._GuToggle(r.HIDE_IF_SAME)
38
- ])}
39
- </div>
40
- `;
41
- }
42
- onRender() {
43
- const e = n.getConfig(this.currentNode);
44
- this._initializeHideToggle(e), this._setFormValues(e), this._updateOrientationDisabled(), this._listenToFormUpdates();
45
- }
46
- onTemplateNodeUpdated(e) {
47
- super.onTemplateNodeUpdated(e), this._setFormValues(n.getConfig(this.currentNode)), this._updateOrientationDisabled();
48
- }
49
- _setFormValues(e) {
50
- this.api.updateValues({
51
- [r.ORIENTATION]: C(e.priceMovedToNextLine),
52
- [r.HIDE_IF_SAME]: e.priceHideIfSameAsDiscounted
53
- });
54
- }
55
- _initializeHideToggle(e) {
56
- this.api.setUIEAttribute(
57
- r.HIDE_IF_SAME,
58
- u.SELECTPICKER.items,
59
- e.priceHideIfSameAsDiscounted
60
- );
61
- }
62
- /**
63
- * Disables the orientation radio when a price element is hidden via Card
64
- * Composition — orientation is meaningless without both prices visible.
65
- * Visibility lives on the attribute rows' `data-visibility` (set by the Card
66
- * Composition control). Inline mode has no standalone original-price row, so
67
- * the merged "Product Prices" entry (the price row) governs.
68
- */
69
- _updateOrientationDisabled() {
70
- const e = l(this.currentNode);
71
- if (!e || !("querySelectorAll" in e))
72
- return;
73
- const s = Array.from(
74
- e.querySelectorAll(".recommendation-attribute-row[data-attribute-type]")
75
- ).some((a) => {
76
- const c = a.getAttribute("data-attribute-type");
77
- return (c === _ || c === I) && a.getAttribute("data-visibility") === "0";
78
- });
79
- this.api.setUIEAttribute(
80
- r.ORIENTATION,
81
- u.RADIO_BUTTONS.disabled,
82
- s ? "true" : "false"
83
- );
84
- }
85
- _onOrientationChange(e) {
86
- if (!this.currentNode)
87
- return;
88
- const t = e === "vertical";
89
- n.getConfig(this.currentNode).priceMovedToNextLine !== t && (n.updateConfig(
90
- this.api,
91
- this.currentNode,
92
- { priceMovedToNextLine: t },
93
- `${t ? "Stacked" : "Inlined"} recommendation prices`
94
- ), this.store.patchCurrentBlockConfig({ priceMovedToNextLine: t }), this._regenerate());
95
- }
96
- _onHideIfSameChange(e) {
97
- !this.currentNode || n.getConfig(this.currentNode).priceHideIfSameAsDiscounted === e || (n.updateConfig(
98
- this.api,
99
- this.currentNode,
100
- { priceHideIfSameAsDiscounted: e },
101
- `${e ? "Enabled" : "Disabled"} hide-if-same price`
102
- ), this.store.patchCurrentBlockConfig({ priceHideIfSameAsDiscounted: e }), this._stampHideIfSameAttr(e));
103
- }
104
- /**
105
- * Mirrors the hide-if-same flag onto the durable `hide-price` block attribute
106
- * read by email-service at send time.
107
- */
108
- _stampHideIfSameAttr(e) {
109
- const t = l(this.currentNode);
110
- t && this.api.getDocumentModifier().modifyHtml(t).setAttribute(N, String(e)).apply(new h("Update hide-if-same price flag"));
111
- }
112
- /**
113
- * Rebuilds the product rows so the renderer re-reads the inline/stacked
114
- * layout flag from the store. Used by the orientation change only.
115
- */
116
- _regenerate() {
117
- this.currentNode && g({
118
- currentNode: this.currentNode,
119
- documentModifier: this.api.getDocumentModifier()
120
- });
121
- }
122
- _listenToFormUpdates() {
123
- this.api.onValueChanged(r.ORIENTATION, (e) => {
124
- (e === "vertical" || e === "horizontal") && this._onOrientationChange(e);
125
- }), this.api.onValueChanged(r.HIDE_IF_SAME, (e) => {
126
- this._onHideIfSameChange(!!e);
127
- });
128
- }
129
- }
130
- export {
131
- E as PRICE_PLACEMENT_CONTROL_ID,
132
- P as PricePlacementControl
133
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * Substitutes recommendation product variables in compiled preview HTML with the
3
- * blocks' fetched sample products, then simulates the email-service hide rule by
4
- * emptying the original-price cell (DOM kept) for slots with no real discount.
5
- * Returns the input unchanged when there are no reco blocks or no products.
6
- */
7
- export declare function substituteRecommendationPreview(html: string): string;
8
- export declare const useRecommendationPreview: () => {
9
- substituteRecommendationPreview: typeof substituteRecommendationPreview;
10
- };