@useinsider/guido 3.24.0 → 3.25.0-beta.2954d1a

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 (68) hide show
  1. package/README.md +7 -1
  2. package/dist/@types/config/schemas.js +9 -7
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +79 -77
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useEditorTrackingIds.js +49 -0
  7. package/dist/composables/useHtmlCompiler.js +2 -0
  8. package/dist/composables/useModuleRepair.js +14 -12
  9. package/dist/composables/useStripo.js +70 -70
  10. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  11. package/dist/config/migrator/index.js +16 -15
  12. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  13. package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
  14. package/dist/config/migrator/recommendationMigrator.js +78 -64
  15. package/dist/extensions/Blocks/Items/block.js +115 -77
  16. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  17. package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
  18. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
  19. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  20. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  21. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  22. package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
  23. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  24. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  25. package/dist/extensions/Blocks/Items/extension.js +15 -13
  26. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  27. package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
  28. package/dist/extensions/Blocks/Items/template.js +250 -212
  29. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  30. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  31. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  32. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  33. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  34. package/dist/extensions/Blocks/controlFactories.js +104 -104
  35. package/dist/guido.css +1 -1
  36. package/dist/package.json.js +2 -2
  37. package/dist/services/templateLibraryApi.js +39 -36
  38. package/dist/src/@types/config/schemas.d.ts +4 -0
  39. package/dist/src/composables/useConfig.d.ts +2 -0
  40. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  41. package/dist/src/composables/useStripo.d.ts +1 -1
  42. package/dist/src/config/migrator/index.d.ts +4 -1
  43. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  44. package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
  45. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
  46. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
  47. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  48. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  49. package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
  50. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
  51. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  52. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
  53. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  54. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  55. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
  56. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  57. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  58. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
  59. package/dist/src/stores/config.d.ts +20 -0
  60. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  61. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  62. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  63. package/dist/utils/itemsCurrencyRepair.js +29 -24
  64. package/dist/utils/linkTrackingIds.js +82 -48
  65. package/dist/utils/pairProductVariables.js +119 -99
  66. package/dist/utils/templatePreparation.js +30 -33
  67. package/dist/utils/trimHrefWhitespace.js +10 -0
  68. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { EditorOpenMetrics } from '@@/Composables/useEditorOpenMetrics';
2
2
  import type { Metadata, Options, Template } from '@@/Types/stripo';
3
3
  export declare const useStripo: (openMetrics: EditorOpenMetrics) => {
4
- initPlugin: (template: Template, metadata: Metadata, options: Options) => Promise<void>;
4
+ initPlugin: (template: Template, metadata: Metadata, options: Options, htmlChanged?: boolean) => Promise<void>;
5
5
  preloadRuntime: () => void;
6
6
  };
@@ -1,3 +1,6 @@
1
1
  import type { LegacyRecommendationConfig } from '@@/Types/config';
2
2
  import { type PartnerScopeMigrationOptions } from './recommendationPartnerMigrator';
3
- export declare const migrate: (html: string, recommendationConfigs?: Record<string, LegacyRecommendationConfig>, partnerScope?: PartnerScopeMigrationOptions) => Promise<string>;
3
+ export interface MigrationFeatureFlags {
4
+ itemsPriceFormatting?: boolean;
5
+ }
6
+ export declare const migrate: (html: string, recommendationConfigs?: Record<string, LegacyRecommendationConfig>, partnerScope?: PartnerScopeMigrationOptions, features?: MigrationFeatureFlags) => Promise<string>;
@@ -0,0 +1 @@
1
+ export declare function migrateItemsPriceFormat(html: string): string;
@@ -0,0 +1,6 @@
1
+ import type { LegacyProductConfig } from './types';
2
+ /**
3
+ * Rebuilds the `esd-dev-product-config` a pre-Guido block never carried from what it rendered.
4
+ * Null when no product card renders or a card cell cannot be mapped (the rebuild would lose it); other fields default.
5
+ */
6
+ export declare function inferLegacyConfig(block: Element, id: number): LegacyProductConfig | null;
@@ -3,7 +3,7 @@ import type { LegacyProductConfig } from './types';
3
3
  * `esd-dev-product-config` is double-HTML-encoded JSON: serialization
4
4
  * escapes once to embed inside the attribute, and Stripo's templating
5
5
  * layer escapes a second time when round-tripping. Returns `null` when
6
- * the attribute is missing or unable to be parsed — the caller treats
6
+ * the attribute is empty or unable to be parsed — the caller treats
7
7
  * either case as an abort.
8
8
  */
9
9
  export declare function parseLegacyConfig(block: Element): LegacyProductConfig | null;
@@ -1,8 +1,4 @@
1
- /**
2
- * Idempotent: the selector matches only blocks that have
3
- * `esd-dev-product-config` AND lack `recommendation-block-v2`, so
4
- * re-running on a migrated template is a no-op.
5
- */
1
+ /** Idempotent: the selector excludes `recommendation-block-v2`, so re-running on a migrated template is a no-op. */
6
2
  import type { LegacyRecommendationConfig } from '@@/Types/config';
7
3
  /**
8
4
  * Migrate all legacy Recommendation Blocks in the given HTML string.
@@ -71,15 +71,12 @@ export declare class ItemsBlock extends Block {
71
71
  */
72
72
  private _resolveInstanceId;
73
73
  /**
74
- * Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
75
- * attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
76
- * Config is the source of truth — never derive from visible text.
77
- *
78
- * Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
79
- * is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
80
- *
81
- * Returns true only when an attr actually changed, so the caller can skip an empty apply that
82
- * would otherwise re-trigger onDocumentChanged and loop.
74
+ * Single self-heal slot: the flag only decides whether a legacy root is converted; a root
75
+ * already in the new format is reconciled from config regardless. Returns whether anything was queued.
83
76
  */
84
77
  private _reconcileCurrencyDomAttributes;
78
+ /** Legacy `<p>` contract via `currencyAttrTargets`: position when recorded, symbol only when custom. */
79
+ private _reconcileLegacyCurrencyAttributes;
80
+ private _priceParagraphs;
81
+ private _isPriceFormattingEnabled;
85
82
  }
@@ -41,3 +41,35 @@ export declare function currencyAttrTargets(config: {
41
41
  priceCurrencyLocation?: string;
42
42
  priceCurrencySymbol?: string;
43
43
  }): CurrencyAttrTargets;
44
+ export declare const ITEMS_PRICE_FORMAT_ATTR: {
45
+ readonly SYMBOL: "currency-symbol";
46
+ readonly ALIGNMENT: "currency-alignment";
47
+ readonly THOUSAND_SEPARATOR: "currency-thousand-separator";
48
+ readonly DECIMAL_SEPARATOR: "currency-decimal-separator";
49
+ readonly DECIMAL_COUNT: "currency-decimal-count";
50
+ readonly SINGLE_PRICE: "data-single_price";
51
+ };
52
+ /** Price `<p>` attrs of the legacy model; a new-format block carries none of them. */
53
+ export declare const LEGACY_PRICE_PARAGRAPH_ATTRS: readonly ["data-formated", "data-single_price", "data-curency", "data-currency_symbol"];
54
+ export declare const PRICE_FORMAT_CONFIG_KEYS: readonly ["priceThousandSeparator", "priceDecimalSeparator", "priceDecimalCount"];
55
+ export interface ItemsPriceFormat {
56
+ thousandSeparator: string;
57
+ decimalSeparator: string;
58
+ decimalCount: number;
59
+ }
60
+ /** en-US, the shape the legacy pre-formatted price tags produced. */
61
+ export declare const DEFAULT_ITEMS_PRICE_FORMAT: ItemsPriceFormat;
62
+ export interface PriceFormatConfigSlice {
63
+ priceThousandSeparator?: string;
64
+ priceDecimalSeparator?: string;
65
+ priceDecimalCount?: number;
66
+ }
67
+ export declare function normalizeDecimalCount(value: unknown): number;
68
+ /** Config → format, defaulting each missing key independently. */
69
+ export declare function priceFormatFromConfig(config: PriceFormatConfigSlice | null | undefined): ItemsPriceFormat;
70
+ export declare function isNewPriceFormatConfig(config: PriceFormatConfigSlice | null | undefined): boolean;
71
+ export interface AttributeReader {
72
+ getAttribute(name: string): string | null | undefined;
73
+ }
74
+ /** The export/control switch: a root carrying `currency-decimal-count` is in the new format. */
75
+ export declare function isNewPriceFormatRoot(root: AttributeReader | null | undefined): boolean;
@@ -0,0 +1,15 @@
1
+ export declare const ItemsBlockBackgroundControl: {
2
+ new (): {
3
+ getId(): string;
4
+ getLabels(): {
5
+ title: string;
6
+ };
7
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
8
+ 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;
9
+ getParentControlId(): string;
10
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
11
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
12
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
13
+ getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
14
+ };
15
+ };
@@ -0,0 +1,24 @@
1
+ import { ControlApi, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
+ import { CommonControl } from '../../common-control';
3
+ import { ItemsBlockControlId } from '../enums/controlEnums';
4
+ import { type ItemsBlockConfig } from '../utils/nodeConfigUtils';
5
+ export declare const CONTROL_BLOCK_ID = ItemsBlockControlId.PRICE_FORMAT;
6
+ export declare function isNewPriceFormatBlock(currentNode: ImmutableHtmlNode | undefined): boolean;
7
+ /** One apply: the config patch, the root attrs the export reads, and both price texts re-rendered. */
8
+ export declare function applyPriceFormatChange(currentNode: ImmutableHtmlNode | undefined, api: ControlApi, patch: Partial<ItemsBlockConfig>, description: string): void;
9
+ export declare class ItemsBlockPriceFormatControl extends CommonControl {
10
+ private lastWritten;
11
+ getId(): string;
12
+ getTemplate(): string;
13
+ onRender(): void;
14
+ onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
15
+ onDestroy(): void;
16
+ _onThousandSeparatorChange(value: string): void;
17
+ _onDecimalSeparatorChange(value: string): void;
18
+ _onDecimalCountChange(value: string): void;
19
+ private _currentFormat;
20
+ private _write;
21
+ private _setSelectItems;
22
+ private _formValues;
23
+ private _getSelectRow;
24
+ }
@@ -35,6 +35,7 @@ export declare class ItemsBlockControl extends CommonControl {
35
35
  _reFillTemplate(itemsType?: ProductType): void;
36
36
  _recalculateTrimming(): void;
37
37
  private _getParagraphFromBlock;
38
+ private _replacePriceText;
38
39
  private _escapeRegex;
39
40
  private _removeCurrencySymbol;
40
41
  private _replacePriceNumber;
@@ -46,6 +46,8 @@ export declare enum ItemsBlockControlId {
46
46
  PRICE_CURRENCY_SYMBOL = "items-block-price-currency-symbol-control",
47
47
  PRICE_CURRENCY_LOCATION = "items-block-price-currency-location-control",
48
48
  PRICE_ORIENTATION = "items-block-price-orientation-control",
49
+ PRICE_FORMAT = "items-block-price-format-control",
50
+ BLOCK_BACKGROUND = "items-block-background-color-control",
49
51
  NAME_ALIGN = "items-block-name-align-control",
50
52
  NAME_COLOR = "items-block-name-color-control",
51
53
  NAME_SIZE = "items-block-name-size-control",
@@ -1,3 +1,4 @@
1
+ import { type ItemsPriceFormat } from './constants/currency';
1
2
  import { type ItemsBlockConfig } from './utils/nodeConfigUtils';
2
3
  declare const migrationTemplate = "ADD YOUR MIGRATION HERE";
3
4
  type ProductType = 'CART_ITEMS' | 'BROWSED_ITEMS' | 'PURCHASED_ITEMS';
@@ -36,6 +37,8 @@ type TemplateParameters = {
36
37
  quantityStyles?: string;
37
38
  /** Price orientation within the card ('vertical' = stacked, 'horizontal' = side-by-side) */
38
39
  priceOrientation?: PriceOrientationType;
40
+ /** New price model (itemsPriceFormatting): root attrs + raw dummy amounts; absent = legacy output. */
41
+ priceFormat?: ItemsPriceFormat;
39
42
  };
40
43
  /**
41
44
  * Applies price orientation styles to the generated HTML template.
@@ -67,5 +70,5 @@ export declare const applyPriceOrientationStyles: (html: string, layoutOrientati
67
70
  * @param params.formattedPrice - Whether to use formatted price display
68
71
  * @returns HTML template string for the Items Block
69
72
  */
70
- export declare function getDefaultTemplate({ orientation, itemsType, itemId, currencySymbol, currencyLocation, migrate, formattedPrice, configBlockAttributes, nodeConfig, nameStyles, buttonStyles, priceStyles, originalPriceStyles, quantityStyles, priceOrientation, }: TemplateParameters): string;
73
+ export declare function getDefaultTemplate({ orientation, itemsType, itemId, currencySymbol, currencyLocation, migrate, formattedPrice, configBlockAttributes, nodeConfig, nameStyles, buttonStyles, priceStyles, originalPriceStyles, quantityStyles, priceOrientation, priceFormat, }: TemplateParameters): string;
71
74
  export default migrationTemplate;
@@ -18,6 +18,9 @@ export interface ItemsBlockConfig {
18
18
  priceCurrencySymbol: string;
19
19
  priceCurrencyLocation: string;
20
20
  priceOrientation: 'vertical' | 'horizontal';
21
+ priceThousandSeparator?: string;
22
+ priceDecimalSeparator?: string;
23
+ priceDecimalCount?: number;
21
24
  quantityControlEnabled: boolean;
22
25
  buttonLink: string;
23
26
  imageLink: string;
@@ -0,0 +1,66 @@
1
+ import { type ItemsPriceFormat } from '../constants/currency';
2
+ import { type ItemsBlockConfig } from './nodeConfigUtils';
3
+ export type PriceParagraphKind = 'price' | 'originalPrice';
4
+ export declare const PRICE_PARAGRAPH_SELECTOR = "p[product-attr=\"price\"], p[product-attr=\"originalPrice\"]";
5
+ type AttrMap = Record<string, string | null | undefined>;
6
+ export interface PriceParagraphSnapshot {
7
+ kind: PriceParagraphKind;
8
+ attrs: AttrMap;
9
+ text: string;
10
+ }
11
+ export interface PriceFormatSnapshot {
12
+ rootAttrs: AttrMap;
13
+ paragraphs: PriceParagraphSnapshot[];
14
+ config: Partial<ItemsBlockConfig> | null;
15
+ }
16
+ export interface PriceTexts {
17
+ price: string;
18
+ originalPrice: string;
19
+ }
20
+ export interface PriceFormatOps {
21
+ rootSet: Record<string, string>;
22
+ paragraphRemove: string[];
23
+ configPatch: Partial<ItemsBlockConfig> | null;
24
+ texts: PriceTexts | null;
25
+ changed: boolean;
26
+ }
27
+ export interface PlanPriceFormatOptions {
28
+ convertLegacy: boolean;
29
+ }
30
+ export interface FormatDummyPriceInput {
31
+ amount: string | number;
32
+ format: ItemsPriceFormat;
33
+ symbol: string | null | undefined;
34
+ alignment: string | null | undefined;
35
+ }
36
+ export declare function paragraphKindOf(productAttr: string | null | undefined): PriceParagraphKind | null;
37
+ export declare function resolvePriceDummyAmounts(config: Pick<Partial<ItemsBlockConfig>, 'type' | 'priceSinglePrice'> | null | undefined): PriceTexts;
38
+ export declare function formatItemsDummyPrice({ amount, format, symbol, alignment }: FormatDummyPriceInput): string;
39
+ export declare function priceTextsFromConfig(config: Partial<ItemsBlockConfig> | null | undefined): PriceTexts;
40
+ /** `text` is decoded DOM text, `html` the rendered markup text (entities allowed). */
41
+ export declare function samePriceText(text: string | null | undefined, html: string | null | undefined): boolean;
42
+ /** Swaps the whole price text inside the paragraph markup, keeping the style wrappers around it. */
43
+ export declare function replacePriceText(innerHtml: string, currentText: string, newText: string): string;
44
+ export declare function planPriceFormatOps(snapshot: PriceFormatSnapshot, options: {
45
+ convertLegacy: true;
46
+ }): PriceFormatOps & {
47
+ texts: PriceTexts;
48
+ };
49
+ export declare function planPriceFormatOps(snapshot: PriceFormatSnapshot, options: PlanPriceFormatOptions): PriceFormatOps;
50
+ export interface PriceParagraphSource {
51
+ kind: PriceParagraphKind;
52
+ attr(name: string): string | null | undefined;
53
+ text: string;
54
+ }
55
+ export interface PriceFormatSnapshotSource {
56
+ rootAttr(name: string): string | null | undefined;
57
+ paragraphs: PriceParagraphSource[];
58
+ config: Partial<ItemsBlockConfig> | null;
59
+ }
60
+ /** Shared snapshot builder so DOM (migrator, repair) and Stripo-node callers read the same attrs. */
61
+ export declare function buildPriceFormatSnapshot(source: PriceFormatSnapshotSource): PriceFormatSnapshot;
62
+ export declare function readPersistedConfigAttribute(root: Element): Partial<ItemsBlockConfig> | null;
63
+ export declare function snapshotPriceFormatFromElement(root: Element): PriceFormatSnapshot;
64
+ /** DOM applier for parsed HTML (migrator, module repair). Returns whether anything was written. */
65
+ export declare function applyPriceFormatOpsToElement(root: Element, ops: PriceFormatOps): boolean;
66
+ export {};
@@ -57,6 +57,7 @@ interface PerBlockState {
57
57
  legacyConversionLoading: boolean;
58
58
  configVersion: number;
59
59
  adoptedSizeVersion: number;
60
+ drawnProducts: RecommendationProduct[] | null;
60
61
  }
61
62
  /**
62
63
  * Persisted-config subset used by `seedBlockUrlConfig` to reconstruct
@@ -491,6 +492,7 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
491
492
  * (SD-149916).
492
493
  */
493
494
  cloneBlockState(sourceId: number, newId: number): void;
495
+ markProductsDrawn(id: number, products: RecommendationProduct[]): void;
494
496
  /**
495
497
  * Marks a block as initialized (initial API data has been fetched).
496
498
  * Automatically cleaned up when removeBlockState deletes the block entry.
@@ -14,6 +14,18 @@ export interface FormatPriceOptions {
14
14
  /** Currency configuration */
15
15
  currency: CurrencyConfig;
16
16
  }
17
+ export interface FormatNumberOptions {
18
+ thousandSeparator: string;
19
+ decimalSeparator: string;
20
+ decimalCount: number;
21
+ }
22
+ /**
23
+ * Formats a number with custom thousand and decimal separators
24
+ * @param value - The numeric value to format
25
+ * @param options - Formatting options
26
+ * @returns Formatted number string
27
+ */
28
+ export declare function formatNumber(value: number, options: FormatNumberOptions): string;
17
29
  /**
18
30
  * Formats a numeric price according to currency settings
19
31
  * @example
@@ -135,7 +135,7 @@ export declare function createTextBackgroundColorControl(controlId: string, targ
135
135
  * next edit. We write inline `background-color` + `bgcolor` on the block `<td>` instead — surviving
136
136
  * regeneration and reaching Outlook, matching the migrator's convention.
137
137
  */
138
- export declare function createBlockBackgroundColorControl(controlId: string, blockRootSelector?: string): {
138
+ export declare function createBlockBackgroundColorControl(controlId: string, blockRootSelector?: string, title?: string): {
139
139
  new (): {
140
140
  getId(): string;
141
141
  /** The parent control renders its own generic title; restore the block-level wording. */
@@ -110,6 +110,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
110
110
  linkTrackingIds: boolean;
111
111
  allowSaveWithErrors: boolean;
112
112
  reusableRecommendationStrategy: boolean;
113
+ itemsPriceFormatting: boolean;
113
114
  };
114
115
  blocks: {
115
116
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -256,6 +257,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
256
257
  linkTrackingIds: boolean;
257
258
  allowSaveWithErrors: boolean;
258
259
  reusableRecommendationStrategy: boolean;
260
+ itemsPriceFormatting: boolean;
259
261
  };
260
262
  blocks: {
261
263
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -402,6 +404,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
402
404
  linkTrackingIds: boolean;
403
405
  allowSaveWithErrors: boolean;
404
406
  reusableRecommendationStrategy: boolean;
407
+ itemsPriceFormatting: boolean;
405
408
  };
406
409
  blocks: {
407
410
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -548,6 +551,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
548
551
  linkTrackingIds: boolean;
549
552
  allowSaveWithErrors: boolean;
550
553
  reusableRecommendationStrategy: boolean;
554
+ itemsPriceFormatting: boolean;
551
555
  };
552
556
  blocks: {
553
557
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -694,6 +698,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
694
698
  linkTrackingIds: boolean;
695
699
  allowSaveWithErrors: boolean;
696
700
  reusableRecommendationStrategy: boolean;
701
+ itemsPriceFormatting: boolean;
697
702
  };
698
703
  blocks: {
699
704
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -840,6 +845,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
840
845
  linkTrackingIds: boolean;
841
846
  allowSaveWithErrors: boolean;
842
847
  reusableRecommendationStrategy: boolean;
848
+ itemsPriceFormatting: boolean;
843
849
  };
844
850
  blocks: {
845
851
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -986,6 +992,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
986
992
  linkTrackingIds: boolean;
987
993
  allowSaveWithErrors: boolean;
988
994
  reusableRecommendationStrategy: boolean;
995
+ itemsPriceFormatting: boolean;
989
996
  };
990
997
  blocks: {
991
998
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1132,6 +1139,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1132
1139
  linkTrackingIds: boolean;
1133
1140
  allowSaveWithErrors: boolean;
1134
1141
  reusableRecommendationStrategy: boolean;
1142
+ itemsPriceFormatting: boolean;
1135
1143
  };
1136
1144
  blocks: {
1137
1145
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1278,6 +1286,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1278
1286
  linkTrackingIds: boolean;
1279
1287
  allowSaveWithErrors: boolean;
1280
1288
  reusableRecommendationStrategy: boolean;
1289
+ itemsPriceFormatting: boolean;
1281
1290
  };
1282
1291
  blocks: {
1283
1292
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1424,6 +1433,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1424
1433
  linkTrackingIds: boolean;
1425
1434
  allowSaveWithErrors: boolean;
1426
1435
  reusableRecommendationStrategy: boolean;
1436
+ itemsPriceFormatting: boolean;
1427
1437
  };
1428
1438
  blocks: {
1429
1439
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1570,6 +1580,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1570
1580
  linkTrackingIds: boolean;
1571
1581
  allowSaveWithErrors: boolean;
1572
1582
  reusableRecommendationStrategy: boolean;
1583
+ itemsPriceFormatting: boolean;
1573
1584
  };
1574
1585
  blocks: {
1575
1586
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1716,6 +1727,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1716
1727
  linkTrackingIds: boolean;
1717
1728
  allowSaveWithErrors: boolean;
1718
1729
  reusableRecommendationStrategy: boolean;
1730
+ itemsPriceFormatting: boolean;
1719
1731
  };
1720
1732
  blocks: {
1721
1733
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1862,6 +1874,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1862
1874
  linkTrackingIds: boolean;
1863
1875
  allowSaveWithErrors: boolean;
1864
1876
  reusableRecommendationStrategy: boolean;
1877
+ itemsPriceFormatting: boolean;
1865
1878
  };
1866
1879
  blocks: {
1867
1880
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2008,6 +2021,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2008
2021
  linkTrackingIds: boolean;
2009
2022
  allowSaveWithErrors: boolean;
2010
2023
  reusableRecommendationStrategy: boolean;
2024
+ itemsPriceFormatting: boolean;
2011
2025
  };
2012
2026
  blocks: {
2013
2027
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2154,6 +2168,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2154
2168
  linkTrackingIds: boolean;
2155
2169
  allowSaveWithErrors: boolean;
2156
2170
  reusableRecommendationStrategy: boolean;
2171
+ itemsPriceFormatting: boolean;
2157
2172
  };
2158
2173
  blocks: {
2159
2174
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2300,6 +2315,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2300
2315
  linkTrackingIds: boolean;
2301
2316
  allowSaveWithErrors: boolean;
2302
2317
  reusableRecommendationStrategy: boolean;
2318
+ itemsPriceFormatting: boolean;
2303
2319
  };
2304
2320
  blocks: {
2305
2321
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2446,6 +2462,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2446
2462
  linkTrackingIds: boolean;
2447
2463
  allowSaveWithErrors: boolean;
2448
2464
  reusableRecommendationStrategy: boolean;
2465
+ itemsPriceFormatting: boolean;
2449
2466
  };
2450
2467
  blocks: {
2451
2468
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2604,6 +2621,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2604
2621
  linkTrackingIds: boolean;
2605
2622
  allowSaveWithErrors: boolean;
2606
2623
  reusableRecommendationStrategy: boolean;
2624
+ itemsPriceFormatting: boolean;
2607
2625
  };
2608
2626
  blocks: {
2609
2627
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2750,6 +2768,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2750
2768
  linkTrackingIds: boolean;
2751
2769
  allowSaveWithErrors: boolean;
2752
2770
  reusableRecommendationStrategy: boolean;
2771
+ itemsPriceFormatting: boolean;
2753
2772
  };
2754
2773
  blocks: {
2755
2774
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2898,6 +2917,7 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2898
2917
  linkTrackingIds: boolean;
2899
2918
  allowSaveWithErrors: boolean;
2900
2919
  reusableRecommendationStrategy: boolean;
2920
+ itemsPriceFormatting: boolean;
2901
2921
  };
2902
2922
  blocks: {
2903
2923
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1,3 +1,7 @@
1
+ export interface ItemsCurrencyRepairOptions {
2
+ /** Convert legacy-model blocks to the root price-format contract (itemsPriceFormatting). */
3
+ convertToPriceFormat?: boolean;
4
+ }
1
5
  /**
2
6
  * Heals stale price currency attributes on every v2 Items block inside a dropped
3
7
  * saved module, driving `data-curency` / `data-currency_symbol` from each block's
@@ -14,4 +18,4 @@
14
18
  * recommendationMigrator wraps). If the wrap fails to capture the blocks (non-`<td>`
15
19
  * root foster-parented out), it bails to the original string.
16
20
  */
17
- export declare function repairItemsCurrencyAttributes(html: string): string;
21
+ export declare function repairItemsCurrencyAttributes(html: string, { convertToPriceFormat }?: ItemsCurrencyRepairOptions): string;
@@ -20,6 +20,25 @@ export declare function readTrackSeq(html: string): number;
20
20
  * Scans the document because a rewrite can strip the seq host but keep the ids.
21
21
  */
22
22
  export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
+ export interface TrackingIdPlan {
24
+ /** Final id per anchor, in the order the raw values were given. */
25
+ ids: number[];
26
+ reassigned: boolean[];
27
+ nextSeq: number;
28
+ seqChanged: boolean;
29
+ changed: boolean;
30
+ }
31
+ /**
32
+ * The id rule shared by the string transform and the editor-model writer: `rawIds` are the
33
+ * anchors' current `data-ins-track-id` values in document order ('' when absent).
34
+ */
35
+ export declare function planTrackingIds(rawIds: readonly string[], persistedSeq: number, floor?: number): TrackingIdPlan;
36
+ /** Reads a `data-ins-track-seq` attribute value the way readTrackSeq reads it from HTML. */
37
+ export declare function parseTrackSeq(value: string | null): number;
38
+ /** The `data-ins-track-id` value of every `<a>` opening tag in `html`, in order ('' when absent). */
39
+ export declare function readAnchorTrackIds(html: string): string[];
40
+ /** Writes `ids[i]` onto the i-th `<a>` opening tag of `html`; `null` or a missing entry leaves it untouched. */
41
+ export declare function writeAnchorTrackIds(html: string, ids: readonly (number | null)[]): string;
23
42
  /**
24
43
  * Ensures every <a> opening tag carries a unique positive-integer id and the
25
44
  * document records the id high-water mark. Ids are minted above
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Browsers ignore whitespace around an href, but the send-time link rewrite does not:
3
+ * a trailing space ends up inside the path and a leading one skips the tracking params.
4
+ */
5
+ export declare function trimHrefWhitespace(html: string): string;
@@ -1,39 +1,44 @@
1
- import { currencyAttrTargets as u, ITEMS_CURRENCY_ATTR as c } from "../extensions/Blocks/Items/constants/currency.js";
2
- import { ItemsBlockId as l } from "../extensions/Blocks/Items/enums/controlEnums.js";
3
- const s = "items-block-v2";
4
- function f(e) {
5
- const i = e.getAttribute("esd-ext-config");
6
- if (!i)
1
+ import { isNewPriceFormatRoot as a, currencyAttrTargets as f, ITEMS_CURRENCY_ATTR as c } from "../extensions/Blocks/Items/constants/currency.js";
2
+ import { ItemsBlockId as p } from "../extensions/Blocks/Items/enums/controlEnums.js";
3
+ import { snapshotPriceFormatFromElement as m, planPriceFormatOps as y, applyPriceFormatOpsToElement as d } from "../extensions/Blocks/Items/utils/priceFormatOps.js";
4
+ const u = "items-block-v2";
5
+ function S(e, i) {
6
+ if (i || a(e)) {
7
+ const t = m(e), l = y(t, { convertLegacy: i });
8
+ return d(e, l);
9
+ }
10
+ const n = e.getAttribute("esd-ext-config");
11
+ if (!n)
7
12
  return !1;
8
- let t, r;
13
+ let r, o;
9
14
  try {
10
- ({ position: t, symbol: r } = u(JSON.parse(i)));
15
+ ({ position: r, symbol: o } = f(JSON.parse(n)));
11
16
  } catch {
12
17
  return !1;
13
18
  }
14
- let o = !1;
15
- return e.querySelectorAll(`.${l.PRICE} p`).forEach((n) => {
16
- t !== void 0 && n.getAttribute(c.POSITION) !== t && (n.setAttribute(c.POSITION, t), o = !0), r !== void 0 && n.getAttribute(c.SYMBOL) !== r && (n.setAttribute(c.SYMBOL, r), o = !0);
17
- }), o;
19
+ let s = !1;
20
+ return e.querySelectorAll(`.${p.PRICE} p`).forEach((t) => {
21
+ r !== void 0 && t.getAttribute(c.POSITION) !== r && (t.setAttribute(c.POSITION, r), s = !0), o !== void 0 && t.getAttribute(c.SYMBOL) !== o && (t.setAttribute(c.SYMBOL, o), s = !0);
22
+ }), s;
18
23
  }
19
- function S(e) {
20
- if (typeof e != "string" || !e.includes(s))
24
+ function I(e, { convertToPriceFormat: i = !1 } = {}) {
25
+ if (typeof e != "string" || !e.includes(u))
21
26
  return e;
22
27
  try {
23
- const t = new DOMParser().parseFromString(
28
+ const r = new DOMParser().parseFromString(
24
29
  `<table><tbody><tr>${e}</tr></tbody></table>`,
25
30
  "text/html"
26
- ).querySelector("tr"), r = t.querySelectorAll(`.${s}`);
27
- if (r.length === 0)
31
+ ).querySelector("tr"), o = r.querySelectorAll(`.${u}`);
32
+ if (o.length === 0)
28
33
  return e;
29
- let o = !1;
30
- return r.forEach((n) => {
31
- f(n) && (o = !0);
32
- }), o ? t.innerHTML : e;
33
- } catch (i) {
34
- return console.error("Failed to repair items currency on module add:", i), e;
34
+ let s = !1;
35
+ return o.forEach((t) => {
36
+ S(t, i) && (s = !0);
37
+ }), s ? r.innerHTML : e;
38
+ } catch (n) {
39
+ return console.error("Failed to repair items currency on module add:", n), e;
35
40
  }
36
41
  }
37
42
  export {
38
- S as repairItemsCurrencyAttributes
43
+ I as repairItemsCurrencyAttributes
39
44
  };