@useinsider/guido 3.17.0-beta.bdc7d25 → 3.17.0-beta.db1a6f8

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 (86) hide show
  1. package/README.md +5 -5
  2. package/dist/@types/config/schemas.js +0 -5
  3. package/dist/components/Guido.vue.js +10 -10
  4. package/dist/components/Guido.vue2.js +93 -85
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +76 -39
  7. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +17 -0
  8. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +57 -0
  9. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +11 -11
  10. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +56 -6
  11. package/dist/components/organisms/header/EditorActions.vue.js +1 -1
  12. package/dist/components/organisms/header/EditorActions.vue2.js +54 -41
  13. package/dist/composables/useActionsApi.js +82 -67
  14. package/dist/composables/useAutoSave.js +31 -26
  15. package/dist/composables/useEditorLock.js +20 -0
  16. package/dist/composables/useGuidoStateBridge.js +37 -31
  17. package/dist/composables/useRecommendation.js +29 -30
  18. package/dist/composables/useSave.js +39 -36
  19. package/dist/composables/useStripo.js +14 -14
  20. package/dist/config/i18n/en/labels.json.js +1 -1
  21. package/dist/config/migrator/index.js +9 -8
  22. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  23. package/dist/config/migrator/recommendation/extractors.js +29 -24
  24. package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
  25. package/dist/config/migrator/recommendation/settingsMapper.js +0 -2
  26. package/dist/config/migrator/recommendationMigrator.js +30 -26
  27. package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
  28. package/dist/enums/date.js +5 -4
  29. package/dist/enums/extensions/recommendationBlock.js +0 -1
  30. package/dist/extensions/Blocks/Recommendation/block.js +12 -11
  31. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  32. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  33. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +24 -24
  34. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +35 -28
  35. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +329 -257
  36. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +180 -133
  37. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +1 -19
  38. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
  39. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
  40. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  41. package/dist/extensions/Blocks/Recommendation/services/configService.js +34 -16
  42. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
  43. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +83 -128
  44. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  45. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
  46. package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
  47. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +22 -0
  48. package/dist/guido.css +1 -1
  49. package/dist/services/recommendationApi.js +10 -16
  50. package/dist/src/@types/config/schemas.d.ts +0 -10
  51. package/dist/src/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.d.ts +2 -0
  52. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +2 -4
  53. package/dist/src/composables/useEditorLock.d.ts +10 -0
  54. package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
  55. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
  56. package/dist/src/enums/date.d.ts +1 -0
  57. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  58. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
  59. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -5
  60. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  61. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
  62. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
  63. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  64. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +39 -15
  65. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -14
  66. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
  67. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
  68. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  69. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +26 -56
  70. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
  71. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -5
  72. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +31 -0
  73. package/dist/src/mock/api/recommendation-strategies.d.ts +0 -61
  74. package/dist/src/services/recommendationApi.d.ts +1 -1
  75. package/dist/src/stores/save-as-template.d.ts +4 -3
  76. package/dist/src/utils/genericUtil.d.ts +5 -0
  77. package/dist/static/assets/icons/line-delete.svg.js +2 -2
  78. package/dist/static/assets/icons/line-plus.svg.js +2 -2
  79. package/dist/static/styles/components/recommendation-strategy.css.js +2 -35
  80. package/dist/static/styles/customEditorStyle.css.js +3 -1
  81. package/dist/utils/dateUtil.js +18 -24
  82. package/dist/utils/genericUtil.js +28 -27
  83. package/dist/utils/templatePreparation.js +0 -2
  84. package/package.json +3 -3
  85. package/dist/src/utils/strategyInfoBox.d.ts +0 -35
  86. package/dist/utils/strategyInfoBox.js +0 -68
@@ -1,42 +1,50 @@
1
- var C = Object.defineProperty;
2
- var g = (d, c, t) => c in d ? C(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
3
- var n = (d, c, t) => g(d, typeof c != "symbol" ? c + "" : c, t);
1
+ var m = Object.defineProperty;
2
+ var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
3
+ var n = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, t);
4
4
  import { useConfig as p } from "../../../../../composables/useConfig.js";
5
- import { CommonControl as y } from "../../../common-control.js";
5
+ import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as N } from "../../../common-control.js";
6
7
  import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
7
- import { RecommendationConfigService as m } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as N } from "../../store/recommendation.js";
9
- import { AlgorithmControl as I } from "./algorithm.js";
10
- import { ALGORITHM_CONTROL_ID as it } from "./algorithm.js";
11
- import { CurrencyControl as R } from "./currency.js";
12
- import { CURRENCY_CONTROL_ID as at } from "./currency.js";
13
- import { FiltersControl as T } from "./filters.js";
14
- import { FILTERS_CONTROL_ID as lt } from "./filters.js";
15
- import { LayoutOrientationControl as b } from "./layoutOrientation.js";
16
- import { LAYOUT_ORIENTATION_CONTROL_ID as dt } from "./layoutOrientation.js";
17
- import { LocaleControl as S } from "./locale.js";
18
- import { LOCALE_CONTROL_ID as ht } from "./locale.js";
19
- import { PricePlacementControl as O } from "./pricePlacement.js";
20
- import { PRICE_PLACEMENT_CONTROL_ID as Ct } from "./pricePlacement.js";
21
- import { ProductCountControl as P } from "./productCount.js";
22
- import { PRODUCT_COUNT_CONTROL_ID as pt } from "./productCount.js";
23
- import { ProductLayoutControl as L } from "./productLayout.js";
24
- import { PRODUCT_LAYOUT_CONTROL_ID as _t } from "./productLayout.js";
25
- import { ShuffleControl as k } from "./shuffle.js";
26
- import { SHUFFLE_CONTROL_ID as It } from "./shuffle.js";
27
- import { StrategyControl as E } from "./strategy.js";
28
- import { STRATEGY_CONTROL_ID as Tt } from "./strategy.js";
29
- import { setCurrencyAttributes as D, getBlockElement as w, isPartnerManagedBlock as B, updateProductContentInPlace as v, regenerateProductRowsWithStyles as $ } from "./utils.js";
30
- import { adjustProductsToSize as St, formatProductPrice as Ot, getCardComposition as Pt, getCurrentLayout as Lt, regenerateMobileProductRows as kt, updatePricesInPlace as Et, updateSingleProductContent as Dt } from "./utils.js";
31
- import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
32
- const A = "recommendation-id", x = "ui-elements-recommendation-block";
33
- class ot extends y {
8
+ import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
9
+ import { RecommendationConfigService as c } from "../../services/configService.js";
10
+ import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
+ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
+ import { AlgorithmControl as T } from "./algorithm.js";
13
+ import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
14
+ import { CurrencyControl as P } from "./currency.js";
15
+ import { CURRENCY_CONTROL_ID as ht } from "./currency.js";
16
+ import { FiltersControl as S } from "./filters.js";
17
+ import { FILTERS_CONTROL_ID as gt } from "./filters.js";
18
+ import { LayoutOrientationControl as O } from "./layoutOrientation.js";
19
+ import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
20
+ import { LocaleControl as L } from "./locale.js";
21
+ import { LOCALE_CONTROL_ID as yt } from "./locale.js";
22
+ import { PricePlacementControl as E } from "./pricePlacement.js";
23
+ import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
24
+ import { ProductCountControl as k } from "./productCount.js";
25
+ import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
26
+ import { ProductLayoutControl as D } from "./productLayout.js";
27
+ import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
28
+ import { ShuffleControl as F } from "./shuffle.js";
29
+ import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
30
+ import { StrategyControl as w } from "./strategy.js";
31
+ import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
32
+ import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
34
+ import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
35
+ const $ = "ui-elements-recommendation-block";
36
+ class at extends N {
34
37
  constructor() {
35
38
  super(...arguments);
36
- n(this, "store", N());
39
+ n(this, "store", R());
37
40
  n(this, "storeUnsubscription", () => {
38
41
  });
39
- n(this, "syncedBlockIds", /* @__PURE__ */ new Set());
42
+ // blockId -> fingerprint of the node config as it looked at the last sync.
43
+ n(this, "syncedConfigs", /* @__PURE__ */ new Map());
44
+ // A config change waiting to reach the node config. Deferred so it can ride the
45
+ // re-render's single apply() — one user action must cost one undo press.
46
+ n(this, "pendingNodeConfigWrite", null);
47
+ n(this, "pendingConfigFlushTimer", null);
40
48
  // Sub-control instances for lifecycle management
41
49
  n(this, "algorithmControl", null);
42
50
  n(this, "localeControl", null);
@@ -48,11 +56,16 @@ class ot extends y {
48
56
  n(this, "pricePlacementControl", null);
49
57
  n(this, "layoutOrientationControl", null);
50
58
  n(this, "strategyControl", null);
59
+ n(this, "rrsEnabled", !1);
51
60
  /**
52
61
  * Debounced product fetch to prevent rapid API calls during config changes
53
62
  */
54
- n(this, "_debouncedFetchProducts", h(() => {
55
- this.store.fetchRecommendationProducts();
63
+ n(this, "_debouncedFetchProducts", f(async () => {
64
+ try {
65
+ await this.store.fetchRecommendationProducts();
66
+ } finally {
67
+ this._scheduleConfigFlush();
68
+ }
56
69
  }, 500));
57
70
  /**
58
71
  * Debounced content update when products arrive from API.
@@ -65,16 +78,20 @@ class ot extends y {
65
78
  * count. The store pads products to the configured size, so in-place only
66
79
  * fails when the size actually changed.
67
80
  */
68
- n(this, "_debouncedRegenerateWithProducts", h(() => {
81
+ n(this, "_debouncedRegenerateWithProducts", f(() => {
69
82
  const t = this.store.recommendationProducts;
70
- if (!this.currentNode || !this.api || B(this.currentNode))
83
+ if (!this.currentNode || !this.api)
84
+ return;
85
+ const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
86
+ if (x(this.currentNode)) {
87
+ o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
71
88
  return;
72
- const e = this.api.getDocumentModifier();
73
- v({
89
+ }
90
+ B({
74
91
  currentNode: this.currentNode,
75
92
  documentModifier: e,
76
93
  products: t
77
- }) || $({
94
+ }) || U({
78
95
  currentNode: this.currentNode,
79
96
  documentModifier: e,
80
97
  products: t
@@ -82,9 +99,8 @@ class ot extends y {
82
99
  }, 100));
83
100
  }
84
101
  getId() {
85
- return x;
102
+ return $;
86
103
  }
87
- /** Every sub-control the coordinator owns, in panel order. */
88
104
  get _subControls() {
89
105
  return [
90
106
  this.layoutOrientationControl,
@@ -100,27 +116,15 @@ class ot extends y {
100
116
  ];
101
117
  }
102
118
  getTemplate() {
103
- const t = p().isFeatureEnabled("reusableRecommendationStrategy");
104
- return this._subControls.forEach((e) => {
119
+ var t;
120
+ return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
105
121
  var o;
106
122
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
107
- }), this.algorithmControl = new I(), this.localeControl = new S(), this.currencyControl = new R(), this.productCountControl = new P(), this.productLayoutControl = new L(), this.filtersControl = new T(), this.shuffleControl = new k(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new b(), this.strategyControl = t ? new E() : null, this._subControls.forEach((e) => {
123
+ }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new D(), this.filtersControl = new S(), this.shuffleControl = new F(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
108
124
  e && (e.api = this.api);
109
- }), t ? `
110
- <div class="recommendation-controls-container">
111
- ${this.strategyControl.getTemplate()}
112
- ${this.layoutOrientationControl.getTemplate()}
113
- ${this.productCountControl.getTemplate()}
114
- ${this.productLayoutControl.getTemplate()}
115
- ${this.algorithmControl.getTemplate()}
116
- ${this.localeControl.getTemplate()}
117
- ${this.pricePlacementControl.getTemplate()}
118
- ${this.currencyControl.getTemplate()}
119
- ${this.filtersControl.getTemplate()}
120
- ${this.shuffleControl.getTemplate()}
121
- </div>
122
- ` : `
125
+ }), `
123
126
  <div class="recommendation-controls-container">
127
+ ${((t = this.strategyControl) == null ? void 0 : t.getTemplate()) ?? ""}
124
128
  ${this.layoutOrientationControl.getTemplate()}
125
129
  ${this.productCountControl.getTemplate()}
126
130
  ${this.productLayoutControl.getTemplate()}
@@ -133,23 +137,19 @@ class ot extends y {
133
137
  </div>
134
138
  `;
135
139
  }
136
- /**
137
- * Shows the selected block's own set of controls. A block is strategy-backed
138
- * when a flag-on session stamped its config version, or when it already
139
- * carries a strategy — an assignment must stay editable however it arrived.
140
- */
141
140
  _showControlsForBlock(t) {
142
141
  var i;
143
142
  const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
144
- if (!e || this._getRecommendationIdFromNode(t) === null)
143
+ if (!e)
145
144
  return;
146
- const o = m.getConfig(t), r = (o.configVersion ?? 0) >= _ || !!o.strategyId;
145
+ const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
147
146
  e.classList.toggle("strategy-block", r);
148
147
  }
149
148
  async onRender() {
150
149
  var o;
150
+ b(this.api);
151
151
  const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
152
- if (e !== null && this.store.setCurrentBlock(e), t !== null && !this.syncedBlockIds.has(t) && (this.syncedBlockIds.add(t), this._syncNodeConfigToStore()), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
152
+ if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
153
153
  this._initializeSubControls();
154
154
  return;
155
155
  }
@@ -159,7 +159,7 @@ class ot extends y {
159
159
  var o;
160
160
  super.onTemplateNodeUpdated(t);
161
161
  const e = this._getRecommendationIdFromNode(t);
162
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.syncedBlockIds.has(e) && (this.syncedBlockIds.add(e), this._syncNodeConfigToStore()), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
162
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
163
163
  this._initializeSubControls();
164
164
  }), this._subControls.forEach((r) => {
165
165
  var i;
@@ -167,7 +167,7 @@ class ot extends y {
167
167
  });
168
168
  }
169
169
  onDestroy() {
170
- this.storeUnsubscription(), this._subControls.forEach((t) => {
170
+ this.storeUnsubscription(), this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
171
171
  var e;
172
172
  return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
173
173
  });
@@ -185,7 +185,6 @@ class ot extends y {
185
185
  /**
186
186
  * Syncs persisted node config into the Pinia store's block state.
187
187
  *
188
- * setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
189
188
  * For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
190
189
  * This method reads it and patches the store so fetchRecommendationProducts()
191
190
  * uses the correct values.
@@ -193,9 +192,73 @@ class ot extends y {
193
192
  * Uses triggerRefetch: false because the fetch hasn't happened yet —
194
193
  * values are being prepared for the upcoming initial fetch.
195
194
  */
195
+ /**
196
+ * Re-syncs the store when the node config moved since we last read it.
197
+ *
198
+ * Undo/redo, the code editor and version-history restore rewrite the node
199
+ * config behind the store's back — Stripo exposes no undo signal, so a
200
+ * fingerprint diff on this hook is the only way to notice (SD-149105).
201
+ * An unchanged fingerprint means the move came from us, so runtime store
202
+ * edits are never clobbered (SD-141049).
203
+ */
204
+ _syncNodeConfigIfChanged(t) {
205
+ this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
206
+ const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
207
+ this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
208
+ }
209
+ _capturePendingNodeConfigWrite() {
210
+ const t = this.store.currentRecommendationId;
211
+ if (!this.currentNode || !this.api || t === null)
212
+ return;
213
+ const { filters: e, strategyId: o, size: r } = this.store.recommendationConfigs;
214
+ this.pendingNodeConfigWrite = {
215
+ blockId: t,
216
+ node: this.currentNode,
217
+ updates: { filters: e, strategyId: o, size: r }
218
+ };
219
+ }
220
+ /**
221
+ * Accumulates the pending write into `documentModifier` without applying, so the
222
+ * caller's apply() commits config and re-render as ONE undo entry.
223
+ *
224
+ * Deliberately does not consume the pending record: the product helpers call
225
+ * apply() only when they actually changed something, so this batch may never be
226
+ * committed and the flush has to stay able to write it standalone.
227
+ * @param documentModifier - The batch to accumulate into
228
+ * @returns Whether anything was staged
229
+ */
230
+ _stagePendingNodeConfig(t) {
231
+ const e = this.pendingNodeConfigWrite;
232
+ return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
233
+ }
234
+ /**
235
+ * Arms the guaranteed fallback write, once the product fetch has settled. The
236
+ * delay only has to outlast the re-render debounce that fetch triggers — firing
237
+ * earlier writes the config on its own and the undo entry splits in two again.
238
+ */
239
+ _scheduleConfigFlush() {
240
+ this._clearConfigFlush(), this.pendingConfigFlushTimer = setTimeout(() => {
241
+ this.pendingConfigFlushTimer = null, this._flushPendingNodeConfig();
242
+ }, 800);
243
+ }
244
+ _clearConfigFlush() {
245
+ this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
246
+ }
247
+ /**
248
+ * Writes the deferred change standalone when the batch it was staged into never
249
+ * committed. Always targets the LIVE node — the captured one is an immutable
250
+ * snapshot the intervening re-render staled, and saveConfig swallows that failure.
251
+ */
252
+ _flushPendingNodeConfig() {
253
+ const t = this.pendingNodeConfigWrite;
254
+ if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
255
+ return;
256
+ const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
257
+ JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
258
+ }
196
259
  _syncNodeConfigToStore() {
197
260
  var r;
198
- const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
261
+ const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
199
262
  this.store.patchCurrentBlockConfig({
200
263
  strategy: t.strategy,
201
264
  strategyId: t.strategyId,
@@ -259,12 +322,12 @@ class ot extends y {
259
322
  _applySmartDefaults() {
260
323
  if (!this.currentNode || !this.api)
261
324
  return;
262
- const t = m.getConfig(this.currentNode), e = {};
325
+ const t = c.getConfig(this.currentNode), e = {};
263
326
  let o = null, r = null, i = null;
264
327
  if (t.currency.code === a.currency.code) {
265
328
  const { currencyList: s } = this.store;
266
329
  s.length > 0 && (s.some(
267
- (u) => u.value === `price.${a.currency.code}`
330
+ (d) => d.value === `price.${a.currency.code}`
268
331
  ) || (o = s[0].value.replace("price.", ""), e.currency = {
269
332
  ...a.currency,
270
333
  code: o,
@@ -274,21 +337,21 @@ class ot extends y {
274
337
  if (t.strategy === a.strategy) {
275
338
  const s = this.store.getActivePredictiveAlgorithms;
276
339
  s.length > 0 && (s.some(
277
- (u) => u.value === a.strategy
340
+ (d) => d.value === a.strategy
278
341
  ) || (r = s[0].value, e.strategy = r));
279
342
  }
280
343
  if (t.language === a.language) {
281
344
  const s = this.store.getLanguages;
282
345
  s.length > 0 && (s.some(
283
- (u) => u.value === a.language
346
+ (d) => d.value === a.language
284
347
  ) || (i = s[0].value, e.language = i));
285
348
  }
286
- !o && !r && !i || (m.updateConfig(
349
+ !o && !r && !i || (c.updateConfig(
287
350
  this.api,
288
351
  this.currentNode,
289
352
  e,
290
353
  "Applied smart defaults"
291
- ), o && e.currency && D({
354
+ ), o && e.currency && A({
292
355
  currentNode: this.currentNode,
293
356
  documentModifier: this.api.getDocumentModifier(),
294
357
  currency: e.currency
@@ -312,10 +375,10 @@ class ot extends y {
312
375
  * Reads the recommendation-id attribute from the block element within the node
313
376
  */
314
377
  _getRecommendationIdFromNode(t) {
315
- const e = w(t);
378
+ const e = v(t);
316
379
  if (!e || !("getAttribute" in e))
317
380
  return null;
318
- const o = e.getAttribute(A);
381
+ const o = e.getAttribute(I);
319
382
  if (!o)
320
383
  return null;
321
384
  const r = parseInt(o);
@@ -344,62 +407,46 @@ class ot extends y {
344
407
  return;
345
408
  }
346
409
  const s = t.$state.configVersion;
347
- s !== o && (o = s, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
348
- const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
349
- u && f && (e = l, this._debouncedRegenerateWithProducts());
410
+ s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
411
+ const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
412
+ d && g && (e = u, this._debouncedRegenerateWithProducts());
350
413
  });
351
414
  }
352
- /**
353
- * Persists filter + strategy state to the Stripo node config so it survives
354
- * save/reload (strategyId must reach esd-ext-config before any save).
355
- * `size` rides along: assigning a strategy writes it to the store only, and a
356
- * stale node config would rebuild the block against the old slot count.
357
- */
358
- _persistFiltersToNodeConfig() {
359
- if (!this.currentNode || !this.api)
360
- return;
361
- const { filters: t, strategyId: e, size: o } = this.store.recommendationConfigs, r = m.getConfig(this.currentNode);
362
- JSON.stringify(r.filters) === JSON.stringify(t) && r.strategyId === e && r.size === o || m.updateConfig(
363
- this.api,
364
- this.currentNode,
365
- { filters: t, strategyId: e, size: o },
366
- "Update recommendation filters"
367
- );
368
- }
369
415
  }
370
416
  export {
371
- it as ALGORITHM_CONTROL_ID,
372
- I as AlgorithmControl,
373
- x as CONTROL_BLOCK_ID,
374
- at as CURRENCY_CONTROL_ID,
375
- R as CurrencyControl,
376
- lt as FILTERS_CONTROL_ID,
377
- T as FiltersControl,
378
- dt as LAYOUT_ORIENTATION_CONTROL_ID,
379
- ht as LOCALE_CONTROL_ID,
380
- b as LayoutOrientationControl,
381
- S as LocaleControl,
382
- Ct as PRICE_PLACEMENT_CONTROL_ID,
383
- pt as PRODUCT_COUNT_CONTROL_ID,
384
- _t as PRODUCT_LAYOUT_CONTROL_ID,
385
- O as PricePlacementControl,
386
- P as ProductCountControl,
387
- L as ProductLayoutControl,
388
- ot as RecommendationBlockControl,
389
- It as SHUFFLE_CONTROL_ID,
390
- Tt as STRATEGY_CONTROL_ID,
391
- k as ShuffleControl,
392
- E as StrategyControl,
393
- St as adjustProductsToSize,
394
- Ot as formatProductPrice,
395
- w as getBlockElement,
396
- Pt as getCardComposition,
397
- Lt as getCurrentLayout,
398
- B as isPartnerManagedBlock,
399
- kt as regenerateMobileProductRows,
400
- $ as regenerateProductRowsWithStyles,
401
- D as setCurrencyAttributes,
402
- Et as updatePricesInPlace,
403
- v as updateProductContentInPlace,
404
- Dt as updateSingleProductContent
417
+ ut as ALGORITHM_CONTROL_ID,
418
+ T as AlgorithmControl,
419
+ $ as CONTROL_BLOCK_ID,
420
+ ht as CURRENCY_CONTROL_ID,
421
+ P as CurrencyControl,
422
+ gt as FILTERS_CONTROL_ID,
423
+ S as FiltersControl,
424
+ Ct as LAYOUT_ORIENTATION_CONTROL_ID,
425
+ yt as LOCALE_CONTROL_ID,
426
+ O as LayoutOrientationControl,
427
+ L as LocaleControl,
428
+ _t as PRICE_PLACEMENT_CONTROL_ID,
429
+ Rt as PRODUCT_COUNT_CONTROL_ID,
430
+ Tt as PRODUCT_LAYOUT_CONTROL_ID,
431
+ E as PricePlacementControl,
432
+ k as ProductCountControl,
433
+ D as ProductLayoutControl,
434
+ at as RecommendationBlockControl,
435
+ St as SHUFFLE_CONTROL_ID,
436
+ Lt as STRATEGY_CONTROL_ID,
437
+ F as ShuffleControl,
438
+ w as StrategyControl,
439
+ kt as adjustProductsToSize,
440
+ Dt as formatProductPrice,
441
+ v as getBlockElement,
442
+ Ft as getCardComposition,
443
+ wt as getCurrentLayout,
444
+ At as getMainContainerTbody,
445
+ x as isPartnerManagedBlock,
446
+ vt as regenerateMobileProductRows,
447
+ U as regenerateProductRowsWithStyles,
448
+ A as setCurrencyAttributes,
449
+ xt as updatePricesInPlace,
450
+ B as updateProductContentInPlace,
451
+ Bt as updateSingleProductContent
405
452
  };
@@ -12,8 +12,6 @@ class f extends h {
12
12
  o(this, "storeUnsubscription", () => {
13
13
  });
14
14
  o(this, "listeners", []);
15
- // The store subscription fires on EVERY mutation of a store six controls
16
- // share, so the last painted state is kept to skip the DOM work.
17
15
  o(this, "lastPaintedState", null);
18
16
  }
19
17
  getId() {
@@ -46,8 +44,6 @@ class f extends h {
46
44
  id: "guido__btn-assign-strategy",
47
45
  className: "strategy-control-cta on"
48
46
  }),
49
- // Create round-trip ships with SD-149916; until then the CTA
50
- // stays inert at full contrast, as the design draws it.
51
47
  this._GuButton({
52
48
  name: "createStrategy",
53
49
  label: this.api.translate("Create New Strategy"),
@@ -77,15 +73,6 @@ class f extends h {
77
73
  </div>
78
74
  `;
79
75
  }
80
- /**
81
- * Change / Remove are icon+text actions in the design, not buttons — and
82
- * `ue-button` cannot pair a caption with an arbitrary icon, so these are
83
- * plain elements. Click wiring is by id, which works on any element.
84
- *
85
- * The icon is a CSS mask, not inline SVG: Stripo re-creates the control's
86
- * markup through Angular, which rebuilds `<svg>` outside the SVG namespace
87
- * (the view-box attribute comes back lowercased) and it never paints.
88
- */
89
76
  _strategyAction({ id: t, label: e, modifier: a }) {
90
77
  return `
91
78
  <button
@@ -117,13 +104,8 @@ class f extends h {
117
104
  const i = t.querySelector(a);
118
105
  i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
119
106
  };
120
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.removeStrategy());
107
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
121
108
  }
122
- /**
123
- * Toggles empty vs assigned state from the store's current block config.
124
- * Display name comes from the listing; falls back to the raw id while the
125
- * listing loads (or when the strategy is no longer listed).
126
- */
127
109
  _renderState() {
128
110
  var l;
129
111
  const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
@@ -438,6 +438,7 @@ export {
438
438
  C as getBlockElement,
439
439
  U as getCardComposition,
440
440
  P as getCurrentLayout,
441
+ oe as getMainContainerTbody,
441
442
  ee as isPartnerManagedBlock,
442
443
  Pe as regenerateMobileProductRows,
443
444
  Te as regenerateProductRowsWithStyles,
@@ -0,0 +1,44 @@
1
+ import { createPaddingsControl as r, createTextBackgroundColorControl as T, createTextFontFamilyControl as e, createTextStyleControl as l, createTextSizeControl as C, createTextColorControl as c, createTextAlignControl as I } from "../../../controlFactories.js";
2
+ import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
+ import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
+ import { BLOCK_ROOT_SELECTOR as n } from "../../constants/selectors.js";
5
+ const L = I(
6
+ t.TITLE_ALIGN,
7
+ o.TITLE,
8
+ n
9
+ ), a = c(
10
+ t.TITLE_COLOR,
11
+ o.TITLE,
12
+ n
13
+ ), i = C(
14
+ t.TITLE_SIZE,
15
+ o.TITLE,
16
+ n
17
+ ), E = l(
18
+ t.TITLE_STYLE,
19
+ o.TITLE,
20
+ n
21
+ ), m = e(
22
+ t.TITLE_FONT_FAMILY,
23
+ o.TITLE,
24
+ n
25
+ ), s = T(
26
+ t.TITLE_BACKGROUND,
27
+ o.TITLE,
28
+ n
29
+ ), d = r(
30
+ t.TITLE_PADDINGS,
31
+ o.TITLE,
32
+ n
33
+ ), x = {
34
+ align: L,
35
+ color: a,
36
+ size: i,
37
+ style: E,
38
+ fontFamily: m,
39
+ background: s,
40
+ paddings: d
41
+ };
42
+ export {
43
+ x as TitleControls
44
+ };
@@ -5,23 +5,24 @@ import { RecommendationBlockControl as i } from "./controls/main/index.js";
5
5
  import "./constants/selectors.js";
6
6
  import "./store/recommendation.js";
7
7
  import "./utils/captureStyleTemplates.js";
8
- import { NameControls as e } from "./controls/name/index.js";
9
- import { PriceControls as l } from "./controls/price/index.js";
10
- import { OldPriceControls as s } from "./controls/oldPrice/index.js";
11
- import { OmnibusPriceControls as p } from "./controls/omnibusPrice/index.js";
12
- import { OmnibusDiscountControls as a } from "./controls/omnibusDiscount/index.js";
13
- import { ButtonControls as c } from "./controls/button/index.js";
14
- import { ImageControls as C } from "./controls/image/index.js";
15
- import { CustomAttributeControls as f } from "./controls/customAttribute/index.js";
16
- import { SpacingControl as d } from "./controls/spacing/index.js";
17
- import { BlockBackgroundColorControl as u } from "./controls/blockBackground/index.js";
18
- import { CardBackgroundColorControl as g } from "./controls/cardBackground/index.js";
19
- import { RecommendationCardCompositionControl as y } from "./controls/cardComposition/index.js";
20
- import { SyncInfoMessageControl as B } from "./controls/syncInfoMessage.js";
21
- import { RecommendationIconsRegistry as P } from "./iconsRegistry.js";
22
- import R from "./recommendation.css.js";
23
- import { SettingsPanel as S } from "./settingsPanel.js";
24
- const k = [
8
+ import { TitleControls as e } from "./controls/title/index.js";
9
+ import { NameControls as l } from "./controls/name/index.js";
10
+ import { PriceControls as s } from "./controls/price/index.js";
11
+ import { OldPriceControls as p } from "./controls/oldPrice/index.js";
12
+ import { OmnibusPriceControls as a } from "./controls/omnibusPrice/index.js";
13
+ import { OmnibusDiscountControls as c } from "./controls/omnibusDiscount/index.js";
14
+ import { ButtonControls as C } from "./controls/button/index.js";
15
+ import { ImageControls as f } from "./controls/image/index.js";
16
+ import { CustomAttributeControls as d } from "./controls/customAttribute/index.js";
17
+ import { SpacingControl as u } from "./controls/spacing/index.js";
18
+ import { BlockBackgroundColorControl as g } from "./controls/blockBackground/index.js";
19
+ import { CardBackgroundColorControl as y } from "./controls/cardBackground/index.js";
20
+ import { RecommendationCardCompositionControl as B } from "./controls/cardComposition/index.js";
21
+ import { SyncInfoMessageControl as P } from "./controls/syncInfoMessage.js";
22
+ import { RecommendationIconsRegistry as R } from "./iconsRegistry.js";
23
+ import S from "./recommendation.css.js";
24
+ import { SettingsPanel as k } from "./settingsPanel.js";
25
+ const w = [
25
26
  e,
26
27
  l,
27
28
  s,
@@ -29,21 +30,22 @@ const k = [
29
30
  a,
30
31
  c,
31
32
  C,
32
- f
33
- ], w = [
33
+ f,
34
+ d
35
+ ], b = [
34
36
  i,
35
- u,
36
37
  g,
37
- d,
38
38
  y,
39
- B
40
- ], b = [
41
- ...w,
42
- ...k.flatMap((o) => Object.values(o))
43
- ], W = b.reduce(
39
+ u,
40
+ B,
41
+ P
42
+ ], v = [
43
+ ...b,
44
+ ...w.flatMap((o) => Object.values(o))
45
+ ], Y = v.reduce(
44
46
  (o, r) => o.addControl(r),
45
- new t().addBlock(m).withSettingsPanelRegistry(S)
46
- ).addStyles(R).withPreviewStyles(n).withIconsRegistry(P).build();
47
+ new t().addBlock(m).withSettingsPanelRegistry(k)
48
+ ).addStyles(S).withPreviewStyles(n).withIconsRegistry(R).build();
47
49
  export {
48
- W as default
50
+ Y as default
49
51
  };