@useinsider/guido 2.1.0-beta.7d0f92a → 2.1.0-beta.860ef21

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 (132) hide show
  1. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +14 -15
  2. package/dist/composables/useHtmlValidator.js +84 -106
  3. package/dist/composables/useRecommendation.js +21 -54
  4. package/dist/config/compiler/recommendationCompilerRules.js +39 -45
  5. package/dist/config/migrator/recommendationMigrator.js +2 -2
  6. package/dist/enums/extensions/recommendationBlock.js +1 -1
  7. package/dist/enums/recommendation.js +15 -16
  8. package/dist/extensions/Blocks/Recommendation/block.js +9 -130
  9. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +187 -0
  10. package/dist/extensions/Blocks/Recommendation/constants.js +13 -0
  11. package/dist/extensions/Blocks/Recommendation/control.js +336 -0
  12. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
  13. package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
  14. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
  15. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textAfter.js → omnibusDiscountTextAfterControl.js} +14 -16
  16. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textBefore.js → omnibusDiscountTextBeforeControl.js} +14 -16
  17. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textAfter.js → omnibusPriceTextAfterControl.js} +14 -16
  18. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textBefore.js → omnibusPriceTextBeforeControl.js} +12 -14
  19. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
  20. package/dist/extensions/Blocks/Recommendation/extension.js +17 -40
  21. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +3 -19
  22. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -13
  23. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +10 -21
  24. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +193 -230
  25. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +181 -0
  26. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +189 -0
  27. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +209 -0
  28. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  29. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +15 -26
  30. package/dist/extensions/Blocks/controlFactories.js +93 -125
  31. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +169 -223
  32. package/dist/services/recommendationApi.js +9 -10
  33. package/dist/services/templateLibraryApi.js +13 -16
  34. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  35. package/dist/src/composables/useRecommendation.d.ts +0 -1
  36. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -67
  37. package/dist/src/extensions/Blocks/Recommendation/{controls/cardComposition/index.d.ts → cardCompositionControl.d.ts} +3 -23
  38. package/dist/src/extensions/Blocks/Recommendation/{constants/controlIds.d.ts → constants.d.ts} +24 -0
  39. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +38 -0
  40. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +589 -21
  41. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
  42. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -9
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +468 -131
  44. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +16 -0
  45. package/dist/src/extensions/Blocks/Recommendation/templates/{grid/migration.d.ts → migrationTemplate.d.ts} +4 -11
  46. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +52 -0
  47. package/dist/static/styles/components/notification.css.js +1 -0
  48. package/dist/static/styles/components/wide-panel.css.js +15 -0
  49. package/dist/static/styles/customEditorStyle.css.js +2 -25
  50. package/dist/utils/pairProductVariables.js +56 -57
  51. package/dist/utils/templatePreparation.js +14 -15
  52. package/package.json +2 -2
  53. package/dist/config/compiler/utils/recommendationCompilerUtils.js +0 -116
  54. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +0 -4
  55. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +0 -4
  56. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +0 -65
  57. package/dist/extensions/Blocks/Recommendation/constants/layout.js +0 -20
  58. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +0 -19
  59. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +0 -64
  60. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +0 -80
  61. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +0 -232
  62. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +0 -19
  63. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +0 -92
  64. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +0 -102
  65. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +0 -209
  66. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +0 -52
  67. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +0 -217
  68. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +0 -70
  69. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +0 -110
  70. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +0 -67
  71. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -286
  72. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +0 -46
  73. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +0 -108
  74. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +0 -44
  75. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +0 -48
  76. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +0 -48
  77. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +0 -44
  78. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +0 -222
  79. package/dist/extensions/Blocks/Recommendation/services/configService.js +0 -240
  80. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +0 -233
  81. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  82. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +0 -69
  83. package/dist/extensions/Blocks/Recommendation/templates/index.js +0 -12
  84. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +0 -174
  85. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +0 -73
  86. package/dist/extensions/Blocks/Recommendation/templates/utils.js +0 -122
  87. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +0 -6
  88. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -29
  89. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +0 -46
  90. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +0 -17
  91. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +0 -13
  92. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -49
  93. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +0 -13
  94. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +0 -35
  95. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -31
  96. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -143
  97. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -31
  98. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -35
  99. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +0 -37
  100. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +0 -29
  101. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +0 -52
  102. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +0 -22
  103. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -68
  104. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +0 -24
  105. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -42
  106. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +0 -23
  107. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -214
  108. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -97
  109. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +0 -34
  110. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -95
  111. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -100
  112. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +0 -15
  113. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +0 -15
  114. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -100
  115. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +0 -15
  116. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +0 -15
  117. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -95
  118. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -83
  119. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -151
  120. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +0 -6
  121. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -20
  122. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +0 -33
  123. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +0 -39
  124. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -8
  125. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +0 -25
  126. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +0 -18
  127. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -57
  128. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +0 -7
  129. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -160
  130. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -33
  131. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
  132. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +0 -77
@@ -1,151 +0,0 @@
1
- /**
2
- * Recommendation Config Service
3
- *
4
- * Service for managing Recommendation block configuration via Stripo's node config API.
5
- * This replaces the Pinia store for persistent configuration data.
6
- *
7
- * Key features:
8
- * - Reads/writes config to/from node using `getNodeConfig`/`setNodeConfig`
9
- * - Configuration persists with the template HTML
10
- * - Each block has independent configuration (no global state)
11
- * - Integrates with Stripo's undo/redo via `ModificationDescription`
12
- *
13
- * Usage pattern similar to legacy `blockConfigurationService`:
14
- * @example
15
- * // Read config
16
- * const config = RecommendationConfigService.getConfig(node);
17
- * // Update config
18
- * RecommendationConfigService.updateConfig(api, node, { strategy: 'mostPopular' }, 'Changed algorithm');
19
- * @see https://plugin.stripo.email/extensions/reference/blocks/Block
20
- */
21
- import type { RecommendationNodeConfig, PartialNodeConfig } from '../types/nodeConfig';
22
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
23
- import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
24
- /**
25
- * Stripo Extension API interface for document modifications
26
- * Extracted to allow type-safe usage without importing full Stripo types
27
- */
28
- interface DocumentModifier {
29
- modifyHtml: (node: ImmutableHtmlNode) => {
30
- setNodeConfig: (config: Record<string, unknown>) => DocumentModifier;
31
- setAttribute: (name: string, value: string) => DocumentModifier;
32
- setStyle: (prop: string, value: string) => DocumentModifier;
33
- setInnerHtml: (html: string) => DocumentModifier;
34
- };
35
- apply: (desc: ModificationDescription) => void;
36
- }
37
- interface DocumentModifierApi {
38
- getDocumentModifier: () => DocumentModifier;
39
- }
40
- /**
41
- * Service for managing Recommendation block configuration
42
- *
43
- * All methods are static for easy usage without instantiation.
44
- * The service follows the same patterns as the legacy `blockConfigurationService`.
45
- */
46
- export declare class RecommendationConfigService {
47
- /**
48
- * Get configuration from a node, with defaults for missing values
49
- *
50
- * This is the primary way to read configuration from a block.
51
- * Always returns a complete config object with defaults merged in.
52
- * @example
53
- * const config = RecommendationConfigService.getConfig(this.currentNode);
54
- * console.log(config.strategy); // 'mostPopular'
55
- * @param node - The immutable HTML node to read config from
56
- * @returns Complete configuration with defaults for missing values
57
- */
58
- static getConfig(node: ImmutableHtmlNode | null | undefined): RecommendationNodeConfig;
59
- /**
60
- * Check if a node has valid configuration stored
61
- *
62
- * Used for migration detection - returns false for legacy templates
63
- * that need their configuration migrated.
64
- * @param node - The immutable HTML node to check
65
- * @returns True if node has valid config with version number
66
- */
67
- static hasConfig(node: ImmutableHtmlNode | null | undefined): boolean;
68
- /**
69
- * Get the configuration version from a node
70
- * @param node - The immutable HTML node to check
71
- * @returns Config version number, or 0 if no config exists
72
- */
73
- static getConfigVersion(node: ImmutableHtmlNode | null | undefined): number;
74
- /**
75
- * Update specific configuration values
76
- *
77
- * Merges the updates with existing config and persists to node.
78
- * This is the primary way to update configuration from controls.
79
- * @example
80
- * RecommendationConfigService.updateConfig(
81
- * this.api,
82
- * this.currentNode,
83
- * { strategy: 'complementaryItems' },
84
- * 'Changed recommendation algorithm'
85
- * );
86
- * @param api - Stripo extension API with document modifier
87
- * @param node - The immutable HTML node to update
88
- * @param updates - Partial config with values to update
89
- * @param description - Human-readable description for undo/redo
90
- * @returns The new complete configuration
91
- */
92
- static updateConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, updates: PartialNodeConfig, description: string): RecommendationNodeConfig;
93
- /**
94
- * Initialize configuration for a new block
95
- *
96
- * Called when a block is first created (dropped into template).
97
- * Can optionally merge in partial config from migration.
98
- * @example
99
- * // In Block.onCreated lifecycle
100
- * RecommendationConfigService.initializeConfig(this.api, node);
101
- * @param api - Stripo extension API with document modifier
102
- * @param node - The immutable HTML node to initialize
103
- * @param partialConfig - Optional partial config to merge with defaults
104
- * @returns The initialized configuration
105
- */
106
- static initializeConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, partialConfig?: PartialNodeConfig): RecommendationNodeConfig;
107
- /**
108
- * Save complete configuration to a node
109
- *
110
- * Low-level method - prefer `updateConfig` or `initializeConfig` in most cases.
111
- * @param api - Stripo extension API with document modifier
112
- * @param node - The immutable HTML node to save to
113
- * @param config - Complete configuration to save
114
- * @param description - Human-readable description for undo/redo
115
- */
116
- static saveConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, config: RecommendationNodeConfig, description: string): void;
117
- /**
118
- * Migrate configuration from legacy data-attributes
119
- *
120
- * Reads existing data-attributes and creates a proper node config.
121
- * Used when loading templates created before node config was implemented.
122
- * @param api - Stripo extension API with document modifier
123
- * @param node - The block node to migrate
124
- * @returns The migrated configuration
125
- */
126
- static migrateFromDataAttributes(api: DocumentModifierApi, node: ImmutableHtmlNode): RecommendationNodeConfig;
127
- /**
128
- * Check if configuration needs migration
129
- * @param node - The block node to check
130
- * @returns True if migration is needed
131
- */
132
- static needsMigration(node: ImmutableHtmlNode | null | undefined): boolean;
133
- /**
134
- * Clone default config to avoid mutations
135
- */
136
- private static cloneDefaults;
137
- /**
138
- * Merge partial config with defaults
139
- *
140
- * Deep merges nested objects like currency, omnibus settings.
141
- */
142
- private static mergeWithDefaults;
143
- /**
144
- * Deep merge for nested objects
145
- *
146
- * Recursively merges source into target, preserving existing values
147
- * that aren't explicitly overwritten.
148
- */
149
- private static deepMerge;
150
- }
151
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Recommendation Extension Services
3
- *
4
- * This module re-exports all services for the Recommendation extension.
5
- */
6
- export { RecommendationConfigService } from './configService';
@@ -1,20 +0,0 @@
1
- import type { ElementRenderer } from '../utils';
2
- /**
3
- * Grid element renderer
4
- * Each element returns a `<td>` containing a nested table structure:
5
- * - Outer `<td>` has padding for column spacing
6
- * - Inner `<table class="product-card-segment">` supports background color
7
- * - Content is inside the inner table
8
- *
9
- * This structure allows:
10
- * 1. Row-based alignment (all same attributes in one row)
11
- * 2. Per-card background color via inner table
12
- * 3. Column spacing via outer cell padding
13
- */
14
- export declare const DEFAULT_CELL_PADDING = "0 5px";
15
- /**
16
- * Class name for outer cells in attribute rows
17
- * Used by controls to reliably select direct children for spacing adjustments
18
- */
19
- export declare const ATTRIBUTE_CELL_CLASS = "attribute-cell";
20
- export declare const gridElementRenderer: ElementRenderer;
@@ -1,33 +0,0 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
2
- import { type ElementRenderer } from '../utils';
3
- /**
4
- * Generates attribute-aligned product rows for grid layout.
5
- * Creates rows where each row contains one attribute type from all products.
6
- * @param products - Array of products in this row group
7
- * @param productsPerRow - Number of products per row (for column width calculation)
8
- * @param elementRenderer - Object mapping attribute types to render functions
9
- * @param composition - Array defining order of card elements
10
- * @returns HTML string for attribute-aligned rows
11
- */
12
- export declare function prepareGridAttributeRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[]): string;
13
- /**
14
- * Prepares grid product rows with attribute-aligned structure
15
- * Groups products into rows, then generates attribute-aligned HTML for each group
16
- * @param products - Array of products to display
17
- * @param productsPerRow - Number of products per row
18
- * @param elementRenderer - Object mapping attribute types to render functions
19
- * @param composition - Array defining order of card elements
20
- * @returns HTML string for all product rows
21
- */
22
- export declare function prepareGridProductRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[]): string;
23
- /**
24
- * Prepares grid product rows with attribute-aligned structure.
25
- * Uses row-based rendering where each attribute type forms a single row across all products.
26
- * @param products - Array of products to display
27
- * @param productsPerRow - Number of products per row
28
- * @param composition - Array defining element order
29
- * @returns HTML string for product rows
30
- */
31
- export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[]): string;
32
- export declare function getDefaultTemplate(recommendationId?: number): string;
33
- export declare function generateBlockTemplate(products: RecommendationProduct[], productsPerRow: number, title?: string, composition?: string[]): string;
@@ -1,39 +0,0 @@
1
- /**
2
- * Unified Template API for Recommendation Block
3
- *
4
- * This module provides a single entry point for working with recommendation
5
- * block templates, abstracting away the layout-specific implementations.
6
- */
7
- import type { RecommendationProduct } from '@@/Types/recommendation';
8
- import { type Orientation, type PrepareProductRowsOptions } from './utils';
9
- export { DEFAULTS, DEFAULT_CARD_COMPOSITION, DEFAULT_CARD_VISIBILITY, getDefaultProducts, spacer, sanitizeImageUrl, createBlockTemplate, type Orientation, type PrepareProductRowsOptions, type ElementRenderer, type ProductCardGetter, } from './utils';
10
- /**
11
- * Unified function to prepare product rows for any layout.
12
- * Delegates to the appropriate layout-specific implementation.
13
- * @example
14
- * // List layout (full-width rows)
15
- * prepareProductRows(products, 'list');
16
- * @example
17
- * // Grid layout
18
- * prepareProductRows(products, 'grid', { productsPerRow: 3 });
19
- * @param products - Array of products to display
20
- * @param layout - The layout orientation ('list' or 'grid')
21
- * @param options - Layout-specific options
22
- * @returns HTML string for product rows
23
- */
24
- export declare function prepareProductRows(products: RecommendationProduct[], layout: Orientation, options?: PrepareProductRowsOptions): string;
25
- /**
26
- * Generates the default template for a given layout.
27
- * @param layout - The layout orientation ('list' or 'grid')
28
- * @returns Complete HTML template with default products
29
- */
30
- export declare function getDefaultTemplate(layout?: Orientation): string;
31
- /**
32
- * Generates a complete block template with custom products.
33
- * @param products - Array of products to display
34
- * @param layout - The layout orientation ('list' or 'grid')
35
- * @param title - Title for the block
36
- * @param options - Layout-specific options
37
- * @returns Complete HTML template
38
- */
39
- export declare function generateBlockTemplate(products: RecommendationProduct[], layout: Orientation, title?: string, options?: PrepareProductRowsOptions): string;
@@ -1,8 +0,0 @@
1
- import type { ElementRenderer } from '../utils';
2
- /**
3
- * List element renderer
4
- * - Image and Button return `<td>` cells for the 3-column layout
5
- * - Name and Prices return `<tr><td>` rows for the info cell table
6
- * All elements have esd-block-* classes for Stripo selection
7
- */
8
- export declare const listElementRenderer: ElementRenderer;
@@ -1,25 +0,0 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
2
- import { DEFAULTS, getDefaultProducts } from '../utils';
3
- /**
4
- * Migration template for list layout
5
- * Used when migrating old recommendation blocks to list format
6
- */
7
- declare const migrationTemplate = "\n <td\n align=\"left\"\n esd-extension-block-id=\"recommendation-block\"\n esd-handler-name=\"esd-extension-RecommendationBlock\"\n class=\"ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20\"\n data-layout=\"list\"\n >\n <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tr>\n <td align=\"center\">\n <table\n class=\"container\"\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\"\n border=\"0\">\n <tbody>\n <tr>\n <td>\n <table\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\"\n border=\"0\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n <tr>\n <td class=\"spacer\" style=\"height: 20px;\"></td>\n </tr>\n <tr>\n <td>\n <table\n class=\"ins-recommendation-product-container\"\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\"\n border=\"0\"\n >\n {-{-PRODUCT_ROWS-}-}\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n </table>\n </td>\n";
8
- export declare function getMigrationTemplate(): string;
9
- /**
10
- * Generates a custom list migration template with specified products
11
- * @param products - Array of products to display
12
- * @param title - Optional title for the block
13
- * @param composition - Optional array defining order of card elements
14
- * @returns Complete HTML template
15
- */
16
- export declare function generateMigrationTemplate(products: RecommendationProduct[], title?: string, composition?: string[]): string;
17
- /**
18
- * Prepares list product rows for migration
19
- * @param products - Array of products to display
20
- * @param composition - Optional array defining order of card elements
21
- * @returns HTML string for product rows
22
- */
23
- export declare function prepareProductRows(products: RecommendationProduct[], composition?: string[]): string;
24
- export { DEFAULTS, getDefaultProducts };
25
- export default migrationTemplate;
@@ -1,18 +0,0 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
2
- /**
3
- * Generates a list product card with 3-column layout
4
- * Uses listElementRenderer to render Image, Info content, and Button
5
- * Layout: [Image (120px)] [Info table (flexible)] [Button (100px)]
6
- * @param product - The product data
7
- * @returns HTML string for a single product card row
8
- */
9
- export declare function getListProductCard(product: RecommendationProduct): string;
10
- /**
11
- * Prepares list product rows
12
- * Each product is a full-width row with 3-column layout
13
- * @param products - Array of products to display
14
- * @returns HTML string for product rows
15
- */
16
- export declare function prepareProductRows(products: RecommendationProduct[]): string;
17
- export declare function getDefaultTemplate(): string;
18
- export declare function generateBlockTemplate(products: RecommendationProduct[], title?: string): string;
@@ -1,57 +0,0 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
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';
3
- export type Orientation = 'list' | 'grid';
4
- /**
5
- * Options for prepareProductRows unified function
6
- */
7
- export interface PrepareProductRowsOptions {
8
- /** Number of products per row (only for grid layout, defaults to 3) */
9
- productsPerRow?: number;
10
- /** Array defining order of card elements */
11
- composition?: string[];
12
- }
13
- /**
14
- * Element renderer interface for product card elements
15
- * Keys are ATTR_PRODUCT_* constants for consistent naming
16
- */
17
- export interface ElementRenderer {
18
- [ATTR_PRODUCT_IMAGE]: (product: RecommendationProduct) => string;
19
- [ATTR_PRODUCT_NAME]: (product: RecommendationProduct) => string;
20
- [ATTR_PRODUCT_PRICE]: (product: RecommendationProduct) => string;
21
- [ATTR_PRODUCT_OLD_PRICE]: (product: RecommendationProduct) => string;
22
- [ATTR_PRODUCT_OMNIBUS_PRICE]: (product: RecommendationProduct) => string;
23
- [ATTR_PRODUCT_OMNIBUS_DISCOUNT]: (product: RecommendationProduct) => string;
24
- [ATTR_PRODUCT_BUTTON]: (product: RecommendationProduct) => string;
25
- }
26
- /**
27
- * Product card getter function type
28
- * Used by prepareProductRows to generate individual product cards
29
- */
30
- export type ProductCardGetter = (product: RecommendationProduct, composition?: string[]) => string;
31
- export declare const DEFAULTS: {
32
- TITLE: string;
33
- DESCRIPTION: string;
34
- };
35
- export declare const DEFAULT_CARD_COMPOSITION: string[];
36
- export declare const DEFAULT_CARD_VISIBILITY: Record<string, boolean>;
37
- export declare const spacer = "\n <tr>\n <td class=\"spacer\" style=\"height: 10px;\"></td>\n </tr>\n";
38
- export declare const PLACEHOLDER_IMAGE = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
39
- /**
40
- * Sanitizes product image URLs for consistent rendering
41
- * - Converts http:// to https:// to avoid mixed content issues
42
- * - Returns placeholder for invalid/empty URLs
43
- * @param url - The image URL to sanitize
44
- * @returns Sanitized HTTPS URL or placeholder
45
- */
46
- export declare function sanitizeImageUrl(url: string | undefined | null): string;
47
- export declare function getDefaultProducts(): RecommendationProduct[];
48
- /**
49
- * Creates the block template wrapper HTML for recommendation blocks.
50
- * The template includes title placeholder and product container.
51
- * @param layout - The layout orientation ('list' or 'grid')
52
- * @param instanceClass - Optional instance-specific class (e.g., 'ins-recommendation-v3-block-1')
53
- * for CSS scoping per block instance. Must be included in the initial template HTML because
54
- * Stripo's Angular rendering manages the class attribute and overwrites dynamic setAttribute changes.
55
- * @returns HTML template string with {-{-TITLE-}-} and {-{-PRODUCT_ROWS-}-} placeholders
56
- */
57
- export declare function createBlockTemplate(layout?: Orientation, instanceClass?: string): string;
@@ -1,7 +0,0 @@
1
- /**
2
- * Recommendation Extension Types
3
- *
4
- * This module re-exports all type definitions for the Recommendation extension.
5
- */
6
- export type { RecommendationNodeConfig, CurrencyConfig, OmnibusTextConfig, PartialNodeConfig, DeepPartialNodeConfig, } from './nodeConfig';
7
- export { isValidNodeConfig, hasMinimalConfig, } from './nodeConfig';
@@ -1,160 +0,0 @@
1
- /**
2
- * Node Configuration Types for Recommendation Block
3
- *
4
- * This module defines the TypeScript interfaces for configuration data
5
- * stored via Stripo's `setNodeConfig`/`getNodeConfig` APIs.
6
- *
7
- * The configuration persists with the template HTML, solving:
8
- * - Configuration loss on save/reload
9
- * - Multi-block independence
10
- * - Undo/redo integration
11
- * @see https://plugin.stripo.email/extensions/reference/blocks/Block
12
- */
13
- import type { Filter } from '@@/Types/recommendation';
14
- /**
15
- * Currency display and formatting settings
16
- */
17
- export interface CurrencyConfig {
18
- /** Currency code (e.g., 'USD', 'EUR', 'TRY') */
19
- code: string;
20
- /** Currency symbol (e.g., '$', '€', '₺') */
21
- symbol: string;
22
- /** Symbol position relative to price */
23
- alignment: 'before' | 'after';
24
- /** Number of decimal places (-1 for no formatting) */
25
- decimalCount: number;
26
- /** Character used for decimal separation */
27
- decimalSeparator: '.' | ',';
28
- /** Character used for thousands separation */
29
- thousandSeparator: '.' | ',' | ' ' | '';
30
- }
31
- /**
32
- * Configuration for omnibus price/discount text wrappers
33
- * Used to display EU Omnibus Directive compliant pricing
34
- */
35
- export interface OmnibusTextConfig {
36
- /** Text to prepend (e.g., 'Lowest 30-day price: ') */
37
- textBefore: string;
38
- /** Text to append */
39
- textAfter: string;
40
- }
41
- /**
42
- * Complete configuration schema for Recommendation Block
43
- *
44
- * This interface combines:
45
- * - Legacy `esd-dev-product-config` structure patterns
46
- * - Current data-attribute based settings
47
- * - Campaign data that was previously in Pinia store
48
- *
49
- * All properties are persisted with the template via `setNodeConfig`.
50
- */
51
- export interface RecommendationNodeConfig {
52
- /**
53
- * Recommendation algorithm/strategy
54
- * @example 'mostPopular', 'complementaryItems', 'manualMerchandising'
55
- */
56
- strategy: string;
57
- /**
58
- * Product IDs for manual merchandising strategy
59
- * Only used when strategy === 'manualMerchandising'
60
- */
61
- productIds: string[];
62
- /**
63
- * Number of products to fetch from API
64
- * Stored as string for consistency with API params
65
- */
66
- size: string;
67
- /**
68
- * Whether to randomize product order on each load
69
- */
70
- shuffleProducts: boolean;
71
- /**
72
- * Locale/language for product data
73
- * @example 'en_US', 'tr_TR', 'de_DE'
74
- */
75
- language: string;
76
- /**
77
- * Currency display and formatting configuration
78
- */
79
- currency: CurrencyConfig;
80
- /**
81
- * Product filters for narrowing recommendations
82
- * Uses existing Filter interface from recommendation types
83
- */
84
- filters: Filter[];
85
- /**
86
- * Layout orientation
87
- * - 'grid': Products in a grid, attributes aligned across products
88
- * - 'list': Products in rows, each product is a full-width card
89
- */
90
- layout: 'grid' | 'list';
91
- /**
92
- * Number of products per row (grid layout only)
93
- */
94
- cardsInRow: number;
95
- /**
96
- * Horizontal spacing between product cards in pixels (grid layout only)
97
- */
98
- columnSpacing: number;
99
- /**
100
- * Vertical spacing between product rows in pixels
101
- */
102
- rowSpacing: number;
103
- /**
104
- * Order of card elements from top to bottom
105
- * Array of ATTR_PRODUCT_* constants
106
- * @example ['productImage', 'productName', 'productPrice', 'productButton']
107
- */
108
- composition: string[];
109
- /**
110
- * Visibility flags for each card element
111
- * Keys are ATTR_PRODUCT_* constants
112
- */
113
- visibility: Record<string, boolean>;
114
- /**
115
- * Omnibus price text configuration
116
- * For EU Omnibus Directive compliance
117
- */
118
- omnibusPrice: OmnibusTextConfig;
119
- /**
120
- * Omnibus discount text configuration
121
- * For EU Omnibus Directive compliance
122
- */
123
- omnibusDiscount: OmnibusTextConfig;
124
- /**
125
- * Whether to trim long product names with ellipsis
126
- */
127
- textTrimming: boolean;
128
- /**
129
- * Configuration version for future migrations
130
- * Increment when making breaking changes to schema
131
- */
132
- configVersion: number;
133
- /**
134
- * Unique identifier for this recommendation block instance
135
- * Used to isolate per-block state in the Pinia store
136
- * 0 = not yet assigned (default for new/migrating blocks)
137
- */
138
- recommendationId: number;
139
- }
140
- /**
141
- * Partial configuration for updates
142
- * All fields are optional to support partial updates via `updateConfig`
143
- */
144
- export type PartialNodeConfig = Partial<RecommendationNodeConfig>;
145
- /**
146
- * Deep partial for nested objects
147
- */
148
- export type DeepPartialNodeConfig = {
149
- [K in keyof RecommendationNodeConfig]?: RecommendationNodeConfig[K] extends object ? Partial<RecommendationNodeConfig[K]> : RecommendationNodeConfig[K];
150
- };
151
- /**
152
- * Check if an object is a valid RecommendationNodeConfig
153
- * Used for migration detection and validation
154
- */
155
- export declare function isValidNodeConfig(obj: unknown): obj is RecommendationNodeConfig;
156
- /**
157
- * Check if a node config has the minimum required fields
158
- * Used to detect legacy templates that need migration
159
- */
160
- export declare function hasMinimalConfig(obj: unknown): boolean;
@@ -1,33 +0,0 @@
1
- /**
2
- * Price Formatting Utilities
3
- *
4
- * Provides functions for formatting prices according to currency settings.
5
- * Used to format prices displayed in recommendation product cards.
6
- */
7
- import type { CurrencyConfig } from '../types/nodeConfig';
8
- /**
9
- * Options for formatting a price
10
- */
11
- export interface FormatPriceOptions {
12
- /** The numeric price value */
13
- price: number;
14
- /** Currency configuration */
15
- currency: CurrencyConfig;
16
- }
17
- /**
18
- * Formats a numeric price according to currency settings
19
- * @example
20
- * // Returns: "$ 1,999.99"
21
- * formatPrice({ price: 1999.99, currency: currencyConfig })
22
- * @param options - Formatting options
23
- * @returns Formatted price string
24
- */
25
- export declare function formatPrice(options: FormatPriceOptions): string;
26
- /**
27
- * Parses a formatted price string back to a number
28
- * Useful for extracting numeric values from formatted price displays
29
- * @param formattedPrice - The formatted price string
30
- * @param currency - Currency configuration for parsing
31
- * @returns Parsed numeric value or NaN if parsing fails
32
- */
33
- export declare function parseFormattedPrice(formattedPrice: string, currency: CurrencyConfig): number;