@useinsider/guido 2.1.0-beta.febc521 → 2.1.0-beta.ff20f87
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.
- package/README.md +36 -0
- package/dist/@types/config/schemas.js +71 -66
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
- package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
- package/dist/composables/useActionsApi.js +15 -13
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useHtmlValidator.js +114 -104
- package/dist/composables/useRecommendation.js +54 -21
- package/dist/config/compiler/recommendationCompilerRules.js +45 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
- package/dist/config/migrator/itemsBlockMigrator.js +138 -117
- package/dist/config/migrator/recommendationMigrator.js +2 -2
- package/dist/enums/defaults.js +8 -4
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/enums/recommendation.js +16 -15
- package/dist/extensions/Blocks/Items/block.js +19 -28
- package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +137 -89
- package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
- package/dist/extensions/Blocks/Items/template.js +181 -175
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
- package/dist/extensions/Blocks/Recommendation/block.js +133 -9
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +66 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +22 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +92 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +209 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +250 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +160 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +307 -0
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +73 -0
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +40 -43
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
- package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +128 -72
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +254 -207
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +36 -0
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
- package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
- package/dist/extensions/Blocks/common-control.js +91 -92
- package/dist/extensions/Blocks/controlFactories.js +125 -93
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +317 -198
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +11 -8
- package/dist/services/stripoApi.js +20 -17
- package/dist/services/templateLibraryApi.js +16 -13
- package/dist/src/@types/config/schemas.d.ts +10 -2
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +19 -11
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +79 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +221 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -468
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +166 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/static/styles/components/notification.css.js +1 -0
- package/dist/static/styles/components/version-history.css.js +10 -2
- package/dist/static/styles/components/wide-panel.css.js +18 -6
- package/dist/static/styles/customEditorStyle.css.js +39 -2
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/stores/unsubscribe.js +37 -34
- package/dist/utils/pairProductVariables.js +57 -56
- package/dist/utils/templatePreparation.js +15 -14
- package/package.json +2 -2
- package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -103
- package/dist/extensions/Blocks/Recommendation/constants.js +0 -5
- package/dist/extensions/Blocks/Recommendation/control.js +0 -306
- package/dist/extensions/Blocks/Recommendation/controls/button/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/border.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/borderRadius.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/fitToContent.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/margins.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/text.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/textSize.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/image/margins.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/image/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -160
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -152
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -180
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
- package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +0 -28
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -35
- package/dist/src/extensions/Blocks/Recommendation/controls/button/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/border.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/borderRadius.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/fitToContent.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/margins.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/text.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/textSize.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/image/margins.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/image/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -44
|
@@ -0,0 +1,20 @@
|
|
|
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,9 +1,17 @@
|
|
|
1
1
|
import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
2
|
-
import { DEFAULTS, getDefaultProducts } from '
|
|
2
|
+
import { DEFAULTS, getDefaultProducts, DEFAULT_CARD_COMPOSITION, DEFAULT_CARD_VISIBILITY } from '../utils';
|
|
3
3
|
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 >\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";
|
|
4
|
+
/**
|
|
5
|
+
* Prepares migration product rows with attribute-aligned structure.
|
|
6
|
+
* @param products - Array of products to display
|
|
7
|
+
* @param productsPerRow - Number of products per row
|
|
8
|
+
* @param composition - Array defining element order
|
|
9
|
+
* @returns HTML string for product rows
|
|
10
|
+
*/
|
|
11
|
+
export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[]): string;
|
|
4
12
|
export declare function getMigrationTemplate(): string;
|
|
5
13
|
/**
|
|
6
|
-
* Generates a custom migration template with specified products and layout
|
|
14
|
+
* Generates a custom migration template with specified products and layout.
|
|
7
15
|
* @param products - Array of products to display
|
|
8
16
|
* @param productsPerRow - Number of products per row
|
|
9
17
|
* @param title - Optional title for the block
|
|
@@ -11,6 +19,5 @@ export declare function getMigrationTemplate(): string;
|
|
|
11
19
|
* @returns Complete HTML template
|
|
12
20
|
*/
|
|
13
21
|
export declare function generateMigrationTemplate(products: RecommendationProduct[], productsPerRow: number, title?: string, composition?: string[]): string;
|
|
14
|
-
export
|
|
15
|
-
export { DEFAULTS, getDefaultProducts };
|
|
22
|
+
export { DEFAULTS, DEFAULT_CARD_COMPOSITION, DEFAULT_CARD_VISIBILITY, getDefaultProducts, };
|
|
16
23
|
export default migrationTemplate;
|
|
@@ -0,0 +1,33 @@
|
|
|
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[], mobileProductsPerRow?: number): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
* Includes both desktop and mobile product containers for grid layouts.
|
|
28
|
+
* @param layout - The layout orientation ('list' or 'grid')
|
|
29
|
+
* @returns Complete HTML template with default products
|
|
30
|
+
*/
|
|
31
|
+
export declare function getDefaultTemplate(layout?: Orientation): string;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a complete block template with custom products.
|
|
34
|
+
* Includes both desktop and mobile product containers for grid layouts.
|
|
35
|
+
* @param products - Array of products to display
|
|
36
|
+
* @param layout - The layout orientation ('list' or 'grid')
|
|
37
|
+
* @param title - Title for the block
|
|
38
|
+
* @param options - Layout-specific options
|
|
39
|
+
* @returns Complete HTML template
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateBlockTemplate(products: RecommendationProduct[], layout: Orientation, title?: string, options?: PrepareProductRowsOptions): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
/** Number of products per row on mobile (only for grid layout, defaults to 1) */
|
|
11
|
+
mobileProductsPerRow?: number;
|
|
12
|
+
/** Array defining order of card elements */
|
|
13
|
+
composition?: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Element renderer interface for product card elements
|
|
17
|
+
* Keys are ATTR_PRODUCT_* constants for consistent naming
|
|
18
|
+
*/
|
|
19
|
+
export interface ElementRenderer {
|
|
20
|
+
[ATTR_PRODUCT_IMAGE]: (product: RecommendationProduct) => string;
|
|
21
|
+
[ATTR_PRODUCT_NAME]: (product: RecommendationProduct) => string;
|
|
22
|
+
[ATTR_PRODUCT_PRICE]: (product: RecommendationProduct) => string;
|
|
23
|
+
[ATTR_PRODUCT_OLD_PRICE]: (product: RecommendationProduct) => string;
|
|
24
|
+
[ATTR_PRODUCT_OMNIBUS_PRICE]: (product: RecommendationProduct) => string;
|
|
25
|
+
[ATTR_PRODUCT_OMNIBUS_DISCOUNT]: (product: RecommendationProduct) => string;
|
|
26
|
+
[ATTR_PRODUCT_BUTTON]: (product: RecommendationProduct) => string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Product card getter function type
|
|
30
|
+
* Used by prepareProductRows to generate individual product cards
|
|
31
|
+
*/
|
|
32
|
+
export type ProductCardGetter = (product: RecommendationProduct, composition?: string[]) => string;
|
|
33
|
+
export declare const DEFAULTS: {
|
|
34
|
+
TITLE: string;
|
|
35
|
+
DESCRIPTION: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const DEFAULT_CARD_COMPOSITION: string[];
|
|
38
|
+
export declare const DEFAULT_CARD_VISIBILITY: Record<string, boolean>;
|
|
39
|
+
export declare const spacer = "\n <tr>\n <td class=\"spacer\" style=\"height: 10px;\"></td>\n </tr>\n";
|
|
40
|
+
export declare const PLACEHOLDER_IMAGE = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
|
|
41
|
+
/**
|
|
42
|
+
* Sanitizes product image URLs for consistent rendering
|
|
43
|
+
* - Converts http:// to https:// to avoid mixed content issues
|
|
44
|
+
* - Returns placeholder for invalid/empty URLs
|
|
45
|
+
* @param url - The image URL to sanitize
|
|
46
|
+
* @returns Sanitized HTTPS URL or placeholder
|
|
47
|
+
*/
|
|
48
|
+
export declare function sanitizeImageUrl(url: string | undefined | null): string;
|
|
49
|
+
export declare function getDefaultProducts(count?: number): RecommendationProduct[];
|
|
50
|
+
/**
|
|
51
|
+
* Creates the block template wrapper HTML for recommendation blocks.
|
|
52
|
+
* The template includes title placeholder and both desktop/mobile product containers.
|
|
53
|
+
*
|
|
54
|
+
* The dual-container approach generates two `ins-recommendation-product-container` tables:
|
|
55
|
+
* - Desktop container: visible by default, hidden on mobile via CSS media query
|
|
56
|
+
* - Mobile container: hidden by default (`display: none`), shown on mobile
|
|
57
|
+
*
|
|
58
|
+
* Both share the `.ins-recommendation-product-container` class so existing selectors
|
|
59
|
+
* (spacing, background color, compiler rules) apply automatically to both.
|
|
60
|
+
* @param layout - The layout orientation ('list' or 'grid')
|
|
61
|
+
* @param instanceClass - Optional instance-specific class (e.g., 'ins-recommendation-v3-block-1')
|
|
62
|
+
* for CSS scoping per block instance. Must be included in the initial template HTML because
|
|
63
|
+
* Stripo's Angular rendering manages the class attribute and overwrites dynamic setAttribute changes.
|
|
64
|
+
* @returns HTML template string with {-{-TITLE-}-}, {-{-PRODUCT_ROWS-}-}, and {-{-MOBILE_PRODUCT_ROWS-}-} placeholders
|
|
65
|
+
*/
|
|
66
|
+
export declare function createBlockTemplate(layout?: Orientation, instanceClass?: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
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';
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
* Number of products per row on mobile (grid layout only)
|
|
97
|
+
* Only applicable when layout is 'grid'
|
|
98
|
+
* @default 1
|
|
99
|
+
*/
|
|
100
|
+
mobileCardsInRow: number;
|
|
101
|
+
/**
|
|
102
|
+
* Horizontal spacing between product cards in pixels (grid layout only)
|
|
103
|
+
*/
|
|
104
|
+
columnSpacing: number;
|
|
105
|
+
/**
|
|
106
|
+
* Vertical spacing between product rows in pixels
|
|
107
|
+
*/
|
|
108
|
+
rowSpacing: number;
|
|
109
|
+
/**
|
|
110
|
+
* Order of card elements from top to bottom
|
|
111
|
+
* Array of ATTR_PRODUCT_* constants
|
|
112
|
+
* @example ['productImage', 'productName', 'productPrice', 'productButton']
|
|
113
|
+
*/
|
|
114
|
+
composition: string[];
|
|
115
|
+
/**
|
|
116
|
+
* Visibility flags for each card element
|
|
117
|
+
* Keys are ATTR_PRODUCT_* constants
|
|
118
|
+
*/
|
|
119
|
+
visibility: Record<string, boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Omnibus price text configuration
|
|
122
|
+
* For EU Omnibus Directive compliance
|
|
123
|
+
*/
|
|
124
|
+
omnibusPrice: OmnibusTextConfig;
|
|
125
|
+
/**
|
|
126
|
+
* Omnibus discount text configuration
|
|
127
|
+
* For EU Omnibus Directive compliance
|
|
128
|
+
*/
|
|
129
|
+
omnibusDiscount: OmnibusTextConfig;
|
|
130
|
+
/**
|
|
131
|
+
* Whether to trim long product names with ellipsis
|
|
132
|
+
*/
|
|
133
|
+
textTrimming: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Configuration version for future migrations
|
|
136
|
+
* Increment when making breaking changes to schema
|
|
137
|
+
*/
|
|
138
|
+
configVersion: number;
|
|
139
|
+
/**
|
|
140
|
+
* Unique identifier for this recommendation block instance
|
|
141
|
+
* Used to isolate per-block state in the Pinia store
|
|
142
|
+
* 0 = not yet assigned (default for new/migrating blocks)
|
|
143
|
+
*/
|
|
144
|
+
recommendationId: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Partial configuration for updates
|
|
148
|
+
* All fields are optional to support partial updates via `updateConfig`
|
|
149
|
+
*/
|
|
150
|
+
export type PartialNodeConfig = Partial<RecommendationNodeConfig>;
|
|
151
|
+
/**
|
|
152
|
+
* Deep partial for nested objects
|
|
153
|
+
*/
|
|
154
|
+
export type DeepPartialNodeConfig = {
|
|
155
|
+
[K in keyof RecommendationNodeConfig]?: RecommendationNodeConfig[K] extends object ? Partial<RecommendationNodeConfig[K]> : RecommendationNodeConfig[K];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Check if an object is a valid RecommendationNodeConfig
|
|
159
|
+
* Used for migration detection and validation
|
|
160
|
+
*/
|
|
161
|
+
export declare function isValidNodeConfig(obj: unknown): obj is RecommendationNodeConfig;
|
|
162
|
+
/**
|
|
163
|
+
* Check if a node config has the minimum required fields
|
|
164
|
+
* Used to detect legacy templates that need migration
|
|
165
|
+
*/
|
|
166
|
+
export declare function hasMinimalConfig(obj: unknown): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for preserving text styling when updating innerHTML
|
|
3
|
+
*/
|
|
4
|
+
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
5
|
+
/**
|
|
6
|
+
* Preserves existing style tags when updating text content
|
|
7
|
+
*
|
|
8
|
+
* When users apply text styles (bold, italic, etc.) in Stripo, the editor wraps
|
|
9
|
+
* content in tags like <strong>, <em>, <u>, <s>. This function extracts those
|
|
10
|
+
* style tags from the original HTML and re-applies them to the new text content.
|
|
11
|
+
* @example
|
|
12
|
+
* // Original: <span class="omnibus-text-before"><strong>Lowest price: </strong></span>
|
|
13
|
+
* // After calling preserveTextStyles(element, 'Best price: ')
|
|
14
|
+
* // Result: <strong>Best price: </strong>
|
|
15
|
+
* @param element - The DOM element or ImmutableHtmlNode containing the styled text
|
|
16
|
+
* @param newText - The new text content to insert
|
|
17
|
+
* @returns The new text wrapped in the original style tags
|
|
18
|
+
*/
|
|
19
|
+
export declare function preserveTextStyles(element: ImmutableHtmlNode | Element, newText: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
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;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Preserver Utility
|
|
3
|
+
*
|
|
4
|
+
* Captures and restores element styles during block regeneration.
|
|
5
|
+
* This ensures user styling is preserved when:
|
|
6
|
+
* - Layout changes (grid <-> list)
|
|
7
|
+
* - Cards per row changes
|
|
8
|
+
* - Composition order changes
|
|
9
|
+
*
|
|
10
|
+
* Works with the node config system to provide complete style persistence.
|
|
11
|
+
*/
|
|
12
|
+
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
13
|
+
import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
|
|
14
|
+
/**
|
|
15
|
+
* Style properties that can be captured for text elements
|
|
16
|
+
*/
|
|
17
|
+
export interface TextElementStyles {
|
|
18
|
+
fontSize?: string;
|
|
19
|
+
fontFamily?: string;
|
|
20
|
+
fontWeight?: string;
|
|
21
|
+
fontStyle?: string;
|
|
22
|
+
color?: string;
|
|
23
|
+
textAlign?: string;
|
|
24
|
+
lineHeight?: string;
|
|
25
|
+
textDecoration?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Style properties for button elements
|
|
29
|
+
*/
|
|
30
|
+
export interface ButtonElementStyles extends TextElementStyles {
|
|
31
|
+
backgroundColor?: string;
|
|
32
|
+
borderRadius?: string;
|
|
33
|
+
border?: string;
|
|
34
|
+
padding?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Style properties for image elements
|
|
38
|
+
*/
|
|
39
|
+
export interface ImageElementStyles {
|
|
40
|
+
width?: string;
|
|
41
|
+
height?: string;
|
|
42
|
+
maxWidth?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Complete captured styles for a recommendation block
|
|
46
|
+
*/
|
|
47
|
+
export interface CapturedStyles {
|
|
48
|
+
/** Product name text styles */
|
|
49
|
+
name: TextElementStyles;
|
|
50
|
+
/** Current price text styles */
|
|
51
|
+
price: TextElementStyles;
|
|
52
|
+
/** Original/old price text styles */
|
|
53
|
+
oldPrice: TextElementStyles;
|
|
54
|
+
/** Omnibus price text styles */
|
|
55
|
+
omnibusPrice: TextElementStyles;
|
|
56
|
+
/** Omnibus discount text styles */
|
|
57
|
+
omnibusDiscount: TextElementStyles;
|
|
58
|
+
/** CTA button styles */
|
|
59
|
+
button: ButtonElementStyles;
|
|
60
|
+
/** Product image styles */
|
|
61
|
+
image: ImageElementStyles;
|
|
62
|
+
/** Card background color */
|
|
63
|
+
cardBackgroundColor: string | null;
|
|
64
|
+
/** Column spacing in pixels */
|
|
65
|
+
columnSpacing: number;
|
|
66
|
+
/** Row spacing in pixels */
|
|
67
|
+
rowSpacing: number;
|
|
68
|
+
/** Element composition order */
|
|
69
|
+
composition: string[];
|
|
70
|
+
/** Element visibility flags */
|
|
71
|
+
visibility: Record<string, boolean>;
|
|
72
|
+
}
|
|
73
|
+
type DocumentModifier = {
|
|
74
|
+
modifyHtml: (node: ImmutableHtmlNode) => {
|
|
75
|
+
setStyle: (prop: string, value: string) => DocumentModifier;
|
|
76
|
+
};
|
|
77
|
+
apply: (description: ModificationDescription) => void;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Capture all styles from a recommendation block
|
|
81
|
+
*
|
|
82
|
+
* Call this BEFORE any operation that regenerates the block HTML.
|
|
83
|
+
* The captured styles can then be restored after regeneration.
|
|
84
|
+
* @example
|
|
85
|
+
* // Before layout change
|
|
86
|
+
* const styles = captureStyles(this.currentNode);
|
|
87
|
+
*
|
|
88
|
+
* // ... regenerate block HTML ...
|
|
89
|
+
*
|
|
90
|
+
* // After regeneration
|
|
91
|
+
* restoreStyles(this.currentNode, this.api.getDocumentModifier(), styles);
|
|
92
|
+
* @param node - The block node to capture styles from
|
|
93
|
+
* @returns Complete captured styles object
|
|
94
|
+
*/
|
|
95
|
+
export declare function captureStyles(node: ImmutableHtmlNode | null | undefined): CapturedStyles;
|
|
96
|
+
/**
|
|
97
|
+
* Restore captured styles to a regenerated block
|
|
98
|
+
*
|
|
99
|
+
* Call this AFTER regenerating block HTML to reapply user styling.
|
|
100
|
+
* @example
|
|
101
|
+
* restoreStyles(this.currentNode, this.api.getDocumentModifier(), capturedStyles);
|
|
102
|
+
* @param node - The block node to restore styles to
|
|
103
|
+
* @param modifier - Document modifier for applying changes
|
|
104
|
+
* @param styles - Previously captured styles
|
|
105
|
+
*/
|
|
106
|
+
export declare function restoreStyles(node: ImmutableHtmlNode | null | undefined, modifier: DocumentModifier, styles: CapturedStyles): void;
|
|
107
|
+
/**
|
|
108
|
+
* Check if styles have meaningful content worth restoring
|
|
109
|
+
* @param styles - Captured styles to check
|
|
110
|
+
* @returns True if styles contain restorable content
|
|
111
|
+
*/
|
|
112
|
+
export declare function hasRestorableStyles(styles: CapturedStyles): boolean;
|
|
113
|
+
export {};
|