@useinsider/guido 3.24.0-beta.7cfd3b1 → 3.24.0-beta.8779b29

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 (51) hide show
  1. package/README.md +1 -0
  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/useModuleRepair.js +14 -12
  6. package/dist/config/migrator/index.js +16 -15
  7. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  8. package/dist/config/migrator/recommendationMigrator.js +59 -66
  9. package/dist/extensions/Blocks/Items/block.js +115 -77
  10. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  11. package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
  12. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
  13. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  14. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  15. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  16. package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
  17. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  18. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  19. package/dist/extensions/Blocks/Items/extension.js +15 -13
  20. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  21. package/dist/extensions/Blocks/Items/settingsPanel.js +38 -25
  22. package/dist/extensions/Blocks/Items/template.js +250 -212
  23. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  24. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  25. package/dist/extensions/Blocks/controlFactories.js +104 -104
  26. package/dist/guido.css +1 -1
  27. package/dist/package.json.js +1 -1
  28. package/dist/src/@types/config/schemas.d.ts +4 -0
  29. package/dist/src/composables/useConfig.d.ts +2 -0
  30. package/dist/src/config/migrator/index.d.ts +4 -1
  31. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  32. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
  33. package/dist/src/config/migrator/recommendationMigrator.d.ts +5 -1
  34. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  35. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  36. package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
  37. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
  38. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  39. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
  40. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  41. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  42. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
  43. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  44. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
  45. package/dist/src/stores/config.d.ts +20 -0
  46. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  47. package/dist/utils/itemsCurrencyRepair.js +29 -24
  48. package/dist/utils/pairProductVariables.js +119 -99
  49. package/package.json +1 -1
  50. package/dist/config/migrator/recommendation/inferLegacyConfig.js +0 -99
  51. package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +0 -6
@@ -415,6 +415,8 @@ export declare const FeaturesSchema: v.ObjectSchema<{
415
415
  /** Allow persisting a template that still has validation errors (drawer "Save and Continue" soft-save). Host sets false for transactional + unsubscribe. */
416
416
  readonly allowSaveWithErrors: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
417
417
  readonly reusableRecommendationStrategy: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
418
+ /** Items block: Recommendation-style price formatting (root currency-* attrs, raw price tags). Released dark. */
419
+ readonly itemsPriceFormatting: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
418
420
  }, undefined>;
419
421
  /**
420
422
  * Default block types available in Stripo
@@ -834,6 +836,8 @@ export declare const GuidoConfigSchema: v.ObjectSchema<{
834
836
  /** Allow persisting a template that still has validation errors (drawer "Save and Continue" soft-save). Host sets false for transactional + unsubscribe. */
835
837
  readonly allowSaveWithErrors: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
836
838
  readonly reusableRecommendationStrategy: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
839
+ /** Items block: Recommendation-style price formatting (root currency-* attrs, raw price tags). Released dark. */
840
+ readonly itemsPriceFormatting: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
837
841
  }, undefined>, {}>;
838
842
  /** Block configuration */
839
843
  readonly blocks: v.OptionalSchema<v.ObjectSchema<{
@@ -105,6 +105,7 @@ export declare const useConfig: () => {
105
105
  linkTrackingIds: boolean;
106
106
  allowSaveWithErrors: boolean;
107
107
  reusableRecommendationStrategy: boolean;
108
+ itemsPriceFormatting: boolean;
108
109
  };
109
110
  blocks: {
110
111
  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")[];
@@ -245,6 +246,7 @@ export declare const useConfig: () => {
245
246
  linkTrackingIds: boolean;
246
247
  allowSaveWithErrors: boolean;
247
248
  reusableRecommendationStrategy: boolean;
249
+ itemsPriceFormatting: boolean;
248
250
  } | null>;
249
251
  blocks: import("vue").ComputedRef<{
250
252
  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,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;
@@ -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 empty or unable to be parsed — the caller treats
6
+ * the attribute is missing 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,4 +1,8 @@
1
- /** Idempotent: the selector excludes `recommendation-block-v2`, so re-running on a migrated template is a no-op. */
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
+ */
2
6
  import type { LegacyRecommendationConfig } from '@@/Types/config';
3
7
  /**
4
8
  * 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 {};
@@ -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;
@@ -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
  };