@useinsider/guido 2.1.0-beta.9ba2e9d → 2.1.0-beta.9ed76a4

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 (65) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  6. package/dist/composables/useBlocksConfig.js +26 -16
  7. package/dist/composables/useHtmlValidator.js +107 -119
  8. package/dist/composables/useStripo.js +25 -23
  9. package/dist/composables/useVersionHistoryApi.js +1 -1
  10. package/dist/config/compiler/utils/recommendationCompilerUtils.js +70 -96
  11. package/dist/config/i18n/en/index.js +11 -0
  12. package/dist/config/i18n/en/labels.json.js +7 -0
  13. package/dist/config/i18n/en/toasters.json.js +56 -0
  14. package/dist/config/i18n/en/tooltips.json.js +82 -0
  15. package/dist/config/i18n/index.js +7 -0
  16. package/dist/config/migrator/itemsBlockMigrator.js +101 -97
  17. package/dist/enums/defaults.js +8 -4
  18. package/dist/enums/extensions/recommendationBlock.js +1 -1
  19. package/dist/extensions/Blocks/Recommendation/block.js +26 -23
  20. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +27 -26
  21. package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
  22. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
  23. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -70
  24. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +87 -37
  25. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
  26. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  27. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +117 -107
  28. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
  29. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
  30. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
  31. package/dist/extensions/Blocks/Recommendation/templates/utils.js +43 -31
  32. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  33. package/dist/guido.css +1 -1
  34. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
  35. package/dist/services/recommendationApi.js +11 -9
  36. package/dist/services/stripoApi.js +20 -17
  37. package/dist/src/@types/config/schemas.d.ts +8 -0
  38. package/dist/src/composables/useConfig.d.ts +4 -0
  39. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  40. package/dist/src/config/i18n/en/index.d.ts +1 -0
  41. package/dist/src/config/i18n/index.d.ts +16 -0
  42. package/dist/src/enums/defaults.d.ts +4 -0
  43. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  44. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
  45. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -1
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
  49. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  50. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
  51. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
  53. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
  54. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  55. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  56. package/dist/src/stores/config.d.ts +36 -0
  57. package/dist/static/styles/components/notification.css.js +19 -0
  58. package/dist/static/styles/components/tools.css.js +6 -2
  59. package/dist/static/styles/components/version-history.css.js +10 -2
  60. package/dist/static/styles/components/wide-panel.css.js +18 -2
  61. package/dist/static/styles/customEditorStyle.css.js +10 -9
  62. package/dist/static/styles/variables.css.js +2 -0
  63. package/dist/static/templates/empty/index.html.js +74 -0
  64. package/dist/static/templates/empty/style.css.js +779 -0
  65. package/package.json +1 -1
@@ -1,12 +1,13 @@
1
- var u = Object.defineProperty;
2
- var p = (r, i, t) => i in r ? u(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
3
- var g = (r, i, t) => p(r, typeof i != "symbol" ? i + "" : i, t);
4
- import { Block as f, BlockCompositionType as I, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
1
+ var p = Object.defineProperty;
2
+ var f = (r, o, t) => o in r ? p(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
3
+ var g = (r, o, t) => f(r, typeof o != "symbol" ? o + "" : o, t);
4
+ import { Block as h, BlockCompositionType as I, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { ensureMobileCssRulesExist as d } from "./controls/mobileLayout/cssRules.js";
5
6
  import { RecommendationConfigService as s } from "./services/configService.js";
6
- import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
7
- import { getDefaultTemplate as _ } from "./templates/grid/template.js";
8
- const k = "recommendation-block", c = "ins-recommendation-v3-block-v2", m = "recommendation-id";
9
- class b extends f {
7
+ import { useRecommendationExtensionStore as u } from "./store/recommendation.js";
8
+ import { getDefaultTemplate as k } from "./templates/grid/template.js";
9
+ const B = "recommendation-block", c = "ins-recommendation-v3-block-v2", a = "recommendation-id";
10
+ class y extends h {
10
11
  constructor() {
11
12
  super();
12
13
  /**
@@ -16,7 +17,7 @@ class b extends f {
16
17
  g(this, "_pendingBlockId", null);
17
18
  }
18
19
  getId() {
19
- return k;
20
+ return B;
20
21
  }
21
22
  getIcon() {
22
23
  return "recommendation-icon";
@@ -39,7 +40,7 @@ class b extends f {
39
40
  */
40
41
  getTemplate() {
41
42
  const t = this._generateNextId();
42
- return this._pendingBlockId = t, _(t);
43
+ return this._pendingBlockId = t, k(t);
43
44
  }
44
45
  /**
45
46
  * Called when a new block is dropped into the template
@@ -50,7 +51,9 @@ class b extends f {
50
51
  */
51
52
  onCreated(t) {
52
53
  const e = this._pendingBlockId ?? this._generateNextId();
53
- this._pendingBlockId = null, this._assignRecommendationId(t, e), s.initializeConfig(this.api, t, { recommendationId: e }), d().setCurrentBlock(e);
54
+ this._pendingBlockId = null, this._assignRecommendationId(t, e);
55
+ const n = s.initializeConfig(this.api, t, { recommendationId: e }), i = u();
56
+ i.setCurrentBlock(e), d(this.api), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
54
57
  }
55
58
  /**
56
59
  * Called when the document changes or template is loaded
@@ -70,7 +73,7 @@ class b extends f {
70
73
  "Assign recommendation ID to legacy block"
71
74
  );
72
75
  }
73
- s.needsMigration(t) && this._migrateFromLegacy(t);
76
+ s.needsMigration(t) && this._migrateFromLegacy(t), d(this.api);
74
77
  }
75
78
  }
76
79
  /**
@@ -81,7 +84,7 @@ class b extends f {
81
84
  */
82
85
  onDelete(t) {
83
86
  const e = this._getRecommendationId(t);
84
- e && d().removeBlockState(e);
87
+ e && u().removeBlockState(e);
85
88
  }
86
89
  /**
87
90
  * Generates the next unique recommendation ID by scanning all existing blocks
@@ -91,9 +94,9 @@ class b extends f {
91
94
  let t = 0;
92
95
  try {
93
96
  const e = this.api.getDocumentRoot();
94
- e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((o) => {
95
- if ("getAttribute" in o) {
96
- const a = o.getAttribute(m), l = a ? parseInt(a) : 0;
97
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((i) => {
98
+ if ("getAttribute" in i) {
99
+ const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
97
100
  l > t && (t = l);
98
101
  }
99
102
  });
@@ -111,8 +114,8 @@ class b extends f {
111
114
  const n = this._getBlockElement(t);
112
115
  if (!n)
113
116
  return;
114
- const o = this.api.getDocumentModifier();
115
- o.modifyHtml(n).setAttribute(m, e.toString()), o.apply(new h(`Assign recommendation ID ${e}`));
117
+ const i = this.api.getDocumentModifier();
118
+ i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new _(`Assign recommendation ID ${e}`));
116
119
  }
117
120
  /**
118
121
  * Gets the recommendation-id from a block node
@@ -121,11 +124,11 @@ class b extends f {
121
124
  const e = this._getBlockElement(t);
122
125
  if (!e || !("getAttribute" in e))
123
126
  return null;
124
- const n = e.getAttribute(m);
127
+ const n = e.getAttribute(a);
125
128
  if (!n)
126
129
  return null;
127
- const o = parseInt(n);
128
- return Number.isNaN(o) ? null : o;
130
+ const i = parseInt(n);
131
+ return Number.isNaN(i) ? null : i;
129
132
  }
130
133
  /**
131
134
  * Gets the block element (the element with BLOCK_CLASS)
@@ -146,6 +149,6 @@ class b extends f {
146
149
  }
147
150
  }
148
151
  export {
149
- k as BLOCK_ID,
150
- b as RecommendationBlock
152
+ B as BLOCK_ID,
153
+ y as RecommendationBlock
151
154
  };
@@ -1,6 +1,6 @@
1
- import { DEFAULT_ROW_SPACING as n, DEFAULT_COLUMN_SPACING as s, DEFAULT_CARDS_IN_ROW as R } from "./layout.js";
2
- import { ATTR_PRODUCT_IMAGE as t, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as _, ATTR_PRODUCT_OMNIBUS_DISCOUNT as r, ATTR_PRODUCT_BUTTON as U } from "./selectors.js";
3
- const I = {
1
+ import { DEFAULT_ROW_SPACING as U, DEFAULT_COLUMN_SPACING as I, DEFAULT_MOBILE_CARDS_IN_ROW as n, DEFAULT_CARDS_IN_ROW as s } from "./layout.js";
2
+ import { ATTR_PRODUCT_IMAGE as t, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as T, ATTR_PRODUCT_OMNIBUS_DISCOUNT as r, ATTR_PRODUCT_BUTTON as R } from "./selectors.js";
3
+ const O = {
4
4
  code: "USD",
5
5
  symbol: "USD",
6
6
  alignment: "after",
@@ -10,56 +10,57 @@ const I = {
10
10
  }, i = {
11
11
  textBefore: "",
12
12
  textAfter: ""
13
- }, O = {
13
+ }, C = {
14
14
  textBefore: "",
15
15
  textAfter: ""
16
- }, C = [
16
+ }, D = [
17
17
  t,
18
18
  e,
19
19
  o,
20
- T,
21
20
  _,
21
+ T,
22
22
  r,
23
- U
24
- ], D = {
23
+ R
24
+ ], A = {
25
25
  [t]: !0,
26
26
  [e]: !0,
27
- [T]: !0,
27
+ [_]: !0,
28
28
  [o]: !0,
29
- [_]: !1,
29
+ [T]: !1,
30
30
  [r]: !1,
31
- [U]: !0
32
- }, a = {
31
+ [R]: !0
32
+ }, E = {
33
33
  // Settings
34
34
  strategy: "mostPopular",
35
35
  productIds: [],
36
36
  size: "6",
37
37
  shuffleProducts: !1,
38
38
  language: "en_US",
39
- currency: I,
39
+ currency: O,
40
40
  filters: [],
41
41
  // Layout
42
42
  layout: "grid",
43
- cardsInRow: R,
44
- columnSpacing: s,
45
- rowSpacing: n,
43
+ cardsInRow: s,
44
+ mobileCardsInRow: n,
45
+ columnSpacing: I,
46
+ rowSpacing: U,
46
47
  // Composition
47
- composition: C,
48
- visibility: D,
48
+ composition: D,
49
+ visibility: A,
49
50
  // Element settings
50
51
  omnibusPrice: i,
51
- omnibusDiscount: O,
52
+ omnibusDiscount: C,
52
53
  textTrimming: !1,
53
54
  // Meta
54
55
  configVersion: 1,
55
56
  recommendationId: 0
56
- }, E = 1;
57
+ }, N = 1;
57
58
  export {
58
- E as CURRENT_CONFIG_VERSION,
59
- C as DEFAULT_COMPOSITION,
60
- I as DEFAULT_CURRENCY,
61
- a as DEFAULT_NODE_CONFIG,
62
- O as DEFAULT_OMNIBUS_DISCOUNT,
59
+ N as CURRENT_CONFIG_VERSION,
60
+ D as DEFAULT_COMPOSITION,
61
+ O as DEFAULT_CURRENCY,
62
+ E as DEFAULT_NODE_CONFIG,
63
+ C as DEFAULT_OMNIBUS_DISCOUNT,
63
64
  i as DEFAULT_OMNIBUS_PRICE,
64
- D as DEFAULT_VISIBILITY
65
+ A as DEFAULT_VISIBILITY
65
66
  };
@@ -4,17 +4,19 @@ const _ = {
4
4
  }, o = [
5
5
  { icon: "grid-orientation", value: _.GRID },
6
6
  { icon: "list-orientation", value: _.LIST }
7
- ], t = 3, n = 3, A = 9, T = 4, c = 10, s = 20, O = 0, S = 50, I = 5;
7
+ ], t = 3, n = 3, A = 9, O = 4, R = 1, T = 2, c = 10, s = 20, I = 0, S = 50, P = 5;
8
8
  export {
9
9
  n as DEFAULT_CARDS_IN_ROW,
10
10
  c as DEFAULT_COLUMN_SPACING,
11
+ R as DEFAULT_MOBILE_CARDS_IN_ROW,
11
12
  t as DEFAULT_PRODUCTS_PER_ROW,
12
13
  s as DEFAULT_ROW_SPACING,
13
14
  o as LAYOUT_OPTIONS,
14
15
  _ as LAYOUT_VALUES,
15
- T as MAX_PRODUCTS_PER_ROW,
16
+ T as MAX_MOBILE_PRODUCTS_PER_ROW,
17
+ O as MAX_PRODUCTS_PER_ROW,
16
18
  A as MAX_PRODUCT_COUNT,
17
19
  S as MAX_SPACING,
18
- O as MIN_SPACING,
19
- I as SPACING_STEP
20
+ I as MIN_SPACING,
21
+ P as SPACING_STEP
20
22
  };
@@ -1,19 +1,21 @@
1
- const c = ".ins-recommendation-product-container", T = {
1
+ const c = ".ins-recommendation-product-container", n = ".ins-recommendation-desktop-container", o = ".ins-recommendation-mobile-container", T = {
2
2
  CURRENCY: "currency",
3
3
  SYMBOL: "currency-symbol",
4
4
  ALIGNMENT: "currency-alignment",
5
5
  THOUSAND_SEPARATOR: "currency-thousand-separator",
6
6
  DECIMAL_SEPARATOR: "currency-decimal-separator",
7
7
  DECIMAL_COUNT: "currency-decimal-count"
8
- }, r = "productImage", n = "productName", o = "productPrice", t = "productOldPrice", R = "productOmnibusPrice", O = "productOmnibusDiscount", _ = "productButton";
8
+ }, t = "productImage", r = "productName", R = "productPrice", e = "productOldPrice", O = "productOmnibusPrice", _ = "productOmnibusDiscount", C = "productButton";
9
9
  export {
10
- _ as ATTR_PRODUCT_BUTTON,
11
- r as ATTR_PRODUCT_IMAGE,
12
- n as ATTR_PRODUCT_NAME,
13
- t as ATTR_PRODUCT_OLD_PRICE,
14
- O as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
15
- R as ATTR_PRODUCT_OMNIBUS_PRICE,
16
- o as ATTR_PRODUCT_PRICE,
10
+ C as ATTR_PRODUCT_BUTTON,
11
+ t as ATTR_PRODUCT_IMAGE,
12
+ r as ATTR_PRODUCT_NAME,
13
+ e as ATTR_PRODUCT_OLD_PRICE,
14
+ _ as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
15
+ O as ATTR_PRODUCT_OMNIBUS_PRICE,
16
+ R as ATTR_PRODUCT_PRICE,
17
17
  c as CONTAINER_SELECTOR,
18
- T as CURRENCY_ATTR
18
+ T as CURRENCY_ATTR,
19
+ n as DESKTOP_CONTAINER_SELECTOR,
20
+ o as MOBILE_CONTAINER_SELECTOR
19
21
  };
@@ -1,55 +1,54 @@
1
1
  var d = Object.defineProperty;
2
- var m = (l, n, t) => n in l ? d(l, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[n] = t;
3
- var i = (l, n, t) => m(l, typeof n != "symbol" ? n + "" : n, t);
2
+ var m = (c, s, t) => s in c ? d(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
+ var n = (c, s, t) => m(c, typeof s != "symbol" ? s + "" : s, t);
4
4
  import { CommonControl as h } from "../../../common-control.js";
5
+ import { RecommendationConfigService as f } from "../../services/configService.js";
5
6
  import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
6
- import { AlgorithmControl as f } from "./algorithm.js";
7
- import { ALGORITHM_CONTROL_ID as M } from "./algorithm.js";
8
- import { CurrencyControl as p } from "./currency.js";
9
- import { CURRENCY_CONTROL_ID as W } from "./currency.js";
10
- import { FiltersControl as g } from "./filters.js";
11
- import { FILTERS_CONTROL_ID as H } from "./filters.js";
12
- import { LocaleControl as R } from "./locale.js";
13
- import { LOCALE_CONTROL_ID as j } from "./locale.js";
7
+ import { AlgorithmControl as p } from "./algorithm.js";
8
+ import { ALGORITHM_CONTROL_ID as W } from "./algorithm.js";
9
+ import { CurrencyControl as g } from "./currency.js";
10
+ import { CURRENCY_CONTROL_ID as H } from "./currency.js";
11
+ import { FiltersControl as R } from "./filters.js";
12
+ import { FILTERS_CONTROL_ID as j } from "./filters.js";
13
+ import { LocaleControl as y } from "./locale.js";
14
+ import { LOCALE_CONTROL_ID as K } from "./locale.js";
14
15
  import { ProductLayoutControl as _ } from "./productLayout.js";
15
- import { PRODUCT_LAYOUT_CONTROL_ID as K } from "./productLayout.js";
16
+ import { PRODUCT_LAYOUT_CONTROL_ID as J } from "./productLayout.js";
16
17
  import { ShuffleControl as N } from "./shuffle.js";
17
- import { SHUFFLE_CONTROL_ID as J } from "./shuffle.js";
18
- import { regenerateProductRowsWithStyles as P, getBlockElement as b, updateProductContentInPlace as y } from "./utils.js";
19
- import { formatProductPrice as X, getCardComposition as Z, getCurrentLayout as tt, reapplySpacing as et, regenerateProductRows as ot, setCurrencyAttributes as rt, updatePricesInPlace as it, updateSingleProductContent as nt } from "./utils.js";
20
- import { useDebounceFn as c } from "../../../../../node_modules/@vueuse/shared/index.js";
21
- const T = "recommendation-id", L = "ui-elements-recommendation-block";
22
- class x extends h {
18
+ import { SHUFFLE_CONTROL_ID as X } from "./shuffle.js";
19
+ import { regenerateProductRowsWithStyles as b, getBlockElement as P, updateProductContentInPlace as I } from "./utils.js";
20
+ import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as nt, regenerateProductRows as it, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
+ import { useDebounceFn as l } from "../../../../../node_modules/@vueuse/shared/index.js";
22
+ const T = "recommendation-id", S = "ui-elements-recommendation-block";
23
+ class $ extends h {
23
24
  constructor() {
24
25
  super(...arguments);
25
- i(this, "store", C());
26
- i(this, "storeUnsubscription", () => {
26
+ n(this, "store", C());
27
+ n(this, "storeUnsubscription", () => {
27
28
  });
28
- // Track if initial data has been fetched per block ID to avoid redundant API calls
29
- i(this, "initializedBlocks", /* @__PURE__ */ new Map());
30
29
  // Sub-control instances for lifecycle management
31
- i(this, "algorithmControl", null);
32
- i(this, "localeControl", null);
33
- i(this, "currencyControl", null);
34
- i(this, "productLayoutControl", null);
35
- i(this, "filtersControl", null);
36
- i(this, "shuffleControl", null);
30
+ n(this, "algorithmControl", null);
31
+ n(this, "localeControl", null);
32
+ n(this, "currencyControl", null);
33
+ n(this, "productLayoutControl", null);
34
+ n(this, "filtersControl", null);
35
+ n(this, "shuffleControl", null);
37
36
  /**
38
37
  * Debounced product fetch to prevent rapid API calls during config changes
39
38
  */
40
- i(this, "_debouncedFetchProducts", c(() => {
39
+ n(this, "_debouncedFetchProducts", l(() => {
41
40
  this.store.fetchRecommendationProducts();
42
41
  }, 500));
43
42
  /**
44
43
  * Debounced regeneration when products arrive from API
45
44
  * Tries in-place update first to preserve styles, falls back to full regeneration
46
45
  */
47
- i(this, "_debouncedRegenerateWithProducts", c(() => {
46
+ n(this, "_debouncedRegenerateWithProducts", l(() => {
48
47
  const t = this.store.recommendationProducts;
49
48
  if (!this.currentNode || !this.api)
50
49
  return;
51
50
  const e = this.api.getDocumentModifier();
52
- y({
51
+ I({
53
52
  currentNode: this.currentNode,
54
53
  documentModifier: e,
55
54
  products: t
@@ -57,10 +56,10 @@ class x extends h {
57
56
  }, 100));
58
57
  }
59
58
  getId() {
60
- return L;
59
+ return S;
61
60
  }
62
61
  getTemplate() {
63
- return this.algorithmControl = new f(), this.localeControl = new R(), this.currencyControl = new p(), this.productLayoutControl = new _(), this.filtersControl = new g(), this.shuffleControl = new N(), `
62
+ return this.algorithmControl = new p(), this.localeControl = new y(), this.currencyControl = new g(), this.productLayoutControl = new _(), this.filtersControl = new R(), this.shuffleControl = new N(), `
64
63
  <div class="recommendation-controls-container">
65
64
  ${this.algorithmControl.getTemplate()}
66
65
  ${this.localeControl.getTemplate()}
@@ -72,8 +71,9 @@ class x extends h {
72
71
  `;
73
72
  }
74
73
  async onRender() {
74
+ var e;
75
75
  const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
76
- if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && this.initializedBlocks.get(t)) {
76
+ if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && ((e = this.store.blockStates[t]) != null && e.isInitialized)) {
77
77
  this._initializeSubControls();
78
78
  return;
79
79
  }
@@ -88,16 +88,17 @@ class x extends h {
88
88
  console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
89
89
  return;
90
90
  }
91
- P({
91
+ b({
92
92
  currentNode: this.currentNode,
93
93
  documentModifier: this.api.getDocumentModifier(),
94
94
  products: t
95
95
  });
96
96
  }
97
97
  onTemplateNodeUpdated(t) {
98
+ var i;
98
99
  super.onTemplateNodeUpdated(t);
99
100
  const e = this._getRecommendationIdFromNode(t);
100
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.initializedBlocks.get(e) && this._fetchBlockData(e), [
101
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
101
102
  this.algorithmControl,
102
103
  this.localeControl,
103
104
  this.currencyControl,
@@ -105,8 +106,8 @@ class x extends h {
105
106
  this.filtersControl,
106
107
  this.shuffleControl
107
108
  ].forEach((r) => {
108
- var s;
109
- r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
109
+ var a;
110
+ r != null && r.api && (r.currentNode = t, (a = r.onTemplateNodeUpdated) == null || a.call(r, t));
110
111
  });
111
112
  }
112
113
  onDestroy() {
@@ -139,36 +140,67 @@ class x extends h {
139
140
  e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
140
141
  });
141
142
  }
143
+ /**
144
+ * Syncs persisted node config into the Pinia store's block state.
145
+ *
146
+ * setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
147
+ * For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
148
+ * This method reads it and patches the store so fetchRecommendationProducts()
149
+ * uses the correct values.
150
+ *
151
+ * Uses triggerRefetch: false because the fetch hasn't happened yet —
152
+ * values are being prepared for the upcoming initial fetch.
153
+ */
154
+ _syncNodeConfigToStore() {
155
+ const t = f.getConfig(this.currentNode);
156
+ this.store.patchCurrentBlockConfig({
157
+ strategy: t.strategy,
158
+ language: t.language,
159
+ size: t.size,
160
+ productIds: t.productIds,
161
+ filters: t.filters,
162
+ shuffleProducts: t.shuffleProducts,
163
+ currencySettings: {
164
+ name: t.currency.code,
165
+ value: t.currency.code,
166
+ symbol: t.currency.symbol,
167
+ alignment: t.currency.alignment === "before" ? "0" : "1",
168
+ decimalCount: t.currency.decimalCount.toString(),
169
+ decimalSeparator: t.currency.decimalSeparator,
170
+ thousandSeparator: t.currency.thousandSeparator
171
+ }
172
+ }, { triggerRefetch: !1 });
173
+ }
142
174
  /**
143
175
  * Fetches initial data for a block (filters, algorithms, products).
144
176
  * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
145
177
  * Marks the block as initialized to prevent redundant fetches on re-selection.
146
178
  */
147
179
  async _fetchBlockData(t) {
148
- t !== null && this.initializedBlocks.set(t, !0), (await Promise.allSettled([
180
+ t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
149
181
  this.store.fetchRecommendationFilters(),
150
182
  this.store.fetchRecommendationCreateData(),
151
183
  this.store.fetchRecommendationProducts()
152
- ])).forEach((o, r) => {
184
+ ])).forEach((o, i) => {
153
185
  o.status === "rejected" && console.warn(`Recommendation block: ${[
154
186
  "fetchRecommendationFilters",
155
187
  "fetchRecommendationCreateData",
156
188
  "fetchRecommendationProducts"
157
- ][r]} failed`, o.reason);
189
+ ][i]} failed`, o.reason);
158
190
  });
159
191
  }
160
192
  /**
161
193
  * Reads the recommendation-id attribute from the block element within the node
162
194
  */
163
195
  _getRecommendationIdFromNode(t) {
164
- const e = b(t);
196
+ const e = P(t);
165
197
  if (!e || !("getAttribute" in e))
166
198
  return null;
167
199
  const o = e.getAttribute(T);
168
200
  if (!o)
169
201
  return null;
170
- const r = parseInt(o);
171
- return Number.isNaN(r) ? null : r;
202
+ const i = parseInt(o);
203
+ return Number.isNaN(i) ? null : i;
172
204
  }
173
205
  /**
174
206
  * Listen to store changes that require product refresh or regeneration.
@@ -181,37 +213,38 @@ class x extends h {
181
213
  const { store: t } = this;
182
214
  let e = t.recommendationProducts, o = t.$state.configVersion;
183
215
  this.storeUnsubscription = t.$subscribe(() => {
184
- const r = t.$state.configVersion;
185
- r !== o && (o = r, this._debouncedFetchProducts());
186
- const s = t.recommendationProducts, a = s !== e, u = Array.isArray(s) && s.length > 0;
187
- a && u && (e = s, this._debouncedRegenerateWithProducts());
216
+ const i = t.$state.configVersion;
217
+ i !== o && (o = i, this._debouncedFetchProducts());
218
+ const r = t.recommendationProducts, a = r !== e, u = Array.isArray(r) && r.length > 0;
219
+ a && u && (e = r, this._debouncedRegenerateWithProducts());
188
220
  });
189
221
  }
190
222
  }
191
223
  export {
192
- M as ALGORITHM_CONTROL_ID,
193
- f as AlgorithmControl,
194
- L as CONTROL_BLOCK_ID,
195
- W as CURRENCY_CONTROL_ID,
196
- p as CurrencyControl,
197
- H as FILTERS_CONTROL_ID,
198
- g as FiltersControl,
199
- j as LOCALE_CONTROL_ID,
200
- R as LocaleControl,
201
- K as PRODUCT_LAYOUT_CONTROL_ID,
224
+ W as ALGORITHM_CONTROL_ID,
225
+ p as AlgorithmControl,
226
+ S as CONTROL_BLOCK_ID,
227
+ H as CURRENCY_CONTROL_ID,
228
+ g as CurrencyControl,
229
+ j as FILTERS_CONTROL_ID,
230
+ R as FiltersControl,
231
+ K as LOCALE_CONTROL_ID,
232
+ y as LocaleControl,
233
+ J as PRODUCT_LAYOUT_CONTROL_ID,
202
234
  _ as ProductLayoutControl,
203
- x as RecommendationBlockControl,
204
- J as SHUFFLE_CONTROL_ID,
235
+ $ as RecommendationBlockControl,
236
+ X as SHUFFLE_CONTROL_ID,
205
237
  N as ShuffleControl,
206
- X as formatProductPrice,
207
- b as getBlockElement,
208
- Z as getCardComposition,
209
- tt as getCurrentLayout,
210
- et as reapplySpacing,
211
- ot as regenerateProductRows,
212
- P as regenerateProductRowsWithStyles,
213
- rt as setCurrencyAttributes,
214
- it as updatePricesInPlace,
215
- y as updateProductContentInPlace,
216
- nt as updateSingleProductContent
238
+ tt as formatProductPrice,
239
+ P as getBlockElement,
240
+ et as getCardComposition,
241
+ ot as getCurrentLayout,
242
+ rt as reapplySpacing,
243
+ nt as regenerateMobileProductRows,
244
+ it as regenerateProductRows,
245
+ b as regenerateProductRowsWithStyles,
246
+ st as setCurrencyAttributes,
247
+ ct as updatePricesInPlace,
248
+ I as updateProductContentInPlace,
249
+ at as updateSingleProductContent
217
250
  };