@useinsider/guido 3.3.0-beta.86ea9cd → 3.3.0-beta.878c1c2

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.
@@ -1,33 +1,33 @@
1
- var k = Object.defineProperty;
2
- var _ = (r, n, t) => n in r ? k(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
- var g = (r, n, t) => _(r, typeof n != "symbol" ? n + "" : n, t);
4
- import { BlockId as B } from "../../../enums/block.js";
5
- import { getMigrationBannerHtml as b } from "../../../utils/migrationBannerHtml.js";
6
- import { Block as R, BlockCompositionType as y, ModificationDescription as C } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- import { regenerateMobileProductRows as A } from "./controls/main/utils.js";
8
- import { ensureMobileCssRulesExist as d, setMobileLayoutOptOut as p, hasMobileLayoutOptOut as D } from "./controls/mobileLayout/cssRules.js";
9
- import { RecommendationConfigService as s } from "./services/configService.js";
10
- import { useRecommendationExtensionStore as f } from "./store/recommendation.js";
1
+ var I = Object.defineProperty;
2
+ var k = (r, n, t) => n in r ? I(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
+ var u = (r, n, t) => k(r, typeof n != "symbol" ? n + "" : n, t);
4
+ import { BlockId as _ } from "../../../enums/block.js";
5
+ import { getMigrationBannerHtml as B } from "../../../utils/migrationBannerHtml.js";
6
+ import { Block as b, BlockCompositionType as R, ModificationDescription as y } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
8
+ import { ensureMobileCssRulesExist as g, setMobileLayoutOptOut as d, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
9
+ import { RecommendationConfigService as c } from "./services/configService.js";
10
+ import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
11
11
  import { getDefaultTemplate as E } from "./templates/grid/template.js";
12
- const h = B.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
13
- let I = !1;
14
- class v extends R {
12
+ const f = _.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
13
+ let h = !1;
14
+ class q extends b {
15
15
  constructor() {
16
16
  super();
17
17
  /**
18
18
  * Stores the ID generated in getTemplate() so onCreated() can reuse it.
19
19
  * This avoids generating a new (different) ID in onCreated().
20
20
  */
21
- g(this, "_pendingBlockId", null);
21
+ u(this, "_pendingBlockId", null);
22
22
  }
23
23
  getId() {
24
- return h;
24
+ return f;
25
25
  }
26
26
  getIcon() {
27
27
  return "recommendation-icon";
28
28
  }
29
29
  getBlockCompositionType() {
30
- return y.CONTAINER;
30
+ return R.CONTAINER;
31
31
  }
32
32
  getName() {
33
33
  return this.api.translate("Recommendation Block");
@@ -38,8 +38,8 @@ class v extends R {
38
38
  );
39
39
  }
40
40
  getSettingsPanelTitleHtml() {
41
- return b(
42
- h,
41
+ return B(
42
+ f,
43
43
  this.api.translate("Recommendation Block"),
44
44
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
45
45
  );
@@ -71,20 +71,13 @@ class v extends R {
71
71
  return;
72
72
  const i = this._pendingBlockId ?? this._generateNextId();
73
73
  this._pendingBlockId = null, this._assignRecommendationId(t, i);
74
- const { config: o, wasFreshDrop: c } = s.initializeConfig(
75
- this.api,
76
- t,
77
- { recommendationId: i }
78
- ), a = f();
79
- if (a.setCurrentBlock(i), c) {
80
- d(this.api);
81
- const u = this._getBlockElement(t);
82
- u && (p(this.api, u, !0), A({
83
- currentNode: t,
84
- documentModifier: this.api.getDocumentModifier()
85
- }));
86
- }
87
- a.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
74
+ const o = c.initializeConfig(this.api, t, { recommendationId: i }), s = p();
75
+ s.setCurrentBlock(i), g(this.api);
76
+ const a = this._getBlockElement(t);
77
+ a && (d(this.api, a, !0), C({
78
+ currentNode: t,
79
+ documentModifier: this.api.getDocumentModifier()
80
+ })), s.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
88
81
  }
89
82
  /**
90
83
  * Called when the document changes or template is loaded
@@ -97,20 +90,20 @@ class v extends R {
97
90
  if (!(!t || !("getNodeConfig" in t))) {
98
91
  if (!this._getRecommendationId(t)) {
99
92
  const e = this._generateNextId();
100
- this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
93
+ this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
101
94
  this.api,
102
95
  t,
103
96
  { recommendationId: e },
104
97
  "Assign recommendation ID to legacy block"
105
98
  );
106
99
  }
107
- s.needsMigration(t) && this._migrateFromLegacy(t);
100
+ c.needsMigration(t) && this._migrateFromLegacy(t);
108
101
  try {
109
- I || (d(this.api), I = !0);
110
- const e = s.getConfig(t), i = this._getBlockElement(t);
102
+ h || (g(this.api), h = !0);
103
+ const e = c.getConfig(t), i = this._getBlockElement(t);
111
104
  if (i) {
112
105
  const o = !e.mobileLayoutEnabled;
113
- D(i) !== o && p(this.api, i, o);
106
+ A(i) !== o && d(this.api, i, o);
114
107
  }
115
108
  } catch {
116
109
  }
@@ -124,7 +117,7 @@ class v extends R {
124
117
  */
125
118
  onDelete(t) {
126
119
  const e = this._getRecommendationId(t);
127
- e && f().removeBlockState(e);
120
+ e && p().removeBlockState(e);
128
121
  }
129
122
  /**
130
123
  * Generates the next unique recommendation ID by scanning all existing blocks
@@ -136,7 +129,7 @@ class v extends R {
136
129
  const e = this.api.getDocumentRoot();
137
130
  e && "querySelectorAll" in e && e.querySelectorAll(`.${l}`).forEach((o) => {
138
131
  if ("getAttribute" in o) {
139
- const c = o.getAttribute(m), a = c ? parseInt(c) : 0;
132
+ const s = o.getAttribute(m), a = s ? parseInt(s) : 0;
140
133
  a > t && (t = a);
141
134
  }
142
135
  });
@@ -155,7 +148,7 @@ class v extends R {
155
148
  if (!i)
156
149
  return;
157
150
  const o = this.api.getDocumentModifier();
158
- o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new C(`Assign recommendation ID ${e}`));
151
+ o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new y(`Assign recommendation ID ${e}`));
159
152
  }
160
153
  /**
161
154
  * Gets the recommendation-id from a block node
@@ -185,10 +178,10 @@ class v extends R {
185
178
  * Migrate configuration from legacy format
186
179
  */
187
180
  _migrateFromLegacy(t) {
188
- s.migrateFromDataAttributes(this.api, t);
181
+ c.migrateFromDataAttributes(this.api, t);
189
182
  }
190
183
  }
191
184
  export {
192
- h as BLOCK_ID,
193
- v as RecommendationBlock
185
+ f as BLOCK_ID,
186
+ q as RecommendationBlock
194
187
  };
@@ -1,5 +1,5 @@
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 { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as r } from "../constants/defaultConfig.js";
3
3
  import { setCurrencyAttributes as D } from "../controls/main/utils.js";
4
4
  import { hasMinimalConfig as A } from "../types/nodeConfig.js";
5
5
  function S(e) {
@@ -8,7 +8,7 @@ function S(e) {
8
8
  function N(e) {
9
9
  return e === "." || e === "," || e === " " || e === "";
10
10
  }
11
- class M {
11
+ class V {
12
12
  // ========================================================================
13
13
  // Read Operations
14
14
  // ========================================================================
@@ -83,7 +83,7 @@ class M {
83
83
  * @returns The new complete configuration
84
84
  */
85
85
  static updateConfig(i, t, o, n) {
86
- const r = this.getConfig(t), u = this.deepMerge(r, o);
86
+ const c = this.getConfig(t), u = this.deepMerge(c, o);
87
87
  return this.saveConfig(i, t, u, n), u;
88
88
  }
89
89
  /**
@@ -91,28 +91,21 @@ class M {
91
91
  *
92
92
  * Called when a block is first created (dropped into template).
93
93
  * Can optionally merge in partial config from migration.
94
- *
95
- * The `wasFreshDrop` flag distinguishes a brand-new drop (no prior config)
96
- * from a clone (Stripo replays the source's setNodeConfig payload before
97
- * onCreated fires). Callers use this to skip side-effects already inherited
98
- * from the source.
99
94
  * @example
100
95
  * // In Block.onCreated lifecycle
101
- * const { config, wasFreshDrop } = RecommendationConfigService.initializeConfig(this.api, node);
96
+ * RecommendationConfigService.initializeConfig(this.api, node);
102
97
  * @param api - Stripo extension API with document modifier
103
98
  * @param node - The immutable HTML node to initialize
104
99
  * @param partialConfig - Optional partial config to merge with defaults
105
- * @returns The initialized configuration and whether the node was a fresh drop
100
+ * @returns The initialized configuration
106
101
  */
107
102
  static initializeConfig(i, t, o) {
108
- if (this.hasConfig(t))
109
- return { config: o ? this.updateConfig(i, t, o, "Initialize recommendation block") : this.getConfig(t), wasFreshDrop: !1 };
110
103
  const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
111
104
  return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
112
105
  currentNode: t,
113
106
  documentModifier: i.getDocumentModifier(),
114
107
  currency: n.currency
115
- }), { config: n, wasFreshDrop: !0 };
108
+ }), n;
116
109
  }
117
110
  /**
118
111
  * Save complete configuration to a node
@@ -125,9 +118,9 @@ class M {
125
118
  */
126
119
  static saveConfig(i, t, o, n) {
127
120
  try {
128
- i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new C(n));
129
- } catch (r) {
130
- console.warn("[RecommendationConfigService] Failed to save config:", r);
121
+ i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(n));
122
+ } catch (c) {
123
+ console.warn("[RecommendationConfigService] Failed to save config:", c);
131
124
  }
132
125
  }
133
126
  // ========================================================================
@@ -164,29 +157,29 @@ class M {
164
157
  s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
165
158
  } catch {
166
159
  }
167
- const r = t.getAttribute("data-layout");
168
- r === "list" || r === "horizontal" ? o.layout = "list" : (r === "grid" || r === "vertical") && (o.layout = "grid");
160
+ const c = t.getAttribute("data-layout");
161
+ c === "list" || c === "horizontal" ? o.layout = "list" : (c === "grid" || c === "vertical") && (o.layout = "grid");
169
162
  const u = t.getAttribute("data-card-composition");
170
163
  u && (o.composition = u.split(",").filter(Boolean));
171
- const b = t.getAttribute("data-column-spacing");
172
- b && (o.columnSpacing = parseInt(b) || c.columnSpacing);
173
- const p = t.getAttribute("data-row-spacing");
174
- if (p && (o.rowSpacing = parseInt(p) || c.rowSpacing), !o.currency) {
164
+ const p = t.getAttribute("data-column-spacing");
165
+ p && (o.columnSpacing = parseInt(p) || r.columnSpacing);
166
+ const b = t.getAttribute("data-row-spacing");
167
+ if (b && (o.rowSpacing = parseInt(b) || r.rowSpacing), !o.currency) {
175
168
  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
169
  if (s || y || d || f || g || m) {
177
- const a = c.currency, h = m ? parseInt(m) : NaN;
170
+ const a = r.currency, C = m ? parseInt(m) : NaN;
178
171
  o.currency = {
179
172
  code: s ?? a.code,
180
173
  symbol: y ?? a.symbol,
181
174
  alignment: d === "0" ? "before" : "after",
182
- decimalCount: Number.isFinite(h) ? h : a.decimalCount,
175
+ decimalCount: Number.isFinite(C) ? C : a.decimalCount,
183
176
  decimalSeparator: S(g) ? g : a.decimalSeparator,
184
177
  thousandSeparator: N(f) ? f : a.thousandSeparator
185
178
  };
186
179
  }
187
180
  }
188
181
  }
189
- return this.initializeConfig(i, t, o).config;
182
+ return this.initializeConfig(i, t, o);
190
183
  }
191
184
  /**
192
185
  * Check if configuration needs migration
@@ -204,12 +197,12 @@ class M {
204
197
  */
205
198
  static cloneDefaults() {
206
199
  return {
207
- ...c,
208
- currency: { ...c.currency },
209
- omnibusPrice: { ...c.omnibusPrice },
210
- omnibusDiscount: { ...c.omnibusDiscount },
211
- composition: [...c.composition],
212
- visibility: { ...c.visibility },
200
+ ...r,
201
+ currency: { ...r.currency },
202
+ omnibusPrice: { ...r.omnibusPrice },
203
+ omnibusDiscount: { ...r.omnibusDiscount },
204
+ composition: [...r.composition],
205
+ visibility: { ...r.visibility },
213
206
  filters: [],
214
207
  productIds: [],
215
208
  recommendationId: 0
@@ -279,5 +272,5 @@ class M {
279
272
  }
280
273
  }
281
274
  export {
282
- M as RecommendationConfigService
275
+ V as RecommendationConfigService
283
276
  };
@@ -95,23 +95,15 @@ export declare class RecommendationConfigService {
95
95
  *
96
96
  * Called when a block is first created (dropped into template).
97
97
  * Can optionally merge in partial config from migration.
98
- *
99
- * The `wasFreshDrop` flag distinguishes a brand-new drop (no prior config)
100
- * from a clone (Stripo replays the source's setNodeConfig payload before
101
- * onCreated fires). Callers use this to skip side-effects already inherited
102
- * from the source.
103
98
  * @example
104
99
  * // In Block.onCreated lifecycle
105
- * const { config, wasFreshDrop } = RecommendationConfigService.initializeConfig(this.api, node);
100
+ * RecommendationConfigService.initializeConfig(this.api, node);
106
101
  * @param api - Stripo extension API with document modifier
107
102
  * @param node - The immutable HTML node to initialize
108
103
  * @param partialConfig - Optional partial config to merge with defaults
109
- * @returns The initialized configuration and whether the node was a fresh drop
104
+ * @returns The initialized configuration
110
105
  */
111
- static initializeConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, partialConfig?: PartialNodeConfig): {
112
- config: RecommendationNodeConfig;
113
- wasFreshDrop: boolean;
114
- };
106
+ static initializeConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, partialConfig?: PartialNodeConfig): RecommendationNodeConfig;
115
107
  /**
116
108
  * Save complete configuration to a node
117
109
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.3.0-beta.86ea9cd",
3
+ "version": "3.3.0-beta.878c1c2",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",