@useinsider/guido 3.20.0-beta.af394f2 → 3.20.0-beta.e801a3b
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 +103 -91
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +203 -246
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
var at = Object.defineProperty;
|
|
2
|
-
var ct = (
|
|
3
|
-
var
|
|
2
|
+
var ct = (_, g, t) => g in _ ? at(_, g, { enumerable: !0, configurable: !0, writable: !0, value: t }) : _[g] = t;
|
|
3
|
+
var v = (_, g, t) => ct(_, typeof g != "symbol" ? g + "" : g, t);
|
|
4
4
|
import { ACADEMY_LINKS as dt } from "../../../../../enums/academy.js";
|
|
5
|
-
import { UIElementType as
|
|
5
|
+
import { UIElementType as f, UEAttr as O, ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as ut } from "../../../common-control.js";
|
|
7
|
-
import { ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_NAME as mt, ATTR_PRODUCT_PRICE as
|
|
7
|
+
import { ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_NAME as mt, ATTR_PRODUCT_PRICE as p, ATTR_PRODUCT_OLD_PRICE as I, ATTR_PRODUCT_OMNIBUS_PRICE as ht, ATTR_PRODUCT_OMNIBUS_DISCOUNT as pt, ATTR_PRODUCT_BUTTON as F, ATTR_RECOMMENDATION_TITLE as $, ATTR_DATA_CARD_COMPOSITION as K, ATTR_DATA_CUSTOM_ATTRIBUTES as W, ATTR_CUSTOM_PREFIX as N, SELECTOR_ATTRIBUTE_ROW as E, SELECTOR_TITLE_CELL as z, ATTR_DATA_VISIBILITY as D, ATTR_DATA_ATTRIBUTE_TYPE as R, CSS_CLASS_ATTRIBUTE_ROW as G, CSS_CLASS_SPACER as _t, BUILT_IN_DEFAULT_ATTRIBUTES as gt } from "../../constants/selectors.js";
|
|
8
8
|
import { DEFAULT_COMPOSITION as Y, DEFAULT_VISIBILITY as X } from "../../constants/defaultConfig.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as T } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as ft } from "../../store/recommendation.js";
|
|
11
11
|
import { ATTRIBUTE_CELL_CLASS as bt, gridElementRenderer as yt, DEFAULT_CELL_PADDING as Tt, buildFillerCell as Ct } from "../../templates/grid/elementRenderer.js";
|
|
12
12
|
import { listElementRenderer as St } from "../../templates/list/elementRenderer.js";
|
|
13
13
|
import { buildTitleRows as At, DEFAULT_TITLE_PARAGRAPH as It, DEFAULT_TITLE_TEXT as $t } from "../../templates/titleRows.js";
|
|
14
14
|
import { resolveInlinePriceOrder as vt, toDisplayName as Nt, toDisplayableAttributeValue as Et, buildElementRenderer as J } from "../../templates/utils.js";
|
|
15
|
-
import { normalizeCompositionKeys as Rt, normalizeCustomAttrValues as Lt, compositionKeyToProductAttr as k,
|
|
15
|
+
import { normalizeCompositionKeys as Rt, normalizeCustomAttrValues as Lt, compositionKeyToProductAttr as k, resolveRowVisibilityKeys as Ot, filterToProductAttrValue as C, findAttributeRow as Dt, rewriteLegacyRowKeyHtml as Q, bareAttributeName as H, isDefaultProductAttr as Ht, productAttrToCompositionKey as M } from "../../utils/compositionKeys.js";
|
|
16
16
|
import { getTableDisplayValue as Pt } from "../../utils/tagName.js";
|
|
17
17
|
import { isPartnerManagedBlock as wt, regenerateProductRowsWithStyles as Bt, getMainContainerTbody as kt, getCurrentLayout as Mt } from "../main/utils.js";
|
|
18
18
|
const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wrapper > tbody", Z = ".product-info-cell > table > tbody", tt = {
|
|
19
19
|
ADD_ATTRIBUTE: "addAttribute"
|
|
20
|
-
},
|
|
20
|
+
}, b = 5, P = "reorderIcon_", qt = '<svg width="14" height="10" viewBox="0 0 14 10" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2.5" r="1.2"/><circle cx="7" cy="2.5" r="1.2"/><circle cx="12" cy="2.5" r="1.2"/><circle cx="2" cy="7.5" r="1.2"/><circle cx="7" cy="7.5" r="1.2"/><circle cx="12" cy="7.5" r="1.2"/></svg>', m = [
|
|
21
21
|
{ key: q, label: "Product Image" },
|
|
22
22
|
{ key: mt, label: "Product Name" },
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
23
|
+
{ key: p, label: "Product Price" },
|
|
24
|
+
{ key: I, label: "Product Original Price" },
|
|
25
25
|
{ key: ht, label: "Omnibus Price" },
|
|
26
26
|
{ key: pt, label: "Omnibus Discount" },
|
|
27
|
-
{ key:
|
|
28
|
-
],
|
|
27
|
+
{ key: F, label: "Product Button" }
|
|
28
|
+
], L = { key: $, label: "Title" }, Ft = new Set(m.map((_) => _.key)), A = "customAttr_", w = "deleteAttr_";
|
|
29
29
|
class se extends ut {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
v(this, "store", ft());
|
|
33
|
+
v(this, "unsubscribeStore", null);
|
|
34
|
+
v(this, "eventController", null);
|
|
35
35
|
/**
|
|
36
36
|
* Guard flag: when true, onTemplateNodeUpdated skips _initializeComposition.
|
|
37
37
|
* Used during _onReorder to prevent multiple intermediate rebuilds.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
v(this, "reorderInProgress", !1);
|
|
40
40
|
}
|
|
41
41
|
getId() {
|
|
42
42
|
return Ut;
|
|
@@ -50,7 +50,7 @@ class se extends ut {
|
|
|
50
50
|
${this._GuToggle(`visibility_${d.key}`)}
|
|
51
51
|
</div>
|
|
52
52
|
`).join(""), e = Array.from(
|
|
53
|
-
{ length:
|
|
53
|
+
{ length: b },
|
|
54
54
|
(d, c) => `
|
|
55
55
|
<div data-custom-select-key="${A}${c}" style="display: none;">
|
|
56
56
|
${this._GuSelect({
|
|
@@ -62,34 +62,34 @@ class se extends ut {
|
|
|
62
62
|
})}
|
|
63
63
|
</div>
|
|
64
64
|
`
|
|
65
|
-
).join(""), r = m.length +
|
|
65
|
+
).join(""), r = m.length + b, i = Array.from(
|
|
66
66
|
{ length: r },
|
|
67
67
|
(d, c) => `
|
|
68
68
|
<div data-reorder-icon-key="${P}${c}" style="display: none;">
|
|
69
|
-
<${
|
|
69
|
+
<${f.BUTTON}
|
|
70
70
|
class="guido-drag-handle-btn flat-inline flat-white"
|
|
71
71
|
${O.BUTTON.name}="${P}${c}"
|
|
72
72
|
>
|
|
73
|
-
<${
|
|
73
|
+
<${f.ICON}
|
|
74
74
|
src="reorder"
|
|
75
75
|
class="icon-button"
|
|
76
|
-
></${
|
|
77
|
-
</${
|
|
76
|
+
></${f.ICON}>
|
|
77
|
+
</${f.BUTTON}>
|
|
78
78
|
</div>
|
|
79
79
|
`
|
|
80
80
|
).join(""), s = Array.from(
|
|
81
|
-
{ length:
|
|
81
|
+
{ length: b },
|
|
82
82
|
(d, c) => `
|
|
83
83
|
<div data-custom-delete-key="${w}${c}" style="display: none;">
|
|
84
|
-
<${
|
|
84
|
+
<${f.BUTTON}
|
|
85
85
|
class="custom-attr-delete flat-inline flat-white"
|
|
86
86
|
${O.BUTTON.name}="${w}${c}"
|
|
87
87
|
>
|
|
88
|
-
<${
|
|
88
|
+
<${f.ICON}
|
|
89
89
|
src="delete"
|
|
90
90
|
class="icon-button"
|
|
91
|
-
></${
|
|
92
|
-
</${
|
|
91
|
+
></${f.ICON}>
|
|
92
|
+
</${f.BUTTON}>
|
|
93
93
|
</div>
|
|
94
94
|
`
|
|
95
95
|
).join(""), o = dt.EMAIL_RECOMMENDATION_BLOCK, n = this.api.translate(
|
|
@@ -123,10 +123,10 @@ class se extends ut {
|
|
|
123
123
|
</div>
|
|
124
124
|
|
|
125
125
|
<div class="orderable-list">
|
|
126
|
-
<div class="orderable-item title-item" data-key="${
|
|
127
|
-
<span class="item-label">${this.api.translate(
|
|
126
|
+
<div class="orderable-item title-item" data-key="${L.key}">
|
|
127
|
+
<span class="item-label">${this.api.translate(L.label)}</span>
|
|
128
128
|
<div class="item-action">
|
|
129
|
-
${this._GuToggle(`visibility_${
|
|
129
|
+
${this._GuToggle(`visibility_${L.key}`)}
|
|
130
130
|
</div>
|
|
131
131
|
</div>
|
|
132
132
|
</div>
|
|
@@ -172,12 +172,12 @@ class se extends ut {
|
|
|
172
172
|
this.api.updateValues(s), i && this._initializeCustomSelects(e), this._updateAddButtonState();
|
|
173
173
|
}
|
|
174
174
|
_registerValueChangeListeners() {
|
|
175
|
-
[
|
|
175
|
+
[L, ...m].forEach((t) => {
|
|
176
176
|
this.api.onValueChanged(`visibility_${t.key}`, (e) => {
|
|
177
177
|
this._applyVisibilityToBlock(t.key, e);
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
|
-
for (let t = 0; t <
|
|
180
|
+
for (let t = 0; t < b; t++) {
|
|
181
181
|
const e = `${A}${t}`, r = t;
|
|
182
182
|
this.api.onValueChanged(e, (i) => {
|
|
183
183
|
this._onCustomAttributeChanged(r, i);
|
|
@@ -193,7 +193,7 @@ class se extends ut {
|
|
|
193
193
|
const t = this.currentNode.getAttribute(K);
|
|
194
194
|
if (t)
|
|
195
195
|
return this._normalizeComposition(t.split(",").filter(Boolean));
|
|
196
|
-
const { composition: e } =
|
|
196
|
+
const { composition: e } = T.getConfig(this.currentNode);
|
|
197
197
|
return e != null && e.length ? this._normalizeComposition([...e]) : [...Y];
|
|
198
198
|
}
|
|
199
199
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
@@ -214,19 +214,19 @@ class se extends ut {
|
|
|
214
214
|
} catch {
|
|
215
215
|
return [];
|
|
216
216
|
}
|
|
217
|
-
return this._readCompositionFromNode().filter((e) => e.startsWith(
|
|
217
|
+
return this._readCompositionFromNode().filter((e) => e.startsWith(N)).map(k);
|
|
218
218
|
}
|
|
219
219
|
_readVisibilityFromRows() {
|
|
220
220
|
if (!this.currentNode)
|
|
221
221
|
return this._getDefaultVisibilities();
|
|
222
|
-
const t = Array.from(this.currentNode.querySelectorAll(
|
|
222
|
+
const t = Array.from(this.currentNode.querySelectorAll(E)), e = this._extractVisibilityFromRows(t);
|
|
223
223
|
if (Object.keys(e).length > 0)
|
|
224
224
|
return this._withTitlePresence(this._mergeWithDefaults(e));
|
|
225
|
-
const r =
|
|
225
|
+
const r = T.getConfig(this.currentNode).visibility;
|
|
226
226
|
return this._withTitlePresence(this._mergeWithDefaults({ ...r }));
|
|
227
227
|
}
|
|
228
228
|
_withTitlePresence(t) {
|
|
229
|
-
return t[
|
|
229
|
+
return t[$] = this._hasTitle(), t;
|
|
230
230
|
}
|
|
231
231
|
_hasTitle() {
|
|
232
232
|
var t;
|
|
@@ -240,8 +240,10 @@ class se extends ut {
|
|
|
240
240
|
return t.forEach((r) => {
|
|
241
241
|
if (!("getAttribute" in r))
|
|
242
242
|
return;
|
|
243
|
-
const i =
|
|
244
|
-
i
|
|
243
|
+
const i = r.getAttribute(D);
|
|
244
|
+
i !== null && Ot(r).forEach((s) => {
|
|
245
|
+
e[s] = this._parseVisibilityValue(i);
|
|
246
|
+
});
|
|
245
247
|
}), e;
|
|
246
248
|
}
|
|
247
249
|
_parseVisibilityValue(t) {
|
|
@@ -253,7 +255,7 @@ class se extends ut {
|
|
|
253
255
|
}), t;
|
|
254
256
|
}
|
|
255
257
|
_buildVisibilityValues(t) {
|
|
256
|
-
return [
|
|
258
|
+
return [L, ...m].reduce((e, r) => (e[`visibility_${r.key}`] = t[r.key] ?? !0, e), {});
|
|
257
259
|
}
|
|
258
260
|
// ========================================================================
|
|
259
261
|
// UI Rendering (Orderable List)
|
|
@@ -270,22 +272,22 @@ class se extends ut {
|
|
|
270
272
|
const i = r.querySelector("[data-composition-list]");
|
|
271
273
|
if (!i)
|
|
272
274
|
return !1;
|
|
273
|
-
const s =
|
|
275
|
+
const s = this._isInlinePrices();
|
|
274
276
|
if (!(i.dataset.inlinePrices !== String(s)) && this._tryReorderInPlace(i, t))
|
|
275
277
|
return !1;
|
|
276
278
|
i.dataset.inlinePrices = String(s);
|
|
277
279
|
const n = new Set(e), l = vt(t);
|
|
278
280
|
let a = 0, d = 0;
|
|
279
281
|
const c = t.map((u) => {
|
|
280
|
-
if (s && (u ===
|
|
282
|
+
if (s && (u === p || u === I))
|
|
281
283
|
return u === l.anchor ? this._createPriceGroupItemHtml(d++, l.originalFirst) : "";
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
return this._createBuiltInItemHtml(
|
|
284
|
+
if (Ft.has(u)) {
|
|
285
|
+
const h = m.find((S) => S.key === u);
|
|
286
|
+
return this._createBuiltInItemHtml(h, d++);
|
|
285
287
|
}
|
|
286
|
-
if (u.startsWith(
|
|
287
|
-
const
|
|
288
|
-
if (n.has(
|
|
288
|
+
if (u.startsWith(N)) {
|
|
289
|
+
const h = k(u);
|
|
290
|
+
if (n.has(h))
|
|
289
291
|
return this._createCustomItemHtml(u, a++, d++);
|
|
290
292
|
}
|
|
291
293
|
return "";
|
|
@@ -306,7 +308,7 @@ class se extends ut {
|
|
|
306
308
|
if (i.length !== e.length)
|
|
307
309
|
return !1;
|
|
308
310
|
const s = [...i].sort().join(","), o = [...e].sort().join(",");
|
|
309
|
-
if (s !== o || e.some((a) => a.startsWith(
|
|
311
|
+
if (s !== o || e.some((a) => a.startsWith(N)))
|
|
310
312
|
return !1;
|
|
311
313
|
const n = /* @__PURE__ */ new Map();
|
|
312
314
|
r.forEach((a) => {
|
|
@@ -344,18 +346,18 @@ class se extends ut {
|
|
|
344
346
|
*/
|
|
345
347
|
_createPriceGroupItemHtml(t, e) {
|
|
346
348
|
var n, l;
|
|
347
|
-
const r = ((n = m.find((a) => a.key ===
|
|
349
|
+
const r = ((n = m.find((a) => a.key === p)) == null ? void 0 : n.label) ?? "Product Price", i = ((l = m.find((a) => a.key === I)) == null ? void 0 : l.label) ?? "Product Original Price", s = (a, d) => `
|
|
348
350
|
<div class="price-suborderable-item" draggable="true" data-subkey="${a}">
|
|
349
351
|
<span class="sub-drag-handle">${qt}</span>
|
|
350
352
|
<span class="item-label">${this.api.translate(d)}</span>
|
|
351
|
-
</div>`, o = e ? s(
|
|
353
|
+
</div>`, o = e ? s(I, i) + s(p, r) : s(p, r) + s(I, i);
|
|
352
354
|
return `
|
|
353
355
|
<div class="orderable-item price-group-item" draggable="true"
|
|
354
|
-
data-key="${
|
|
356
|
+
data-key="${p}" data-group="prices">
|
|
355
357
|
<div class="price-group-header">
|
|
356
358
|
<span class="guido-drag-handle" data-reorder-icon-slot="${t}"></span>
|
|
357
359
|
<span class="item-label">${this.api.translate("Product Prices")}</span>
|
|
358
|
-
<div class="item-action" data-action-for="${
|
|
360
|
+
<div class="item-action" data-action-for="${p}"></div>
|
|
359
361
|
</div>
|
|
360
362
|
<div class="price-suborderable-list">${o}</div>
|
|
361
363
|
</div>
|
|
@@ -395,13 +397,13 @@ class se extends ut {
|
|
|
395
397
|
const i = /* @__PURE__ */ new Map();
|
|
396
398
|
r.forEach((o) => i.set(o.attributeName, (i.get(o.attributeName) ?? 0) + 1));
|
|
397
399
|
const s = new Set(e);
|
|
398
|
-
return s.delete(t), r.filter((o) => !s.has(
|
|
400
|
+
return s.delete(t), r.filter((o) => !s.has(C(o))).map((o) => ({
|
|
399
401
|
text: this._toOptionLabel(
|
|
400
402
|
o.displayName,
|
|
401
403
|
o.type === "defaultAttribute",
|
|
402
404
|
(i.get(o.attributeName) ?? 0) > 1
|
|
403
405
|
),
|
|
404
|
-
value:
|
|
406
|
+
value: C(o)
|
|
405
407
|
}));
|
|
406
408
|
}
|
|
407
409
|
/**
|
|
@@ -463,7 +465,7 @@ class se extends ut {
|
|
|
463
465
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
464
466
|
*/
|
|
465
467
|
_rescueSelectsToStore(t) {
|
|
466
|
-
for (let e = 0; e <
|
|
468
|
+
for (let e = 0; e < b; e++) {
|
|
467
469
|
const r = `${A}${e}`, i = t.querySelector(`[data-custom-select-key="${r}"]`), s = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
468
470
|
if (s) {
|
|
469
471
|
const o = s.querySelector("ue-select");
|
|
@@ -489,7 +491,7 @@ class se extends ut {
|
|
|
489
491
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
490
492
|
*/
|
|
491
493
|
_rescueDeleteButtonsToStore(t) {
|
|
492
|
-
for (let e = 0; e <
|
|
494
|
+
for (let e = 0; e < b; e++) {
|
|
493
495
|
const r = `${w}${e}`, i = t.querySelector(`[data-custom-delete-key="${r}"]`), s = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
494
496
|
if (s) {
|
|
495
497
|
const o = s.querySelector("ue-button");
|
|
@@ -515,7 +517,7 @@ class se extends ut {
|
|
|
515
517
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
516
518
|
*/
|
|
517
519
|
_rescueReorderIconsToStore(t) {
|
|
518
|
-
const e = m.length +
|
|
520
|
+
const e = m.length + b;
|
|
519
521
|
for (let r = 0; r < e; r++) {
|
|
520
522
|
const i = `${P}${r}`, s = t.querySelector(`[data-reorder-icon-key="${i}"]`), o = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
521
523
|
if (o) {
|
|
@@ -534,8 +536,8 @@ class se extends ut {
|
|
|
534
536
|
return;
|
|
535
537
|
const r = e.querySelector("[data-composition-list]"), i = e.querySelector("#guido__btn-add-attribute");
|
|
536
538
|
r && (this._setupDragAndDrop(r, t), this._setupDeleteHandler(r, t)), i && i.addEventListener("click", () => {
|
|
537
|
-
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(
|
|
538
|
-
o && this._onAddAttribute(
|
|
539
|
+
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(C(n)));
|
|
540
|
+
o && this._onAddAttribute(C(o), o.displayName);
|
|
539
541
|
}, { signal: t });
|
|
540
542
|
}
|
|
541
543
|
/**
|
|
@@ -646,11 +648,11 @@ class se extends ut {
|
|
|
646
648
|
this._updateBothAttributes(o, r), this._injectCustomAttributeHtml(e, l, s, o), this._renderOrderableItems(o, r), this._initializeCustomSelects(r);
|
|
647
649
|
}
|
|
648
650
|
_onReorder(t) {
|
|
649
|
-
const e = t.filter((r) => r.startsWith(
|
|
651
|
+
const e = t.filter((r) => r.startsWith(N)).map(k);
|
|
650
652
|
this.reorderInProgress = !0;
|
|
651
653
|
try {
|
|
652
654
|
this._updateBothAttributes(t, e);
|
|
653
|
-
const r =
|
|
655
|
+
const r = this._isInlinePrices();
|
|
654
656
|
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && Bt({
|
|
655
657
|
currentNode: this.currentNode,
|
|
656
658
|
documentModifier: this.api.getDocumentModifier()
|
|
@@ -673,7 +675,7 @@ class se extends ut {
|
|
|
673
675
|
if (r && "getOuterHTML" in r)
|
|
674
676
|
return Q(r.getOuterHTML(), e);
|
|
675
677
|
const i = t.querySelector(
|
|
676
|
-
`${
|
|
678
|
+
`${E}[${R}="${e}"]`
|
|
677
679
|
);
|
|
678
680
|
return i && "getOuterHTML" in i ? Q(i.getOuterHTML(), e) : "";
|
|
679
681
|
}
|
|
@@ -686,15 +688,15 @@ class se extends ut {
|
|
|
686
688
|
const s = this.currentNode.querySelectorAll(U);
|
|
687
689
|
if (!(s != null && s.length))
|
|
688
690
|
return;
|
|
689
|
-
const o =
|
|
691
|
+
const o = T.getConfig(this.currentNode), l = `0 ${Math.floor(o.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), d = this.store.recommendationProducts.length;
|
|
690
692
|
let c = 0;
|
|
691
693
|
s.forEach((u) => {
|
|
692
694
|
var V;
|
|
693
|
-
const
|
|
695
|
+
const h = u.querySelector(E), S = ((V = h == null ? void 0 : h.querySelectorAll(`.${bt}`)) == null ? void 0 : V.length) || 1, x = (100 / S).toFixed(2), { bgStyle: et, bgAttr: rt } = this._extractSegmentBgFromCard(u), B = d > 0 ? Math.min(S, d - c) : S, it = i.map((j) => {
|
|
694
696
|
if (j === r) {
|
|
695
697
|
const st = Array.from(
|
|
696
698
|
{ length: B },
|
|
697
|
-
(
|
|
699
|
+
(xt, nt) => {
|
|
698
700
|
const lt = this._resolveAttributeContent(
|
|
699
701
|
t,
|
|
700
702
|
e,
|
|
@@ -703,14 +705,14 @@ class se extends ut {
|
|
|
703
705
|
return this._getGridCellHtml(
|
|
704
706
|
t,
|
|
705
707
|
lt,
|
|
706
|
-
|
|
708
|
+
x,
|
|
707
709
|
et,
|
|
708
710
|
rt,
|
|
709
711
|
l
|
|
710
712
|
);
|
|
711
713
|
}
|
|
712
|
-
).join(""), ot = Ct(
|
|
713
|
-
return `<tr class="${G}" ${
|
|
714
|
+
).join(""), ot = Ct(x, l).repeat(S - B);
|
|
715
|
+
return `<tr class="${G}" ${R}="${r}" ${D}="1">${st}${ot}</tr>`;
|
|
714
716
|
}
|
|
715
717
|
return this._getExistingRowHtml(u, j);
|
|
716
718
|
}).join("");
|
|
@@ -721,7 +723,7 @@ class se extends ut {
|
|
|
721
723
|
const s = this.currentNode.querySelectorAll(Z);
|
|
722
724
|
if (!(s != null && s.length))
|
|
723
725
|
return;
|
|
724
|
-
const o = i.filter((l) => l !== q && l !==
|
|
726
|
+
const o = i.filter((l) => l !== q && l !== F), n = this.api.getDocumentModifier();
|
|
725
727
|
s.forEach((l, a) => {
|
|
726
728
|
const d = o.map((c) => {
|
|
727
729
|
if (c === r) {
|
|
@@ -748,7 +750,7 @@ class se extends ut {
|
|
|
748
750
|
r.modifyHtml(s).setInnerHtml(o);
|
|
749
751
|
});
|
|
750
752
|
} else {
|
|
751
|
-
const i = t.filter((o) => o !== q && o !==
|
|
753
|
+
const i = t.filter((o) => o !== q && o !== F), s = this.currentNode.querySelectorAll(Z);
|
|
752
754
|
s == null || s.forEach((o) => {
|
|
753
755
|
const n = this._buildCompositionHtml(o, i);
|
|
754
756
|
r.modifyHtml(o).setInnerHtml(n);
|
|
@@ -770,7 +772,7 @@ class se extends ut {
|
|
|
770
772
|
if (!this.currentNode)
|
|
771
773
|
return;
|
|
772
774
|
const r = {
|
|
773
|
-
...
|
|
775
|
+
...T.getConfig(this.currentNode),
|
|
774
776
|
composition: t
|
|
775
777
|
};
|
|
776
778
|
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(K, t.join(",")).setAttribute(W, JSON.stringify(e)).setNodeConfig(r).apply(new y(this.api.translate("Update card composition")));
|
|
@@ -804,37 +806,47 @@ class se extends ut {
|
|
|
804
806
|
_applyVisibilityToBlock(t, e) {
|
|
805
807
|
if (!this.currentNode)
|
|
806
808
|
return;
|
|
807
|
-
if (t ===
|
|
809
|
+
if (t === $) {
|
|
808
810
|
this._applyTitleVisibilityToBlock(e);
|
|
809
811
|
return;
|
|
810
812
|
}
|
|
811
|
-
const r = this.currentNode.querySelectorAll(`${
|
|
812
|
-
if (!
|
|
813
|
+
const r = this._resolveVisibilityKeys(t), { currentNode: i } = this, s = r.flatMap((c) => Array.from(i.querySelectorAll(`${E}[${R}="${c}"]`) ?? []));
|
|
814
|
+
if (!s.length)
|
|
813
815
|
return;
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
|
|
816
|
+
const o = e ? "1" : "0", n = e ? this.api.translate("visible") : this.api.translate("hidden"), l = `${this.api.translate("Set visibility")}: ${t} → ${n}`, a = this.api.getDocumentModifier();
|
|
817
|
+
s.forEach((c) => {
|
|
818
|
+
const u = Pt(c), h = e ? u : "none";
|
|
819
|
+
a.modifyHtml(c).setStyle("display", h).setAttribute(D, o);
|
|
818
820
|
});
|
|
819
|
-
const
|
|
820
|
-
...
|
|
821
|
-
visibility: {
|
|
821
|
+
const d = {
|
|
822
|
+
...T.getConfig(this.currentNode),
|
|
823
|
+
visibility: {
|
|
824
|
+
...this._readVisibilityFromRows(),
|
|
825
|
+
...Object.fromEntries(r.map((c) => [c, e]))
|
|
826
|
+
}
|
|
822
827
|
};
|
|
823
|
-
|
|
828
|
+
a.modifyHtml(this.currentNode).setNodeConfig(d), a.apply(new y(l));
|
|
829
|
+
}
|
|
830
|
+
/** Inline "Product Prices" group row is tagged with whichever price comes first, so it drives both keys. */
|
|
831
|
+
_resolveVisibilityKeys(t) {
|
|
832
|
+
return this._isInlinePrices() && t === p ? [p, I] : [t];
|
|
833
|
+
}
|
|
834
|
+
_isInlinePrices() {
|
|
835
|
+
return !T.getConfig(this.currentNode).priceMovedToNextLine;
|
|
824
836
|
}
|
|
825
837
|
_applyTitleVisibilityToBlock(t) {
|
|
826
|
-
const e =
|
|
838
|
+
const e = T.getConfig(this.currentNode), r = t ? this._resolveTitleInjection(e) : null, i = t ? [] : this._findTitleRows(), s = t ? this._hasTitle() || !r : i.length === 0;
|
|
827
839
|
if (!this.currentNode || s)
|
|
828
840
|
return;
|
|
829
841
|
const o = this.api.getDocumentModifier();
|
|
830
842
|
r ? o.modifyHtml(r.containerBody).setInnerHtml(r.html) : i.forEach((l) => o.modifyHtml(l).delete()), o.modifyHtml(this.currentNode).setNodeConfig({
|
|
831
843
|
...e,
|
|
832
844
|
previousTitleHtml: t ? e.previousTitleHtml : this._readTitleHtml(i),
|
|
833
|
-
visibility: { ...this._readVisibilityFromRows(), [
|
|
845
|
+
visibility: { ...this._readVisibilityFromRows(), [$]: t }
|
|
834
846
|
});
|
|
835
847
|
const n = t ? this.api.translate("visible") : this.api.translate("hidden");
|
|
836
848
|
o.apply(new y(
|
|
837
|
-
`${this.api.translate("Set visibility")}: ${
|
|
849
|
+
`${this.api.translate("Set visibility")}: ${$} → ${n}`
|
|
838
850
|
));
|
|
839
851
|
}
|
|
840
852
|
_resolveTitleInjection(t) {
|
|
@@ -850,7 +862,7 @@ class se extends ut {
|
|
|
850
862
|
_findTitleRows() {
|
|
851
863
|
var e;
|
|
852
864
|
const t = Array.from(((e = this.currentNode) == null ? void 0 : e.querySelectorAll(
|
|
853
|
-
`${
|
|
865
|
+
`${E}[${R}="${$}"]`
|
|
854
866
|
)) ?? []);
|
|
855
867
|
return t.length > 0 ? t : this._findTitleRowsByClass();
|
|
856
868
|
}
|
|
@@ -884,7 +896,7 @@ class se extends ut {
|
|
|
884
896
|
_findNthCustomKeyIndex(t, e) {
|
|
885
897
|
let r = 0;
|
|
886
898
|
for (let i = 0; i < t.length; i++)
|
|
887
|
-
if (t[i].startsWith(
|
|
899
|
+
if (t[i].startsWith(N)) {
|
|
888
900
|
if (r === e)
|
|
889
901
|
return i;
|
|
890
902
|
r++;
|
|
@@ -944,7 +956,7 @@ class se extends ut {
|
|
|
944
956
|
* or when all available filters have already been added (no unused attributes left).
|
|
945
957
|
*/
|
|
946
958
|
_updateAddButtonState() {
|
|
947
|
-
const t = this._readCustomAttributesFromNode(), e = t.length >=
|
|
959
|
+
const t = this._readCustomAttributesFromNode(), e = t.length >= b, r = new Set(t), i = this._getAddableFilters(), s = i.length > 0 && i.every((o) => r.has(C(o)));
|
|
948
960
|
this.api.setUIEAttribute(
|
|
949
961
|
tt.ADD_ATTRIBUTE,
|
|
950
962
|
O.BUTTON.disabled,
|
|
@@ -977,7 +989,7 @@ class se extends ut {
|
|
|
977
989
|
_getAddableFilters() {
|
|
978
990
|
const t = /* @__PURE__ */ new Set();
|
|
979
991
|
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" && gt.has(e.attributeName))).filter((e) => {
|
|
980
|
-
const r =
|
|
992
|
+
const r = C(e);
|
|
981
993
|
return t.has(r) ? !1 : (t.add(r), !0);
|
|
982
994
|
});
|
|
983
995
|
}
|
|
@@ -987,7 +999,7 @@ class se extends ut {
|
|
|
987
999
|
* resolve to their own entry. Falls back to Title Case of the bare name.
|
|
988
1000
|
*/
|
|
989
1001
|
_getDisplayNameForAttribute(t) {
|
|
990
|
-
const e = Object.values(this.store.filterList).find((r) =>
|
|
1002
|
+
const e = Object.values(this.store.filterList).find((r) => C(r) === t);
|
|
991
1003
|
return e ? e.displayName : Nt(H(t));
|
|
992
1004
|
}
|
|
993
1005
|
/**
|
|
@@ -1015,7 +1027,7 @@ class se extends ut {
|
|
|
1015
1027
|
[i]: e,
|
|
1016
1028
|
product_attributes: { [i]: e }
|
|
1017
1029
|
}, l = s[r](o).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
1018
|
-
return `<tr class="${G}" ${
|
|
1030
|
+
return `<tr class="${G}" ${R}="${r}" ${D}="1">${l}</tr>`;
|
|
1019
1031
|
}
|
|
1020
1032
|
}
|
|
1021
1033
|
export {
|