@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,52 +0,0 @@
1
- /**
2
- * Currency Settings Control
3
- *
4
- * Handles all currency-related configuration for recommendation products:
5
- * - Currency type
6
- * - Currency location (before/after)
7
- * - Currency symbol
8
- * - Thousand separator
9
- * - Decimal separator
10
- * - Decimal count
11
- *
12
- * Configuration is stored via node config (persists with template).
13
- * Currency options are fetched from API and cached in Pinia store.
14
- */
15
- import type { CurrencyConfig } from '../../types/nodeConfig';
16
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
17
- import { CommonControl } from '../../../common-control';
18
- export declare const CURRENCY_CONTROL_ID = "recommendation-currency-control";
19
- /**
20
- * Control for managing currency display settings in recommendation blocks
21
- */
22
- export declare class CurrencyControl extends CommonControl {
23
- private store;
24
- private storeUnsubscription;
25
- getId(): string;
26
- getTemplate(): string;
27
- onRender(): void;
28
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
29
- onDestroy(): void;
30
- _setFormValues(): void;
31
- _initializeSelectItems(): void;
32
- /**
33
- * Applies currency updates to node config, HTML attributes, Pinia store, and DOM.
34
- * @param updates - Partial currency config to merge
35
- * @param triggerRefetch - Whether to trigger a product API refetch.
36
- * true for currency code changes (different prices from API),
37
- * false for display-only changes (symbol, separators, alignment, decimal count).
38
- */
39
- _updateCurrency(updates: Partial<CurrencyConfig>, triggerRefetch?: boolean): void;
40
- _onCurrencyChange(value: string): void;
41
- _onCurrencyLocationChange(value: string): void;
42
- _onCurrencySymbolChange(value: string): void;
43
- _onThousandSeparatorChange(value: string): void;
44
- _onDecimalSeparatorChange(value: string): void;
45
- _onDecimalCountChange(value: string): void;
46
- _listenToFormUpdates(): void;
47
- /**
48
- * Subscribe to store changes to update currency selects when API data arrives
49
- * This handles the case where the control renders before currency list is loaded
50
- */
51
- _subscribeToStoreChanges(): void;
52
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Filters Control
3
- *
4
- * Handles the filter selection UI for recommendation products
5
- * Opens filter selection drawer when button is clicked
6
- */
7
- import { CommonControl } from '../../../common-control';
8
- export declare const FILTERS_CONTROL_ID = "recommendation-filters-control";
9
- /**
10
- * Control for managing recommendation product filters
11
- */
12
- export declare class FiltersControl extends CommonControl {
13
- private store;
14
- private addFilterListener;
15
- private addFilterButton;
16
- getId(): string;
17
- getTemplate(): string;
18
- onRender(): void;
19
- onDestroy(): void;
20
- _onFilterSelectClick(): void;
21
- _setupButtonListener(): void;
22
- }
@@ -1,68 +0,0 @@
1
- import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
- import { CommonControl } from '../../../common-control';
3
- import { AlgorithmControl, ALGORITHM_CONTROL_ID } from './algorithm';
4
- import { CurrencyControl, CURRENCY_CONTROL_ID } from './currency';
5
- import { FiltersControl, FILTERS_CONTROL_ID } from './filters';
6
- import { LocaleControl, LOCALE_CONTROL_ID } from './locale';
7
- import { ProductLayoutControl, PRODUCT_LAYOUT_CONTROL_ID } from './productLayout';
8
- import { ShuffleControl, SHUFFLE_CONTROL_ID } from './shuffle';
9
- export declare const CONTROL_BLOCK_ID = "ui-elements-recommendation-block";
10
- export { AlgorithmControl, ALGORITHM_CONTROL_ID, LocaleControl, LOCALE_CONTROL_ID, CurrencyControl, CURRENCY_CONTROL_ID, ProductLayoutControl, PRODUCT_LAYOUT_CONTROL_ID, FiltersControl, FILTERS_CONTROL_ID, ShuffleControl, SHUFFLE_CONTROL_ID, };
11
- export * from './utils';
12
- /**
13
- * Main recommendation block control that composes all sub-controls
14
- * Registered in the Settings tab of the block's settings panel
15
- */
16
- export declare class RecommendationBlockControl extends CommonControl {
17
- private store;
18
- private storeUnsubscription;
19
- private initializedBlocks;
20
- private algorithmControl;
21
- private localeControl;
22
- private currencyControl;
23
- private productLayoutControl;
24
- private filtersControl;
25
- private shuffleControl;
26
- getId(): string;
27
- getTemplate(): string;
28
- onRender(): Promise<void>;
29
- /**
30
- * Immediately regenerate products with styles (no debounce)
31
- * Used for initial load after fetch completes
32
- */
33
- private _regenerateWithProducts;
34
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
35
- onDestroy(): void;
36
- /**
37
- * Initialize all sub-controls with the shared API context
38
- * Each sub-control manages its own form values and event listeners
39
- */
40
- _initializeSubControls(): void;
41
- /**
42
- * Fetches initial data for a block (filters, algorithms, products).
43
- * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
44
- * Marks the block as initialized to prevent redundant fetches on re-selection.
45
- */
46
- private _fetchBlockData;
47
- /**
48
- * Reads the recommendation-id attribute from the block element within the node
49
- */
50
- private _getRecommendationIdFromNode;
51
- /**
52
- * Debounced product fetch to prevent rapid API calls during config changes
53
- */
54
- private _debouncedFetchProducts;
55
- /**
56
- * Debounced regeneration when products arrive from API
57
- * Tries in-place update first to preserve styles, falls back to full regeneration
58
- */
59
- private _debouncedRegenerateWithProducts;
60
- /**
61
- * Listen to store changes that require product refresh or regeneration.
62
- *
63
- * Uses configVersion counter (incremented only by patchCurrentBlockConfig)
64
- * to distinguish user-initiated config changes from internal mutations
65
- * (e.g., fetchRecommendationCreateData setting preferred currency).
66
- */
67
- _listenStateUpdates(): void;
68
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Locale Selection Control
3
- *
4
- * Handles locale/language selection for recommendation products.
5
- * Configuration is stored via node config (persists with template).
6
- * Language options are fetched from API and cached in Pinia store.
7
- */
8
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
9
- import { CommonControl } from '../../../common-control';
10
- export declare const LOCALE_CONTROL_ID = "recommendation-locale-control";
11
- /**
12
- * Control for selecting recommendation content locale/language
13
- */
14
- export declare class LocaleControl extends CommonControl {
15
- private store;
16
- getId(): string;
17
- getTemplate(): string;
18
- onRender(): void;
19
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
20
- _setFormValues(): void;
21
- _initializeSelectItems(): void;
22
- _onLocaleChange(value: string): void;
23
- _listenToFormUpdates(): void;
24
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Product Layout Control
3
- *
4
- * Handles product display configuration:
5
- * - Number of products to show
6
- * - Products per row (hidden for list layout)
7
- * - Triggers product row regeneration on changes
8
- *
9
- * Configuration is stored via node config (persists with template).
10
- */
11
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
12
- import { CommonControl } from '../../../common-control';
13
- export declare const PRODUCT_LAYOUT_CONTROL_ID = "recommendation-product-layout-control";
14
- /**
15
- * Control for configuring product count and layout density
16
- */
17
- export declare class ProductLayoutControl extends CommonControl {
18
- private store;
19
- private storeUnsubscription;
20
- getId(): string;
21
- getTemplate(): string;
22
- onRender(): void;
23
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
24
- onDestroy(): void;
25
- _setFormValues(): void;
26
- /**
27
- * Updates "Products in One Row" visibility based on layout orientation
28
- * This control is hidden for list layout (products always take full width)
29
- * Reads from node config first, falls back to DOM
30
- */
31
- _updateProductsInRowVisibility(): void;
32
- _onProductCountChange(value: string): void;
33
- _onProductsInRowChange(value: number): void;
34
- _regenerateProductRows(): void;
35
- _debouncedRegenerateProductRows: import("@vueuse/shared").PromisifyFn<() => void>;
36
- _listenToFormUpdates(): void;
37
- /**
38
- * Subscribe to store changes to update visibility when layout changes
39
- * This is still needed because layout changes come from LayoutControl
40
- */
41
- _listenStateUpdates(): void;
42
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Shuffle Products Control
3
- *
4
- * Handles the toggle for shuffling/randomizing recommended products.
5
- * Configuration is stored via node config (persists with template).
6
- */
7
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
8
- import { CommonControl } from '../../../common-control';
9
- export declare const SHUFFLE_CONTROL_ID = "recommendation-shuffle-control";
10
- /**
11
- * Control for toggling product shuffle/randomization
12
- */
13
- export declare class ShuffleControl extends CommonControl {
14
- private store;
15
- getId(): string;
16
- getTemplate(): string;
17
- onRender(): void;
18
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
19
- _setFormValues(): void;
20
- _initializeToggle(): void;
21
- _onShuffleChange(value: boolean): void;
22
- _listenToFormUpdates(): void;
23
- }
@@ -1,214 +0,0 @@
1
- /**
2
- * Shared utilities for Recommendation block controls
3
- *
4
- * Provides common functionality used across multiple controls:
5
- * - Layout detection from DOM
6
- * - Card composition retrieval
7
- * - Product row regeneration
8
- * - Spacing reapplication
9
- * - In-place content updates (style-preserving)
10
- */
11
- import type { CurrencyConfig } from '../../types/nodeConfig';
12
- import type { RecommendationProduct } from '@@/Types/recommendation';
13
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
14
- import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
15
- import { type Orientation } from '../../templates';
16
- /**
17
- * Type for document modifier returned by api.getDocumentModifier()
18
- *
19
- * Uses `any` for the modifyHtml return type because:
20
- * 1. Stripo's actual API uses complex generics (TemplateModifier<HtmlNodeModifier, CssNodeModifier>)
21
- * 2. Multiple files define their own DocumentModifier with different methods
22
- * 3. The methods (setStyle, setInnerHtml, setAttribute) chain and return the same object
23
- *
24
- * The actual chaining like modifier.modifyHtml(node).setStyle(...).setAttribute(...).apply()
25
- * works correctly at runtime - this is just a TypeScript compatibility issue.
26
- */
27
- interface DocumentModifier {
28
- modifyHtml: (node: ImmutableHtmlNode) => any;
29
- apply: (description: ModificationDescription) => void;
30
- }
31
- /**
32
- * Gets the block element from the current node
33
- * The currentNode could BE the block element or contain it
34
- * @param currentNode - The current template node
35
- * @returns The block element or null if not found
36
- */
37
- export declare function getBlockElement(currentNode: ImmutableHtmlNode | null | undefined): ImmutableHtmlNode | null;
38
- /**
39
- * Gets the current layout orientation from the block's data attribute
40
- * Supports both old (horizontal/vertical) and new (list/grid) values for backward compatibility
41
- * @param currentNode - The current template node
42
- * @returns The layout value ('grid' or 'list'), defaults to 'grid'
43
- */
44
- export declare function getCurrentLayout(currentNode: ImmutableHtmlNode | null | undefined): Orientation;
45
- /**
46
- * Gets the current card composition from block data attribute or use default
47
- * @param currentNode - The current template node
48
- * @returns Array of card element types in order
49
- */
50
- export declare function getCardComposition(currentNode: ImmutableHtmlNode | null | undefined): string[];
51
- export interface RegenerateProductRowsOptions {
52
- currentNode: ImmutableHtmlNode | null | undefined;
53
- documentModifier: DocumentModifier;
54
- afterRegenerate?: () => void;
55
- /** Optional: pass products directly instead of reading from store */
56
- products?: RecommendationProduct[];
57
- /** Optional: pass layout directly to avoid stale DOM reads after setAttribute */
58
- layout?: Orientation;
59
- }
60
- /**
61
- * Regenerates product rows based on current store configuration
62
- * Reads products, layout, and composition from store/DOM and rebuilds the HTML
63
- * @param options - Configuration options for regeneration
64
- */
65
- export declare function regenerateProductRows(options: RegenerateProductRowsOptions): void;
66
- export interface ReapplySpacingOptions {
67
- currentNode: ImmutableHtmlNode | null | undefined;
68
- documentModifier: DocumentModifier;
69
- }
70
- /**
71
- * Reapplies spacing values from data attributes after product regeneration
72
- * This ensures spacing persists when products are regenerated
73
- * @param options - Configuration options
74
- */
75
- export declare function reapplySpacing(options: ReapplySpacingOptions): void;
76
- export interface RegenerateWithStylesOptions extends Omit<RegenerateProductRowsOptions, 'products' | 'layout'> {
77
- /** Skip style capture/restore if styles were already handled externally */
78
- skipStylePreservation?: boolean;
79
- /** Optional: pass products directly instead of reading from store */
80
- products?: RecommendationProduct[];
81
- /** Optional: pass layout directly to avoid stale DOM reads after setAttribute */
82
- layout?: Orientation;
83
- }
84
- /**
85
- * Regenerates product rows while preserving user-applied styles
86
- *
87
- * This unified function handles the complete regeneration flow:
88
- * 1. Captures existing styles (fonts, colors, button styles, etc.)
89
- * 2. Regenerates HTML with new products/layout
90
- * 3. Restores captured styles to new elements
91
- * 4. Reapplies spacing from data attributes
92
- *
93
- * NOTE: Style restoration is temporarily disabled due to Stripo selection bug.
94
- * Multiple apply() calls (setInnerHtml + restoreStyles + reapplySpacing) cause
95
- * Stripo's internal cursor/selection tracking to lose node references, resulting in
96
- * "Cannot read properties of undefined (reading 'textContent')" errors.
97
- *
98
- * Use this instead of `regenerateProductRows` when styles must be preserved.
99
- * @example
100
- * // When products change (API response, count change, layout change)
101
- * regenerateProductRowsWithStyles({
102
- * currentNode: this.currentNode,
103
- * documentModifier: this.api.getDocumentModifier(),
104
- * });
105
- * @param options - Configuration options for regeneration
106
- */
107
- export declare function regenerateProductRowsWithStyles(options: RegenerateWithStylesOptions): void;
108
- type PriceKey = 'price' | 'original_price' | 'discount';
109
- /**
110
- * Formats a product price using current currency settings
111
- * @param product - The product containing price data
112
- * @param priceKey - Which price to use ('price', 'original_price', or 'discount')
113
- * @returns Formatted price string
114
- */
115
- export declare function formatProductPrice(product: RecommendationProduct, priceKey?: PriceKey): string;
116
- interface UpdateSingleProductContentOptions {
117
- documentModifier: DocumentModifier;
118
- product: RecommendationProduct;
119
- imageEl: ImmutableHtmlNode | null;
120
- nameEl: ImmutableHtmlNode | null;
121
- priceEl: ImmutableHtmlNode | null;
122
- oldPriceEl: ImmutableHtmlNode | null;
123
- omnibusPriceEl: ImmutableHtmlNode | null;
124
- omnibusDiscountEl: ImmutableHtmlNode | null;
125
- buttonEl: ImmutableHtmlNode | null;
126
- }
127
- /**
128
- * Updates a single product's dynamic content (image, name, prices, button URL)
129
- * without touching the styled container elements.
130
- *
131
- * Uses setText() on text nodes instead of setInnerHtml() to preserve Stripo's
132
- * internal node references and avoid cursor/selection tracking issues.
133
- * @returns true if any modifications were made
134
- */
135
- export declare function updateSingleProductContent(options: UpdateSingleProductContentOptions): boolean;
136
- export interface UpdateProductContentInPlaceOptions {
137
- currentNode: ImmutableHtmlNode | null | undefined;
138
- documentModifier: DocumentModifier;
139
- products: RecommendationProduct[];
140
- }
141
- /**
142
- * Updates product content in-place without regenerating HTML structure.
143
- * Preserves all user-applied styles by only touching dynamic content.
144
- *
145
- * This is the preferred method when:
146
- * - Product data changed but count remains the same
147
- * - Currency/locale changed (prices need reformatting)
148
- *
149
- * Uses setText() on text nodes instead of setInnerHtml() to preserve
150
- * Stripo's internal node references and avoid cursor/selection tracking issues.
151
- *
152
- * Falls back to false when:
153
- * - Product count changed (need to add/remove elements)
154
- * - Cannot find required elements
155
- * @param options - Configuration options
156
- * @returns true if in-place update was successful, false to fall back to full regeneration
157
- */
158
- export declare function updateProductContentInPlace(options: UpdateProductContentInPlaceOptions): boolean;
159
- export interface UpdatePricesInPlaceOptions {
160
- currentNode: ImmutableHtmlNode | null | undefined;
161
- documentModifier: DocumentModifier;
162
- }
163
- /**
164
- * Updates only price displays in-place (for currency changes).
165
- * This is a lightweight update when only formatting changes, not product data.
166
- *
167
- * Perfect for:
168
- * - Currency symbol change
169
- * - Currency alignment change
170
- * - Decimal/thousand separator changes
171
- *
172
- * Uses setText() on text nodes instead of setInnerHtml() to preserve
173
- * Stripo's internal node references and avoid cursor/selection tracking issues.
174
- * @param options - Configuration options
175
- * @returns true if update was successful, false otherwise
176
- */
177
- export declare function updatePricesInPlace(options: UpdatePricesInPlaceOptions): boolean;
178
- /**
179
- * Gets current card background color from existing elements
180
- * Checks both grid (.product-card-segment) and list (.product-card-wrapper) selectors
181
- * @param currentNode - The current template node
182
- * @returns Background color string or null if not found
183
- */
184
- export declare function getCurrentCardBackgroundColor(currentNode: ImmutableHtmlNode | null | undefined): string | null;
185
- export interface ApplyCardBackgroundColorOptions {
186
- currentNode: ImmutableHtmlNode | null | undefined;
187
- documentModifier: DocumentModifier;
188
- bgColor: string | null;
189
- layout: Orientation;
190
- }
191
- /**
192
- * Applies card background color to appropriate elements based on layout
193
- * @param options - Configuration options
194
- */
195
- export declare function applyCardBackgroundColor(options: ApplyCardBackgroundColorOptions): void;
196
- export interface SetCurrencyAttributesOptions {
197
- currentNode: ImmutableHtmlNode | null | undefined;
198
- documentModifier: DocumentModifier;
199
- currency: CurrencyConfig;
200
- }
201
- /**
202
- * Sets currency configuration as HTML attributes on the block element
203
- * These attributes are read by the HTML compiler at runtime to format prices
204
- * @param options - Configuration options
205
- */
206
- export declare function setCurrencyAttributes(options: SetCurrencyAttributesOptions): void;
207
- /**
208
- * Reads currency configuration from block HTML attributes
209
- * Used to restore settings when loading a template
210
- * @param currentNode - The current template node
211
- * @returns CurrencyConfig or null if attributes not found
212
- */
213
- export declare function getCurrencyAttributesFromBlock(currentNode: ImmutableHtmlNode | null | undefined): Partial<CurrencyConfig> | null;
214
- export {};
@@ -1,97 +0,0 @@
1
- /**
2
- * Name Element Controls
3
- *
4
- * Controls for styling the product name element in recommendation cards.
5
- */
6
- import { NameTextTrimControl } from './textTrim';
7
- /**
8
- * Grouped Name Controls
9
- * Use this object for cleaner imports in extension.ts
10
- */
11
- export declare const NameControls: {
12
- readonly align: {
13
- new (): {
14
- getId(): string;
15
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
16
- getParentControlId(): string;
17
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
18
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
19
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
20
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
21
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
22
- };
23
- };
24
- readonly color: {
25
- new (): {
26
- getId(): string;
27
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
28
- getParentControlId(): string;
29
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
30
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
31
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
32
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
33
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
34
- };
35
- };
36
- readonly size: {
37
- new (): {
38
- getId(): string;
39
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
40
- getParentControlId(): string;
41
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
42
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
43
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
44
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
45
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
46
- };
47
- };
48
- readonly style: {
49
- new (): {
50
- getId(): string;
51
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
52
- getParentControlId(): string;
53
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
54
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
55
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
56
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
57
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
58
- };
59
- };
60
- readonly fontFamily: {
61
- new (): {
62
- getId(): string;
63
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
64
- getParentControlId(): string;
65
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
66
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
67
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
68
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
69
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
70
- };
71
- };
72
- readonly background: {
73
- new (): {
74
- getId(): string;
75
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
76
- getParentControlId(): string;
77
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
78
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
79
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
80
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
81
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
82
- };
83
- };
84
- readonly paddings: {
85
- new (): {
86
- getId(): string;
87
- getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
88
- getParentControlId(): string;
89
- api: import("@stripoinc/ui-editor-extensions").ControlApi;
90
- getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
91
- getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
92
- getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
93
- isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
94
- };
95
- };
96
- readonly textTrim: typeof NameTextTrimControl;
97
- };
@@ -1,34 +0,0 @@
1
- import { ImmutableCssNode, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
- import { CommonControl } from '../../../common-control';
3
- /**
4
- * Control for enabling/disabling text trimming on product names
5
- * When enabled, adds a CSS class that applies text-overflow: ellipsis
6
- * and injects the required CSS rules into the document stylesheet
7
- */
8
- export declare class NameTextTrimControl extends CommonControl {
9
- getId(): string;
10
- getTemplate(): string;
11
- onRender(): void;
12
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
13
- _setFormValues(): void;
14
- _getCurrentTrimState(): boolean;
15
- /**
16
- * Finds an existing CSS rule in the document stylesheet by exact query
17
- * @param query - The CSS query to search for (uses Stripo's CSS query syntax)
18
- * @returns The CSS rule node if found, undefined otherwise
19
- */
20
- _findCssRule(query: string): ImmutableCssNode | undefined;
21
- /**
22
- * Finds the .text-trim-enabled p rule by searching all text-trim rules and comparing selectors
23
- * This is needed because Stripo's CSS query syntax interprets spaces as path separators
24
- * @returns true if the rule exists
25
- */
26
- _hasParagraphRule(): boolean;
27
- /**
28
- * Ensures the text-trim CSS rules exist in the document stylesheet
29
- * Only adds rules if they don't already exist (prevents duplicates across multiple blocks)
30
- */
31
- _ensureCssRulesExist(): void;
32
- _onTextTrimChange(enabled: boolean): void;
33
- _listenToFormUpdates(): void;
34
- }