@useinsider/guido 3.17.0-beta.ddd4dde → 3.17.0-beta.e23d5cd

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 (62) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +7 -6
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +77 -73
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
  7. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  8. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  9. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  10. package/dist/composables/useRecommendation.js +41 -34
  11. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  12. package/dist/config/migrator/recommendationMigrator.js +5 -4
  13. package/dist/enums/academy.js +2 -1
  14. package/dist/enums/date.js +5 -3
  15. package/dist/enums/extensions/recommendationBlock.js +3 -1
  16. package/dist/extensions/Blocks/Items/block.js +49 -98
  17. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
  18. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +11 -12
  19. package/dist/extensions/Blocks/Items/template.js +152 -153
  20. package/dist/extensions/Blocks/Recommendation/block.js +26 -21
  21. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -34
  22. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
  23. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +238 -185
  24. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
  25. package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
  26. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +165 -79
  27. package/dist/extensions/Blocks/common-control.js +22 -19
  28. package/dist/guido.css +1 -1
  29. package/dist/services/recommendationApi.js +69 -30
  30. package/dist/src/@types/config/schemas.d.ts +2 -0
  31. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  32. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
  33. package/dist/src/composables/useConfig.d.ts +2 -0
  34. package/dist/src/composables/useRecommendation.d.ts +1 -0
  35. package/dist/src/enums/academy.d.ts +1 -0
  36. package/dist/src/enums/date.d.ts +1 -0
  37. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  38. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -21
  39. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +2 -6
  40. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
  43. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  44. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +150 -10
  45. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -0
  46. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  47. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  48. package/dist/src/services/recommendationApi.d.ts +4 -1
  49. package/dist/src/stores/config.d.ts +18 -0
  50. package/dist/src/stores/save-as-template.d.ts +4 -3
  51. package/dist/src/utils/genericUtil.d.ts +5 -0
  52. package/dist/static/assets/icons/line-change.svg.js +5 -0
  53. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  54. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  55. package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
  56. package/dist/utils/dateUtil.js +23 -10
  57. package/dist/utils/genericUtil.js +28 -27
  58. package/dist/utils/pairProductVariables.js +59 -60
  59. package/dist/utils/templatePreparation.js +35 -34
  60. package/package.json +2 -1
  61. package/dist/extensions/Blocks/Items/constants/currency.js +0 -11
  62. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -19
@@ -0,0 +1,124 @@
1
+ var d = Object.defineProperty;
2
+ var y = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
+ var o = (r, s, t) => y(r, typeof s != "symbol" ? s + "" : s, t);
4
+ import { ACADEMY_LINKS as m } from "../../../../../enums/academy.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { useRecommendationExtensionStore as u } from "../../store/recommendation.js";
7
+ const p = "recommendation-strategy-control";
8
+ class f extends h {
9
+ constructor() {
10
+ super(...arguments);
11
+ o(this, "store", u());
12
+ o(this, "storeUnsubscription", () => {
13
+ });
14
+ o(this, "listeners", []);
15
+ o(this, "lastPaintedState", null);
16
+ }
17
+ getId() {
18
+ return p;
19
+ }
20
+ getTemplate() {
21
+ const t = this.api.translate(
22
+ "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
23
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
24
+ return `
25
+ <div class="strategy-control-container">
26
+ <div class="strategy-control-header">
27
+ <h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
28
+ </div>
29
+ <div class="strategy-control-description-row">
30
+ <p class="strategy-control-description">
31
+ ${t}
32
+ ${e}
33
+ <a
34
+ href="${m.EMAIL_RECOMMENDATION_BLOCK}"
35
+ target="_blank"
36
+ rel="noopener noreferrer">${a}</a>.
37
+ </p>
38
+ </div>
39
+ <div data-strategy-empty-state>
40
+ ${this._GuTwoColumns([
41
+ this._GuButton({
42
+ name: "assignStrategy",
43
+ label: this.api.translate("Assign Strategy"),
44
+ id: "guido__btn-assign-strategy",
45
+ className: "strategy-control-cta on"
46
+ }),
47
+ this._GuButton({
48
+ name: "createStrategy",
49
+ label: this.api.translate("Create New Strategy"),
50
+ id: "guido__btn-create-strategy",
51
+ className: "strategy-control-cta primary",
52
+ disabled: !0
53
+ })
54
+ ], "strategy-control-cta-row")}
55
+ </div>
56
+ <div data-strategy-assigned-state style="display: none;">
57
+ <div class="strategy-control-name-band">
58
+ <span class="strategy-control-name" data-strategy-name></span>
59
+ </div>
60
+ <div class="strategy-control-actions">
61
+ ${this._strategyAction({
62
+ id: "guido__btn-change-strategy",
63
+ label: this.api.translate("Change"),
64
+ modifier: "change"
65
+ })}
66
+ ${this._strategyAction({
67
+ id: "guido__btn-remove-strategy",
68
+ label: this.api.translate("Remove"),
69
+ modifier: "remove"
70
+ })}
71
+ </div>
72
+ </div>
73
+ </div>
74
+ `;
75
+ }
76
+ _strategyAction({ id: t, label: e, modifier: a }) {
77
+ return `
78
+ <button
79
+ id="${t}"
80
+ type="button"
81
+ class="strategy-control-action strategy-control-action--${a}">
82
+ <span>${e}</span>
83
+ </button>
84
+ `;
85
+ }
86
+ onRender() {
87
+ this._teardown(), this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
88
+ this._renderState();
89
+ }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
90
+ });
91
+ }
92
+ onDestroy() {
93
+ this._teardown();
94
+ }
95
+ _teardown() {
96
+ this.storeUnsubscription(), this.storeUnsubscription = () => {
97
+ }, this.lastPaintedState = null, this.listeners.forEach(({ element: t, handler: e }) => t.removeEventListener("click", e)), this.listeners = [];
98
+ }
99
+ _setupButtonListeners() {
100
+ const t = this.getContainer();
101
+ if (!t)
102
+ return;
103
+ const e = (a, n) => {
104
+ const i = t.querySelector(a);
105
+ i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
106
+ };
107
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.removeStrategy());
108
+ }
109
+ _renderState() {
110
+ var l;
111
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
112
+ if (a === this.lastPaintedState)
113
+ return;
114
+ const n = this.getContainer();
115
+ if (!n)
116
+ return;
117
+ const i = n.querySelector("[data-strategy-empty-state]"), c = n.querySelector("[data-strategy-assigned-state]"), g = n.querySelector("[data-strategy-name]");
118
+ !i || !c || (i.style.display = t ? "none" : "", c.style.display = t ? "" : "none", g && t && (g.textContent = e || `#${t}`), this.lastPaintedState = a);
119
+ }
120
+ }
121
+ export {
122
+ p as STRATEGY_CONTROL_ID,
123
+ f as StrategyControl
124
+ };
@@ -1,12 +1,12 @@
1
- import { ModificationDescription as C } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
1
+ import { ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { PRE_RRS_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
3
3
  import { setCurrencyAttributes as D } from "../controls/main/utils.js";
4
- import { hasMinimalConfig as A } from "../types/nodeConfig.js";
5
- function S(e) {
6
- return e === "." || e === "," || e === " ";
4
+ import { hasMinimalConfig as S } from "../types/nodeConfig.js";
5
+ function A(r) {
6
+ return r === "." || r === "," || r === " ";
7
7
  }
8
- function N(e) {
9
- return e === "." || e === "," || e === " " || e === "";
8
+ function N(r) {
9
+ return r === "." || r === "," || r === " " || r === "";
10
10
  }
11
11
  class M {
12
12
  // ========================================================================
@@ -48,7 +48,7 @@ class M {
48
48
  return !1;
49
49
  try {
50
50
  const t = i.getNodeConfig();
51
- return A(t);
51
+ return S(t);
52
52
  } catch {
53
53
  return !1;
54
54
  }
@@ -82,9 +82,27 @@ class M {
82
82
  * @param description - Human-readable description for undo/redo
83
83
  * @returns The new complete configuration
84
84
  */
85
- static updateConfig(i, t, o, n) {
86
- const r = this.getConfig(t), u = this.deepMerge(r, o);
87
- return this.saveConfig(i, t, u, n), u;
85
+ static updateConfig(i, t, o, e) {
86
+ const n = this.getConfig(t), u = this.deepMerge(n, o);
87
+ return this.saveConfig(i, t, u, e), u;
88
+ }
89
+ /**
90
+ * Accumulate a config update into an existing modifier batch, WITHOUT applying.
91
+ *
92
+ * The caller owns the apply(), so the write shares one undo entry with the rest
93
+ * of that batch — a change whose visible result only lands after an async product
94
+ * fetch would otherwise cost the user two undo presses (SD-149105).
95
+ * @param documentModifier - The batch to accumulate into (caller applies)
96
+ * @param node - The immutable HTML node to write to
97
+ * @param updates - Partial config with values to update
98
+ */
99
+ static stageConfig(i, t, o) {
100
+ const e = this.deepMerge(this.getConfig(t), o);
101
+ try {
102
+ i.modifyHtml(t).setNodeConfig(e);
103
+ } catch (n) {
104
+ console.warn("[RecommendationConfigService] Failed to stage config:", n);
105
+ }
88
106
  }
89
107
  /**
90
108
  * Initialize configuration for a new block
@@ -107,12 +125,12 @@ class M {
107
125
  static initializeConfig(i, t, o) {
108
126
  if (this.hasConfig(t))
109
127
  return { config: o ? this.updateConfig(i, t, o, "Initialize recommendation block") : this.getConfig(t), wasFreshDrop: !1 };
110
- const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
111
- return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
128
+ const e = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
129
+ return this.saveConfig(i, t, e, "Initialize recommendation block"), D({
112
130
  currentNode: t,
113
131
  documentModifier: i.getDocumentModifier(),
114
- currency: n.currency
115
- }), { config: n, wasFreshDrop: !0 };
132
+ currency: e.currency
133
+ }), { config: e, wasFreshDrop: !0 };
116
134
  }
117
135
  /**
118
136
  * Save complete configuration to a node
@@ -123,11 +141,11 @@ class M {
123
141
  * @param config - Complete configuration to save
124
142
  * @param description - Human-readable description for undo/redo
125
143
  */
126
- static saveConfig(i, t, o, n) {
144
+ static saveConfig(i, t, o, e) {
127
145
  try {
128
- i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new C(n));
129
- } catch (r) {
130
- console.warn("[RecommendationConfigService] Failed to save config:", r);
146
+ i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(e));
147
+ } catch (n) {
148
+ console.warn("[RecommendationConfigService] Failed to save config:", n);
131
149
  }
132
150
  }
133
151
  // ========================================================================
@@ -154,33 +172,33 @@ class M {
154
172
  */
155
173
  static migrateFromDataAttributes(i, t) {
156
174
  const o = {
157
- configVersion: l
175
+ configVersion: C
158
176
  };
159
177
  if ("getAttribute" in t && typeof t.getAttribute == "function") {
160
- const n = t.getAttribute("esd-ext-config");
161
- if (n)
178
+ const e = t.getAttribute("esd-ext-config");
179
+ if (e)
162
180
  try {
163
- const s = JSON.parse(n);
164
- s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
181
+ const s = JSON.parse(e);
182
+ s && typeof s == "object" && Object.assign(o, s);
165
183
  } catch {
166
184
  }
167
- const r = t.getAttribute("data-layout");
168
- r === "list" || r === "horizontal" ? o.layout = "list" : (r === "grid" || r === "vertical") && (o.layout = "grid");
185
+ const n = t.getAttribute("data-layout");
186
+ n === "list" || n === "horizontal" ? o.layout = "list" : (n === "grid" || n === "vertical") && (o.layout = "grid");
169
187
  const u = t.getAttribute("data-card-composition");
170
188
  u && (o.composition = u.split(",").filter(Boolean));
171
- const b = t.getAttribute("data-column-spacing");
172
- b && (o.columnSpacing = parseInt(b) || c.columnSpacing);
189
+ const l = t.getAttribute("data-column-spacing");
190
+ l && (o.columnSpacing = parseInt(l) || c.columnSpacing);
173
191
  const p = t.getAttribute("data-row-spacing");
174
192
  if (p && (o.rowSpacing = parseInt(p) || c.rowSpacing), !o.currency) {
175
- const s = t.getAttribute("currency"), y = t.getAttribute("currency-symbol"), d = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
176
- if (s || y || d || f || g || m) {
177
- const a = c.currency, h = m ? parseInt(m) : NaN;
193
+ const s = t.getAttribute("currency"), b = t.getAttribute("currency-symbol"), y = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
194
+ if (s || b || y || f || g || m) {
195
+ const a = c.currency, d = m ? parseInt(m) : NaN;
178
196
  o.currency = {
179
197
  code: s ?? a.code,
180
- symbol: y ?? a.symbol,
181
- alignment: d === "0" ? "before" : "after",
182
- decimalCount: Number.isFinite(h) ? h : a.decimalCount,
183
- decimalSeparator: S(g) ? g : a.decimalSeparator,
198
+ symbol: b ?? a.symbol,
199
+ alignment: y === "0" ? "before" : "after",
200
+ decimalCount: Number.isFinite(d) ? d : a.decimalCount,
201
+ decimalSeparator: A(g) ? g : a.decimalSeparator,
184
202
  thousandSeparator: N(f) ? f : a.thousandSeparator
185
203
  };
186
204
  }
@@ -194,7 +212,7 @@ class M {
194
212
  * @returns True if migration is needed
195
213
  */
196
214
  static needsMigration(i) {
197
- return i ? this.hasConfig(i) ? this.getConfigVersion(i) < l : !0 : !1;
215
+ return i ? !this.hasConfig(i) : !1;
198
216
  }
199
217
  // ========================================================================
200
218
  // Internal Helpers