@useinsider/guido 3.8.1-beta.2ee94c2 → 3.8.1-beta.6c331cf
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/composables/useHtmlValidator.js +180 -133
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +58 -57
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/extensions/Blocks/Items/block.js +48 -29
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +26 -20
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +55 -41
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +58 -57
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +43 -31
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +55 -45
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +63 -56
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +3 -2
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +13 -12
- package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -6
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/src/composables/useHtmlValidator.d.ts +27 -0
- package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var T = (a, n, t) => n in a ? f(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
|
+
var l = (a, n, t) => T(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { UEAttr as d, EditorStatePropertyType as b, PreviewDeviceMode as N } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as P } from "../../../common-control.js";
|
|
6
|
-
import
|
|
6
|
+
import "../../constants/selectors.js";
|
|
7
|
+
import { MAX_PRODUCTS_PER_ROW as C, MAX_MOBILE_PRODUCTS_PER_ROW as D, DEFAULT_MOBILE_CARDS_IN_ROW as _ } from "../../constants/layout.js";
|
|
7
8
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { setMobileLayoutOptOut as
|
|
10
|
-
import {
|
|
11
|
-
import { useDebounceFn as
|
|
9
|
+
import { useRecommendationExtensionStore as M } from "../../store/recommendation.js";
|
|
10
|
+
import { setMobileLayoutOptOut as m, ensureMobileCssRulesExist as L } from "../mobileLayout/cssRules.js";
|
|
11
|
+
import { isPartnerManagedBlock as y, getCurrentLayout as w, getBlockElement as U, adjustProductsToSize as I, regenerateProductRowsWithStyles as g, regenerateMobileProductRows as E } from "./utils.js";
|
|
12
|
+
import { useDebounceFn as A } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
12
13
|
const B = "recommendation-product-layout-control", e = {
|
|
13
14
|
// "Products in One Row" — shown when toggle is OFF
|
|
14
15
|
PRODUCT_IN_ROW: "cardsInRow",
|
|
@@ -23,14 +24,14 @@ const B = "recommendation-product-layout-control", e = {
|
|
|
23
24
|
MOBILE_LAYOUT_TOGGLE: "mobileLayoutEnabled",
|
|
24
25
|
MOBILE_LAYOUT_LABEL: "mobileLayoutLabel"
|
|
25
26
|
};
|
|
26
|
-
class
|
|
27
|
+
class F extends P {
|
|
27
28
|
constructor() {
|
|
28
29
|
super(...arguments);
|
|
29
30
|
// Store is used for backward compatibility with product fetching and regeneration
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
l(this, "store", M());
|
|
32
|
+
l(this, "storeUnsubscription", () => {
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
+
l(this, "_debouncedRegenerateProductRows", A(() => {
|
|
34
35
|
this._regenerateProductRows();
|
|
35
36
|
}, 500));
|
|
36
37
|
}
|
|
@@ -45,19 +46,19 @@ class v extends P {
|
|
|
45
46
|
text: this.api.translate("Products in One Row"),
|
|
46
47
|
name: e.PRODUCT_IN_ROW_LABEL
|
|
47
48
|
}),
|
|
48
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue:
|
|
49
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: C }),
|
|
49
50
|
this._GuLabel({
|
|
50
51
|
text: this.api.translate("Products in One Row on Desktop"),
|
|
51
52
|
name: e.PRODUCT_IN_ROW_DESKTOP_LABEL
|
|
52
53
|
}),
|
|
53
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue:
|
|
54
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW_DESKTOP, maxValue: C }),
|
|
54
55
|
this._GuLabel({
|
|
55
56
|
text: this.api.translate("Products in One Row on Mobile"),
|
|
56
57
|
name: e.MOBILE_CARDS_IN_ROW_LABEL
|
|
57
58
|
}),
|
|
58
59
|
this._GuCounter({
|
|
59
60
|
name: e.MOBILE_CARDS_IN_ROW,
|
|
60
|
-
maxValue:
|
|
61
|
+
maxValue: D
|
|
61
62
|
}),
|
|
62
63
|
this._GuLabel({
|
|
63
64
|
text: this.api.translate("Mobile Layout Optimization"),
|
|
@@ -74,10 +75,19 @@ class v extends P {
|
|
|
74
75
|
`;
|
|
75
76
|
}
|
|
76
77
|
onRender() {
|
|
77
|
-
this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
|
|
78
|
+
this._initializeMobileLayoutToggle(), this._setFormValues(), this._updateProductsInRowVisibility(), this._syncDisabledState(), this._listenToFormUpdates(), this._listenStateUpdates(), this._listenEditorModeChanges();
|
|
78
79
|
}
|
|
79
80
|
onTemplateNodeUpdated(t) {
|
|
80
|
-
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
|
|
81
|
+
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility(), this._syncDisabledState();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Products-per-row and mobile-layout restructure the block, which is
|
|
85
|
+
* meaningless for partner-managed (`ins-skip-compile`) blocks — disable
|
|
86
|
+
* these inputs there. Disabling coexists with the visibility logic above.
|
|
87
|
+
*/
|
|
88
|
+
_syncDisabledState() {
|
|
89
|
+
const t = y(this.currentNode);
|
|
90
|
+
this.api.setUIEAttribute(e.PRODUCT_IN_ROW, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.PRODUCT_IN_ROW_DESKTOP, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_CARDS_IN_ROW, d.COUNTER.disabled, t), this.api.setUIEAttribute(e.MOBILE_LAYOUT_TOGGLE, d.SWITCHER.disabled, t);
|
|
81
91
|
}
|
|
82
92
|
onDestroy() {
|
|
83
93
|
this.storeUnsubscription();
|
|
@@ -95,7 +105,7 @@ class v extends P {
|
|
|
95
105
|
* Returns true when the editor preview is in mobile mode.
|
|
96
106
|
*/
|
|
97
107
|
_isMobilePreview() {
|
|
98
|
-
return this.api.getEditorState()[
|
|
108
|
+
return this.api.getEditorState()[b.previewDeviceMode] === N.MOBILE;
|
|
99
109
|
}
|
|
100
110
|
/**
|
|
101
111
|
* Updates counter visibility based on layout, mobileLayoutEnabled, and editor preview mode.
|
|
@@ -110,12 +120,12 @@ class v extends P {
|
|
|
110
120
|
*/
|
|
111
121
|
_updateProductsInRowVisibility() {
|
|
112
122
|
var p;
|
|
113
|
-
const t = s.getConfig(this.currentNode),
|
|
114
|
-
this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE,
|
|
115
|
-
const
|
|
116
|
-
this.api.setVisibility(e.PRODUCT_IN_ROW,
|
|
117
|
-
const
|
|
118
|
-
|
|
123
|
+
const t = s.getConfig(this.currentNode), i = (t.layout || w(this.currentNode)) === "grid", { mobileLayoutEnabled: r } = t, u = this._isMobilePreview();
|
|
124
|
+
this.api.setVisibility(e.MOBILE_LAYOUT_TOGGLE, i), this.api.setVisibility(e.MOBILE_LAYOUT_LABEL, i);
|
|
125
|
+
const c = i && !r, h = i && r && !u, R = i && r && u;
|
|
126
|
+
this.api.setVisibility(e.PRODUCT_IN_ROW, c), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, c), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP, h), this.api.setVisibility(e.PRODUCT_IN_ROW_DESKTOP_LABEL, h), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, R), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, R);
|
|
127
|
+
const O = (p = this.getContainer()) == null ? void 0 : p.querySelector("[data-product-layout-control]");
|
|
128
|
+
O && (O.style.display = i ? "" : "none");
|
|
119
129
|
}
|
|
120
130
|
/**
|
|
121
131
|
* Initializes the mobile layout toggle using the same pattern as shuffle.ts.
|
|
@@ -125,7 +135,7 @@ class v extends P {
|
|
|
125
135
|
const t = s.getConfig(this.currentNode);
|
|
126
136
|
this.api.setUIEAttribute(
|
|
127
137
|
e.MOBILE_LAYOUT_TOGGLE,
|
|
128
|
-
|
|
138
|
+
d.SELECTPICKER.items,
|
|
129
139
|
t.mobileLayoutEnabled
|
|
130
140
|
);
|
|
131
141
|
}
|
|
@@ -137,12 +147,12 @@ class v extends P {
|
|
|
137
147
|
_onMobileLayoutToggleChange(t) {
|
|
138
148
|
if (!this.currentNode)
|
|
139
149
|
return;
|
|
140
|
-
const
|
|
141
|
-
if (
|
|
150
|
+
const o = s.getConfig(this.currentNode);
|
|
151
|
+
if (o.mobileLayoutEnabled === t)
|
|
142
152
|
return;
|
|
143
|
-
const
|
|
153
|
+
const i = U(this.currentNode);
|
|
144
154
|
if (t) {
|
|
145
|
-
const r =
|
|
155
|
+
const r = o.previousMobileCardsInRow || _;
|
|
146
156
|
s.updateConfig(
|
|
147
157
|
this.api,
|
|
148
158
|
this.currentNode,
|
|
@@ -157,31 +167,31 @@ class v extends P {
|
|
|
157
167
|
mobileCardsInRow: r
|
|
158
168
|
},
|
|
159
169
|
{ triggerRefetch: !1 }
|
|
160
|
-
),
|
|
161
|
-
const u = parseInt(
|
|
170
|
+
), i && m(this.api, i, !1), L(this.api);
|
|
171
|
+
const u = parseInt(o.size) || 6, c = I(this.store.recommendationProducts, u);
|
|
162
172
|
g({
|
|
163
173
|
currentNode: this.currentNode,
|
|
164
174
|
documentModifier: this.api.getDocumentModifier(),
|
|
165
|
-
products:
|
|
175
|
+
products: c
|
|
166
176
|
});
|
|
167
177
|
} else {
|
|
168
|
-
const r =
|
|
178
|
+
const r = o.mobileCardsInRow;
|
|
169
179
|
s.updateConfig(
|
|
170
180
|
this.api,
|
|
171
181
|
this.currentNode,
|
|
172
182
|
{
|
|
173
183
|
mobileLayoutEnabled: !1,
|
|
174
184
|
previousMobileCardsInRow: r,
|
|
175
|
-
mobileCardsInRow:
|
|
185
|
+
mobileCardsInRow: _
|
|
176
186
|
},
|
|
177
187
|
"Disabled mobile layout optimization"
|
|
178
188
|
), this.store.patchCurrentBlockConfig(
|
|
179
189
|
{
|
|
180
190
|
mobileLayoutEnabled: !1,
|
|
181
|
-
mobileCardsInRow:
|
|
191
|
+
mobileCardsInRow: _
|
|
182
192
|
},
|
|
183
193
|
{ triggerRefetch: !1 }
|
|
184
|
-
),
|
|
194
|
+
), i && m(this.api, i, !0), E({
|
|
185
195
|
currentNode: this.currentNode,
|
|
186
196
|
documentModifier: this.api.getDocumentModifier()
|
|
187
197
|
});
|
|
@@ -202,20 +212,20 @@ class v extends P {
|
|
|
202
212
|
this.currentNode,
|
|
203
213
|
{ mobileCardsInRow: t },
|
|
204
214
|
`Changed mobile products per row to ${t}`
|
|
205
|
-
),
|
|
215
|
+
), L(this.api), this.store.patchCurrentBlockConfig(
|
|
206
216
|
{ mobileCardsInRow: t },
|
|
207
217
|
{ triggerRefetch: !1 }
|
|
208
|
-
),
|
|
218
|
+
), E({
|
|
209
219
|
currentNode: this.currentNode,
|
|
210
220
|
documentModifier: this.api.getDocumentModifier()
|
|
211
221
|
}));
|
|
212
222
|
}
|
|
213
223
|
_regenerateProductRows() {
|
|
214
|
-
const t = s.getConfig(this.currentNode),
|
|
224
|
+
const t = s.getConfig(this.currentNode), o = parseInt(t.size) || 6, i = I(this.store.recommendationProducts, o);
|
|
215
225
|
g({
|
|
216
226
|
currentNode: this.currentNode,
|
|
217
227
|
documentModifier: this.api.getDocumentModifier(),
|
|
218
|
-
products:
|
|
228
|
+
products: i
|
|
219
229
|
});
|
|
220
230
|
}
|
|
221
231
|
_listenToFormUpdates() {
|
|
@@ -236,8 +246,8 @@ class v extends P {
|
|
|
236
246
|
_listenStateUpdates() {
|
|
237
247
|
let t = this.store.recommendationConfigs.orientation;
|
|
238
248
|
this.storeUnsubscription = this.store.$subscribe(() => {
|
|
239
|
-
const
|
|
240
|
-
|
|
249
|
+
const o = this.store.recommendationConfigs.orientation;
|
|
250
|
+
o !== t && (t = o, this._updateProductsInRowVisibility());
|
|
241
251
|
});
|
|
242
252
|
}
|
|
243
253
|
/**
|
|
@@ -247,7 +257,7 @@ class v extends P {
|
|
|
247
257
|
*/
|
|
248
258
|
_listenEditorModeChanges() {
|
|
249
259
|
this.api.onEditorStatePropUpdated(
|
|
250
|
-
|
|
260
|
+
b.previewDeviceMode,
|
|
251
261
|
() => {
|
|
252
262
|
s.getConfig(this.currentNode).mobileLayoutEnabled && this._updateProductsInRowVisibility();
|
|
253
263
|
}
|
|
@@ -256,5 +266,5 @@ class v extends P {
|
|
|
256
266
|
}
|
|
257
267
|
export {
|
|
258
268
|
B as PRODUCT_LAYOUT_CONTROL_ID,
|
|
259
|
-
|
|
269
|
+
F as ProductLayoutControl
|
|
260
270
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { RecommendationBlockId as m } from "../../constants/blockIds.js";
|
|
3
|
-
import { CURRENCY_ATTR as
|
|
3
|
+
import { CURRENCY_ATTR as y, CSS_CLASS_SKIP_COMPILE as F, MOBILE_CONTAINER_SELECTOR as O, DESKTOP_CONTAINER_SELECTOR as w, CONTAINER_SELECTOR as G, MOBILE_ROW_SELECTOR as N, ATTR_PRODUCT_ATTR as K, PRODUCT_ATTRIBUTE_PREFIX as R } from "../../constants/selectors.js";
|
|
4
4
|
import { RecommendationConfigService as S } from "../../services/configService.js";
|
|
5
5
|
import { useRecommendationExtensionStore as P } from "../../store/recommendation.js";
|
|
6
6
|
import { prepareProductRows as _ } from "../../templates/index.js";
|
|
@@ -8,7 +8,7 @@ import { captureStyles as k } from "../../utils/captureStyleTemplates.js";
|
|
|
8
8
|
import { formatPrice as V } from "../../utils/priceFormatter.js";
|
|
9
9
|
import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as T, sanitizeImageUrl as W, toDisplayableAttributeValue as Y } from "../../templates/utils.js";
|
|
10
10
|
const M = "recommendation-block-v2";
|
|
11
|
-
function
|
|
11
|
+
function A(e) {
|
|
12
12
|
if (!e)
|
|
13
13
|
return null;
|
|
14
14
|
if ("getAttribute" in e) {
|
|
@@ -18,15 +18,19 @@ function q(e) {
|
|
|
18
18
|
}
|
|
19
19
|
return "querySelector" in e ? e.querySelector(`.${M}`) ?? null : null;
|
|
20
20
|
}
|
|
21
|
+
function X(e) {
|
|
22
|
+
const t = A(e);
|
|
23
|
+
return !t || !("getAttribute" in t) ? !1 : (t.getAttribute("class") ?? "").split(/\s+/).includes(F);
|
|
24
|
+
}
|
|
21
25
|
function C(e) {
|
|
22
|
-
const t =
|
|
26
|
+
const t = A(e);
|
|
23
27
|
if (!t || !("getAttribute" in t))
|
|
24
28
|
return "grid";
|
|
25
29
|
const n = t.getAttribute("data-layout");
|
|
26
30
|
return n === "list" || n === "horizontal" ? "list" : "grid";
|
|
27
31
|
}
|
|
28
32
|
function x(e) {
|
|
29
|
-
const t =
|
|
33
|
+
const t = A(e);
|
|
30
34
|
if (!t || !("getAttribute" in t))
|
|
31
35
|
return T;
|
|
32
36
|
const n = t.getAttribute("data-card-composition");
|
|
@@ -51,25 +55,25 @@ function U(e) {
|
|
|
51
55
|
if (typeof e == "number")
|
|
52
56
|
return `0 ${e / 2}px`;
|
|
53
57
|
}
|
|
54
|
-
function
|
|
58
|
+
function z(e) {
|
|
55
59
|
const { currentNode: t, documentModifier: n } = e;
|
|
56
60
|
if (!t || !("querySelector" in t))
|
|
57
61
|
return !1;
|
|
58
62
|
const o = t.querySelector(N);
|
|
59
63
|
return o ? (n.modifyHtml(o).setInnerHtml(""), !0) : !1;
|
|
60
64
|
}
|
|
61
|
-
function
|
|
65
|
+
function J(e) {
|
|
62
66
|
return "getOuterHTML" in e && typeof e.getOuterHTML == "function" ? e.getOuterHTML() : "";
|
|
63
67
|
}
|
|
64
|
-
function
|
|
68
|
+
function Q(e) {
|
|
65
69
|
const t = e.querySelector(".container");
|
|
66
70
|
return !t || !("childNodes" in t) ? null : t.childNodes().find((o) => "getTagName" in o && o.getTagName() === "tbody") ?? t.querySelector("tbody") ?? null;
|
|
67
71
|
}
|
|
68
|
-
function
|
|
69
|
-
const o =
|
|
72
|
+
function Z(e, t, n) {
|
|
73
|
+
const o = Q(e);
|
|
70
74
|
if (!o || !("childNodes" in o))
|
|
71
75
|
return;
|
|
72
|
-
const r = o.childNodes().map(
|
|
76
|
+
const r = o.childNodes().map(J).join(""), s = `<tr class="ins-recommendation-mobile-row">${n}</tr>`;
|
|
73
77
|
t.modifyHtml(o).setInnerHtml(r + s), t.apply(new g("Added mobile product row"));
|
|
74
78
|
}
|
|
75
79
|
function $(e, t = {}) {
|
|
@@ -84,8 +88,8 @@ function $(e, t = {}) {
|
|
|
84
88
|
return !1;
|
|
85
89
|
const u = s ?? C(n), c = S.getConfig(n);
|
|
86
90
|
if (u === "list" || !c.mobileLayoutEnabled)
|
|
87
|
-
return
|
|
88
|
-
const l = P(), a = H(r, l.recommendationProducts), d = i ?? x(n),
|
|
91
|
+
return z({ currentNode: n, documentModifier: o });
|
|
92
|
+
const l = P(), a = H(r, l.recommendationProducts), d = i ?? x(n), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${_(a, u, {
|
|
89
93
|
productsPerRow: c.mobileCardsInRow,
|
|
90
94
|
composition: d,
|
|
91
95
|
filterList: l.filterList,
|
|
@@ -94,12 +98,12 @@ function $(e, t = {}) {
|
|
|
94
98
|
rowSpacingPx: c.mobileRowSpacing,
|
|
95
99
|
...t
|
|
96
100
|
})}</table></td>`, E = n.querySelector(N);
|
|
97
|
-
return E ? (o.modifyHtml(E).setInnerHtml(
|
|
101
|
+
return E ? (o.modifyHtml(E).setInnerHtml(p), !0) : (Z(n, o, p), !1);
|
|
98
102
|
}
|
|
99
|
-
function
|
|
103
|
+
function pe(e) {
|
|
100
104
|
$(e, k(e.currentNode)) && e.documentModifier.apply(new g("Updated mobile product rows"));
|
|
101
105
|
}
|
|
102
|
-
function
|
|
106
|
+
function ee(e, t = {}) {
|
|
103
107
|
const {
|
|
104
108
|
currentNode: n,
|
|
105
109
|
documentModifier: o,
|
|
@@ -109,21 +113,21 @@ function Q(e, t = {}) {
|
|
|
109
113
|
} = e;
|
|
110
114
|
if (!n || !("querySelector" in n))
|
|
111
115
|
return !1;
|
|
112
|
-
const u = n.querySelector(w) ?? n.querySelector(
|
|
116
|
+
const u = n.querySelector(w) ?? n.querySelector(G);
|
|
113
117
|
if (!u)
|
|
114
118
|
return !1;
|
|
115
|
-
const c = P(), l = H(r, c.recommendationProducts), { cardsInRow: a } = S.getConfig(n), d = i ?? x(n), f = s ?? C(n),
|
|
119
|
+
const c = P(), l = H(r, c.recommendationProducts), { cardsInRow: a } = S.getConfig(n), d = i ?? x(n), f = s ?? C(n), p = S.getConfig(n), E = _(l, f, {
|
|
116
120
|
productsPerRow: a,
|
|
117
121
|
composition: d,
|
|
118
122
|
filterList: c.filterList,
|
|
119
123
|
// One product per row has no gutter — suppress padding without clobbering the stored value.
|
|
120
|
-
cellPadding: a === 1 ? "0" : U(
|
|
121
|
-
rowSpacingPx:
|
|
124
|
+
cellPadding: a === 1 ? "0" : U(p.columnSpacing),
|
|
125
|
+
rowSpacingPx: p.rowSpacing,
|
|
122
126
|
...t
|
|
123
127
|
});
|
|
124
128
|
return o.modifyHtml(u).setInnerHtml(E), !0;
|
|
125
129
|
}
|
|
126
|
-
function
|
|
130
|
+
function ye(e) {
|
|
127
131
|
const {
|
|
128
132
|
currentNode: t,
|
|
129
133
|
documentModifier: n,
|
|
@@ -142,10 +146,10 @@ function me(e) {
|
|
|
142
146
|
layout: s,
|
|
143
147
|
composition: i
|
|
144
148
|
};
|
|
145
|
-
let a =
|
|
149
|
+
let a = ee(l, c);
|
|
146
150
|
a = $(l, c) || a, a && n.apply(new g("Regenerate products with styles")), o == null || o();
|
|
147
151
|
}
|
|
148
|
-
function
|
|
152
|
+
function be(e, t) {
|
|
149
153
|
return e.length === t ? e : e.length > t ? e.slice(0, t) : [...e, ...L(t - e.length)];
|
|
150
154
|
}
|
|
151
155
|
function B() {
|
|
@@ -159,14 +163,14 @@ function B() {
|
|
|
159
163
|
thousandSeparator: t.thousandSeparator
|
|
160
164
|
};
|
|
161
165
|
}
|
|
162
|
-
function
|
|
166
|
+
function q(e, t = "price") {
|
|
163
167
|
const n = B(), o = e[t], r = (o == null ? void 0 : o[n.code]) ?? Object.values(o ?? {})[0] ?? 0;
|
|
164
168
|
return V({
|
|
165
169
|
price: r,
|
|
166
170
|
currency: n
|
|
167
171
|
});
|
|
168
172
|
}
|
|
169
|
-
function
|
|
173
|
+
function te(e) {
|
|
170
174
|
var s, i;
|
|
171
175
|
const t = B(), n = ((s = e.original_price) == null ? void 0 : s[t.code]) ?? Object.values(e.original_price ?? {})[0] ?? 0, o = ((i = e.price) == null ? void 0 : i[t.code]) ?? Object.values(e.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
|
|
172
176
|
return r > 0 ? `-${r}%` : "0%";
|
|
@@ -175,24 +179,24 @@ function v(e) {
|
|
|
175
179
|
const { documentModifier: t, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: i } = e;
|
|
176
180
|
let u = !1;
|
|
177
181
|
if (o && "querySelector" in o) {
|
|
178
|
-
const c = o.querySelector("strong") ?? o.querySelector("p"), l =
|
|
182
|
+
const c = o.querySelector("strong") ?? o.querySelector("p"), l = q(n, "price");
|
|
179
183
|
b(t, c ?? null, l) && (u = !0);
|
|
180
184
|
}
|
|
181
185
|
if (r && "querySelector" in r) {
|
|
182
|
-
const c = r.querySelector("strong") ?? r.querySelector("p"), l =
|
|
186
|
+
const c = r.querySelector("strong") ?? r.querySelector("p"), l = q(n, "original_price");
|
|
183
187
|
b(t, c ?? null, l) && (u = !0);
|
|
184
188
|
}
|
|
185
189
|
if (s && "querySelector" in s) {
|
|
186
|
-
const c = s.querySelector(".omnibus-price-value") ?? null, l =
|
|
190
|
+
const c = s.querySelector(".omnibus-price-value") ?? null, l = q(n, "original_price");
|
|
187
191
|
b(t, c, l) && (u = !0);
|
|
188
192
|
}
|
|
189
193
|
if (i && "querySelector" in i) {
|
|
190
|
-
const c = i.querySelector(".omnibus-discount-value") ?? null, l =
|
|
194
|
+
const c = i.querySelector(".omnibus-discount-value") ?? null, l = te(n);
|
|
191
195
|
b(t, c, l) && (u = !0);
|
|
192
196
|
}
|
|
193
197
|
return u;
|
|
194
198
|
}
|
|
195
|
-
function
|
|
199
|
+
function ne(e) {
|
|
196
200
|
const {
|
|
197
201
|
documentModifier: t,
|
|
198
202
|
product: n,
|
|
@@ -231,7 +235,7 @@ function ee(e) {
|
|
|
231
235
|
function j(e) {
|
|
232
236
|
return "querySelector" in e ? e.querySelector(w) ?? e : e;
|
|
233
237
|
}
|
|
234
|
-
function
|
|
238
|
+
function oe(e, t) {
|
|
235
239
|
var o;
|
|
236
240
|
let n;
|
|
237
241
|
if (e.startsWith(R)) {
|
|
@@ -241,7 +245,7 @@ function te(e, t) {
|
|
|
241
245
|
n = t[e];
|
|
242
246
|
return Y(n) || null;
|
|
243
247
|
}
|
|
244
|
-
function
|
|
248
|
+
function re(e, t, n) {
|
|
245
249
|
if (!("querySelectorAll" in e))
|
|
246
250
|
return !1;
|
|
247
251
|
const o = e.querySelectorAll(
|
|
@@ -253,7 +257,7 @@ function ne(e, t, n) {
|
|
|
253
257
|
o.forEach((i) => {
|
|
254
258
|
if (!("getAttribute" in i))
|
|
255
259
|
return;
|
|
256
|
-
const u = i.getAttribute(
|
|
260
|
+
const u = i.getAttribute(K);
|
|
257
261
|
if (!u)
|
|
258
262
|
return;
|
|
259
263
|
const c = r.get(u) ?? [];
|
|
@@ -265,7 +269,7 @@ function ne(e, t, n) {
|
|
|
265
269
|
i.slice(0, c).forEach((l, a) => {
|
|
266
270
|
if (!("querySelector" in l))
|
|
267
271
|
return;
|
|
268
|
-
const d =
|
|
272
|
+
const d = oe(u, n[a]);
|
|
269
273
|
if (d === null)
|
|
270
274
|
return;
|
|
271
275
|
const f = l.querySelector("p") ?? null;
|
|
@@ -273,7 +277,7 @@ function ne(e, t, n) {
|
|
|
273
277
|
});
|
|
274
278
|
}), s;
|
|
275
279
|
}
|
|
276
|
-
function
|
|
280
|
+
function I(e, t, n) {
|
|
277
281
|
if (!("querySelectorAll" in e))
|
|
278
282
|
return !1;
|
|
279
283
|
const o = e.querySelectorAll(
|
|
@@ -293,7 +297,7 @@ function h(e, t, n) {
|
|
|
293
297
|
), a = Math.min(o.length, n.length);
|
|
294
298
|
let d = !1;
|
|
295
299
|
for (let f = 0; f < a; f++) {
|
|
296
|
-
const
|
|
300
|
+
const p = ne({
|
|
297
301
|
documentModifier: t,
|
|
298
302
|
product: n[f],
|
|
299
303
|
imageEl: o[f] ?? null,
|
|
@@ -304,11 +308,11 @@ function h(e, t, n) {
|
|
|
304
308
|
omnibusDiscountEl: c[f] ?? null,
|
|
305
309
|
buttonEl: l[f] ?? null
|
|
306
310
|
});
|
|
307
|
-
d = d ||
|
|
311
|
+
d = d || p;
|
|
308
312
|
}
|
|
309
|
-
return
|
|
313
|
+
return re(e, t, n) && (d = !0), d;
|
|
310
314
|
}
|
|
311
|
-
function
|
|
315
|
+
function ge(e) {
|
|
312
316
|
const { currentNode: t, documentModifier: n, products: o } = e;
|
|
313
317
|
if (!t || !("querySelectorAll" in t))
|
|
314
318
|
return !1;
|
|
@@ -317,12 +321,12 @@ function pe(e) {
|
|
|
317
321
|
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
318
322
|
).length !== o.length)
|
|
319
323
|
return !1;
|
|
320
|
-
let i =
|
|
324
|
+
let i = I(r, n, o);
|
|
321
325
|
const u = C(t), c = S.getConfig(t);
|
|
322
326
|
if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
|
|
323
327
|
const l = t.querySelector(O);
|
|
324
328
|
if (l) {
|
|
325
|
-
const a =
|
|
329
|
+
const a = I(
|
|
326
330
|
l,
|
|
327
331
|
n,
|
|
328
332
|
o
|
|
@@ -332,7 +336,7 @@ function pe(e) {
|
|
|
332
336
|
}
|
|
333
337
|
return i && n.apply(new g("Updated product content in-place")), !0;
|
|
334
338
|
}
|
|
335
|
-
function
|
|
339
|
+
function h(e, t, n) {
|
|
336
340
|
if (!("querySelectorAll" in e))
|
|
337
341
|
return !1;
|
|
338
342
|
const o = e.querySelectorAll(
|
|
@@ -356,44 +360,47 @@ function I(e, t, n) {
|
|
|
356
360
|
}) && (c = !0);
|
|
357
361
|
return c;
|
|
358
362
|
}
|
|
359
|
-
function
|
|
363
|
+
function Se(e) {
|
|
360
364
|
const { currentNode: t, documentModifier: n } = e;
|
|
361
365
|
if (!t || !("querySelectorAll" in t))
|
|
362
366
|
return !1;
|
|
367
|
+
if (X(t))
|
|
368
|
+
return !0;
|
|
363
369
|
const r = P().recommendationProducts;
|
|
364
370
|
if (r.length === 0)
|
|
365
371
|
return !1;
|
|
366
372
|
const s = j(t);
|
|
367
|
-
let i =
|
|
373
|
+
let i = h(s, n, r);
|
|
368
374
|
const u = C(t), c = S.getConfig(t);
|
|
369
375
|
if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
|
|
370
376
|
const l = t.querySelector(O);
|
|
371
377
|
if (l) {
|
|
372
|
-
const a =
|
|
378
|
+
const a = h(l, n, r);
|
|
373
379
|
i = i || a;
|
|
374
380
|
}
|
|
375
381
|
}
|
|
376
382
|
return i && n.apply(new g("Updated price formatting in-place")), i;
|
|
377
383
|
}
|
|
378
|
-
function
|
|
379
|
-
const { currentNode: t, documentModifier: n, currency: o } = e, r =
|
|
384
|
+
function Ee(e) {
|
|
385
|
+
const { currentNode: t, documentModifier: n, currency: o } = e, r = A(t);
|
|
380
386
|
if (!r)
|
|
381
387
|
return;
|
|
382
388
|
const s = o.alignment === "before" ? "0" : "1", i = (u, c) => {
|
|
383
389
|
n.modifyHtml(r).setAttribute(u, c);
|
|
384
390
|
};
|
|
385
|
-
i(
|
|
391
|
+
i(y.CURRENCY, o.code), i(y.SYMBOL, o.symbol), i(y.ALIGNMENT, s), i(y.THOUSAND_SEPARATOR, o.thousandSeparator), i(y.DECIMAL_SEPARATOR, o.decimalSeparator), i(y.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new g("Update currency attributes"));
|
|
386
392
|
}
|
|
387
393
|
export {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
394
|
+
be as adjustProductsToSize,
|
|
395
|
+
q as formatProductPrice,
|
|
396
|
+
A as getBlockElement,
|
|
391
397
|
x as getCardComposition,
|
|
392
398
|
C as getCurrentLayout,
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
+
X as isPartnerManagedBlock,
|
|
400
|
+
pe as regenerateMobileProductRows,
|
|
401
|
+
ye as regenerateProductRowsWithStyles,
|
|
402
|
+
Ee as setCurrencyAttributes,
|
|
403
|
+
Se as updatePricesInPlace,
|
|
404
|
+
ge as updateProductContentInPlace,
|
|
405
|
+
ne as updateSingleProductContent
|
|
399
406
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var a = (o, e, t) =>
|
|
4
|
-
import { UIElementType as c, UEAttr as
|
|
2
|
+
var p = (o, e, t) => e in o ? m(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var a = (o, e, t) => p(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { UIElementType as c, UEAttr as _ } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as d } from "../../common-control.js";
|
|
6
6
|
import { RecommendationControlId as C } from "../constants/controlIds.js";
|
|
7
|
+
import "../constants/selectors.js";
|
|
7
8
|
const S = C.SYNC_INFO_MESSAGE, r = "sync-info-message", u = "Note that changes will be applied to all product cards in your recommendation block.";
|
|
8
|
-
class
|
|
9
|
+
class O extends d {
|
|
9
10
|
constructor() {
|
|
10
11
|
super(...arguments);
|
|
11
12
|
a(this, "_repositionedElement", null);
|
|
@@ -17,7 +18,7 @@ class h extends d {
|
|
|
17
18
|
return `
|
|
18
19
|
<div class="${r}">
|
|
19
20
|
<${c.ICON}
|
|
20
|
-
${
|
|
21
|
+
${_.ICON.src}="migration-info-icon"
|
|
21
22
|
class="${r}__icon">
|
|
22
23
|
</${c.ICON}>
|
|
23
24
|
<p class="${r}__text">
|
|
@@ -61,5 +62,5 @@ class h extends d {
|
|
|
61
62
|
}
|
|
62
63
|
export {
|
|
63
64
|
S as SYNC_INFO_MESSAGE_CONTROL_ID,
|
|
64
|
-
|
|
65
|
+
O as SyncInfoMessageControl
|
|
65
66
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ExtensionBuilder as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { RecommendationBlock as m } from "./block.js";
|
|
3
3
|
import { RecommendationBlockControl as n } from "./controls/main/index.js";
|
|
4
|
+
import "./constants/selectors.js";
|
|
4
5
|
import "./store/recommendation.js";
|
|
5
6
|
import "./utils/captureStyleTemplates.js";
|
|
6
7
|
import { NameControls as i } from "./controls/name/index.js";
|
|
@@ -36,10 +37,10 @@ const b = [
|
|
|
36
37
|
], S = [
|
|
37
38
|
...P,
|
|
38
39
|
...b.flatMap((o) => Object.values(o))
|
|
39
|
-
],
|
|
40
|
+
], Q = S.reduce(
|
|
40
41
|
(o, t) => o.addControl(t),
|
|
41
42
|
new r().addBlock(m).withSettingsPanelRegistry(B)
|
|
42
43
|
).addStyles(y).withIconsRegistry(R).build();
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
+
Q as default
|
|
45
46
|
};
|
|
@@ -2,6 +2,7 @@ import { SettingsPanelRegistry as E, SettingsPanelTab as _, SettingsTab as O, Co
|
|
|
2
2
|
import { BLOCK_ID as U } from "./block.js";
|
|
3
3
|
import { RecommendationBlockId as S } from "./constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as T } from "./constants/controlIds.js";
|
|
5
|
+
import "./constants/selectors.js";
|
|
5
6
|
import { CONTROL_BLOCK_ID as A } from "./controls/main/index.js";
|
|
6
7
|
import "./store/recommendation.js";
|
|
7
8
|
import "./utils/captureStyleTemplates.js";
|
|
@@ -16,7 +17,7 @@ import { SPACING_CONTROL_ID as L } from "./controls/spacing/index.js";
|
|
|
16
17
|
import { CARD_BACKGROUND_COLOR_CONTROL_ID as D } from "./controls/cardBackground/index.js";
|
|
17
18
|
import { COMPOSITION_CONTROL_BLOCK_ID as B } from "./controls/cardComposition/index.js";
|
|
18
19
|
import { SYNC_INFO_MESSAGE_CONTROL_ID as N } from "./controls/syncInfoMessage.js";
|
|
19
|
-
class
|
|
20
|
+
class d extends E {
|
|
20
21
|
registerBlockControls(I) {
|
|
21
22
|
I[U] = [
|
|
22
23
|
new _(
|
|
@@ -195,5 +196,5 @@ class a extends E {
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
export {
|
|
198
|
-
|
|
199
|
+
d as SettingsPanel
|
|
199
200
|
};
|