@useinsider/guido 3.24.0 → 3.25.0-beta.0d90126

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 (70) hide show
  1. package/README.md +8 -1
  2. package/dist/@types/config/schemas.js +19 -15
  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/useSave.js +57 -52
  10. package/dist/composables/useSaveValidation.js +118 -110
  11. package/dist/composables/useStripo.js +70 -70
  12. package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
  13. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  14. package/dist/config/migrator/index.js +16 -15
  15. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  16. package/dist/enums/save-validation.js +1 -1
  17. package/dist/extensions/Blocks/Items/block.js +115 -77
  18. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  19. package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
  20. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
  21. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  22. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  23. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  24. package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
  25. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  26. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  27. package/dist/extensions/Blocks/Items/extension.js +15 -13
  28. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  29. package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
  30. package/dist/extensions/Blocks/Items/template.js +250 -212
  31. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  32. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  33. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  34. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  35. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  36. package/dist/extensions/Blocks/controlFactories.js +104 -104
  37. package/dist/guido.css +1 -1
  38. package/dist/package.json.js +2 -2
  39. package/dist/services/templateLibraryApi.js +39 -36
  40. package/dist/src/@types/config/schemas.d.ts +8 -0
  41. package/dist/src/composables/useConfig.d.ts +4 -0
  42. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  43. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  44. package/dist/src/composables/useStripo.d.ts +1 -1
  45. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
  46. package/dist/src/config/migrator/index.d.ts +4 -1
  47. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  48. package/dist/src/enums/save-validation.d.ts +2 -1
  49. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  50. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  51. package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
  52. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
  53. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  54. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
  55. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  56. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  57. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
  58. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  59. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  60. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
  61. package/dist/src/stores/config.d.ts +40 -0
  62. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  63. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  64. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  65. package/dist/utils/itemsCurrencyRepair.js +29 -24
  66. package/dist/utils/linkTrackingIds.js +82 -48
  67. package/dist/utils/pairProductVariables.js +119 -99
  68. package/dist/utils/templatePreparation.js +30 -33
  69. package/dist/utils/trimHrefWhitespace.js +10 -0
  70. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ export interface EditorTrackingIdsResult {
2
+ changed: boolean;
3
+ nextSeq: number;
4
+ }
5
+ export declare const useEditorTrackingIds: () => {
6
+ writeTrackingIds: (floor: number) => EditorTrackingIdsResult;
7
+ };
@@ -1,6 +1,6 @@
1
1
  import type { DynamicContent } from '@@/Types/generic';
2
2
  import type { SaveValidationError } from '@@/Types/save-validation';
3
3
  export declare const useSaveValidation: () => {
4
- collectSaveValidationErrors: (compiledHtml: string, dynamicContentList: DynamicContent[]) => Promise<SaveValidationError[]>;
4
+ collectSaveValidationErrors: (compiledHtml: string, dynamicContentList: DynamicContent[], rawHtml: string) => Promise<SaveValidationError[]>;
5
5
  validateCurrentTemplate: () => Promise<SaveValidationError[]>;
6
6
  };
@@ -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
  };
@@ -3,6 +3,9 @@ declare const SINGLETON_BLOCK_RULES: {
3
3
  messageKey: string;
4
4
  }[];
5
5
  export declare const EMPTY_BLOCK_KEY = "unsubscription-preference.select-page-to-continue";
6
+ export declare const EXTERNALLY_MANAGED_UNSUBSCRIBE_KEY = "newsletter.sfmc-remove-unsubscribe-link";
7
+ /** Pure core: whether the html carries an Insider unsubscribe merge tag or ASM unsubscribe code. */
8
+ export declare function hasInsiderUnsubscribeCode(html: string): boolean;
6
9
  /** Pure core: the singleton rules whose page type appears more than once. */
7
10
  export declare function findDuplicateUnsubPageTypes(html: string): typeof SINGLETON_BLOCK_RULES;
8
11
  /** Pure core: count of unsubscribe blocks with no page type or page list chosen. */
@@ -10,5 +13,6 @@ export declare function countUnsubBlocksWithoutPage(html: string): number;
10
13
  export declare const useUnsubscribeBlockValidator: () => {
11
14
  validateUnsubscribeBlockUniqueness: (html: string) => boolean;
12
15
  validateUnsubscribeBlockHasTemplate: (html: string) => boolean;
16
+ validateNoInsiderUnsubscribeCode: (html: string, silent?: boolean) => boolean;
13
17
  };
14
18
  export {};
@@ -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;
@@ -23,5 +23,6 @@ export declare enum SaveValidationRule {
23
23
  RecommendationFilters = "recommendation-filters",
24
24
  InvalidImageType = "invalid-image-type",
25
25
  CheckboxUnsubGroup = "checkbox-unsub-group",
26
- RadioButtonUnsubGroup = "radio-button-unsub-group"
26
+ RadioButtonUnsubGroup = "radio-button-unsub-group",
27
+ ExternallyManagedUnsubscribe = "externally-managed-unsubscribe"
27
28
  }
@@ -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,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
110
110
  linkTrackingIds: boolean;
111
111
  allowSaveWithErrors: boolean;
112
112
  reusableRecommendationStrategy: boolean;
113
+ itemsPriceFormatting: boolean;
114
+ blockUnsubscribeLinks: boolean;
113
115
  };
114
116
  blocks: {
115
117
  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 +258,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
256
258
  linkTrackingIds: boolean;
257
259
  allowSaveWithErrors: boolean;
258
260
  reusableRecommendationStrategy: boolean;
261
+ itemsPriceFormatting: boolean;
262
+ blockUnsubscribeLinks: boolean;
259
263
  };
260
264
  blocks: {
261
265
  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 +406,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
402
406
  linkTrackingIds: boolean;
403
407
  allowSaveWithErrors: boolean;
404
408
  reusableRecommendationStrategy: boolean;
409
+ itemsPriceFormatting: boolean;
410
+ blockUnsubscribeLinks: boolean;
405
411
  };
406
412
  blocks: {
407
413
  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 +554,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
548
554
  linkTrackingIds: boolean;
549
555
  allowSaveWithErrors: boolean;
550
556
  reusableRecommendationStrategy: boolean;
557
+ itemsPriceFormatting: boolean;
558
+ blockUnsubscribeLinks: boolean;
551
559
  };
552
560
  blocks: {
553
561
  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 +702,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
694
702
  linkTrackingIds: boolean;
695
703
  allowSaveWithErrors: boolean;
696
704
  reusableRecommendationStrategy: boolean;
705
+ itemsPriceFormatting: boolean;
706
+ blockUnsubscribeLinks: boolean;
697
707
  };
698
708
  blocks: {
699
709
  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 +850,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
840
850
  linkTrackingIds: boolean;
841
851
  allowSaveWithErrors: boolean;
842
852
  reusableRecommendationStrategy: boolean;
853
+ itemsPriceFormatting: boolean;
854
+ blockUnsubscribeLinks: boolean;
843
855
  };
844
856
  blocks: {
845
857
  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 +998,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
986
998
  linkTrackingIds: boolean;
987
999
  allowSaveWithErrors: boolean;
988
1000
  reusableRecommendationStrategy: boolean;
1001
+ itemsPriceFormatting: boolean;
1002
+ blockUnsubscribeLinks: boolean;
989
1003
  };
990
1004
  blocks: {
991
1005
  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 +1146,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1132
1146
  linkTrackingIds: boolean;
1133
1147
  allowSaveWithErrors: boolean;
1134
1148
  reusableRecommendationStrategy: boolean;
1149
+ itemsPriceFormatting: boolean;
1150
+ blockUnsubscribeLinks: boolean;
1135
1151
  };
1136
1152
  blocks: {
1137
1153
  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 +1294,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1278
1294
  linkTrackingIds: boolean;
1279
1295
  allowSaveWithErrors: boolean;
1280
1296
  reusableRecommendationStrategy: boolean;
1297
+ itemsPriceFormatting: boolean;
1298
+ blockUnsubscribeLinks: boolean;
1281
1299
  };
1282
1300
  blocks: {
1283
1301
  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 +1442,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1424
1442
  linkTrackingIds: boolean;
1425
1443
  allowSaveWithErrors: boolean;
1426
1444
  reusableRecommendationStrategy: boolean;
1445
+ itemsPriceFormatting: boolean;
1446
+ blockUnsubscribeLinks: boolean;
1427
1447
  };
1428
1448
  blocks: {
1429
1449
  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 +1590,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1570
1590
  linkTrackingIds: boolean;
1571
1591
  allowSaveWithErrors: boolean;
1572
1592
  reusableRecommendationStrategy: boolean;
1593
+ itemsPriceFormatting: boolean;
1594
+ blockUnsubscribeLinks: boolean;
1573
1595
  };
1574
1596
  blocks: {
1575
1597
  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 +1738,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1716
1738
  linkTrackingIds: boolean;
1717
1739
  allowSaveWithErrors: boolean;
1718
1740
  reusableRecommendationStrategy: boolean;
1741
+ itemsPriceFormatting: boolean;
1742
+ blockUnsubscribeLinks: boolean;
1719
1743
  };
1720
1744
  blocks: {
1721
1745
  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 +1886,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1862
1886
  linkTrackingIds: boolean;
1863
1887
  allowSaveWithErrors: boolean;
1864
1888
  reusableRecommendationStrategy: boolean;
1889
+ itemsPriceFormatting: boolean;
1890
+ blockUnsubscribeLinks: boolean;
1865
1891
  };
1866
1892
  blocks: {
1867
1893
  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 +2034,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2008
2034
  linkTrackingIds: boolean;
2009
2035
  allowSaveWithErrors: boolean;
2010
2036
  reusableRecommendationStrategy: boolean;
2037
+ itemsPriceFormatting: boolean;
2038
+ blockUnsubscribeLinks: boolean;
2011
2039
  };
2012
2040
  blocks: {
2013
2041
  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 +2182,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2154
2182
  linkTrackingIds: boolean;
2155
2183
  allowSaveWithErrors: boolean;
2156
2184
  reusableRecommendationStrategy: boolean;
2185
+ itemsPriceFormatting: boolean;
2186
+ blockUnsubscribeLinks: boolean;
2157
2187
  };
2158
2188
  blocks: {
2159
2189
  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 +2330,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2300
2330
  linkTrackingIds: boolean;
2301
2331
  allowSaveWithErrors: boolean;
2302
2332
  reusableRecommendationStrategy: boolean;
2333
+ itemsPriceFormatting: boolean;
2334
+ blockUnsubscribeLinks: boolean;
2303
2335
  };
2304
2336
  blocks: {
2305
2337
  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 +2478,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2446
2478
  linkTrackingIds: boolean;
2447
2479
  allowSaveWithErrors: boolean;
2448
2480
  reusableRecommendationStrategy: boolean;
2481
+ itemsPriceFormatting: boolean;
2482
+ blockUnsubscribeLinks: boolean;
2449
2483
  };
2450
2484
  blocks: {
2451
2485
  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 +2638,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2604
2638
  linkTrackingIds: boolean;
2605
2639
  allowSaveWithErrors: boolean;
2606
2640
  reusableRecommendationStrategy: boolean;
2641
+ itemsPriceFormatting: boolean;
2642
+ blockUnsubscribeLinks: boolean;
2607
2643
  };
2608
2644
  blocks: {
2609
2645
  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 +2786,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2750
2786
  linkTrackingIds: boolean;
2751
2787
  allowSaveWithErrors: boolean;
2752
2788
  reusableRecommendationStrategy: boolean;
2789
+ itemsPriceFormatting: boolean;
2790
+ blockUnsubscribeLinks: boolean;
2753
2791
  };
2754
2792
  blocks: {
2755
2793
  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 +2936,8 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2898
2936
  linkTrackingIds: boolean;
2899
2937
  allowSaveWithErrors: boolean;
2900
2938
  reusableRecommendationStrategy: boolean;
2939
+ itemsPriceFormatting: boolean;
2940
+ blockUnsubscribeLinks: boolean;
2901
2941
  };
2902
2942
  blocks: {
2903
2943
  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
  };