@useinsider/guido 3.20.1-beta.2a573b4 → 3.20.1-beta.2c8da49

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 (44) hide show
  1. package/dist/composables/useActionsApi.js +80 -63
  2. package/dist/composables/useGuidoStateBridge.js +3 -3
  3. package/dist/composables/useStripo.js +8 -8
  4. package/dist/extensions/Blocks/Recommendation/block.js +33 -29
  5. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +78 -83
  6. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
  7. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +2 -12
  8. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +104 -86
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +222 -210
  10. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -50
  11. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +16 -21
  12. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +44 -40
  13. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +14 -19
  14. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +104 -102
  15. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +18 -23
  16. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +312 -286
  17. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +24 -20
  18. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +6 -7
  19. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  20. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +113 -151
  21. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +20 -11
  22. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  23. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +25 -0
  24. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +9 -9
  25. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +106 -50
  26. package/dist/extensions/Blocks/Recommendation/utils/productIds.js +3 -5
  27. package/dist/src/composables/useActionsApi.d.ts +5 -1
  28. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -6
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  31. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -11
  32. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +6 -3
  33. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +6 -5
  34. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -3
  35. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +21 -9
  36. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +19 -13
  37. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +10 -8
  38. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +9 -5
  39. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +6 -0
  40. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +13 -13
  41. package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +0 -2
  42. package/dist/src/stores/editor.d.ts +3 -1
  43. package/dist/stores/editor.js +5 -0
  44. package/package.json +1 -1
@@ -1,21 +1,21 @@
1
1
  import "../constants/selectors.js";
2
2
  import { RRS_CONFIG_VERSION as m } from "../constants/defaultConfig.js";
3
- import { sanitizeProductIds as p, PRODUCT_ID_SEPARATOR as d } from "./productIds.js";
4
- const u = "manualMerchandising";
5
- function f({ strategyId: e, nodeConfigVersion: t }) {
3
+ import { sanitizeProductIds as p } from "./productIds.js";
4
+ const d = "manualMerchandising";
5
+ function N({ strategyId: e, nodeConfigVersion: t }) {
6
6
  return !e && t < m;
7
7
  }
8
8
  const o = (e) => {
9
9
  const t = String(e ?? "").trim();
10
10
  return /^[1-9]\d*$/.test(t) ? t : null;
11
11
  };
12
- function R({ campaignId: e, templateLibraryId: t }) {
12
+ function f({ campaignId: e, templateLibraryId: t }) {
13
13
  if (o(e))
14
14
  return { scope: "campaign" };
15
15
  const n = o(t);
16
16
  return n ? { scope: "template", templateId: n } : { scope: "campaign" };
17
17
  }
18
- function S({
18
+ function y({
19
19
  blockId: e,
20
20
  url: t,
21
21
  campaignId: n,
@@ -24,7 +24,7 @@ function S({
24
24
  productIds: s,
25
25
  target: r
26
26
  }) {
27
- const i = c === u ? p(s).split(d).filter(Boolean) : [];
27
+ const i = c === d ? p(s).split(",").filter(Boolean) : [];
28
28
  return {
29
29
  ...r.scope === "template" ? { templateId: Number.parseInt(r.templateId) } : {
30
30
  campaignId: Number.parseInt(n) || 0,
@@ -36,7 +36,7 @@ function S({
36
36
  };
37
37
  }
38
38
  export {
39
- S as buildLegacyMigrationPayload,
40
- f as isLegacyStrategyConfig,
41
- R as resolveMigrationTarget
39
+ y as buildLegacyMigrationPayload,
40
+ N as isLegacyStrategyConfig,
41
+ f as resolveMigrationTarget
42
42
  };
@@ -1,68 +1,124 @@
1
1
  import { ModificationDescription as g } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { RECOMMENDATION_ID_ATTR as l } from "../constants/selectors.js";
3
- import { isPartnerManagedBlock as m, updateProductContentInPlace as d, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
4
- import { RecommendationConfigService as c } from "../services/configService.js";
5
- import { useRecommendationExtensionStore as y } from "../store/recommendation.js";
6
- let r = null;
7
- function M(n) {
8
- r = n;
2
+ import { RECOMMENDATION_ID_ATTR as m } from "../constants/selectors.js";
3
+ import { setCurrencyAttributes as h, isPartnerManagedBlock as p, updateProductContentInPlace as O, regenerateProductRowsWithStyles as N } from "../controls/main/utils.js";
4
+ import { RecommendationConfigService as u } from "../services/configService.js";
5
+ import { useRecommendationExtensionStore as S } from "../store/recommendation.js";
6
+ const D = "Update recommendation filters", E = [
7
+ ["strategyId", () => "Updated recommendation strategy"],
8
+ ["strategy", (e) => `Changed algorithm to ${e.strategy}`],
9
+ ["productIds", () => "Updated product IDs"],
10
+ ["size", (e) => `Changed product count to ${e.size}`],
11
+ ["language", (e) => `Changed language to ${e.language}`],
12
+ ["shuffleProducts", (e) => `${e.shuffleProducts ? "Enabled" : "Disabled"} product shuffle`],
13
+ ["currency", (e) => {
14
+ var n;
15
+ return `Changed currency to ${(n = e.currency) == null ? void 0 : n.code}`;
16
+ }],
17
+ ["filters", () => D]
18
+ ];
19
+ let i = null;
20
+ const a = /* @__PURE__ */ new Set();
21
+ function _(e) {
22
+ i = e;
9
23
  }
10
- function a(n) {
11
- const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
12
- return !e || !("querySelector" in e) ? null : e.querySelector(`[${l}="${n}"]`) ?? null;
24
+ function w(e) {
25
+ return a.add(e), () => {
26
+ a.delete(e);
27
+ };
13
28
  }
14
- function N(n, e) {
15
- const o = c.getConfig(n);
16
- return Object.keys(e).some((t) => JSON.stringify(o[t]) !== JSON.stringify(e[t]));
29
+ function A() {
30
+ let e = 0;
31
+ return [...a].forEach((n) => {
32
+ try {
33
+ n() && (e += 1);
34
+ } catch (t) {
35
+ console.error("[recommendation] pending config flush failed", t);
36
+ }
37
+ }), e;
17
38
  }
18
- function S(n, e) {
19
- const o = c.getConfig(n);
20
- return ["filters", "strategy", "strategyId", "size"].some((t) => t in e && JSON.stringify(o[t]) !== JSON.stringify(e[t]));
39
+ function C(e) {
40
+ const n = i == null ? void 0 : i.getDocumentRootHtmlNode();
41
+ return !n || !("querySelector" in n) ? null : n.querySelector(`[${m}="${e}"]`) ?? null;
21
42
  }
22
- function P(n, e, o) {
23
- const t = a(n);
24
- return !r || !t ? !1 : (S(t, e) && c.updateConfig(r, t, e, o), !0);
43
+ function d(e) {
44
+ return JSON.stringify(e, (n, t) => t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t).sort(([r], [o]) => r.localeCompare(o))) : t);
25
45
  }
26
- function p(n, e) {
27
- const o = y(), t = o.currentRecommendationId;
28
- if (t === n || !o.blockStates[n]) {
29
- e();
46
+ function l(e, n, t) {
47
+ return t in n && d(e[t]) !== d(n[t]);
48
+ }
49
+ function I(e, n) {
50
+ const t = u.getConfig(e);
51
+ return Object.keys(n).some((r) => l(t, n, r));
52
+ }
53
+ function P(e, n) {
54
+ const t = E.find(([r]) => l(e, n, r));
55
+ return t ? t[1](n) : null;
56
+ }
57
+ function y(e, n, t) {
58
+ u.stageConfig(e, n, t), t.currency && l(u.getConfig(n), t, "currency") && h({ currentNode: n, documentModifier: e, currency: t.currency, stageOnly: !0 });
59
+ }
60
+ function k(e, n, t) {
61
+ const r = C(e);
62
+ if (!i || !r)
63
+ return "missing";
64
+ const o = P(u.getConfig(r), n);
65
+ if (o === null)
66
+ return "unchanged";
67
+ const c = i.getDocumentModifier();
68
+ return y(c, r, n), c.apply(new g(t ?? o)), "applied";
69
+ }
70
+ function R(e, n) {
71
+ const t = S(), r = t.currentRecommendationId;
72
+ if (r === e || !t.blockStates[e]) {
73
+ n();
30
74
  return;
31
75
  }
32
- o.setCurrentBlock(n);
76
+ t.setCurrentBlock(e);
33
77
  try {
34
- e();
78
+ n();
35
79
  } finally {
36
- o.$patch({ currentRecommendationId: t });
80
+ t.$patch({ currentRecommendationId: r });
37
81
  }
38
82
  }
39
- function I(n) {
40
- const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
41
- return !e || !("querySelectorAll" in e) ? [] : e.querySelectorAll(`[${l}="${n}"]`).map((o) => c.getConfig(o));
83
+ function F(e) {
84
+ const n = i == null ? void 0 : i.getDocumentRootHtmlNode();
85
+ return !n || !("querySelectorAll" in n) ? [] : n.querySelectorAll(`[${m}="${e}"]`).map((t) => u.getConfig(t));
42
86
  }
43
- function $(n, e, o, t) {
44
- const i = a(n);
45
- if (!r || !i)
87
+ function j(e, n, t, r) {
88
+ const o = C(e);
89
+ if (!i || !o)
46
90
  return !1;
47
- const f = r.getDocumentModifier(), s = N(i, e);
48
- if (c.stageConfig(f, i, e), m(i))
49
- return s && f.apply(new g(t)), !0;
50
- let u = !1;
51
- return p(n, () => {
52
- d({
53
- currentNode: i,
54
- documentModifier: f,
55
- products: o,
56
- onApplied: () => {
57
- u = !0;
91
+ const c = i.getDocumentModifier(), s = I(o, n);
92
+ if (y(c, o, n), p(o))
93
+ return s && c.apply(new g(r)), !0;
94
+ let f = !1;
95
+ return R(e, () => {
96
+ O({
97
+ currentNode: o,
98
+ documentModifier: c,
99
+ products: t,
100
+ stageOnly: !0,
101
+ configOverrides: n,
102
+ onChanged: () => {
103
+ f = !0;
58
104
  }
59
- }) || (u = C({ currentNode: i, documentModifier: f, products: o }));
60
- }), !u && s && f.apply(new g(t)), !0;
105
+ }) || (f = N({
106
+ currentNode: o,
107
+ documentModifier: c,
108
+ products: t,
109
+ stageOnly: !0,
110
+ configOverrides: n
111
+ }));
112
+ }), (s || f) && c.apply(new g(r)), !0;
61
113
  }
62
114
  export {
63
- $ as commitBlockChangeOutsidePanel,
64
- S as hasEditedConfigChange,
65
- I as readBlockNodeConfigs,
66
- M as registerNodeConfigWriter,
67
- P as writeBlockConfigOutsidePanel
115
+ D as UPDATE_FILTERS_DESCRIPTION,
116
+ j as commitBlockChangeOutsidePanel,
117
+ P as describeConfigChange,
118
+ A as flushPendingNodeConfigWrites,
119
+ F as readBlockNodeConfigs,
120
+ _ as registerNodeConfigWriter,
121
+ w as registerPendingConfigFlush,
122
+ y as stageConfigChange,
123
+ k as writeBlockConfigOutsidePanel
68
124
  };
@@ -1,8 +1,6 @@
1
- const i = ",";
2
- function o(t) {
3
- return t.map((n) => String(n ?? "").trim()).filter(Boolean).join(",");
1
+ function n(t) {
2
+ return t.map((i) => String(i ?? "").trim()).filter(Boolean).join(",");
4
3
  }
5
4
  export {
6
- i as PRODUCT_ID_SEPARATOR,
7
- o as sanitizeProductIds
5
+ n as sanitizeProductIds
8
6
  };
@@ -1,11 +1,15 @@
1
1
  import type { CompileEmailOptions } from '@@/Types/actions-api';
2
2
  import { GetCompiledEmailOptions, CompiledEmailResult, TemplateData } from '@@/Types/actions-api';
3
+ interface TemplateReadOptions {
4
+ flushPendingEdits?: boolean;
5
+ }
3
6
  export declare const useActionsApi: () => {
4
7
  getCompiledEmail: (options?: GetCompiledEmailOptions) => Promise<CompiledEmailResult>;
5
- getTemplateData: () => Promise<TemplateData>;
8
+ getTemplateData: ({ flushPendingEdits }?: TemplateReadOptions) => Promise<TemplateData>;
6
9
  activateCustomViewStyles: (isActive?: boolean) => void;
7
10
  getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
8
11
  updateTimerInClonedTemplate: () => Promise<string | null>;
9
12
  updateHtmlAndCss: (html: string, css: string) => Promise<void>;
10
13
  editorSave: () => Promise<boolean>;
11
14
  };
15
+ export {};
@@ -36,6 +36,7 @@ export declare class RecommendationBlock extends Block {
36
36
  * attribute and overwrites dynamically added classes via setAttribute.
37
37
  */
38
38
  getTemplate(): string;
39
+ onDocumentInit(): void;
39
40
  /**
40
41
  * Called when a new block is dropped into the template
41
42
  *
@@ -171,13 +171,10 @@ export declare class RecommendationCardCompositionControl extends CommonControl
171
171
  */
172
172
  private _removeCustomAttributeHtml;
173
173
  /**
174
- * Atomically updates both composition and custom-attributes in a single apply()
175
- * so that onTemplateNodeUpdated fires only once with fully consistent state.
176
- * Two separate apply() calls would cause an intermediate onTemplateNodeUpdated
177
- * where composition is updated but customAttributes still has the old order,
178
- * producing a flicker on the custom attribute dropdowns.
174
+ * Stages composition and custom-attributes into the caller's batch, so one apply()
175
+ * lands both with the card DOM and onTemplateNodeUpdated sees consistent state.
179
176
  */
180
- private _updateBothAttributes;
177
+ private _stageBothAttributes;
181
178
  /**
182
179
  * Reorders attribute rows within each product card based on composition order.
183
180
  * Only used for grid layout (list layout has fixed 3-column structure).
@@ -30,13 +30,13 @@ export declare class CurrencyControl extends CommonControl {
30
30
  _setFormValues(): void;
31
31
  _initializeSelectItems(): void;
32
32
  /**
33
- * Applies currency updates to node config, HTML attributes, Pinia store, and DOM.
33
+ * Applies a display-only currency change (symbol, separators, alignment, decimal count) to node
34
+ * config, block attributes, store and the price text in ONE apply. No product refetch.
34
35
  * @param updates - Partial currency config to merge
35
- * @param triggerRefetch - Whether to trigger a product API refetch.
36
- * true for currency code changes (different prices from API),
37
- * false for display-only changes (symbol, separators, alignment, decimal count).
38
36
  */
39
- _updateCurrency(updates: Partial<CurrencyConfig>, triggerRefetch?: boolean): void;
37
+ _updateCurrency(updates: Partial<CurrencyConfig>): void;
38
+ /** Re-stamps the compiler-read block attributes where they drifted from the node config. */
39
+ private _repairCurrencyAttributes;
40
40
  _onCurrencyChange(value: string): void;
41
41
  _onCurrencyLocationChange(value: string): void;
42
42
  _onCurrencySymbolChange(value: string): void;
@@ -20,6 +20,7 @@ export * from './utils';
20
20
  export declare class RecommendationBlockControl extends CommonControl {
21
21
  private store;
22
22
  private storeUnsubscription;
23
+ private unregisterConfigFlush;
23
24
  private pendingNodeConfigWrite;
24
25
  private pendingConfigFlushTimer;
25
26
  private trackedBlockId;
@@ -78,18 +79,16 @@ export declare class RecommendationBlockControl extends CommonControl {
78
79
  /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
79
80
  private _isPendingStrategyIdChange;
80
81
  private _capturePendingNodeConfigWrite;
82
+ private _pendingUpdates;
83
+ private _pendingUpdatesForCurrentNode;
81
84
  private _getNodeConfigUpdates;
82
85
  /**
83
86
  * Accumulates the pending write into `documentModifier` without applying, so the
84
87
  * caller's apply() commits config and re-render as ONE undo entry.
85
- *
86
- * Deliberately does not consume the pending record: the product helpers call
87
- * apply() only when they actually changed something, so this batch may never be
88
- * committed and the flush has to stay able to write it standalone.
89
- * @param documentModifier - The batch to accumulate into
90
- * @returns Whether anything was staged
88
+ * @returns the undo label, null when only stamps moved; undefined when nothing was staged
91
89
  */
92
90
  private _stagePendingNodeConfig;
91
+ private _consumePendingNodeConfig;
93
92
  /**
94
93
  * Arms the guaranteed fallback write, once the product fetch has settled. The
95
94
  * delay only has to outlast the re-render debounce that fetch triggers — firing
@@ -97,11 +96,6 @@ export declare class RecommendationBlockControl extends CommonControl {
97
96
  */
98
97
  private _scheduleConfigFlush;
99
98
  private _clearConfigFlush;
100
- /**
101
- * Writes the deferred change standalone when the batch it was staged into never
102
- * committed. Always targets a LIVE node — a captured one is an immutable snapshot
103
- * the intervening re-render staled, and saveConfig swallows that failure.
104
- */
105
99
  private _flushPendingNodeConfig;
106
100
  private _syncNodeConfigToStore;
107
101
  /**
@@ -6,6 +6,8 @@
6
6
  *
7
7
  * Configuration is stored via node config (persists with template).
8
8
  */
9
+ import type { DocumentModifier } from '../../services/configService';
10
+ import type { PartialNodeConfig } from '../../types/nodeConfig';
9
11
  import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
10
12
  import { CommonControl } from '../../../common-control';
11
13
  import { type Orientation } from '../../templates';
@@ -33,11 +35,12 @@ export declare class LayoutOrientationControl extends CommonControl {
33
35
  */
34
36
  _onLayoutChange(layout: Orientation): void;
35
37
  /**
36
- * Regenerates product rows based on the selected layout
37
- * Uses unified style-preserving regeneration to maintain user customizations
38
+ * Stages the product rows for the selected layout into the caller's batch,
39
+ * with the user's styles preserved.
38
40
  * @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
39
41
  * @param composition - The preserved card composition, incl. customAttr:* entries
42
+ * @param configOverrides - The config staged in the same batch (spacing defaults)
40
43
  */
41
- _regenerateProductRows(layout: Orientation, composition: string[]): void;
44
+ _regenerateProductRows(documentModifier: DocumentModifier, layout: Orientation, composition: string[], configOverrides: PartialNodeConfig): void;
42
45
  _listenToFormUpdates(): void;
43
46
  }
@@ -18,7 +18,8 @@
18
18
  * `hide-price` attribute; the visual hide is simulated in the preview and applied
19
19
  * for real server-side by email-service.
20
20
  */
21
- import type { RecommendationNodeConfig } from '../../types/nodeConfig';
21
+ import type { DocumentModifier } from '../../services/configService';
22
+ import type { PartialNodeConfig, RecommendationNodeConfig } from '../../types/nodeConfig';
22
23
  import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
23
24
  import { CommonControl } from '../../../common-control';
24
25
  export declare const PRICE_PLACEMENT_CONTROL_ID = "recommendation-price-placement-control";
@@ -48,12 +49,12 @@ export declare class PricePlacementControl extends CommonControl {
48
49
  * Mirrors the hide-if-same flag onto the durable `hide-price` block attribute
49
50
  * read by email-service at send time.
50
51
  */
51
- _stampHideIfSameAttr(value: boolean): void;
52
+ _stampHideIfSameAttr(documentModifier: DocumentModifier, value: boolean): void;
52
53
  /**
53
- * Rebuilds the product rows so the renderer re-reads the inline/stacked
54
- * layout flag from the store. Used by the orientation change only.
54
+ * Stages the rebuilt product rows into the caller's batch so the renderer
55
+ * reads the inline/stacked flag being written. Used by the orientation change only.
55
56
  */
56
- _regenerate(): void;
57
+ _regenerate(documentModifier: DocumentModifier, configOverrides: PartialNodeConfig): void;
57
58
  _listenToFormUpdates(): void;
58
59
  }
59
60
  export {};
@@ -15,8 +15,10 @@
15
15
  *
16
16
  * Configuration is stored via node config (persists with template).
17
17
  */
18
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
18
+ import type { PartialNodeConfig } from '../../types/nodeConfig';
19
+ import type { CssNodeModifier, HtmlNodeModifier, ImmutableHtmlNode, TemplateModifier } from '@stripoinc/ui-editor-extensions';
19
20
  import { CommonControl } from '../../../common-control';
21
+ type DocumentModifier = TemplateModifier<HtmlNodeModifier, CssNodeModifier>;
20
22
  export declare const PRODUCT_LAYOUT_CONTROL_ID = "recommendation-product-layout-control";
21
23
  /**
22
24
  * Control for configuring product layout density.
@@ -65,10 +67,10 @@ export declare class ProductLayoutControl extends CommonControl {
65
67
  * When disabled: snapshots current mobileCardsInRow, resets to 1, opts out.
66
68
  */
67
69
  _onMobileLayoutToggleChange(enabled: boolean): void;
70
+ private _commitMobileLayoutToggle;
68
71
  _onProductsInRowChange(value: number): void;
69
72
  _onMobileCardsInRowChange(value: number): void;
70
- _regenerateProductRows(): void;
71
- _debouncedRegenerateProductRows: import("@vueuse/shared").PromisifyFn<() => void>;
73
+ _regenerateProductRows(modifier: DocumentModifier, configOverrides: PartialNodeConfig): void;
72
74
  _listenToFormUpdates(): void;
73
75
  /**
74
76
  * Subscribe to store changes to update visibility when layout changes
@@ -82,3 +84,4 @@ export declare class ProductLayoutControl extends CommonControl {
82
84
  */
83
85
  _listenEditorModeChanges(): void;
84
86
  }
87
+ export {};
@@ -8,7 +8,7 @@
8
8
  * - Spacing reapplication
9
9
  * - In-place content updates (style-preserving)
10
10
  */
11
- import type { CurrencyConfig } from '../../types/nodeConfig';
11
+ import type { CurrencyConfig, PartialNodeConfig } from '../../types/nodeConfig';
12
12
  import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
13
13
  import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
14
14
  import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
@@ -69,6 +69,10 @@ export interface RegenerateProductRowsOptions {
69
69
  layout?: Orientation;
70
70
  /** Optional: pass composition directly to avoid stale DOM reads after setAttribute */
71
71
  composition?: string[];
72
+ /** Accumulate only; the caller applies the batch (one undo entry with the change that caused it) */
73
+ stageOnly?: boolean;
74
+ /** Config staged in the same batch — the node still holds the pre-change values */
75
+ configOverrides?: PartialNodeConfig;
72
76
  }
73
77
  export declare function getMainContainerTbody(currentNode: ImmutableHtmlNode): ImmutableHtmlNode | null;
74
78
  /**
@@ -80,7 +84,7 @@ export declare function getMainContainerTbody(currentNode: ImmutableHtmlNode): I
80
84
  * For list layout / disabled mobile layout: clears the mobile row content.
81
85
  * For grid layout with mobileLayoutEnabled ON: rebuilds the full mobile row.
82
86
  */
83
- export declare function regenerateMobileProductRows(options: Omit<RegenerateProductRowsOptions, 'afterRegenerate'>): void;
87
+ export declare function regenerateMobileProductRows(options: Omit<RegenerateProductRowsOptions, 'afterRegenerate'>): boolean;
84
88
  export interface RegenerateWithStylesOptions extends Omit<RegenerateProductRowsOptions, 'products' | 'layout'> {
85
89
  /** Skip style capture if styles were already handled externally */
86
90
  skipStylePreservation?: boolean;
@@ -151,11 +155,12 @@ export interface UpdateProductContentInPlaceOptions {
151
155
  currentNode: ImmutableHtmlNode | null | undefined;
152
156
  documentModifier: DocumentModifier;
153
157
  products: RecommendationProduct[];
154
- /**
155
- * Called when the batch was actually committed. Identical products commit nothing, which
156
- * leaves anything a caller staged into the same batch unwritten unless it applies itself.
157
- */
158
- onApplied?: () => void;
158
+ /** Called when a product cell actually changed; identical products stage nothing. */
159
+ onChanged?: () => void;
160
+ /** Accumulate only; the caller applies the batch */
161
+ stageOnly?: boolean;
162
+ /** Config staged in the same batch — the node still holds the pre-change values */
163
+ configOverrides?: PartialNodeConfig;
159
164
  }
160
165
  /**
161
166
  * Updates product content in-place without regenerating HTML structure.
@@ -166,13 +171,17 @@ export interface UpdateProductContentInPlaceOptions {
166
171
  * After updating desktop, also updates mobile container to keep them in sync.
167
172
  *
168
173
  * Falls back to false when product count changed (need to add/remove elements).
169
- * @param options - Configuration options; `onApplied` fires only when a batch was committed
174
+ * @param options - Configuration options; `onChanged` fires only when a cell changed
170
175
  * @returns true if in-place update was successful, false to fall back to full regeneration
171
176
  */
172
177
  export declare function updateProductContentInPlace(options: UpdateProductContentInPlaceOptions): boolean;
173
178
  export interface UpdatePricesInPlaceOptions {
174
179
  currentNode: ImmutableHtmlNode | null | undefined;
175
180
  documentModifier: DocumentModifier;
181
+ /** Accumulate only; the caller applies the batch */
182
+ stageOnly?: boolean;
183
+ /** Config staged in the same batch — the node still holds the pre-change values */
184
+ configOverrides?: PartialNodeConfig;
176
185
  }
177
186
  /**
178
187
  * Updates only price displays in-place (for currency changes).
@@ -211,13 +220,16 @@ export interface SetCurrencyAttributesOptions {
211
220
  currentNode: ImmutableHtmlNode | null | undefined;
212
221
  documentModifier: DocumentModifier;
213
222
  currency: CurrencyConfig;
223
+ /** Accumulate only; the caller applies the batch */
224
+ stageOnly?: boolean;
214
225
  }
215
226
  /**
216
227
  * Sets currency configuration as HTML attributes on the block element
217
228
  * These attributes are read by the HTML compiler at runtime to format prices
218
229
  * @param options - Configuration options
230
+ * @returns whether the block element was found and its attributes staged
219
231
  */
220
- export declare function setCurrencyAttributes(options: SetCurrencyAttributesOptions): void;
232
+ export declare function setCurrencyAttributes(options: SetCurrencyAttributesOptions): boolean;
221
233
  /**
222
234
  * Reads currency configuration from block HTML attributes
223
235
  * Used to restore settings when loading a template
@@ -13,35 +13,41 @@ export declare const CSS_CLASS_DESKTOP_CONTAINER = "ins-recommendation-desktop-c
13
13
  export declare const CSS_CLASS_MOBILE_CONTAINER = "ins-recommendation-mobile-container";
14
14
  /** CSS class that opts a block out of the mobile layout container swap */
15
15
  export declare const CSS_CLASS_NO_MOBILE_LAYOUT = "ins-recommendation-no-mobile-layout";
16
+ interface HtmlModifier {
17
+ modifyHtml: (node: ImmutableHtmlNode) => {
18
+ setClass: (cls: string) => void;
19
+ removeClass: (cls: string) => void;
20
+ };
21
+ }
16
22
  interface HtmlModifierApi {
17
- getDocumentModifier: () => {
18
- modifyHtml: (node: ImmutableHtmlNode) => {
19
- setClass: (cls: string) => void;
20
- removeClass: (cls: string) => void;
21
- };
23
+ getDocumentModifier: () => HtmlModifier & {
22
24
  apply: (desc: ModificationDescription) => void;
23
25
  };
24
26
  }
27
+ interface CssModifier {
28
+ modifyCss: (node: ImmutableCssNode) => {
29
+ appendRule: (rule: string) => void;
30
+ };
31
+ apply: (desc: ModificationDescription) => void;
32
+ }
25
33
  interface CssModifierApi {
26
34
  getDocumentRootCssNode: () => ImmutableCssNode | null;
27
- getDocumentModifier: () => {
28
- modifyCss: (node: ImmutableCssNode) => {
29
- appendRule: (rule: string) => void;
30
- };
31
- apply: (desc: ModificationDescription) => void;
32
- };
35
+ getDocumentModifier: () => CssModifier;
33
36
  }
34
37
  /**
35
38
  * Ensures mobile layout CSS rules exist in the document stylesheet.
36
39
  * Only adds rules if they don't already exist (prevents duplicates across multiple blocks).
37
- * Follows the same pattern as textTrim's _ensureCssRulesExist().
40
+ * @param batch - stage into this modifier and let the caller apply it (one undo entry)
41
+ * @returns whether any rule was staged
38
42
  */
39
- export declare function ensureMobileCssRulesExist(api: CssModifierApi): void;
43
+ export declare function ensureMobileCssRulesExist(api: CssModifierApi, batch?: CssModifier): boolean;
40
44
  /**
41
45
  * Checks if a block element has the mobile layout opt-out class.
42
46
  * Read-side companion to setMobileLayoutOptOut().
43
47
  */
44
48
  export declare function hasMobileLayoutOptOut(blockElement: ImmutableHtmlNode): boolean;
49
+ /** Stages the opt-out class change on a modifier; the caller applies it. */
50
+ export declare function stageMobileLayoutOptOut(modifier: HtmlModifier, blockElement: ImmutableHtmlNode, optOut: boolean): void;
45
51
  /**
46
52
  * Adds or removes the mobile layout opt-out class on a block element.
47
53
  * When optOut is true, the block keeps the desktop container visible on mobile.
@@ -11,19 +11,21 @@
11
11
  import type { ImmutableCssNode } from '@stripoinc/ui-editor-extensions';
12
12
  import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
13
13
  export declare const CSS_CLASS_TEXT_TRIM = "text-trim-enabled";
14
+ interface CssModifier {
15
+ modifyCss: (node: ImmutableCssNode) => {
16
+ appendRule: (rule: string) => void;
17
+ };
18
+ apply: (desc: ModificationDescription) => void;
19
+ }
14
20
  interface CssCapableApi {
15
21
  getDocumentRootCssNode: () => ImmutableCssNode | null;
16
- getDocumentModifier: () => {
17
- modifyCss: (node: ImmutableCssNode) => {
18
- appendRule: (rule: string) => void;
19
- };
20
- apply: (desc: ModificationDescription) => void;
21
- };
22
+ getDocumentModifier: () => CssModifier;
22
23
  }
23
24
  /**
24
25
  * Ensures the text-trim CSS rules exist in the document stylesheet.
25
26
  * Only adds rules if they don't already exist (prevents duplicates across blocks).
26
- * Calls getDocumentRootCssNode once and passes it to both checks.
27
+ * @param batch - stage into this modifier and let the caller apply it (one undo entry)
28
+ * @returns whether any rule was staged
27
29
  */
28
- export declare function ensureTextTrimCssRulesExist(api: CssCapableApi): void;
30
+ export declare function ensureTextTrimCssRulesExist(api: CssCapableApi, batch?: CssModifier): boolean;
29
31
  export {};
@@ -12,8 +12,9 @@
12
12
  * Configuration is stored via node config (persists with template).
13
13
  * Actual spacing is applied to DOM elements via inline styles.
14
14
  */
15
- import { type ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
15
+ import type { CssNodeModifier, HtmlNodeModifier, ImmutableHtmlNode, TemplateModifier } from '@stripoinc/ui-editor-extensions';
16
16
  import { CommonControl } from '../../../common-control';
17
+ type DocumentModifier = TemplateModifier<HtmlNodeModifier, CssNodeModifier>;
17
18
  export declare const SPACING_CONTROL_ID = "recommendation-spacing-control";
18
19
  /**
19
20
  * Control for managing spacing between product cards
@@ -81,10 +82,12 @@ export declare class SpacingControl extends CommonControl {
81
82
  * Applies height only to spacer elements in the mobile container.
82
83
  */
83
84
  _onMobileRowSpacingChange(spacing: number): void;
84
- /**
85
- * Stores a spacing value as a data attribute on the block root element
86
- */
87
- _storeDataAttribute(attr: string, spacing: number): void;
85
+ /** Horizontal padding on every card cell inside the container the selector finds. */
86
+ _stageColumnPadding(modifier: DocumentModifier, containerSelector: string, spacing: number): void;
87
+ /** Height on every spacer row inside the container the selector finds. */
88
+ _stageSpacerHeight(modifier: DocumentModifier, containerSelector: string, spacing: number): void;
89
+ /** Mirrors a spacing value onto the block root as a data attribute (regeneration reads it back). */
90
+ _stageDataAttribute(modifier: DocumentModifier, attr: string, spacing: number): void;
88
91
  _listenToFormUpdates(): void;
89
92
  /**
90
93
  * Debounced version of _onColumnSpacingChange
@@ -109,3 +112,4 @@ export declare class SpacingControl extends CommonControl {
109
112
  */
110
113
  _subscribeToOrientationChanges(): void;
111
114
  }
115
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { PerBlockConfigs } from '../store/recommendation';
2
+ import type { CurrencyConfig } from '../types/nodeConfig';
3
+ export type CurrencySettings = PerBlockConfigs['currencySettings'];
4
+ /** The store mirror of a node currency: alignment is '0' | '1' and decimalCount a string. */
5
+ export declare function toCurrencySettings(currency: CurrencyConfig): CurrencySettings;
6
+ export declare function toCurrencyConfig(settings: CurrencySettings): CurrencyConfig;