@useinsider/guido 2.1.0-beta.038f431 → 2.1.0-beta.07fb1d6
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.
- package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
- package/dist/composables/useActionsApi.js +15 -13
- package/dist/composables/useHtmlValidator.js +95 -87
- package/dist/composables/useRecommendation.js +54 -21
- package/dist/config/compiler/recommendationCompilerRules.js +45 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +116 -0
- package/dist/config/migrator/itemsBlockMigrator.js +140 -123
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/enums/recommendation.js +16 -15
- package/dist/extensions/Blocks/Items/block.js +19 -28
- package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
- package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
- package/dist/extensions/Blocks/Items/template.js +181 -175
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
- package/dist/extensions/Blocks/Recommendation/block.js +20 -18
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -42
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +114 -102
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +4 -4
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +19 -23
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
- package/dist/extensions/Blocks/common-control.js +91 -92
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +11 -9
- package/dist/services/templateLibraryApi.js +16 -13
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
- package/dist/static/styles/components/notification.css.js +1 -0
- package/dist/static/styles/components/version-history.css.js +10 -2
- package/dist/static/styles/components/wide-panel.css.js +18 -2
- package/dist/utils/pairProductVariables.js +57 -56
- package/dist/utils/templatePreparation.js +15 -14
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { ModificationDescription as b } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { DefaultConfigValues as
|
|
3
|
-
function
|
|
2
|
+
import { DefaultConfigValues as o, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
|
|
3
|
+
function _() {
|
|
4
4
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
5
5
|
}
|
|
6
|
-
const E = (
|
|
6
|
+
const E = (r) => r.replace(/\$/g, "$$$$");
|
|
7
7
|
function S() {
|
|
8
8
|
return {
|
|
9
9
|
initialized: !0,
|
|
10
|
-
blockInstanceId:
|
|
10
|
+
blockInstanceId: _(),
|
|
11
11
|
source: n.ITEMS_TYPE.CART_ITEMS,
|
|
12
12
|
type: n.ITEMS_TYPE.CART_ITEMS,
|
|
13
|
-
itemsSelectValue:
|
|
13
|
+
itemsSelectValue: o.cartItemsSelectControlValue,
|
|
14
14
|
orientation: n.ORIENTATION.VERTICAL,
|
|
15
|
-
nameTrimming:
|
|
16
|
-
priceHideDiscount:
|
|
17
|
-
priceFormatted:
|
|
15
|
+
nameTrimming: o.productNameTrimmingControlValue === "1",
|
|
16
|
+
priceHideDiscount: o.productPriceHideDiscountControlValue === "1",
|
|
17
|
+
priceFormatted: o.productPriceFormattedControlValue === "1",
|
|
18
18
|
priceSinglePrice: !1,
|
|
19
|
-
priceCurrencySymbol:
|
|
20
|
-
priceCurrencyLocation:
|
|
19
|
+
priceCurrencySymbol: o.productPriceCurrencySymbolControlValue,
|
|
20
|
+
priceCurrencyLocation: o.productPriceCurrencyLocationControlValue,
|
|
21
21
|
priceOrientation: "horizontal",
|
|
22
|
-
quantityControlEnabled:
|
|
23
|
-
buttonLink:
|
|
24
|
-
imageLink:
|
|
22
|
+
quantityControlEnabled: o.productQuantityControlEnabled === "1",
|
|
23
|
+
buttonLink: o.productButtonLinkControlValue,
|
|
24
|
+
imageLink: o.productImageLinkControlValue,
|
|
25
25
|
buttonLabel: "Buy",
|
|
26
26
|
buttonFullWidth: !0,
|
|
27
27
|
// Default to full width (es-fw class)
|
|
28
|
-
imageVisible:
|
|
29
|
-
nameVisible:
|
|
30
|
-
quantityVisible:
|
|
31
|
-
priceVisible:
|
|
32
|
-
originalPriceVisible:
|
|
33
|
-
buttonVisible:
|
|
28
|
+
imageVisible: o.productImageVisible === "1",
|
|
29
|
+
nameVisible: o.productNameVisible === "1",
|
|
30
|
+
quantityVisible: o.productQuantityVisible === "1",
|
|
31
|
+
priceVisible: o.productPriceVisible === "1",
|
|
32
|
+
originalPriceVisible: o.productOriginalPriceVisible === "1",
|
|
33
|
+
buttonVisible: o.productButtonVisible === "1"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
if (!
|
|
36
|
+
function p(r) {
|
|
37
|
+
if (!r)
|
|
38
38
|
return null;
|
|
39
|
-
const t =
|
|
40
|
-
return t ||
|
|
39
|
+
const t = r.closest(".items-block-v2");
|
|
40
|
+
return t || r.closest(".esd-cart-items-block");
|
|
41
41
|
}
|
|
42
|
-
function m(
|
|
43
|
-
return
|
|
42
|
+
function m(r) {
|
|
43
|
+
return r ? {
|
|
44
44
|
CartItems: n.ITEMS_TYPE.CART_ITEMS,
|
|
45
45
|
BrowsedItems: n.ITEMS_TYPE.BROWSED_ITEMS,
|
|
46
46
|
PurchasedItems: n.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
@@ -48,34 +48,34 @@ function m(o) {
|
|
|
48
48
|
CART_ITEMS: n.ITEMS_TYPE.CART_ITEMS,
|
|
49
49
|
BROWSED_ITEMS: n.ITEMS_TYPE.BROWSED_ITEMS,
|
|
50
50
|
PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
|
|
51
|
-
}[
|
|
51
|
+
}[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
|
|
52
52
|
}
|
|
53
|
-
function I(
|
|
54
|
-
if (!
|
|
55
|
-
return
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
58
|
-
if (/^\d+$/.test(
|
|
59
|
-
const e = parseInt(
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
53
|
+
function I(r, t) {
|
|
54
|
+
if (!r)
|
|
55
|
+
return o.cartItemsSelectControlValue;
|
|
56
|
+
if (r.includes("{{"))
|
|
57
|
+
return r;
|
|
58
|
+
if (/^\d+$/.test(r)) {
|
|
59
|
+
const e = parseInt(r) - 1, i = g[t];
|
|
60
|
+
if (i && i[e])
|
|
61
|
+
return i[e].value;
|
|
62
62
|
}
|
|
63
|
-
return
|
|
63
|
+
return o.cartItemsSelectControlValue;
|
|
64
64
|
}
|
|
65
|
-
function C(
|
|
66
|
-
const t =
|
|
65
|
+
function C(r) {
|
|
66
|
+
const t = r.querySelector("esd-config-block");
|
|
67
67
|
if (!t)
|
|
68
68
|
return null;
|
|
69
|
-
const e = (c,
|
|
69
|
+
const e = (c, s) => c == null ? s : c === "1" || c === "true", i = (c, s) => c || s, u = t.getAttribute("data-type"), a = m(u), d = t.getAttribute("data-cart_items_select_control_value"), l = I(d, a);
|
|
70
70
|
return {
|
|
71
71
|
initialized: e(t.getAttribute("data-initialized"), !1),
|
|
72
|
-
blockInstanceId:
|
|
72
|
+
blockInstanceId: i(
|
|
73
73
|
t.getAttribute("data-block-instance-id"),
|
|
74
|
-
|
|
74
|
+
_()
|
|
75
75
|
),
|
|
76
|
-
source:
|
|
77
|
-
type:
|
|
78
|
-
itemsSelectValue:
|
|
76
|
+
source: a,
|
|
77
|
+
type: a,
|
|
78
|
+
itemsSelectValue: l,
|
|
79
79
|
orientation: t.getAttribute("data-card_orientation_control_value") || n.ORIENTATION.VERTICAL,
|
|
80
80
|
nameTrimming: e(
|
|
81
81
|
t.getAttribute("data-product_name_control_trim"),
|
|
@@ -93,28 +93,28 @@ function C(o) {
|
|
|
93
93
|
t.getAttribute("data-product_price_control_single_price"),
|
|
94
94
|
!1
|
|
95
95
|
),
|
|
96
|
-
priceCurrencySymbol:
|
|
97
|
-
t.getAttribute("data-
|
|
98
|
-
|
|
96
|
+
priceCurrencySymbol: i(
|
|
97
|
+
t.getAttribute("data-product_price_control_currency_symbol"),
|
|
98
|
+
o.productPriceCurrencySymbolControlValue
|
|
99
99
|
),
|
|
100
|
-
priceCurrencyLocation:
|
|
100
|
+
priceCurrencyLocation: i(
|
|
101
101
|
t.getAttribute("data-product_price_currency_location"),
|
|
102
|
-
|
|
102
|
+
o.productPriceCurrencyLocationControlValue
|
|
103
103
|
),
|
|
104
104
|
priceOrientation: t.getAttribute("data-product_original_price_control_orientation") || "horizontal",
|
|
105
105
|
quantityControlEnabled: e(
|
|
106
106
|
t.getAttribute("data-product_quantity_control_enabled"),
|
|
107
107
|
!0
|
|
108
108
|
),
|
|
109
|
-
buttonLink:
|
|
109
|
+
buttonLink: i(
|
|
110
110
|
t.getAttribute("data-product_button_link"),
|
|
111
|
-
|
|
111
|
+
o.productButtonLinkControlValue
|
|
112
112
|
),
|
|
113
|
-
imageLink:
|
|
113
|
+
imageLink: i(
|
|
114
114
|
t.getAttribute("data-product_image_link"),
|
|
115
|
-
|
|
115
|
+
o.productImageLinkControlValue
|
|
116
116
|
),
|
|
117
|
-
buttonLabel:
|
|
117
|
+
buttonLabel: i(
|
|
118
118
|
t.getAttribute("data-product_button_control_label"),
|
|
119
119
|
"Buy"
|
|
120
120
|
),
|
|
@@ -149,28 +149,28 @@ function C(o) {
|
|
|
149
149
|
)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function y(
|
|
153
|
-
const t =
|
|
152
|
+
function y(r) {
|
|
153
|
+
const t = p(r);
|
|
154
154
|
if (!t)
|
|
155
155
|
return null;
|
|
156
156
|
const e = t.getNodeConfig();
|
|
157
157
|
if (e && e.initialized)
|
|
158
158
|
return e;
|
|
159
|
-
const
|
|
160
|
-
return
|
|
159
|
+
const i = C(t);
|
|
160
|
+
return i || null;
|
|
161
161
|
}
|
|
162
|
-
function A(
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
162
|
+
function A(r, t, e, i) {
|
|
163
|
+
const u = p(r);
|
|
164
|
+
if (!u)
|
|
165
165
|
return;
|
|
166
|
-
const
|
|
167
|
-
|
|
166
|
+
const d = { ...u.getNodeConfig() || {}, ...e }, l = i ?? t.getDocumentModifier();
|
|
167
|
+
l.modifyHtml(u).setNodeConfig(d), i || l.apply(new b("Update Items block configuration"));
|
|
168
168
|
}
|
|
169
169
|
export {
|
|
170
170
|
E as escapeReplacement,
|
|
171
|
-
|
|
171
|
+
_ as generateBlockInstanceId,
|
|
172
172
|
S as getDefaultItemsBlockConfig,
|
|
173
173
|
y as getItemsBlockConfig,
|
|
174
|
-
|
|
174
|
+
p as getItemsBlockContainer,
|
|
175
175
|
A as setItemsBlockConfig
|
|
176
176
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
|
-
var p = (r,
|
|
3
|
-
var g = (r,
|
|
2
|
+
var p = (r, o, t) => o in r ? u(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
|
|
3
|
+
var g = (r, o, t) => p(r, typeof o != "symbol" ? o + "" : o, t);
|
|
4
4
|
import { Block as f, BlockCompositionType as I, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { RecommendationConfigService as
|
|
5
|
+
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
6
6
|
import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
|
|
7
7
|
import { getDefaultTemplate as _ } from "./templates/grid/template.js";
|
|
8
|
-
const k = "recommendation-block",
|
|
8
|
+
const k = "recommendation-block", s = "ins-recommendation-v3-block-v2", a = "recommendation-id";
|
|
9
9
|
class b extends f {
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
@@ -50,7 +50,9 @@ class b extends f {
|
|
|
50
50
|
*/
|
|
51
51
|
onCreated(t) {
|
|
52
52
|
const e = this._pendingBlockId ?? this._generateNextId();
|
|
53
|
-
this._pendingBlockId = null, this._assignRecommendationId(t, e)
|
|
53
|
+
this._pendingBlockId = null, this._assignRecommendationId(t, e);
|
|
54
|
+
const n = c.initializeConfig(this.api, t, { recommendationId: e }), i = d();
|
|
55
|
+
i.setCurrentBlock(e), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Called when the document changes or template is loaded
|
|
@@ -63,14 +65,14 @@ class b extends f {
|
|
|
63
65
|
if (!(!t || !("getNodeConfig" in t))) {
|
|
64
66
|
if (!this._getRecommendationId(t)) {
|
|
65
67
|
const e = this._generateNextId();
|
|
66
|
-
this._assignRecommendationId(t, e),
|
|
68
|
+
this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
|
|
67
69
|
this.api,
|
|
68
70
|
t,
|
|
69
71
|
{ recommendationId: e },
|
|
70
72
|
"Assign recommendation ID to legacy block"
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
@@ -91,9 +93,9 @@ class b extends f {
|
|
|
91
93
|
let t = 0;
|
|
92
94
|
try {
|
|
93
95
|
const e = this.api.getDocumentRoot();
|
|
94
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
95
|
-
if ("getAttribute" in
|
|
96
|
-
const
|
|
96
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${s}`).forEach((i) => {
|
|
97
|
+
if ("getAttribute" in i) {
|
|
98
|
+
const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
|
|
97
99
|
l > t && (t = l);
|
|
98
100
|
}
|
|
99
101
|
});
|
|
@@ -111,8 +113,8 @@ class b extends f {
|
|
|
111
113
|
const n = this._getBlockElement(t);
|
|
112
114
|
if (!n)
|
|
113
115
|
return;
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
+
const i = this.api.getDocumentModifier();
|
|
117
|
+
i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new h(`Assign recommendation ID ${e}`));
|
|
116
118
|
}
|
|
117
119
|
/**
|
|
118
120
|
* Gets the recommendation-id from a block node
|
|
@@ -121,11 +123,11 @@ class b extends f {
|
|
|
121
123
|
const e = this._getBlockElement(t);
|
|
122
124
|
if (!e || !("getAttribute" in e))
|
|
123
125
|
return null;
|
|
124
|
-
const n = e.getAttribute(
|
|
126
|
+
const n = e.getAttribute(a);
|
|
125
127
|
if (!n)
|
|
126
128
|
return null;
|
|
127
|
-
const
|
|
128
|
-
return Number.isNaN(
|
|
129
|
+
const i = parseInt(n);
|
|
130
|
+
return Number.isNaN(i) ? null : i;
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
131
133
|
* Gets the block element (the element with BLOCK_CLASS)
|
|
@@ -133,16 +135,16 @@ class b extends f {
|
|
|
133
135
|
_getBlockElement(t) {
|
|
134
136
|
if ("getAttribute" in t) {
|
|
135
137
|
const e = t.getAttribute("class");
|
|
136
|
-
if (e && e.includes(
|
|
138
|
+
if (e && e.includes(s))
|
|
137
139
|
return t;
|
|
138
140
|
}
|
|
139
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
141
|
+
return "querySelector" in t ? t.querySelector(`.${s}`) : null;
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
142
144
|
* Migrate configuration from legacy format
|
|
143
145
|
*/
|
|
144
146
|
_migrateFromLegacy(t) {
|
|
145
|
-
|
|
147
|
+
c.migrateFromDataAttributes(this.api, t);
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
|
-
var m = (
|
|
3
|
-
var
|
|
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
5
|
import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
|
|
6
6
|
import { AlgorithmControl as f } from "./algorithm.js";
|
|
@@ -15,36 +15,34 @@ import { ProductLayoutControl as _ } from "./productLayout.js";
|
|
|
15
15
|
import { PRODUCT_LAYOUT_CONTROL_ID as K } from "./productLayout.js";
|
|
16
16
|
import { ShuffleControl as N } from "./shuffle.js";
|
|
17
17
|
import { SHUFFLE_CONTROL_ID as J } from "./shuffle.js";
|
|
18
|
-
import { regenerateProductRowsWithStyles as
|
|
19
|
-
import { formatProductPrice as X, getCardComposition as Z, getCurrentLayout as tt, reapplySpacing as et, regenerateProductRows as ot, setCurrencyAttributes as rt, updatePricesInPlace as
|
|
20
|
-
import { useDebounceFn as
|
|
21
|
-
const
|
|
22
|
-
class
|
|
18
|
+
import { regenerateProductRowsWithStyles as b, getBlockElement as P, 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 nt, updateSingleProductContent as it } from "./utils.js";
|
|
20
|
+
import { useDebounceFn as a } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
21
|
+
const I = "recommendation-id", T = "ui-elements-recommendation-block";
|
|
22
|
+
class B extends h {
|
|
23
23
|
constructor() {
|
|
24
24
|
super(...arguments);
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
n(this, "store", C());
|
|
26
|
+
n(this, "storeUnsubscription", () => {
|
|
27
27
|
});
|
|
28
|
-
// Track if initial data has been fetched per block ID to avoid redundant API calls
|
|
29
|
-
i(this, "initializedBlocks", /* @__PURE__ */ new Map());
|
|
30
28
|
// Sub-control instances for lifecycle management
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
n(this, "algorithmControl", null);
|
|
30
|
+
n(this, "localeControl", null);
|
|
31
|
+
n(this, "currencyControl", null);
|
|
32
|
+
n(this, "productLayoutControl", null);
|
|
33
|
+
n(this, "filtersControl", null);
|
|
34
|
+
n(this, "shuffleControl", null);
|
|
37
35
|
/**
|
|
38
36
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
39
37
|
*/
|
|
40
|
-
|
|
38
|
+
n(this, "_debouncedFetchProducts", a(() => {
|
|
41
39
|
this.store.fetchRecommendationProducts();
|
|
42
40
|
}, 500));
|
|
43
41
|
/**
|
|
44
42
|
* Debounced regeneration when products arrive from API
|
|
45
43
|
* Tries in-place update first to preserve styles, falls back to full regeneration
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
n(this, "_debouncedRegenerateWithProducts", a(() => {
|
|
48
46
|
const t = this.store.recommendationProducts;
|
|
49
47
|
if (!this.currentNode || !this.api)
|
|
50
48
|
return;
|
|
@@ -57,7 +55,7 @@ class x extends h {
|
|
|
57
55
|
}, 100));
|
|
58
56
|
}
|
|
59
57
|
getId() {
|
|
60
|
-
return
|
|
58
|
+
return T;
|
|
61
59
|
}
|
|
62
60
|
getTemplate() {
|
|
63
61
|
return this.algorithmControl = new f(), this.localeControl = new R(), this.currencyControl = new p(), this.productLayoutControl = new _(), this.filtersControl = new g(), this.shuffleControl = new N(), `
|
|
@@ -72,8 +70,9 @@ class x extends h {
|
|
|
72
70
|
`;
|
|
73
71
|
}
|
|
74
72
|
async onRender() {
|
|
73
|
+
var e;
|
|
75
74
|
const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
|
|
76
|
-
if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && this.
|
|
75
|
+
if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && ((e = this.store.blockStates[t]) != null && e.isInitialized)) {
|
|
77
76
|
this._initializeSubControls();
|
|
78
77
|
return;
|
|
79
78
|
}
|
|
@@ -88,16 +87,17 @@ class x extends h {
|
|
|
88
87
|
console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
|
-
|
|
90
|
+
b({
|
|
92
91
|
currentNode: this.currentNode,
|
|
93
92
|
documentModifier: this.api.getDocumentModifier(),
|
|
94
93
|
products: t
|
|
95
94
|
});
|
|
96
95
|
}
|
|
97
96
|
onTemplateNodeUpdated(t) {
|
|
97
|
+
var i;
|
|
98
98
|
super.onTemplateNodeUpdated(t);
|
|
99
99
|
const e = this._getRecommendationIdFromNode(t);
|
|
100
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.
|
|
100
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
|
|
101
101
|
this.algorithmControl,
|
|
102
102
|
this.localeControl,
|
|
103
103
|
this.currencyControl,
|
|
@@ -105,8 +105,8 @@ class x extends h {
|
|
|
105
105
|
this.filtersControl,
|
|
106
106
|
this.shuffleControl
|
|
107
107
|
].forEach((r) => {
|
|
108
|
-
var
|
|
109
|
-
r != null && r.api && (r.currentNode = t, (
|
|
108
|
+
var l;
|
|
109
|
+
r != null && r.api && (r.currentNode = t, (l = r.onTemplateNodeUpdated) == null || l.call(r, t));
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
onDestroy() {
|
|
@@ -145,30 +145,30 @@ class x extends h {
|
|
|
145
145
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
146
146
|
*/
|
|
147
147
|
async _fetchBlockData(t) {
|
|
148
|
-
t !== null && this.
|
|
148
|
+
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
149
149
|
this.store.fetchRecommendationFilters(),
|
|
150
150
|
this.store.fetchRecommendationCreateData(),
|
|
151
151
|
this.store.fetchRecommendationProducts()
|
|
152
|
-
])).forEach((o,
|
|
152
|
+
])).forEach((o, i) => {
|
|
153
153
|
o.status === "rejected" && console.warn(`Recommendation block: ${[
|
|
154
154
|
"fetchRecommendationFilters",
|
|
155
155
|
"fetchRecommendationCreateData",
|
|
156
156
|
"fetchRecommendationProducts"
|
|
157
|
-
][
|
|
157
|
+
][i]} failed`, o.reason);
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Reads the recommendation-id attribute from the block element within the node
|
|
162
162
|
*/
|
|
163
163
|
_getRecommendationIdFromNode(t) {
|
|
164
|
-
const e =
|
|
164
|
+
const e = P(t);
|
|
165
165
|
if (!e || !("getAttribute" in e))
|
|
166
166
|
return null;
|
|
167
|
-
const o = e.getAttribute(
|
|
167
|
+
const o = e.getAttribute(I);
|
|
168
168
|
if (!o)
|
|
169
169
|
return null;
|
|
170
|
-
const
|
|
171
|
-
return Number.isNaN(
|
|
170
|
+
const i = parseInt(o);
|
|
171
|
+
return Number.isNaN(i) ? null : i;
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -181,17 +181,17 @@ class x extends h {
|
|
|
181
181
|
const { store: t } = this;
|
|
182
182
|
let e = t.recommendationProducts, o = t.$state.configVersion;
|
|
183
183
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
184
|
+
const i = t.$state.configVersion;
|
|
185
|
+
i !== o && (o = i, this._debouncedFetchProducts());
|
|
186
|
+
const r = t.recommendationProducts, l = r !== e, u = Array.isArray(r) && r.length > 0;
|
|
187
|
+
l && u && (e = r, this._debouncedRegenerateWithProducts());
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
export {
|
|
192
192
|
M as ALGORITHM_CONTROL_ID,
|
|
193
193
|
f as AlgorithmControl,
|
|
194
|
-
|
|
194
|
+
T as CONTROL_BLOCK_ID,
|
|
195
195
|
W as CURRENCY_CONTROL_ID,
|
|
196
196
|
p as CurrencyControl,
|
|
197
197
|
H as FILTERS_CONTROL_ID,
|
|
@@ -200,18 +200,18 @@ export {
|
|
|
200
200
|
R as LocaleControl,
|
|
201
201
|
K as PRODUCT_LAYOUT_CONTROL_ID,
|
|
202
202
|
_ as ProductLayoutControl,
|
|
203
|
-
|
|
203
|
+
B as RecommendationBlockControl,
|
|
204
204
|
J as SHUFFLE_CONTROL_ID,
|
|
205
205
|
N as ShuffleControl,
|
|
206
206
|
X as formatProductPrice,
|
|
207
|
-
|
|
207
|
+
P as getBlockElement,
|
|
208
208
|
Z as getCardComposition,
|
|
209
209
|
tt as getCurrentLayout,
|
|
210
210
|
et as reapplySpacing,
|
|
211
211
|
ot as regenerateProductRows,
|
|
212
|
-
|
|
212
|
+
b as regenerateProductRowsWithStyles,
|
|
213
213
|
rt as setCurrencyAttributes,
|
|
214
|
-
|
|
214
|
+
nt as updatePricesInPlace,
|
|
215
215
|
y as updateProductContentInPlace,
|
|
216
|
-
|
|
216
|
+
it as updateSingleProductContent
|
|
217
217
|
};
|