@useinsider/guido 3.19.0-beta.b539426 → 3.19.0-beta.bfba628
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/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +53 -47
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -105
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +70 -72
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +60 -69
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +5 -3
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +0 -4
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +2 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
var at = Object.defineProperty;
|
|
2
|
-
var ct = (
|
|
3
|
-
var
|
|
2
|
+
var ct = (h, p, t) => p in h ? at(h, p, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[p] = t;
|
|
3
|
+
var $ = (h, p, t) => ct(h, typeof p != "symbol" ? p + "" : p, t);
|
|
4
4
|
import { ACADEMY_LINKS as dt } from "../../../../../enums/academy.js";
|
|
5
|
-
import { UIElementType as
|
|
5
|
+
import { UIElementType as _, 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 C, ATTR_PRODUCT_OLD_PRICE as L, ATTR_PRODUCT_OMNIBUS_PRICE as ht, ATTR_PRODUCT_OMNIBUS_DISCOUNT as pt, ATTR_PRODUCT_BUTTON as x, ATTR_RECOMMENDATION_TITLE as I, ATTR_DATA_CARD_COMPOSITION as K, ATTR_DATA_CUSTOM_ATTRIBUTES as W, ATTR_CUSTOM_PREFIX as v, SELECTOR_ATTRIBUTE_ROW as N, SELECTOR_TITLE_CELL as z, ATTR_DATA_VISIBILITY as D, ATTR_DATA_ATTRIBUTE_TYPE as E, 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 g } 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
|
|
15
|
+
import { normalizeCompositionKeys as Rt, normalizeCustomAttrValues as Lt, compositionKeyToProductAttr as k, resolveRowCompositionKey as Ot, filterToProductAttrValue as T, 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
|
-
import { isPartnerManagedBlock as wt, regenerateProductRowsWithStyles as Bt, getMainContainerTbody as
|
|
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
|
+
}, f = 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: C, label: "Product Price" },
|
|
24
|
+
{ key: L, label: "Product Original Price" },
|
|
25
25
|
{ key: ht, label: "Omnibus Price" },
|
|
26
26
|
{ key: pt, label: "Omnibus Discount" },
|
|
27
27
|
{ key: x, label: "Product Button" }
|
|
28
|
-
],
|
|
28
|
+
], R = { key: I, label: "Title" }, xt = new Set(m.map((h) => h.key)), A = "customAttr_", w = "deleteAttr_";
|
|
29
29
|
class se extends ut {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
$(this, "store", ft());
|
|
33
|
+
$(this, "unsubscribeStore", null);
|
|
34
|
+
$(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
|
+
$(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: f },
|
|
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 + f, 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
|
+
<${_.BUTTON}
|
|
70
70
|
class="guido-drag-handle-btn flat-inline flat-white"
|
|
71
71
|
${O.BUTTON.name}="${P}${c}"
|
|
72
72
|
>
|
|
73
|
-
<${
|
|
73
|
+
<${_.ICON}
|
|
74
74
|
src="reorder"
|
|
75
75
|
class="icon-button"
|
|
76
|
-
></${
|
|
77
|
-
</${
|
|
76
|
+
></${_.ICON}>
|
|
77
|
+
</${_.BUTTON}>
|
|
78
78
|
</div>
|
|
79
79
|
`
|
|
80
80
|
).join(""), s = Array.from(
|
|
81
|
-
{ length:
|
|
81
|
+
{ length: f },
|
|
82
82
|
(d, c) => `
|
|
83
83
|
<div data-custom-delete-key="${w}${c}" style="display: none;">
|
|
84
|
-
<${
|
|
84
|
+
<${_.BUTTON}
|
|
85
85
|
class="custom-attr-delete flat-inline flat-white"
|
|
86
86
|
${O.BUTTON.name}="${w}${c}"
|
|
87
87
|
>
|
|
88
|
-
<${
|
|
88
|
+
<${_.ICON}
|
|
89
89
|
src="delete"
|
|
90
90
|
class="icon-button"
|
|
91
|
-
></${
|
|
92
|
-
</${
|
|
91
|
+
></${_.ICON}>
|
|
92
|
+
</${_.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="${R.key}">
|
|
127
|
+
<span class="item-label">${this.api.translate(R.label)}</span>
|
|
128
128
|
<div class="item-action">
|
|
129
|
-
${this._GuToggle(`visibility_${
|
|
129
|
+
${this._GuToggle(`visibility_${R.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
|
+
[R, ...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 < f; 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 } = g.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(v)).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(N)), 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 = g.getConfig(this.currentNode).visibility;
|
|
226
226
|
return this._withTitlePresence(this._mergeWithDefaults({ ...r }));
|
|
227
227
|
}
|
|
228
228
|
_withTitlePresence(t) {
|
|
229
|
-
return t[
|
|
229
|
+
return t[I] = this._hasTitle(), t;
|
|
230
230
|
}
|
|
231
231
|
_hasTitle() {
|
|
232
232
|
var t;
|
|
@@ -240,10 +240,8 @@ class se extends ut {
|
|
|
240
240
|
return t.forEach((r) => {
|
|
241
241
|
if (!("getAttribute" in r))
|
|
242
242
|
return;
|
|
243
|
-
const i = r.getAttribute(D);
|
|
244
|
-
i !== null &&
|
|
245
|
-
e[s] = this._parseVisibilityValue(i);
|
|
246
|
-
});
|
|
243
|
+
const i = Ot(r), s = r.getAttribute(D);
|
|
244
|
+
i && s !== null && (e[i] = this._parseVisibilityValue(s));
|
|
247
245
|
}), e;
|
|
248
246
|
}
|
|
249
247
|
_parseVisibilityValue(t) {
|
|
@@ -255,7 +253,7 @@ class se extends ut {
|
|
|
255
253
|
}), t;
|
|
256
254
|
}
|
|
257
255
|
_buildVisibilityValues(t) {
|
|
258
|
-
return [
|
|
256
|
+
return [R, ...m].reduce((e, r) => (e[`visibility_${r.key}`] = t[r.key] ?? !0, e), {});
|
|
259
257
|
}
|
|
260
258
|
// ========================================================================
|
|
261
259
|
// UI Rendering (Orderable List)
|
|
@@ -272,22 +270,22 @@ class se extends ut {
|
|
|
272
270
|
const i = r.querySelector("[data-composition-list]");
|
|
273
271
|
if (!i)
|
|
274
272
|
return !1;
|
|
275
|
-
const s = !
|
|
273
|
+
const s = !g.getConfig(this.currentNode).priceMovedToNextLine;
|
|
276
274
|
if (!(i.dataset.inlinePrices !== String(s)) && this._tryReorderInPlace(i, t))
|
|
277
275
|
return !1;
|
|
278
276
|
i.dataset.inlinePrices = String(s);
|
|
279
277
|
const n = new Set(e), l = vt(t);
|
|
280
278
|
let a = 0, d = 0;
|
|
281
279
|
const c = t.map((u) => {
|
|
282
|
-
if (s && (u ===
|
|
280
|
+
if (s && (u === C || u === L))
|
|
283
281
|
return u === l.anchor ? this._createPriceGroupItemHtml(d++, l.originalFirst) : "";
|
|
284
282
|
if (xt.has(u)) {
|
|
285
|
-
const
|
|
286
|
-
return this._createBuiltInItemHtml(
|
|
283
|
+
const b = m.find((S) => S.key === u);
|
|
284
|
+
return this._createBuiltInItemHtml(b, d++);
|
|
287
285
|
}
|
|
288
|
-
if (u.startsWith(
|
|
289
|
-
const
|
|
290
|
-
if (n.has(
|
|
286
|
+
if (u.startsWith(v)) {
|
|
287
|
+
const b = k(u);
|
|
288
|
+
if (n.has(b))
|
|
291
289
|
return this._createCustomItemHtml(u, a++, d++);
|
|
292
290
|
}
|
|
293
291
|
return "";
|
|
@@ -308,7 +306,7 @@ class se extends ut {
|
|
|
308
306
|
if (i.length !== e.length)
|
|
309
307
|
return !1;
|
|
310
308
|
const s = [...i].sort().join(","), o = [...e].sort().join(",");
|
|
311
|
-
if (s !== o || e.some((a) => a.startsWith(
|
|
309
|
+
if (s !== o || e.some((a) => a.startsWith(v)))
|
|
312
310
|
return !1;
|
|
313
311
|
const n = /* @__PURE__ */ new Map();
|
|
314
312
|
r.forEach((a) => {
|
|
@@ -346,18 +344,18 @@ class se extends ut {
|
|
|
346
344
|
*/
|
|
347
345
|
_createPriceGroupItemHtml(t, e) {
|
|
348
346
|
var n, l;
|
|
349
|
-
const r = ((n = m.find((a) => a.key ===
|
|
347
|
+
const r = ((n = m.find((a) => a.key === C)) == null ? void 0 : n.label) ?? "Product Price", i = ((l = m.find((a) => a.key === L)) == null ? void 0 : l.label) ?? "Product Original Price", s = (a, d) => `
|
|
350
348
|
<div class="price-suborderable-item" draggable="true" data-subkey="${a}">
|
|
351
349
|
<span class="sub-drag-handle">${qt}</span>
|
|
352
350
|
<span class="item-label">${this.api.translate(d)}</span>
|
|
353
|
-
</div>`, o = e ? s(
|
|
351
|
+
</div>`, o = e ? s(L, i) + s(C, r) : s(C, r) + s(L, i);
|
|
354
352
|
return `
|
|
355
353
|
<div class="orderable-item price-group-item" draggable="true"
|
|
356
|
-
data-key="${
|
|
354
|
+
data-key="${C}" data-group="prices">
|
|
357
355
|
<div class="price-group-header">
|
|
358
356
|
<span class="guido-drag-handle" data-reorder-icon-slot="${t}"></span>
|
|
359
357
|
<span class="item-label">${this.api.translate("Product Prices")}</span>
|
|
360
|
-
<div class="item-action" data-action-for="${
|
|
358
|
+
<div class="item-action" data-action-for="${C}"></div>
|
|
361
359
|
</div>
|
|
362
360
|
<div class="price-suborderable-list">${o}</div>
|
|
363
361
|
</div>
|
|
@@ -397,13 +395,13 @@ class se extends ut {
|
|
|
397
395
|
const i = /* @__PURE__ */ new Map();
|
|
398
396
|
r.forEach((o) => i.set(o.attributeName, (i.get(o.attributeName) ?? 0) + 1));
|
|
399
397
|
const s = new Set(e);
|
|
400
|
-
return s.delete(t), r.filter((o) => !s.has(
|
|
398
|
+
return s.delete(t), r.filter((o) => !s.has(T(o))).map((o) => ({
|
|
401
399
|
text: this._toOptionLabel(
|
|
402
400
|
o.displayName,
|
|
403
401
|
o.type === "defaultAttribute",
|
|
404
402
|
(i.get(o.attributeName) ?? 0) > 1
|
|
405
403
|
),
|
|
406
|
-
value:
|
|
404
|
+
value: T(o)
|
|
407
405
|
}));
|
|
408
406
|
}
|
|
409
407
|
/**
|
|
@@ -465,7 +463,7 @@ class se extends ut {
|
|
|
465
463
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
466
464
|
*/
|
|
467
465
|
_rescueSelectsToStore(t) {
|
|
468
|
-
for (let e = 0; e <
|
|
466
|
+
for (let e = 0; e < f; e++) {
|
|
469
467
|
const r = `${A}${e}`, i = t.querySelector(`[data-custom-select-key="${r}"]`), s = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
470
468
|
if (s) {
|
|
471
469
|
const o = s.querySelector("ue-select");
|
|
@@ -491,7 +489,7 @@ class se extends ut {
|
|
|
491
489
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
492
490
|
*/
|
|
493
491
|
_rescueDeleteButtonsToStore(t) {
|
|
494
|
-
for (let e = 0; e <
|
|
492
|
+
for (let e = 0; e < f; e++) {
|
|
495
493
|
const r = `${w}${e}`, i = t.querySelector(`[data-custom-delete-key="${r}"]`), s = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
496
494
|
if (s) {
|
|
497
495
|
const o = s.querySelector("ue-button");
|
|
@@ -517,7 +515,7 @@ class se extends ut {
|
|
|
517
515
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
518
516
|
*/
|
|
519
517
|
_rescueReorderIconsToStore(t) {
|
|
520
|
-
const e = m.length +
|
|
518
|
+
const e = m.length + f;
|
|
521
519
|
for (let r = 0; r < e; r++) {
|
|
522
520
|
const i = `${P}${r}`, s = t.querySelector(`[data-reorder-icon-key="${i}"]`), o = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
523
521
|
if (o) {
|
|
@@ -536,8 +534,8 @@ class se extends ut {
|
|
|
536
534
|
return;
|
|
537
535
|
const r = e.querySelector("[data-composition-list]"), i = e.querySelector("#guido__btn-add-attribute");
|
|
538
536
|
r && (this._setupDragAndDrop(r, t), this._setupDeleteHandler(r, t)), i && i.addEventListener("click", () => {
|
|
539
|
-
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(
|
|
540
|
-
o && this._onAddAttribute(
|
|
537
|
+
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(T(n)));
|
|
538
|
+
o && this._onAddAttribute(T(o), o.displayName);
|
|
541
539
|
}, { signal: t });
|
|
542
540
|
}
|
|
543
541
|
/**
|
|
@@ -618,7 +616,7 @@ class se extends ut {
|
|
|
618
616
|
// Actions (Add, Delete, Reorder)
|
|
619
617
|
// ========================================================================
|
|
620
618
|
_onAddAttribute(t, e) {
|
|
621
|
-
const r =
|
|
619
|
+
const r = M(t), i = this._readCompositionFromNode();
|
|
622
620
|
i.push(r);
|
|
623
621
|
const s = [...this._readCustomAttributesFromNode(), t];
|
|
624
622
|
this._updateBothAttributes(i, s), this._injectCustomAttributeHtml(t, e, r, i), this._renderOrderableItems(i, s), this._initializeCustomSelects(s), this._updateAddButtonState();
|
|
@@ -642,17 +640,17 @@ class se extends ut {
|
|
|
642
640
|
const r = this._readCustomAttributesFromNode(), i = r[t];
|
|
643
641
|
if (i === void 0 || i === e)
|
|
644
642
|
return;
|
|
645
|
-
const s =
|
|
643
|
+
const s = M(e), o = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(o, t);
|
|
646
644
|
n !== -1 && (o[n] = s), r[t] = e;
|
|
647
645
|
const l = this._getDisplayNameForAttribute(e);
|
|
648
646
|
this._updateBothAttributes(o, r), this._injectCustomAttributeHtml(e, l, s, o), this._renderOrderableItems(o, r), this._initializeCustomSelects(r);
|
|
649
647
|
}
|
|
650
648
|
_onReorder(t) {
|
|
651
|
-
const e = t.filter((r) => r.startsWith(
|
|
649
|
+
const e = t.filter((r) => r.startsWith(v)).map(k);
|
|
652
650
|
this.reorderInProgress = !0;
|
|
653
651
|
try {
|
|
654
652
|
this._updateBothAttributes(t, e);
|
|
655
|
-
const r = !
|
|
653
|
+
const r = !g.getConfig(this.currentNode).priceMovedToNextLine;
|
|
656
654
|
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && Bt({
|
|
657
655
|
currentNode: this.currentNode,
|
|
658
656
|
documentModifier: this.api.getDocumentModifier()
|
|
@@ -675,7 +673,7 @@ class se extends ut {
|
|
|
675
673
|
if (r && "getOuterHTML" in r)
|
|
676
674
|
return Q(r.getOuterHTML(), e);
|
|
677
675
|
const i = t.querySelector(
|
|
678
|
-
`${
|
|
676
|
+
`${N}[${E}="${e}"]`
|
|
679
677
|
);
|
|
680
678
|
return i && "getOuterHTML" in i ? Q(i.getOuterHTML(), e) : "";
|
|
681
679
|
}
|
|
@@ -688,11 +686,11 @@ class se extends ut {
|
|
|
688
686
|
const s = this.currentNode.querySelectorAll(U);
|
|
689
687
|
if (!(s != null && s.length))
|
|
690
688
|
return;
|
|
691
|
-
const o =
|
|
689
|
+
const o = g.getConfig(this.currentNode), l = `0 ${Math.floor(o.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), d = this.store.recommendationProducts.length;
|
|
692
690
|
let c = 0;
|
|
693
691
|
s.forEach((u) => {
|
|
694
692
|
var V;
|
|
695
|
-
const
|
|
693
|
+
const b = u.querySelector(N), S = ((V = b == null ? void 0 : b.querySelectorAll(`.${bt}`)) == null ? void 0 : V.length) || 1, F = (100 / S).toFixed(2), { bgStyle: et, bgAttr: rt } = this._extractSegmentBgFromCard(u), B = d > 0 ? Math.min(S, d - c) : S, it = i.map((j) => {
|
|
696
694
|
if (j === r) {
|
|
697
695
|
const st = Array.from(
|
|
698
696
|
{ length: B },
|
|
@@ -712,12 +710,12 @@ class se extends ut {
|
|
|
712
710
|
);
|
|
713
711
|
}
|
|
714
712
|
).join(""), ot = Ct(F, l).repeat(S - B);
|
|
715
|
-
return `<tr class="${G}" ${
|
|
713
|
+
return `<tr class="${G}" ${E}="${r}" ${D}="1">${st}${ot}</tr>`;
|
|
716
714
|
}
|
|
717
715
|
return this._getExistingRowHtml(u, j);
|
|
718
716
|
}).join("");
|
|
719
717
|
c += B, d > 0 && c >= d && (c = 0), a.modifyHtml(u).setInnerHtml(it);
|
|
720
|
-
}), a.apply(new
|
|
718
|
+
}), a.apply(new y(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
721
719
|
}
|
|
722
720
|
_injectListAttributeRow(t, e, r, i) {
|
|
723
721
|
const s = this.currentNode.querySelectorAll(Z);
|
|
@@ -733,7 +731,7 @@ class se extends ut {
|
|
|
733
731
|
return this._getExistingRowHtml(l, c);
|
|
734
732
|
}).join("");
|
|
735
733
|
n.modifyHtml(l).setInnerHtml(d);
|
|
736
|
-
}), n.apply(new
|
|
734
|
+
}), n.apply(new y(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
737
735
|
}
|
|
738
736
|
/**
|
|
739
737
|
* Removes a custom attribute by rebuilding product card content without it.
|
|
@@ -756,7 +754,7 @@ class se extends ut {
|
|
|
756
754
|
r.modifyHtml(o).setInnerHtml(n);
|
|
757
755
|
});
|
|
758
756
|
}
|
|
759
|
-
r.apply(new
|
|
757
|
+
r.apply(new y(this.api.translate("Remove custom attribute")));
|
|
760
758
|
}
|
|
761
759
|
// ========================================================================
|
|
762
760
|
// DOM Mutation (Block Root Attributes, Reorder)
|
|
@@ -772,10 +770,10 @@ class se extends ut {
|
|
|
772
770
|
if (!this.currentNode)
|
|
773
771
|
return;
|
|
774
772
|
const r = {
|
|
775
|
-
...
|
|
773
|
+
...g.getConfig(this.currentNode),
|
|
776
774
|
composition: t
|
|
777
775
|
};
|
|
778
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(K, t.join(",")).setAttribute(W, JSON.stringify(e)).setNodeConfig(r).apply(new
|
|
776
|
+
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")));
|
|
779
777
|
}
|
|
780
778
|
/**
|
|
781
779
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -791,7 +789,7 @@ class se extends ut {
|
|
|
791
789
|
e.forEach((i) => {
|
|
792
790
|
const s = this._buildCompositionHtml(i, t);
|
|
793
791
|
r.modifyHtml(i).setInnerHtml(s);
|
|
794
|
-
}), r.apply(new
|
|
792
|
+
}), r.apply(new y(this.api.translate("Reorder product attributes")));
|
|
795
793
|
}
|
|
796
794
|
/**
|
|
797
795
|
* Builds HTML string with attributes ordered according to composition.
|
|
@@ -806,44 +804,37 @@ class se extends ut {
|
|
|
806
804
|
_applyVisibilityToBlock(t, e) {
|
|
807
805
|
if (!this.currentNode)
|
|
808
806
|
return;
|
|
809
|
-
if (t ===
|
|
807
|
+
if (t === I) {
|
|
810
808
|
this._applyTitleVisibilityToBlock(e);
|
|
811
809
|
return;
|
|
812
810
|
}
|
|
813
|
-
const r = this.
|
|
814
|
-
if (!
|
|
811
|
+
const r = this.currentNode.querySelectorAll(`${N}[${E}="${t}"]`);
|
|
812
|
+
if (!(r != null && r.length))
|
|
815
813
|
return;
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
|
|
814
|
+
const i = e ? "1" : "0", s = e ? this.api.translate("visible") : this.api.translate("hidden"), o = `${this.api.translate("Set visibility")}: ${t} → ${s}`, n = this.api.getDocumentModifier();
|
|
815
|
+
r.forEach((a) => {
|
|
816
|
+
const d = Pt(a), c = e ? d : "none";
|
|
817
|
+
n.modifyHtml(a).setStyle("display", c).setAttribute(D, i);
|
|
820
818
|
});
|
|
821
|
-
const
|
|
822
|
-
...
|
|
823
|
-
visibility: {
|
|
824
|
-
...this._readVisibilityFromRows(),
|
|
825
|
-
...Object.fromEntries(r.map((c) => [c, e]))
|
|
826
|
-
}
|
|
819
|
+
const l = {
|
|
820
|
+
...g.getConfig(this.currentNode),
|
|
821
|
+
visibility: { ...this._readVisibilityFromRows(), [t]: e }
|
|
827
822
|
};
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
/** Inline "Product Prices" group row is tagged with whichever price comes first, so it drives both keys. */
|
|
831
|
-
_resolveVisibilityKeys(t) {
|
|
832
|
-
return !p.getConfig(this.currentNode).priceMovedToNextLine && t === _ ? [_, I] : [t];
|
|
823
|
+
n.modifyHtml(this.currentNode).setNodeConfig(l), n.apply(new y(o));
|
|
833
824
|
}
|
|
834
825
|
_applyTitleVisibilityToBlock(t) {
|
|
835
|
-
const e =
|
|
826
|
+
const e = g.getConfig(this.currentNode), r = t ? this._resolveTitleInjection(e) : null, i = t ? [] : this._findTitleRows(), s = t ? this._hasTitle() || !r : i.length === 0;
|
|
836
827
|
if (!this.currentNode || s)
|
|
837
828
|
return;
|
|
838
829
|
const o = this.api.getDocumentModifier();
|
|
839
830
|
r ? o.modifyHtml(r.containerBody).setInnerHtml(r.html) : i.forEach((l) => o.modifyHtml(l).delete()), o.modifyHtml(this.currentNode).setNodeConfig({
|
|
840
831
|
...e,
|
|
841
832
|
previousTitleHtml: t ? e.previousTitleHtml : this._readTitleHtml(i),
|
|
842
|
-
visibility: { ...this._readVisibilityFromRows(), [
|
|
833
|
+
visibility: { ...this._readVisibilityFromRows(), [I]: t }
|
|
843
834
|
});
|
|
844
835
|
const n = t ? this.api.translate("visible") : this.api.translate("hidden");
|
|
845
|
-
o.apply(new
|
|
846
|
-
`${this.api.translate("Set visibility")}: ${
|
|
836
|
+
o.apply(new y(
|
|
837
|
+
`${this.api.translate("Set visibility")}: ${I} → ${n}`
|
|
847
838
|
));
|
|
848
839
|
}
|
|
849
840
|
_resolveTitleInjection(t) {
|
|
@@ -859,7 +850,7 @@ class se extends ut {
|
|
|
859
850
|
_findTitleRows() {
|
|
860
851
|
var e;
|
|
861
852
|
const t = Array.from(((e = this.currentNode) == null ? void 0 : e.querySelectorAll(
|
|
862
|
-
`${
|
|
853
|
+
`${N}[${E}="${I}"]`
|
|
863
854
|
)) ?? []);
|
|
864
855
|
return t.length > 0 ? t : this._findTitleRowsByClass();
|
|
865
856
|
}
|
|
@@ -874,7 +865,7 @@ class se extends ut {
|
|
|
874
865
|
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(_t));
|
|
875
866
|
}
|
|
876
867
|
_findTitleContainerBody() {
|
|
877
|
-
return (this.currentNode ?
|
|
868
|
+
return (this.currentNode ? kt(this.currentNode) : null) ?? void 0;
|
|
878
869
|
}
|
|
879
870
|
_readInnerHtml(t) {
|
|
880
871
|
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : null;
|
|
@@ -893,7 +884,7 @@ class se extends ut {
|
|
|
893
884
|
_findNthCustomKeyIndex(t, e) {
|
|
894
885
|
let r = 0;
|
|
895
886
|
for (let i = 0; i < t.length; i++)
|
|
896
|
-
if (t[i].startsWith(
|
|
887
|
+
if (t[i].startsWith(v)) {
|
|
897
888
|
if (r === e)
|
|
898
889
|
return i;
|
|
899
890
|
r++;
|
|
@@ -901,7 +892,7 @@ class se extends ut {
|
|
|
901
892
|
return -1;
|
|
902
893
|
}
|
|
903
894
|
_getCurrentLayout() {
|
|
904
|
-
return this.store.recommendationConfigs.orientation ||
|
|
895
|
+
return this.store.recommendationConfigs.orientation || Mt(this.currentNode);
|
|
905
896
|
}
|
|
906
897
|
/**
|
|
907
898
|
* Extracts background color properties from existing card elements.
|
|
@@ -953,7 +944,7 @@ class se extends ut {
|
|
|
953
944
|
* or when all available filters have already been added (no unused attributes left).
|
|
954
945
|
*/
|
|
955
946
|
_updateAddButtonState() {
|
|
956
|
-
const t = this._readCustomAttributesFromNode(), e = t.length >=
|
|
947
|
+
const t = this._readCustomAttributesFromNode(), e = t.length >= f, r = new Set(t), i = this._getAddableFilters(), s = i.length > 0 && i.every((o) => r.has(T(o)));
|
|
957
948
|
this.api.setUIEAttribute(
|
|
958
949
|
tt.ADD_ATTRIBUTE,
|
|
959
950
|
O.BUTTON.disabled,
|
|
@@ -986,7 +977,7 @@ class se extends ut {
|
|
|
986
977
|
_getAddableFilters() {
|
|
987
978
|
const t = /* @__PURE__ */ new Set();
|
|
988
979
|
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" && gt.has(e.attributeName))).filter((e) => {
|
|
989
|
-
const r =
|
|
980
|
+
const r = T(e);
|
|
990
981
|
return t.has(r) ? !1 : (t.add(r), !0);
|
|
991
982
|
});
|
|
992
983
|
}
|
|
@@ -996,7 +987,7 @@ class se extends ut {
|
|
|
996
987
|
* resolve to their own entry. Falls back to Title Case of the bare name.
|
|
997
988
|
*/
|
|
998
989
|
_getDisplayNameForAttribute(t) {
|
|
999
|
-
const e = Object.values(this.store.filterList).find((r) =>
|
|
990
|
+
const e = Object.values(this.store.filterList).find((r) => T(r) === t);
|
|
1000
991
|
return e ? e.displayName : Nt(H(t));
|
|
1001
992
|
}
|
|
1002
993
|
/**
|
|
@@ -1009,7 +1000,7 @@ class se extends ut {
|
|
|
1009
1000
|
return Et(n) ?? e;
|
|
1010
1001
|
}
|
|
1011
1002
|
_getGridCellHtml(t, e, r, i = "", s = "", o = "") {
|
|
1012
|
-
const n =
|
|
1003
|
+
const n = M(t), l = H(t), a = J(yt, [n], this.store.filterList), d = {
|
|
1013
1004
|
[l]: e,
|
|
1014
1005
|
product_attributes: { [l]: e }
|
|
1015
1006
|
};
|
|
@@ -1024,7 +1015,7 @@ class se extends ut {
|
|
|
1024
1015
|
[i]: e,
|
|
1025
1016
|
product_attributes: { [i]: e }
|
|
1026
1017
|
}, l = s[r](o).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
1027
|
-
return `<tr class="${G}" ${
|
|
1018
|
+
return `<tr class="${G}" ${E}="${r}" ${D}="1">${l}</tr>`;
|
|
1028
1019
|
}
|
|
1029
1020
|
}
|
|
1030
1021
|
export {
|