@useinsider/guido 3.6.0-beta.0e98cf4 → 3.6.0-beta.177b0b7
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/extensions/Blocks/Recommendation/controls/cardComposition/index.js +123 -127
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +12 -11
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +46 -46
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +29 -31
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +28 -28
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +49 -56
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +20 -20
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -8
- package/package.json +1 -1
- /package/dist/src/extensions/Blocks/Recommendation/{templates/utils.test.d.ts → utils/priceFormatter.test.d.ts} +0 -0
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UIElementType as f, UEAttr as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_PRODUCT_IMAGE as
|
|
7
|
-
import { DEFAULT_COMPOSITION as
|
|
8
|
-
import { RecommendationConfigService as
|
|
9
|
-
import { useRecommendationExtensionStore as
|
|
10
|
-
import { ATTRIBUTE_CELL_CLASS as
|
|
11
|
-
import { listElementRenderer as
|
|
12
|
-
import { toDisplayName as
|
|
13
|
-
import { getTableDisplayValue as
|
|
14
|
-
import { getCurrentLayout as
|
|
15
|
-
const
|
|
1
|
+
var X = Object.defineProperty;
|
|
2
|
+
var J = (p, _, t) => _ in p ? X(p, _, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[_] = t;
|
|
3
|
+
var C = (p, _, t) => J(p, typeof _ != "symbol" ? _ + "" : _, t);
|
|
4
|
+
import { UIElementType as f, UEAttr as $, ModificationDescription as A } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as Q } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_IMAGE as L, ATTR_PRODUCT_NAME as Z, ATTR_PRODUCT_PRICE as tt, ATTR_PRODUCT_OLD_PRICE as et, ATTR_PRODUCT_OMNIBUS_PRICE as rt, ATTR_PRODUCT_OMNIBUS_DISCOUNT as ot, ATTR_PRODUCT_BUTTON as D, ATTR_DATA_CUSTOM_ATTRIBUTES as k, ATTR_CUSTOM_PREFIX as m, BUILT_IN_DEFAULT_ATTRIBUTES as st } from "../../constants/selectors.js";
|
|
7
|
+
import { DEFAULT_COMPOSITION as q, DEFAULT_VISIBILITY as P } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RecommendationConfigService as it } from "../../services/configService.js";
|
|
9
|
+
import { useRecommendationExtensionStore as nt } from "../../store/recommendation.js";
|
|
10
|
+
import { ATTRIBUTE_CELL_CLASS as lt, gridElementRenderer as at, DEFAULT_CELL_PADDING as ct } from "../../templates/grid/elementRenderer.js";
|
|
11
|
+
import { listElementRenderer as ut } from "../../templates/list/elementRenderer.js";
|
|
12
|
+
import { toDisplayName as dt, isDefaultAttribute as mt, buildElementRenderer as F } from "../../templates/utils.js";
|
|
13
|
+
import { getTableDisplayValue as ht } from "../../utils/tagName.js";
|
|
14
|
+
import { getCurrentLayout as pt } from "../main/utils.js";
|
|
15
|
+
const _t = "ui-elements-recommendation-card-composition", S = ".recommendation-attribute-row", N = ".product-card-wrapper > tbody", w = ".product-info-cell > table > tbody", M = "data-card-composition", y = "data-attribute-type", I = "data-visibility", x = {
|
|
16
16
|
ADD_ATTRIBUTE: "addAttribute"
|
|
17
|
-
}, g = 5,
|
|
18
|
-
{ key:
|
|
19
|
-
{ key:
|
|
20
|
-
{ key:
|
|
21
|
-
{ key:
|
|
22
|
-
{ key:
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
25
|
-
],
|
|
26
|
-
class
|
|
17
|
+
}, g = 5, v = "reorderIcon_", h = [
|
|
18
|
+
{ key: L, label: "Product Image" },
|
|
19
|
+
{ key: Z, label: "Product Name" },
|
|
20
|
+
{ key: tt, label: "Product Price" },
|
|
21
|
+
{ key: et, label: "Product Original Price" },
|
|
22
|
+
{ key: rt, label: "Omnibus Price" },
|
|
23
|
+
{ key: ot, label: "Omnibus Discount" },
|
|
24
|
+
{ key: D, label: "Product Button" }
|
|
25
|
+
], ft = new Set(h.map((p) => p.key)), T = "customAttr_", E = "deleteAttr_";
|
|
26
|
+
class Nt extends Q {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
C(this, "store", nt());
|
|
30
|
+
C(this, "unsubscribeStore", null);
|
|
31
|
+
C(this, "eventController", null);
|
|
32
32
|
/**
|
|
33
33
|
* Guard flag: when true, onTemplateNodeUpdated skips _initializeComposition.
|
|
34
34
|
* Used during _onReorder to prevent multiple intermediate rebuilds.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
C(this, "reorderInProgress", !1);
|
|
37
37
|
}
|
|
38
38
|
getId() {
|
|
39
|
-
return
|
|
39
|
+
return _t;
|
|
40
40
|
}
|
|
41
41
|
// ========================================================================
|
|
42
42
|
// Lifecycle
|
|
@@ -60,10 +60,10 @@ class Ut extends Z {
|
|
|
60
60
|
).join(""), e = h.length + g, o = Array.from(
|
|
61
61
|
{ length: e },
|
|
62
62
|
(l, u) => `
|
|
63
|
-
<div data-reorder-icon-key="${
|
|
63
|
+
<div data-reorder-icon-key="${v}${u}" style="display: none;">
|
|
64
64
|
<${f.BUTTON}
|
|
65
65
|
class="drag-handle-btn flat-inline flat-white"
|
|
66
|
-
${
|
|
66
|
+
${$.BUTTON.name}="${v}${u}"
|
|
67
67
|
>
|
|
68
68
|
<${f.ICON}
|
|
69
69
|
src="reorder"
|
|
@@ -75,10 +75,10 @@ class Ut extends Z {
|
|
|
75
75
|
).join(""), s = Array.from(
|
|
76
76
|
{ length: g },
|
|
77
77
|
(l, u) => `
|
|
78
|
-
<div data-custom-delete-key="${
|
|
78
|
+
<div data-custom-delete-key="${E}${u}" style="display: none;">
|
|
79
79
|
<${f.BUTTON}
|
|
80
80
|
class="custom-attr-delete flat-inline flat-white"
|
|
81
|
-
${
|
|
81
|
+
${$.BUTTON.name}="${E}${u}"
|
|
82
82
|
>
|
|
83
83
|
<${f.ICON}
|
|
84
84
|
src="delete"
|
|
@@ -89,15 +89,15 @@ class Ut extends Z {
|
|
|
89
89
|
`
|
|
90
90
|
).join(""), i = "https://academy.insiderone.com/docs/new-editor-email-recommendation-block", n = this.api.translate(
|
|
91
91
|
"Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
|
|
92
|
-
),
|
|
92
|
+
), c = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
93
93
|
return `
|
|
94
94
|
<div class="recommendation-controls-container" data-card-composition-control>
|
|
95
95
|
<div class="container">
|
|
96
96
|
<p class="card-composition-description">
|
|
97
97
|
${n}
|
|
98
|
-
${
|
|
98
|
+
${c}
|
|
99
99
|
<!-- cspell:disable-next-line -->
|
|
100
|
-
<a href="${i}" target="_blank" rel="noopener noreferrer">${
|
|
100
|
+
<a href="${i}" target="_blank" rel="noopener noreferrer">${a}</a>.
|
|
101
101
|
</p>
|
|
102
102
|
</div>
|
|
103
103
|
|
|
@@ -161,14 +161,14 @@ class Ut extends Z {
|
|
|
161
161
|
// ========================================================================
|
|
162
162
|
_readCompositionFromNode() {
|
|
163
163
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
164
|
-
return [...
|
|
165
|
-
const t = this.currentNode.getAttribute(
|
|
166
|
-
return t ? t.split(",").filter(Boolean) : [...
|
|
164
|
+
return [...q];
|
|
165
|
+
const t = this.currentNode.getAttribute(M);
|
|
166
|
+
return t ? t.split(",").filter(Boolean) : [...q];
|
|
167
167
|
}
|
|
168
168
|
_readCustomAttributesFromNode() {
|
|
169
169
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
170
170
|
return [];
|
|
171
|
-
const t = this.currentNode.getAttribute(
|
|
171
|
+
const t = this.currentNode.getAttribute(k);
|
|
172
172
|
if (!t)
|
|
173
173
|
return [];
|
|
174
174
|
try {
|
|
@@ -180,18 +180,18 @@ class Ut extends Z {
|
|
|
180
180
|
_readVisibilityFromRows() {
|
|
181
181
|
if (!this.currentNode)
|
|
182
182
|
return this._getDefaultVisibilities();
|
|
183
|
-
const t = Array.from(this.currentNode.querySelectorAll(
|
|
183
|
+
const t = Array.from(this.currentNode.querySelectorAll(S)), r = this._extractVisibilityFromRows(t);
|
|
184
184
|
return this._mergeWithDefaults(r);
|
|
185
185
|
}
|
|
186
186
|
_getDefaultVisibilities() {
|
|
187
|
-
return { ...
|
|
187
|
+
return { ...P };
|
|
188
188
|
}
|
|
189
189
|
_extractVisibilityFromRows(t) {
|
|
190
190
|
const r = {};
|
|
191
191
|
return t.forEach((e) => {
|
|
192
192
|
if (!("getAttribute" in e))
|
|
193
193
|
return;
|
|
194
|
-
const o = e.getAttribute(y), s = e.getAttribute(
|
|
194
|
+
const o = e.getAttribute(y), s = e.getAttribute(I);
|
|
195
195
|
o && s !== null && (r[o] = this._parseVisibilityValue(s));
|
|
196
196
|
}), r;
|
|
197
197
|
}
|
|
@@ -199,7 +199,7 @@ class Ut extends Z {
|
|
|
199
199
|
return t === "1" || t === "true";
|
|
200
200
|
}
|
|
201
201
|
_mergeWithDefaults(t) {
|
|
202
|
-
return Object.entries(
|
|
202
|
+
return Object.entries(P).forEach(([r, e]) => {
|
|
203
203
|
r in t || (t[r] = e);
|
|
204
204
|
}), t;
|
|
205
205
|
}
|
|
@@ -223,19 +223,19 @@ class Ut extends Z {
|
|
|
223
223
|
return !1;
|
|
224
224
|
const s = new Set(r);
|
|
225
225
|
let i = 0, n = 0;
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
const l = h.find((u) => u.key ===
|
|
226
|
+
const c = t.map((a) => {
|
|
227
|
+
if (ft.has(a)) {
|
|
228
|
+
const l = h.find((u) => u.key === a);
|
|
229
229
|
return this._createBuiltInItemHtml(l, n++);
|
|
230
230
|
}
|
|
231
|
-
if (
|
|
232
|
-
const l =
|
|
231
|
+
if (a.startsWith(m)) {
|
|
232
|
+
const l = a.substring(m.length);
|
|
233
233
|
if (s.has(l))
|
|
234
|
-
return this._createCustomItemHtml(
|
|
234
|
+
return this._createCustomItemHtml(a, i++, n++);
|
|
235
235
|
}
|
|
236
236
|
return "";
|
|
237
237
|
}).join("");
|
|
238
|
-
return this._rescueTogglesToStore(e), this._rescueSelectsToStore(e), this._rescueDeleteButtonsToStore(e), this._rescueReorderIconsToStore(e), o.innerHTML =
|
|
238
|
+
return this._rescueTogglesToStore(e), this._rescueSelectsToStore(e), this._rescueDeleteButtonsToStore(e), this._rescueReorderIconsToStore(e), o.innerHTML = c, this._moveTogglesIntoItems(e), this._moveSelectsIntoItems(e, r.length), this._moveDeleteButtonsIntoItems(e, r.length), this._moveReorderIconsIntoItems(e, n), !0;
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
241
|
* Attempts to reorder existing orderable-item elements to match the composition order.
|
|
@@ -247,27 +247,27 @@ class Ut extends Z {
|
|
|
247
247
|
const e = Array.from(t.querySelectorAll(".orderable-item"));
|
|
248
248
|
if (e.length !== r.length)
|
|
249
249
|
return !1;
|
|
250
|
-
const o = e.map((
|
|
250
|
+
const o = e.map((a) => a.dataset.key).filter(Boolean);
|
|
251
251
|
if (o.length !== r.length)
|
|
252
252
|
return !1;
|
|
253
253
|
const s = [...o].sort().join(","), i = [...r].sort().join(",");
|
|
254
|
-
if (s !== i || r.some((
|
|
254
|
+
if (s !== i || r.some((a) => a.startsWith(m)))
|
|
255
255
|
return !1;
|
|
256
256
|
const n = /* @__PURE__ */ new Map();
|
|
257
|
-
e.forEach((
|
|
258
|
-
const { key: l } =
|
|
257
|
+
e.forEach((a) => {
|
|
258
|
+
const { key: l } = a.dataset;
|
|
259
259
|
if (l) {
|
|
260
260
|
const u = n.get(l) || [];
|
|
261
|
-
u.push(
|
|
261
|
+
u.push(a), n.set(l, u);
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
|
-
const
|
|
265
|
-
return r.forEach((
|
|
266
|
-
const l = n.get(
|
|
264
|
+
const c = /* @__PURE__ */ new Map();
|
|
265
|
+
return r.forEach((a) => {
|
|
266
|
+
const l = n.get(a);
|
|
267
267
|
if (!l)
|
|
268
268
|
return;
|
|
269
|
-
const u =
|
|
270
|
-
|
|
269
|
+
const u = c.get(a) || 0;
|
|
270
|
+
c.set(a, u + 1), l[u] && t.appendChild(l[u]);
|
|
271
271
|
}), !0;
|
|
272
272
|
}
|
|
273
273
|
_createBuiltInItemHtml(t, r) {
|
|
@@ -316,7 +316,7 @@ class Ut extends Z {
|
|
|
316
316
|
t.length !== 0 && setTimeout(() => {
|
|
317
317
|
t.forEach((r, e) => {
|
|
318
318
|
const o = `${T}${e}`, s = this._getSelectOptions(r, t);
|
|
319
|
-
this.api.setUIEAttribute(o,
|
|
319
|
+
this.api.setUIEAttribute(o, $.SELECTPICKER.items, s), this.api.updateValues({ [o]: r });
|
|
320
320
|
});
|
|
321
321
|
}, 0);
|
|
322
322
|
}
|
|
@@ -380,7 +380,7 @@ class Ut extends Z {
|
|
|
380
380
|
*/
|
|
381
381
|
_moveDeleteButtonsIntoItems(t, r) {
|
|
382
382
|
for (let e = 0; e < r; e++) {
|
|
383
|
-
const o = `${
|
|
383
|
+
const o = `${E}${e}`, s = t.querySelector(`[data-custom-delete-key="${o}"]`), i = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
384
384
|
if (s && i) {
|
|
385
385
|
const n = s.querySelector("ue-button");
|
|
386
386
|
n && i.appendChild(n);
|
|
@@ -393,7 +393,7 @@ class Ut extends Z {
|
|
|
393
393
|
*/
|
|
394
394
|
_rescueDeleteButtonsToStore(t) {
|
|
395
395
|
for (let r = 0; r < g; r++) {
|
|
396
|
-
const e = `${
|
|
396
|
+
const e = `${E}${r}`, o = t.querySelector(`[data-custom-delete-key="${e}"]`), s = t.querySelector(`[data-custom-delete-slot="${r}"]`);
|
|
397
397
|
if (s) {
|
|
398
398
|
const i = s.querySelector("ue-button");
|
|
399
399
|
i && o && o.appendChild(i);
|
|
@@ -406,7 +406,7 @@ class Ut extends Z {
|
|
|
406
406
|
*/
|
|
407
407
|
_moveReorderIconsIntoItems(t, r) {
|
|
408
408
|
for (let e = 0; e < r; e++) {
|
|
409
|
-
const o = `${
|
|
409
|
+
const o = `${v}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
|
|
410
410
|
if (s && i) {
|
|
411
411
|
const n = s.querySelector("ue-button");
|
|
412
412
|
n && i.appendChild(n);
|
|
@@ -420,7 +420,7 @@ class Ut extends Z {
|
|
|
420
420
|
_rescueReorderIconsToStore(t) {
|
|
421
421
|
const r = h.length + g;
|
|
422
422
|
for (let e = 0; e < r; e++) {
|
|
423
|
-
const o = `${
|
|
423
|
+
const o = `${v}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
|
|
424
424
|
if (i) {
|
|
425
425
|
const n = i.querySelector("ue-button");
|
|
426
426
|
n && s && s.appendChild(n);
|
|
@@ -444,22 +444,22 @@ class Ut extends Z {
|
|
|
444
444
|
_setupDragAndDrop(t, r) {
|
|
445
445
|
let e = null, o = null;
|
|
446
446
|
t.addEventListener("dragstart", (s) => {
|
|
447
|
-
var
|
|
447
|
+
var c;
|
|
448
448
|
const n = s.target.closest(".orderable-item");
|
|
449
|
-
n && (e = n, n.classList.add("dragging"), (
|
|
449
|
+
n && (e = n, n.classList.add("dragging"), (c = s.dataTransfer) == null || c.setData("text/plain", n.dataset.key || ""));
|
|
450
450
|
}, { signal: r }), t.addEventListener("dragend", () => {
|
|
451
451
|
e && e.classList.remove("dragging"), e = null, o == null || o.classList.remove("drag-over"), o = null;
|
|
452
452
|
}, { signal: r }), t.addEventListener("dragover", (s) => {
|
|
453
453
|
s.preventDefault();
|
|
454
|
-
const n = s.target.closest(".orderable-item"),
|
|
455
|
-
|
|
454
|
+
const n = s.target.closest(".orderable-item"), c = n && n !== e ? n : null;
|
|
455
|
+
c !== o && (o == null || o.classList.remove("drag-over"), o = c, o == null || o.classList.add("drag-over"));
|
|
456
456
|
}, { signal: r }), t.addEventListener("drop", (s) => {
|
|
457
457
|
s.preventDefault();
|
|
458
458
|
const n = s.target.closest(".orderable-item");
|
|
459
459
|
if (!n || !e || n === e)
|
|
460
460
|
return;
|
|
461
|
-
const
|
|
462
|
-
s.clientY <
|
|
461
|
+
const c = n.getBoundingClientRect(), a = c.top + c.height / 2;
|
|
462
|
+
s.clientY < a ? t.insertBefore(e, n) : t.insertBefore(e, n.nextSibling), o == null || o.classList.remove("drag-over"), o = null, e.classList.remove("dragging");
|
|
463
463
|
const u = t.querySelectorAll(".orderable-item"), d = Array.from(u).map((b) => b.dataset.key).filter(Boolean);
|
|
464
464
|
this._onReorder(d), e = null;
|
|
465
465
|
}, { signal: r });
|
|
@@ -490,7 +490,7 @@ class Ut extends Z {
|
|
|
490
490
|
const r = this._readCustomAttributesFromNode();
|
|
491
491
|
if (r[t] === void 0)
|
|
492
492
|
return;
|
|
493
|
-
const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((
|
|
493
|
+
const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((c, a) => a !== s), n = r.filter((c, a) => a !== t);
|
|
494
494
|
this._updateBothAttributes(i, n), this._removeCustomAttributeHtml(i), this._renderOrderableItems(i, n), this._initializeCustomSelects(n), this._updateAddButtonState();
|
|
495
495
|
}
|
|
496
496
|
/**
|
|
@@ -503,8 +503,8 @@ class Ut extends Z {
|
|
|
503
503
|
return;
|
|
504
504
|
const s = `${m}${r}`, i = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(i, t);
|
|
505
505
|
n !== -1 && (i[n] = s), e[t] = r;
|
|
506
|
-
const
|
|
507
|
-
this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r,
|
|
506
|
+
const c = this._getDisplayNameForAttribute(r);
|
|
507
|
+
this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r, c, s, i), this._renderOrderableItems(i, e), this._initializeCustomSelects(e);
|
|
508
508
|
}
|
|
509
509
|
_onReorder(t) {
|
|
510
510
|
const r = t.filter((e) => e.startsWith(m)).map((e) => e.substring(m.length));
|
|
@@ -525,60 +525,56 @@ class Ut extends Z {
|
|
|
525
525
|
this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, r, e, o) : this._injectListAttributeRow(t, r, e, o);
|
|
526
526
|
}
|
|
527
527
|
_injectGridAttributeRow(t, r, e, o) {
|
|
528
|
-
const s = this.currentNode.querySelectorAll(
|
|
528
|
+
const s = this.currentNode.querySelectorAll(N);
|
|
529
529
|
if (!(s != null && s.length))
|
|
530
530
|
return;
|
|
531
|
-
const i =
|
|
531
|
+
const i = it.getConfig(this.currentNode), c = `0 ${Math.floor(i.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), l = this.store.recommendationProducts.length;
|
|
532
532
|
let u = 0;
|
|
533
533
|
s.forEach((d) => {
|
|
534
|
-
var
|
|
535
|
-
const b = d.querySelector(
|
|
536
|
-
if (
|
|
534
|
+
var U;
|
|
535
|
+
const b = d.querySelector(S), R = ((U = b == null ? void 0 : b.querySelectorAll(`.${lt}`)) == null ? void 0 : U.length) || 1, V = (100 / R).toFixed(2), { bgStyle: j, bgAttr: W } = this._extractSegmentBgFromCard(d), K = o.map((B) => {
|
|
536
|
+
if (B === e) {
|
|
537
537
|
const z = Array.from(
|
|
538
|
-
{ length:
|
|
539
|
-
(
|
|
540
|
-
const
|
|
541
|
-
t,
|
|
542
|
-
r,
|
|
543
|
-
u + Y
|
|
544
|
-
);
|
|
538
|
+
{ length: R },
|
|
539
|
+
(gt, H) => {
|
|
540
|
+
const G = l > 0 ? (u + H) % l : H, Y = this._resolveAttributeContent(t, r, G);
|
|
545
541
|
return this._getGridCellHtml(
|
|
546
542
|
t,
|
|
547
|
-
|
|
548
|
-
|
|
543
|
+
Y,
|
|
544
|
+
V,
|
|
549
545
|
j,
|
|
550
546
|
W,
|
|
551
|
-
|
|
547
|
+
c
|
|
552
548
|
);
|
|
553
549
|
}
|
|
554
|
-
).join("")
|
|
555
|
-
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${
|
|
550
|
+
).join("");
|
|
551
|
+
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${I}="1">${z}</tr>`;
|
|
556
552
|
}
|
|
557
|
-
const
|
|
558
|
-
`${
|
|
553
|
+
const O = d.querySelector(
|
|
554
|
+
`${S}[${y}="${B}"]`
|
|
559
555
|
);
|
|
560
|
-
return
|
|
556
|
+
return O && "getOuterHTML" in O ? O.getOuterHTML() : "";
|
|
561
557
|
}).join("");
|
|
562
|
-
u +=
|
|
563
|
-
}),
|
|
558
|
+
u += R, l > 0 && u >= l && (u = 0), a.modifyHtml(d).setInnerHtml(K);
|
|
559
|
+
}), a.apply(new A(`${this.api.translate("Add custom attribute")}: ${r}`));
|
|
564
560
|
}
|
|
565
561
|
_injectListAttributeRow(t, r, e, o) {
|
|
566
|
-
const s = this.currentNode.querySelectorAll(
|
|
562
|
+
const s = this.currentNode.querySelectorAll(w);
|
|
567
563
|
if (!(s != null && s.length))
|
|
568
564
|
return;
|
|
569
|
-
const i = o.filter((
|
|
570
|
-
s.forEach((
|
|
565
|
+
const i = o.filter((c) => c !== L && c !== D), n = this.api.getDocumentModifier();
|
|
566
|
+
s.forEach((c, a) => {
|
|
571
567
|
const l = i.map((u) => {
|
|
572
568
|
if (u === e) {
|
|
573
|
-
const b = this._resolveAttributeContent(t, r,
|
|
569
|
+
const b = this._resolveAttributeContent(t, r, a);
|
|
574
570
|
return this._getListRowHtml(t, b, e);
|
|
575
571
|
}
|
|
576
|
-
const d =
|
|
577
|
-
`${
|
|
572
|
+
const d = c.querySelector(
|
|
573
|
+
`${S}[${y}="${u}"]`
|
|
578
574
|
);
|
|
579
575
|
return d && "getOuterHTML" in d ? d.getOuterHTML() : "";
|
|
580
576
|
}).join("");
|
|
581
|
-
n.modifyHtml(
|
|
577
|
+
n.modifyHtml(c).setInnerHtml(l);
|
|
582
578
|
}), n.apply(new A(`${this.api.translate("Add custom attribute")}: ${r}`));
|
|
583
579
|
}
|
|
584
580
|
/**
|
|
@@ -590,13 +586,13 @@ class Ut extends Z {
|
|
|
590
586
|
return;
|
|
591
587
|
const r = this._getCurrentLayout(), e = this.api.getDocumentModifier();
|
|
592
588
|
if (r === "grid") {
|
|
593
|
-
const o = this.currentNode.querySelectorAll(
|
|
589
|
+
const o = this.currentNode.querySelectorAll(N);
|
|
594
590
|
o == null || o.forEach((s) => {
|
|
595
591
|
const i = this._buildCompositionHtml(s, t);
|
|
596
592
|
e.modifyHtml(s).setInnerHtml(i);
|
|
597
593
|
});
|
|
598
594
|
} else {
|
|
599
|
-
const o = t.filter((i) => i !==
|
|
595
|
+
const o = t.filter((i) => i !== L && i !== D), s = this.currentNode.querySelectorAll(w);
|
|
600
596
|
s == null || s.forEach((i) => {
|
|
601
597
|
const n = this._buildCompositionHtml(i, o);
|
|
602
598
|
e.modifyHtml(i).setInnerHtml(n);
|
|
@@ -615,7 +611,7 @@ class Ut extends Z {
|
|
|
615
611
|
* producing a flicker on the custom attribute dropdowns.
|
|
616
612
|
*/
|
|
617
613
|
_updateBothAttributes(t, r) {
|
|
618
|
-
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(
|
|
614
|
+
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(M, t.join(",")).setAttribute(k, JSON.stringify(r)).apply(new A(this.api.translate("Update card composition")));
|
|
619
615
|
}
|
|
620
616
|
/**
|
|
621
617
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -624,7 +620,7 @@ class Ut extends Z {
|
|
|
624
620
|
_reorderProductAttributes(t) {
|
|
625
621
|
if (!this.currentNode)
|
|
626
622
|
return;
|
|
627
|
-
const r = this.currentNode.querySelectorAll(
|
|
623
|
+
const r = this.currentNode.querySelectorAll(N);
|
|
628
624
|
if (!(r != null && r.length))
|
|
629
625
|
return;
|
|
630
626
|
const e = this.api.getDocumentModifier();
|
|
@@ -639,7 +635,7 @@ class Ut extends Z {
|
|
|
639
635
|
*/
|
|
640
636
|
_buildCompositionHtml(t, r) {
|
|
641
637
|
return r.reduce((e, o) => {
|
|
642
|
-
const s = t.querySelector(`${
|
|
638
|
+
const s = t.querySelector(`${S}[${y}="${o}"]`);
|
|
643
639
|
return s && "getOuterHTML" in s ? e + s.getOuterHTML() : e;
|
|
644
640
|
}, "");
|
|
645
641
|
}
|
|
@@ -649,13 +645,13 @@ class Ut extends Z {
|
|
|
649
645
|
_applyVisibilityToBlock(t, r) {
|
|
650
646
|
if (!this.currentNode)
|
|
651
647
|
return;
|
|
652
|
-
const e = this.currentNode.querySelectorAll(`${
|
|
648
|
+
const e = this.currentNode.querySelectorAll(`${S}[${y}="${t}"]`);
|
|
653
649
|
if (!(e != null && e.length))
|
|
654
650
|
return;
|
|
655
651
|
const o = r ? "1" : "0", s = r ? this.api.translate("visible") : this.api.translate("hidden"), i = `${this.api.translate("Set visibility")}: ${t} → ${s}`, n = this.api.getDocumentModifier();
|
|
656
|
-
e.forEach((
|
|
657
|
-
const
|
|
658
|
-
n.modifyHtml(
|
|
652
|
+
e.forEach((c) => {
|
|
653
|
+
const a = ht(c), l = r ? a : "none";
|
|
654
|
+
n.modifyHtml(c).setStyle("display", l).setAttribute(I, o);
|
|
659
655
|
}), n.apply(new A(i));
|
|
660
656
|
}
|
|
661
657
|
// ========================================================================
|
|
@@ -677,7 +673,7 @@ class Ut extends Z {
|
|
|
677
673
|
return -1;
|
|
678
674
|
}
|
|
679
675
|
_getCurrentLayout() {
|
|
680
|
-
return this.store.recommendationConfigs.orientation ||
|
|
676
|
+
return this.store.recommendationConfigs.orientation || pt(this.currentNode);
|
|
681
677
|
}
|
|
682
678
|
/**
|
|
683
679
|
* Extracts background color properties from existing card elements.
|
|
@@ -731,7 +727,7 @@ class Ut extends Z {
|
|
|
731
727
|
const t = this._readCustomAttributesFromNode(), r = t.length >= g, e = new Set(t), o = this._getAddableFilters(), s = o.length > 0 && o.every((i) => e.has(i.attributeName));
|
|
732
728
|
this.api.setUIEAttribute(
|
|
733
729
|
x.ADD_ATTRIBUTE,
|
|
734
|
-
|
|
730
|
+
$.BUTTON.disabled,
|
|
735
731
|
r || s ? "true" : "false"
|
|
736
732
|
);
|
|
737
733
|
}
|
|
@@ -754,7 +750,7 @@ class Ut extends Z {
|
|
|
754
750
|
* excluding default attributes already covered by built-in toggle items.
|
|
755
751
|
*/
|
|
756
752
|
_getAddableFilters() {
|
|
757
|
-
return Object.values(this.store.filterList).filter((t) => !(t.type === "defaultAttribute" &&
|
|
753
|
+
return Object.values(this.store.filterList).filter((t) => !(t.type === "defaultAttribute" && st.has(t.attributeName)));
|
|
758
754
|
}
|
|
759
755
|
/**
|
|
760
756
|
* Looks up the display name for an attribute from the store's filterList.
|
|
@@ -762,7 +758,7 @@ class Ut extends Z {
|
|
|
762
758
|
*/
|
|
763
759
|
_getDisplayNameForAttribute(t) {
|
|
764
760
|
const r = Object.values(this.store.filterList).find((e) => e.attributeName === t);
|
|
765
|
-
return r ? r.displayName :
|
|
761
|
+
return r ? r.displayName : dt(t);
|
|
766
762
|
}
|
|
767
763
|
/**
|
|
768
764
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -770,29 +766,29 @@ class Ut extends Z {
|
|
|
770
766
|
*/
|
|
771
767
|
_resolveAttributeContent(t, r, e) {
|
|
772
768
|
var n;
|
|
773
|
-
const s = this.store.recommendationProducts[e], i =
|
|
774
|
-
return
|
|
769
|
+
const s = this.store.recommendationProducts[e], i = mt(t, this.store.filterList) ? s == null ? void 0 : s[t] : (n = s == null ? void 0 : s.product_attributes) == null ? void 0 : n[t];
|
|
770
|
+
return typeof i == "string" ? i : typeof i == "number" ? String(i) : r;
|
|
775
771
|
}
|
|
776
772
|
_getGridCellHtml(t, r, e, o = "", s = "", i = "") {
|
|
777
|
-
const n = `${m}${t}`,
|
|
773
|
+
const n = `${m}${t}`, c = F(at, [n], this.store.filterList), a = {
|
|
778
774
|
[t]: r,
|
|
779
775
|
product_attributes: { [t]: r }
|
|
780
776
|
};
|
|
781
|
-
let l =
|
|
777
|
+
let l = c[n](a);
|
|
782
778
|
return l = l.replace("<td", `<td width="${e}%"`), i && (l = l.replace(
|
|
783
|
-
`padding: ${
|
|
779
|
+
`padding: ${ct}`,
|
|
784
780
|
`padding: ${i}`
|
|
785
781
|
)), o && (l = l.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${o}"`)), s && (l = l.replace(/border="0"/, `border="0" bgcolor="${s}"`)), l;
|
|
786
782
|
}
|
|
787
783
|
_getListRowHtml(t, r, e) {
|
|
788
|
-
const o =
|
|
784
|
+
const o = F(ut, [e], this.store.filterList), s = {
|
|
789
785
|
[t]: r,
|
|
790
786
|
product_attributes: { [t]: r }
|
|
791
787
|
}, n = o[e](s).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
792
|
-
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${
|
|
788
|
+
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${I}="1">${n}</tr>`;
|
|
793
789
|
}
|
|
794
790
|
}
|
|
795
791
|
export {
|
|
796
|
-
|
|
797
|
-
|
|
792
|
+
_t as COMPOSITION_CONTROL_BLOCK_ID,
|
|
793
|
+
Nt as RecommendationCardCompositionControl
|
|
798
794
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var r = (o, e, t) =>
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var A = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var r = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as N } from "../../../common-control.js";
|
|
6
6
|
import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
|
|
@@ -9,9 +9,9 @@ import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
|
|
|
9
9
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
|
|
11
11
|
import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
|
|
12
|
-
const U = "recommendation-layout-orientation-control",
|
|
12
|
+
const U = "recommendation-layout-orientation-control", O = "recommendationInfoBannerTest", a = {
|
|
13
13
|
LAYOUT: "layout"
|
|
14
|
-
}, y = "data-card-composition",
|
|
14
|
+
}, y = "data-card-composition", n = {
|
|
15
15
|
LAYOUT: "data-layout",
|
|
16
16
|
COLUMN_SPACING: "data-column-spacing",
|
|
17
17
|
ROW_SPACING: "data-row-spacing",
|
|
@@ -30,7 +30,7 @@ class Y extends N {
|
|
|
30
30
|
getTemplate() {
|
|
31
31
|
return `
|
|
32
32
|
<div class="layout-control-container">
|
|
33
|
-
${this._GuOnPageMessage({ name:
|
|
33
|
+
${this._GuOnPageMessage({ name: O })}
|
|
34
34
|
|
|
35
35
|
${this._GuTwoColumns([
|
|
36
36
|
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
@@ -44,10 +44,11 @@ class Y extends N {
|
|
|
44
44
|
}
|
|
45
45
|
onRender() {
|
|
46
46
|
this._setInfoMessageValue(
|
|
47
|
-
|
|
47
|
+
O,
|
|
48
48
|
this.api.translate(
|
|
49
|
-
`Note that updating the Layout Orientation, Number of Products
|
|
50
|
-
Products in One Row
|
|
49
|
+
`Note that updating the Layout Orientation, Number of Products,
|
|
50
|
+
Products in One Row and Mobile Layout Optimization settings
|
|
51
|
+
resets the style of your Recommendation block.`
|
|
51
52
|
)
|
|
52
53
|
), this._setFormValues(), this._listenToFormUpdates();
|
|
53
54
|
}
|
|
@@ -83,8 +84,8 @@ class Y extends N {
|
|
|
83
84
|
},
|
|
84
85
|
`Changed layout to ${t}`
|
|
85
86
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
86
|
-
const
|
|
87
|
-
t === "list" ? (
|
|
87
|
+
const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
|
|
88
|
+
t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.setAttribute(y, _.join(",")).setAttribute(L, "[]"), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
88
89
|
} finally {
|
|
89
90
|
this.isChangingLayout = !1;
|
|
90
91
|
}
|