@useinsider/guido 3.30.0-beta.1360af2 → 3.30.0-beta.16d665a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +16 -11
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -51
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/composables/useExport.js +7 -8
- package/dist/composables/useHtmlValidator.js +100 -102
- package/dist/composables/useToaster.js +10 -11
- package/dist/composables/useVersionHistoryApi.js +21 -22
- package/dist/composables/validators/useLiquidValidator.js +24 -26
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +141 -148
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +53 -53
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +39 -40
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +26 -27
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +32 -33
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +22 -23
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +78 -79
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +41 -50
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +0 -2
- package/dist/src/stores/preview.d.ts +0 -3
- package/dist/stores/preview.js +15 -21
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
- package/dist/src/utils/ampPreviewSanitizer.d.ts +0 -5
- package/dist/utils/ampPreviewSanitizer.js +0 -46
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var v = (_,
|
|
4
|
-
import { ACADEMY_LINKS as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
const xt = "ui-elements-recommendation-card-composition", F = ".product-card-wrapper > tbody", et = ".product-info-cell > table > tbody", rt = {
|
|
1
|
+
var at = Object.defineProperty;
|
|
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
|
+
import { ACADEMY_LINKS as dt } from "../../../../../enums/academy.js";
|
|
5
|
+
import { UIElementType as f, UEAttr as O, ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
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 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 G, ATTR_DATA_VISIBILITY as D, ATTR_DATA_ATTRIBUTE_TYPE as R, CSS_CLASS_ATTRIBUTE_ROW as z, CSS_CLASS_SPACER as _t, BUILT_IN_DEFAULT_ATTRIBUTES as gt } from "../../constants/selectors.js";
|
|
8
|
+
import { DEFAULT_COMPOSITION as Y, DEFAULT_VISIBILITY as X } from "../../constants/defaultConfig.js";
|
|
9
|
+
import { RecommendationConfigService as T } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as ft } from "../../store/recommendation.js";
|
|
11
|
+
import { ATTRIBUTE_CELL_CLASS as bt, gridElementRenderer as yt, DEFAULT_CELL_PADDING as Tt, buildFillerCell as Ct } from "../../templates/grid/elementRenderer.js";
|
|
12
|
+
import { listElementRenderer as St } from "../../templates/list/elementRenderer.js";
|
|
13
|
+
import { buildTitleRows as At, DEFAULT_TITLE_PARAGRAPH as It, DEFAULT_TITLE_TEXT as $t } from "../../templates/titleRows.js";
|
|
14
|
+
import { toDisplayName as vt, toDisplayableAttributeValue as Nt, buildElementRenderer as J } from "../../templates/utils.js";
|
|
15
|
+
import { normalizeCompositionKeys as Et, normalizeCustomAttrValues as Rt, compositionKeyToProductAttr as k, resolveRowVisibilityKeys as Lt, filterToProductAttrValue as C, findAttributeRow as Ot, rewriteLegacyRowKeyHtml as Q, bareAttributeName as H, isDefaultProductAttr as Dt, productAttrToCompositionKey as M } from "../../utils/compositionKeys.js";
|
|
16
|
+
import { getTableDisplayValue as Ht } from "../../utils/tagName.js";
|
|
17
|
+
import { isPartnerManagedBlock as Pt, regenerateProductRowsWithStyles as wt, getMainContainerTbody as Bt, getCurrentLayout as kt } from "../main/utils.js";
|
|
18
|
+
import { resolveInlinePriceOrder as Mt } from "../../utils/inlinePriceOrder.js";
|
|
19
|
+
const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wrapper > tbody", Z = ".product-info-cell > table > tbody", tt = {
|
|
21
20
|
ADD_ATTRIBUTE: "addAttribute"
|
|
22
|
-
},
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
21
|
+
}, 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 = [
|
|
22
|
+
{ key: q, label: "Product Image" },
|
|
23
|
+
{ key: mt, label: "Product Name" },
|
|
25
24
|
{ key: p, label: "Product Price" },
|
|
26
25
|
{ key: I, label: "Product Original Price" },
|
|
27
|
-
{ key:
|
|
28
|
-
{ key:
|
|
29
|
-
{ key:
|
|
30
|
-
], L = { key: $, label: "Title" },
|
|
31
|
-
class
|
|
26
|
+
{ key: ht, label: "Omnibus Price" },
|
|
27
|
+
{ key: pt, label: "Omnibus Discount" },
|
|
28
|
+
{ key: F, label: "Product Button" }
|
|
29
|
+
], L = { key: $, label: "Title" }, Ft = new Set(m.map((_) => _.key)), A = "customAttr_", w = "deleteAttr_";
|
|
30
|
+
class oe extends ut {
|
|
32
31
|
constructor() {
|
|
33
32
|
super(...arguments);
|
|
34
|
-
v(this, "store",
|
|
33
|
+
v(this, "store", ft());
|
|
35
34
|
v(this, "unsubscribeStore", null);
|
|
36
35
|
v(this, "eventController", null);
|
|
37
36
|
/**
|
|
@@ -41,7 +40,7 @@ class ce extends ht {
|
|
|
41
40
|
v(this, "reorderInProgress", !1);
|
|
42
41
|
}
|
|
43
42
|
getId() {
|
|
44
|
-
return
|
|
43
|
+
return Ut;
|
|
45
44
|
}
|
|
46
45
|
// ========================================================================
|
|
47
46
|
// Lifecycle
|
|
@@ -52,7 +51,7 @@ class ce extends ht {
|
|
|
52
51
|
${this._GuToggle(`visibility_${d.key}`)}
|
|
53
52
|
</div>
|
|
54
53
|
`).join(""), e = Array.from(
|
|
55
|
-
{ length:
|
|
54
|
+
{ length: b },
|
|
56
55
|
(d, c) => `
|
|
57
56
|
<div data-custom-select-key="${A}${c}" style="display: none;">
|
|
58
57
|
${this._GuSelect({
|
|
@@ -64,37 +63,37 @@ class ce extends ht {
|
|
|
64
63
|
})}
|
|
65
64
|
</div>
|
|
66
65
|
`
|
|
67
|
-
).join(""), r = m.length +
|
|
66
|
+
).join(""), r = m.length + b, i = Array.from(
|
|
68
67
|
{ length: r },
|
|
69
68
|
(d, c) => `
|
|
70
|
-
<div data-reorder-icon-key="${
|
|
71
|
-
<${
|
|
69
|
+
<div data-reorder-icon-key="${P}${c}" style="display: none;">
|
|
70
|
+
<${f.BUTTON}
|
|
72
71
|
class="guido-drag-handle-btn flat-inline flat-white"
|
|
73
|
-
${O.BUTTON.name}="${
|
|
72
|
+
${O.BUTTON.name}="${P}${c}"
|
|
74
73
|
>
|
|
75
|
-
<${
|
|
74
|
+
<${f.ICON}
|
|
76
75
|
src="reorder"
|
|
77
76
|
class="icon-button"
|
|
78
|
-
></${
|
|
79
|
-
</${
|
|
77
|
+
></${f.ICON}>
|
|
78
|
+
</${f.BUTTON}>
|
|
80
79
|
</div>
|
|
81
80
|
`
|
|
82
81
|
).join(""), s = Array.from(
|
|
83
|
-
{ length:
|
|
82
|
+
{ length: b },
|
|
84
83
|
(d, c) => `
|
|
85
|
-
<div data-custom-delete-key="${
|
|
86
|
-
<${
|
|
84
|
+
<div data-custom-delete-key="${w}${c}" style="display: none;">
|
|
85
|
+
<${f.BUTTON}
|
|
87
86
|
class="custom-attr-delete flat-inline flat-white"
|
|
88
|
-
${O.BUTTON.name}="${
|
|
87
|
+
${O.BUTTON.name}="${w}${c}"
|
|
89
88
|
>
|
|
90
|
-
<${
|
|
89
|
+
<${f.ICON}
|
|
91
90
|
src="delete"
|
|
92
91
|
class="icon-button"
|
|
93
|
-
></${
|
|
94
|
-
</${
|
|
92
|
+
></${f.ICON}>
|
|
93
|
+
</${f.BUTTON}>
|
|
95
94
|
</div>
|
|
96
95
|
`
|
|
97
|
-
).join(""), o =
|
|
96
|
+
).join(""), o = dt.EMAIL_RECOMMENDATION_BLOCK, n = this.api.translate(
|
|
98
97
|
"Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
|
|
99
98
|
), l = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
100
99
|
return `
|
|
@@ -136,7 +135,7 @@ class ce extends ht {
|
|
|
136
135
|
<div class="orderable-list" data-composition-list></div>
|
|
137
136
|
|
|
138
137
|
${this._GuButton({
|
|
139
|
-
name:
|
|
138
|
+
name: tt.ADD_ATTRIBUTE,
|
|
140
139
|
label: this.api.translate("Add Attribute"),
|
|
141
140
|
id: "guido__btn-add-attribute"
|
|
142
141
|
})}
|
|
@@ -157,7 +156,7 @@ class ce extends ht {
|
|
|
157
156
|
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector("[data-card-composition-control]");
|
|
158
157
|
if (!t)
|
|
159
158
|
return;
|
|
160
|
-
const e =
|
|
159
|
+
const e = Pt(this.currentNode);
|
|
161
160
|
t.style.pointerEvents = e ? "none" : "", t.style.opacity = e ? "0.5" : "";
|
|
162
161
|
}
|
|
163
162
|
onTemplateNodeUpdated(t) {
|
|
@@ -179,7 +178,7 @@ class ce extends ht {
|
|
|
179
178
|
this._applyVisibilityToBlock(t.key, e);
|
|
180
179
|
});
|
|
181
180
|
});
|
|
182
|
-
for (let t = 0; t <
|
|
181
|
+
for (let t = 0; t < b; t++) {
|
|
183
182
|
const e = `${A}${t}`, r = t;
|
|
184
183
|
this.api.onValueChanged(e, (i) => {
|
|
185
184
|
this._onCustomAttributeChanged(r, i);
|
|
@@ -191,36 +190,32 @@ class ce extends ht {
|
|
|
191
190
|
// ========================================================================
|
|
192
191
|
_readCompositionFromNode() {
|
|
193
192
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
194
|
-
return [...
|
|
195
|
-
const t = this.currentNode.getAttribute(
|
|
193
|
+
return [...Y];
|
|
194
|
+
const t = this.currentNode.getAttribute(K);
|
|
196
195
|
if (t)
|
|
197
196
|
return this._normalizeComposition(t.split(",").filter(Boolean));
|
|
198
|
-
const { composition: e } =
|
|
199
|
-
return e != null && e.length ? this._normalizeComposition([...e]) : [...
|
|
197
|
+
const { composition: e } = T.getConfig(this.currentNode);
|
|
198
|
+
return e != null && e.length ? this._normalizeComposition([...e]) : [...Y];
|
|
200
199
|
}
|
|
201
200
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
202
201
|
_normalizeComposition(t) {
|
|
203
|
-
return
|
|
204
|
-
Ot(t),
|
|
205
|
-
this.currentNode,
|
|
206
|
-
this.store.filterList
|
|
207
|
-
);
|
|
202
|
+
return Et(t, this.currentNode, this.store.filterList);
|
|
208
203
|
}
|
|
209
204
|
_readCustomAttributesFromNode() {
|
|
210
205
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
211
206
|
return [];
|
|
212
|
-
const t = this.currentNode.getAttribute(
|
|
207
|
+
const t = this.currentNode.getAttribute(W);
|
|
213
208
|
if (t)
|
|
214
209
|
try {
|
|
215
|
-
return
|
|
216
|
-
JSON.parse(t).map((e) => String(e))
|
|
210
|
+
return Rt(
|
|
211
|
+
JSON.parse(t).map((e) => String(e)),
|
|
217
212
|
this.currentNode,
|
|
218
213
|
this.store.filterList
|
|
219
214
|
);
|
|
220
215
|
} catch {
|
|
221
216
|
return [];
|
|
222
217
|
}
|
|
223
|
-
return this._readCompositionFromNode().filter((e) => e.startsWith(N)).map(
|
|
218
|
+
return this._readCompositionFromNode().filter((e) => e.startsWith(N)).map(k);
|
|
224
219
|
}
|
|
225
220
|
_readVisibilityFromRows() {
|
|
226
221
|
if (!this.currentNode)
|
|
@@ -228,7 +223,7 @@ class ce extends ht {
|
|
|
228
223
|
const t = Array.from(this.currentNode.querySelectorAll(E)), e = this._extractVisibilityFromRows(t);
|
|
229
224
|
if (Object.keys(e).length > 0)
|
|
230
225
|
return this._withTitlePresence(this._mergeWithDefaults(e));
|
|
231
|
-
const r =
|
|
226
|
+
const r = T.getConfig(this.currentNode).visibility;
|
|
232
227
|
return this._withTitlePresence(this._mergeWithDefaults({ ...r }));
|
|
233
228
|
}
|
|
234
229
|
_withTitlePresence(t) {
|
|
@@ -236,10 +231,10 @@ class ce extends ht {
|
|
|
236
231
|
}
|
|
237
232
|
_hasTitle() {
|
|
238
233
|
var t;
|
|
239
|
-
return !!((t = this.currentNode) != null && t.querySelector(
|
|
234
|
+
return !!((t = this.currentNode) != null && t.querySelector(G));
|
|
240
235
|
}
|
|
241
236
|
_getDefaultVisibilities() {
|
|
242
|
-
return { ...
|
|
237
|
+
return { ...X };
|
|
243
238
|
}
|
|
244
239
|
_extractVisibilityFromRows(t) {
|
|
245
240
|
const e = {};
|
|
@@ -247,7 +242,7 @@ class ce extends ht {
|
|
|
247
242
|
if (!("getAttribute" in r))
|
|
248
243
|
return;
|
|
249
244
|
const i = r.getAttribute(D);
|
|
250
|
-
i !== null &&
|
|
245
|
+
i !== null && Lt(r).forEach((s) => {
|
|
251
246
|
e[s] = this._parseVisibilityValue(i);
|
|
252
247
|
});
|
|
253
248
|
}), e;
|
|
@@ -256,7 +251,7 @@ class ce extends ht {
|
|
|
256
251
|
return t === "1" || t === "true";
|
|
257
252
|
}
|
|
258
253
|
_mergeWithDefaults(t) {
|
|
259
|
-
return Object.entries(
|
|
254
|
+
return Object.entries(X).forEach(([e, r]) => {
|
|
260
255
|
e in t || (t[e] = r);
|
|
261
256
|
}), t;
|
|
262
257
|
}
|
|
@@ -282,17 +277,17 @@ class ce extends ht {
|
|
|
282
277
|
if (!(i.dataset.inlinePrices !== String(s)) && this._tryReorderInPlace(i, t))
|
|
283
278
|
return !1;
|
|
284
279
|
i.dataset.inlinePrices = String(s);
|
|
285
|
-
const n = new Set(e), l =
|
|
280
|
+
const n = new Set(e), l = Mt(t);
|
|
286
281
|
let a = 0, d = 0;
|
|
287
282
|
const c = t.map((u) => {
|
|
288
283
|
if (s && (u === p || u === I))
|
|
289
284
|
return u === l.anchor ? this._createPriceGroupItemHtml(d++, l.originalFirst) : "";
|
|
290
|
-
if (
|
|
285
|
+
if (Ft.has(u)) {
|
|
291
286
|
const h = m.find((S) => S.key === u);
|
|
292
287
|
return this._createBuiltInItemHtml(h, d++);
|
|
293
288
|
}
|
|
294
289
|
if (u.startsWith(N)) {
|
|
295
|
-
const h =
|
|
290
|
+
const h = k(u);
|
|
296
291
|
if (n.has(h))
|
|
297
292
|
return this._createCustomItemHtml(u, a++, d++);
|
|
298
293
|
}
|
|
@@ -354,7 +349,7 @@ class ce extends ht {
|
|
|
354
349
|
var n, l;
|
|
355
350
|
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) => `
|
|
356
351
|
<div class="price-suborderable-item" draggable="true" data-subkey="${a}">
|
|
357
|
-
<span class="sub-drag-handle">${
|
|
352
|
+
<span class="sub-drag-handle">${qt}</span>
|
|
358
353
|
<span class="item-label">${this.api.translate(d)}</span>
|
|
359
354
|
</div>`, o = e ? s(I, i) + s(p, r) : s(p, r) + s(I, i);
|
|
360
355
|
return `
|
|
@@ -372,7 +367,7 @@ class ce extends ht {
|
|
|
372
367
|
_createCustomItemHtml(t, e, r) {
|
|
373
368
|
return `
|
|
374
369
|
<div class="orderable-item" draggable="true"
|
|
375
|
-
data-key="${
|
|
370
|
+
data-key="${t}" data-custom-index="${e}">
|
|
376
371
|
<span class="guido-drag-handle" data-reorder-icon-slot="${r}"></span>
|
|
377
372
|
<div class="custom-attr-select-wrap"
|
|
378
373
|
data-custom-select-slot="${e}"></div>
|
|
@@ -403,13 +398,13 @@ class ce extends ht {
|
|
|
403
398
|
const i = /* @__PURE__ */ new Map();
|
|
404
399
|
r.forEach((o) => i.set(o.attributeName, (i.get(o.attributeName) ?? 0) + 1));
|
|
405
400
|
const s = new Set(e);
|
|
406
|
-
return s.delete(t), r.filter((o) => !s.has(
|
|
401
|
+
return s.delete(t), r.filter((o) => !s.has(C(o))).map((o) => ({
|
|
407
402
|
text: this._toOptionLabel(
|
|
408
403
|
o.displayName,
|
|
409
404
|
o.type === "defaultAttribute",
|
|
410
405
|
(i.get(o.attributeName) ?? 0) > 1
|
|
411
406
|
),
|
|
412
|
-
value:
|
|
407
|
+
value: C(o)
|
|
413
408
|
}));
|
|
414
409
|
}
|
|
415
410
|
/**
|
|
@@ -471,7 +466,7 @@ class ce extends ht {
|
|
|
471
466
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
472
467
|
*/
|
|
473
468
|
_rescueSelectsToStore(t) {
|
|
474
|
-
for (let e = 0; e <
|
|
469
|
+
for (let e = 0; e < b; e++) {
|
|
475
470
|
const r = `${A}${e}`, i = t.querySelector(`[data-custom-select-key="${r}"]`), s = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
476
471
|
if (s) {
|
|
477
472
|
const o = s.querySelector("ue-select");
|
|
@@ -485,7 +480,7 @@ class ce extends ht {
|
|
|
485
480
|
*/
|
|
486
481
|
_moveDeleteButtonsIntoItems(t, e) {
|
|
487
482
|
for (let r = 0; r < e; r++) {
|
|
488
|
-
const i = `${
|
|
483
|
+
const i = `${w}${r}`, s = t.querySelector(`[data-custom-delete-key="${i}"]`), o = t.querySelector(`[data-custom-delete-slot="${r}"]`);
|
|
489
484
|
if (s && o) {
|
|
490
485
|
const n = s.querySelector("ue-button");
|
|
491
486
|
n && o.appendChild(n);
|
|
@@ -497,8 +492,8 @@ class ce extends ht {
|
|
|
497
492
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
498
493
|
*/
|
|
499
494
|
_rescueDeleteButtonsToStore(t) {
|
|
500
|
-
for (let e = 0; e <
|
|
501
|
-
const r = `${
|
|
495
|
+
for (let e = 0; e < b; e++) {
|
|
496
|
+
const r = `${w}${e}`, i = t.querySelector(`[data-custom-delete-key="${r}"]`), s = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
502
497
|
if (s) {
|
|
503
498
|
const o = s.querySelector("ue-button");
|
|
504
499
|
o && i && i.appendChild(o);
|
|
@@ -511,7 +506,7 @@ class ce extends ht {
|
|
|
511
506
|
*/
|
|
512
507
|
_moveReorderIconsIntoItems(t, e) {
|
|
513
508
|
for (let r = 0; r < e; r++) {
|
|
514
|
-
const i = `${
|
|
509
|
+
const i = `${P}${r}`, s = t.querySelector(`[data-reorder-icon-key="${i}"]`), o = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
515
510
|
if (s && o) {
|
|
516
511
|
const n = s.querySelector("ue-button");
|
|
517
512
|
n && o.appendChild(n);
|
|
@@ -523,9 +518,9 @@ class ce extends ht {
|
|
|
523
518
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
524
519
|
*/
|
|
525
520
|
_rescueReorderIconsToStore(t) {
|
|
526
|
-
const e = m.length +
|
|
521
|
+
const e = m.length + b;
|
|
527
522
|
for (let r = 0; r < e; r++) {
|
|
528
|
-
const i = `${
|
|
523
|
+
const i = `${P}${r}`, s = t.querySelector(`[data-reorder-icon-key="${i}"]`), o = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
529
524
|
if (o) {
|
|
530
525
|
const n = o.querySelector("ue-button");
|
|
531
526
|
n && s && s.appendChild(n);
|
|
@@ -542,8 +537,8 @@ class ce extends ht {
|
|
|
542
537
|
return;
|
|
543
538
|
const r = e.querySelector("[data-composition-list]"), i = e.querySelector("#guido__btn-add-attribute");
|
|
544
539
|
r && (this._setupDragAndDrop(r, t), this._setupDeleteHandler(r, t)), i && i.addEventListener("click", () => {
|
|
545
|
-
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(
|
|
546
|
-
o && this._onAddAttribute(
|
|
540
|
+
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(C(n)));
|
|
541
|
+
o && this._onAddAttribute(C(o), o.displayName);
|
|
547
542
|
}, { signal: t });
|
|
548
543
|
}
|
|
549
544
|
/**
|
|
@@ -624,9 +619,7 @@ class ce extends ht {
|
|
|
624
619
|
// Actions (Add, Delete, Reorder)
|
|
625
620
|
// ========================================================================
|
|
626
621
|
_onAddAttribute(t, e) {
|
|
627
|
-
|
|
628
|
-
return;
|
|
629
|
-
const r = q(t), i = this._readCompositionFromNode();
|
|
622
|
+
const r = M(t), i = this._readCompositionFromNode();
|
|
630
623
|
i.push(r);
|
|
631
624
|
const s = [...this._readCustomAttributesFromNode(), t];
|
|
632
625
|
this._updateBothAttributes(i, s), this._injectCustomAttributeHtml(t, e, r, i), this._renderOrderableItems(i, s), this._initializeCustomSelects(s), this._updateAddButtonState();
|
|
@@ -648,20 +641,20 @@ class ce extends ht {
|
|
|
648
641
|
*/
|
|
649
642
|
_onCustomAttributeChanged(t, e) {
|
|
650
643
|
const r = this._readCustomAttributesFromNode(), i = r[t];
|
|
651
|
-
if (i === void 0 || i === e
|
|
644
|
+
if (i === void 0 || i === e)
|
|
652
645
|
return;
|
|
653
|
-
const s =
|
|
646
|
+
const s = M(e), o = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(o, t);
|
|
654
647
|
n !== -1 && (o[n] = s), r[t] = e;
|
|
655
648
|
const l = this._getDisplayNameForAttribute(e);
|
|
656
649
|
this._updateBothAttributes(o, r), this._injectCustomAttributeHtml(e, l, s, o), this._renderOrderableItems(o, r), this._initializeCustomSelects(r);
|
|
657
650
|
}
|
|
658
651
|
_onReorder(t) {
|
|
659
|
-
const e = t.filter((r) => r.startsWith(N)).map(
|
|
652
|
+
const e = t.filter((r) => r.startsWith(N)).map(k);
|
|
660
653
|
this.reorderInProgress = !0;
|
|
661
654
|
try {
|
|
662
655
|
this._updateBothAttributes(t, e);
|
|
663
656
|
const r = this._isInlinePrices();
|
|
664
|
-
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode &&
|
|
657
|
+
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && wt({
|
|
665
658
|
currentNode: this.currentNode,
|
|
666
659
|
documentModifier: this.api.getDocumentModifier()
|
|
667
660
|
});
|
|
@@ -679,13 +672,13 @@ class ce extends ht {
|
|
|
679
672
|
* DOM converge on the next composition change without writing on open.
|
|
680
673
|
*/
|
|
681
674
|
_getExistingRowHtml(t, e) {
|
|
682
|
-
const r =
|
|
675
|
+
const r = Ot(t, e);
|
|
683
676
|
if (r && "getOuterHTML" in r)
|
|
684
|
-
return
|
|
677
|
+
return Q(r.getOuterHTML(), e);
|
|
685
678
|
const i = t.querySelector(
|
|
686
679
|
`${E}[${R}="${e}"]`
|
|
687
680
|
);
|
|
688
|
-
return i && "getOuterHTML" in i ?
|
|
681
|
+
return i && "getOuterHTML" in i ? Q(i.getOuterHTML(), e) : "";
|
|
689
682
|
}
|
|
690
683
|
_injectCustomAttributeHtml(t, e, r, i) {
|
|
691
684
|
if (!this.currentNode)
|
|
@@ -693,45 +686,45 @@ class ce extends ht {
|
|
|
693
686
|
this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, e, r, i) : this._injectListAttributeRow(t, e, r, i);
|
|
694
687
|
}
|
|
695
688
|
_injectGridAttributeRow(t, e, r, i) {
|
|
696
|
-
const s = this.currentNode.querySelectorAll(
|
|
689
|
+
const s = this.currentNode.querySelectorAll(U);
|
|
697
690
|
if (!(s != null && s.length))
|
|
698
691
|
return;
|
|
699
|
-
const o =
|
|
692
|
+
const o = T.getConfig(this.currentNode), l = `0 ${Math.floor(o.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), d = this.store.recommendationProducts.length;
|
|
700
693
|
let c = 0;
|
|
701
694
|
s.forEach((u) => {
|
|
702
|
-
var
|
|
703
|
-
const h = u.querySelector(E), S = ((
|
|
704
|
-
if (
|
|
705
|
-
const
|
|
706
|
-
{ length:
|
|
707
|
-
(
|
|
708
|
-
const
|
|
695
|
+
var V;
|
|
696
|
+
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) => {
|
|
697
|
+
if (j === r) {
|
|
698
|
+
const st = Array.from(
|
|
699
|
+
{ length: B },
|
|
700
|
+
(xt, nt) => {
|
|
701
|
+
const lt = this._resolveAttributeContent(
|
|
709
702
|
t,
|
|
710
703
|
e,
|
|
711
|
-
c +
|
|
704
|
+
c + nt
|
|
712
705
|
);
|
|
713
706
|
return this._getGridCellHtml(
|
|
714
707
|
t,
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
708
|
+
lt,
|
|
709
|
+
x,
|
|
710
|
+
et,
|
|
711
|
+
rt,
|
|
719
712
|
l
|
|
720
713
|
);
|
|
721
714
|
}
|
|
722
|
-
).join(""),
|
|
723
|
-
return `<tr class="${
|
|
715
|
+
).join(""), ot = Ct(x, l).repeat(S - B);
|
|
716
|
+
return `<tr class="${z}" ${R}="${r}" ${D}="1">${st}${ot}</tr>`;
|
|
724
717
|
}
|
|
725
|
-
return this._getExistingRowHtml(u,
|
|
718
|
+
return this._getExistingRowHtml(u, j);
|
|
726
719
|
}).join("");
|
|
727
|
-
c +=
|
|
728
|
-
}), a.apply(new
|
|
720
|
+
c += B, d > 0 && c >= d && (c = 0), a.modifyHtml(u).setInnerHtml(it);
|
|
721
|
+
}), a.apply(new y(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
729
722
|
}
|
|
730
723
|
_injectListAttributeRow(t, e, r, i) {
|
|
731
|
-
const s = this.currentNode.querySelectorAll(
|
|
724
|
+
const s = this.currentNode.querySelectorAll(Z);
|
|
732
725
|
if (!(s != null && s.length))
|
|
733
726
|
return;
|
|
734
|
-
const o = i.filter((l) => l !==
|
|
727
|
+
const o = i.filter((l) => l !== q && l !== F), n = this.api.getDocumentModifier();
|
|
735
728
|
s.forEach((l, a) => {
|
|
736
729
|
const d = o.map((c) => {
|
|
737
730
|
if (c === r) {
|
|
@@ -741,7 +734,7 @@ class ce extends ht {
|
|
|
741
734
|
return this._getExistingRowHtml(l, c);
|
|
742
735
|
}).join("");
|
|
743
736
|
n.modifyHtml(l).setInnerHtml(d);
|
|
744
|
-
}), n.apply(new
|
|
737
|
+
}), n.apply(new y(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
745
738
|
}
|
|
746
739
|
/**
|
|
747
740
|
* Removes a custom attribute by rebuilding product card content without it.
|
|
@@ -752,19 +745,19 @@ class ce extends ht {
|
|
|
752
745
|
return;
|
|
753
746
|
const e = this._getCurrentLayout(), r = this.api.getDocumentModifier();
|
|
754
747
|
if (e === "grid") {
|
|
755
|
-
const i = this.currentNode.querySelectorAll(
|
|
748
|
+
const i = this.currentNode.querySelectorAll(U);
|
|
756
749
|
i == null || i.forEach((s) => {
|
|
757
750
|
const o = this._buildCompositionHtml(s, t);
|
|
758
751
|
r.modifyHtml(s).setInnerHtml(o);
|
|
759
752
|
});
|
|
760
753
|
} else {
|
|
761
|
-
const i = t.filter((o) => o !==
|
|
754
|
+
const i = t.filter((o) => o !== q && o !== F), s = this.currentNode.querySelectorAll(Z);
|
|
762
755
|
s == null || s.forEach((o) => {
|
|
763
756
|
const n = this._buildCompositionHtml(o, i);
|
|
764
757
|
r.modifyHtml(o).setInnerHtml(n);
|
|
765
758
|
});
|
|
766
759
|
}
|
|
767
|
-
r.apply(new
|
|
760
|
+
r.apply(new y(this.api.translate("Remove custom attribute")));
|
|
768
761
|
}
|
|
769
762
|
// ========================================================================
|
|
770
763
|
// DOM Mutation (Block Root Attributes, Reorder)
|
|
@@ -780,10 +773,10 @@ class ce extends ht {
|
|
|
780
773
|
if (!this.currentNode)
|
|
781
774
|
return;
|
|
782
775
|
const r = {
|
|
783
|
-
...
|
|
776
|
+
...T.getConfig(this.currentNode),
|
|
784
777
|
composition: t
|
|
785
778
|
};
|
|
786
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(
|
|
779
|
+
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")));
|
|
787
780
|
}
|
|
788
781
|
/**
|
|
789
782
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -792,14 +785,14 @@ class ce extends ht {
|
|
|
792
785
|
_reorderProductAttributes(t) {
|
|
793
786
|
if (!this.currentNode)
|
|
794
787
|
return;
|
|
795
|
-
const e = this.currentNode.querySelectorAll(
|
|
788
|
+
const e = this.currentNode.querySelectorAll(U);
|
|
796
789
|
if (!(e != null && e.length))
|
|
797
790
|
return;
|
|
798
791
|
const r = this.api.getDocumentModifier();
|
|
799
792
|
e.forEach((i) => {
|
|
800
793
|
const s = this._buildCompositionHtml(i, t);
|
|
801
794
|
r.modifyHtml(i).setInnerHtml(s);
|
|
802
|
-
}), r.apply(new
|
|
795
|
+
}), r.apply(new y(this.api.translate("Reorder product attributes")));
|
|
803
796
|
}
|
|
804
797
|
/**
|
|
805
798
|
* Builds HTML string with attributes ordered according to composition.
|
|
@@ -823,27 +816,27 @@ class ce extends ht {
|
|
|
823
816
|
return;
|
|
824
817
|
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();
|
|
825
818
|
s.forEach((c) => {
|
|
826
|
-
const u =
|
|
819
|
+
const u = Ht(c), h = e ? u : "none";
|
|
827
820
|
a.modifyHtml(c).setStyle("display", h).setAttribute(D, o);
|
|
828
821
|
});
|
|
829
822
|
const d = {
|
|
830
|
-
...
|
|
823
|
+
...T.getConfig(this.currentNode),
|
|
831
824
|
visibility: {
|
|
832
825
|
...this._readVisibilityFromRows(),
|
|
833
826
|
...Object.fromEntries(r.map((c) => [c, e]))
|
|
834
827
|
}
|
|
835
828
|
};
|
|
836
|
-
a.modifyHtml(this.currentNode).setNodeConfig(d), a.apply(new
|
|
829
|
+
a.modifyHtml(this.currentNode).setNodeConfig(d), a.apply(new y(l));
|
|
837
830
|
}
|
|
838
831
|
/** Inline "Product Prices" group row is tagged with whichever price comes first, so it drives both keys. */
|
|
839
832
|
_resolveVisibilityKeys(t) {
|
|
840
833
|
return this._isInlinePrices() && t === p ? [p, I] : [t];
|
|
841
834
|
}
|
|
842
835
|
_isInlinePrices() {
|
|
843
|
-
return !
|
|
836
|
+
return !T.getConfig(this.currentNode).priceMovedToNextLine;
|
|
844
837
|
}
|
|
845
838
|
_applyTitleVisibilityToBlock(t) {
|
|
846
|
-
const e =
|
|
839
|
+
const e = T.getConfig(this.currentNode), r = t ? this._resolveTitleInjection(e) : null, i = t ? [] : this._findTitleRows(), s = t ? this._hasTitle() || !r : i.length === 0;
|
|
847
840
|
if (!this.currentNode || s)
|
|
848
841
|
return;
|
|
849
842
|
const o = this.api.getDocumentModifier();
|
|
@@ -853,7 +846,7 @@ class ce extends ht {
|
|
|
853
846
|
visibility: { ...this._readVisibilityFromRows(), [$]: t }
|
|
854
847
|
});
|
|
855
848
|
const n = t ? this.api.translate("visible") : this.api.translate("hidden");
|
|
856
|
-
o.apply(new
|
|
849
|
+
o.apply(new y(
|
|
857
850
|
`${this.api.translate("Set visibility")}: ${$} → ${n}`
|
|
858
851
|
));
|
|
859
852
|
}
|
|
@@ -861,7 +854,7 @@ class ce extends ht {
|
|
|
861
854
|
const e = this._findTitleContainerBody(), r = e ? this._readInnerHtml(e) : null;
|
|
862
855
|
if (!e || r === null)
|
|
863
856
|
return null;
|
|
864
|
-
const i = t.previousTitleHtml ||
|
|
857
|
+
const i = t.previousTitleHtml || At(this._defaultTitleParagraph(), !0, t.rowSpacing);
|
|
865
858
|
return { containerBody: e, html: i + r };
|
|
866
859
|
}
|
|
867
860
|
_readTitleHtml(t) {
|
|
@@ -875,23 +868,23 @@ class ce extends ht {
|
|
|
875
868
|
return t.length > 0 ? t : this._findTitleRowsByClass();
|
|
876
869
|
}
|
|
877
870
|
_findTitleRowsByClass() {
|
|
878
|
-
const t = this._findTitleContainerBody(), e = t && "children" in t ? t.children() : [], r = e.findIndex((s) => !!s.querySelector(
|
|
871
|
+
const t = this._findTitleContainerBody(), e = t && "children" in t ? t.children() : [], r = e.findIndex((s) => !!s.querySelector(G));
|
|
879
872
|
if (r === -1)
|
|
880
873
|
return [];
|
|
881
874
|
const i = e[r + 1];
|
|
882
875
|
return i && this._isSpacerRow(i) ? [e[r], i] : [e[r]];
|
|
883
876
|
}
|
|
884
877
|
_isSpacerRow(t) {
|
|
885
|
-
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(
|
|
878
|
+
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(_t));
|
|
886
879
|
}
|
|
887
880
|
_findTitleContainerBody() {
|
|
888
|
-
return (this.currentNode ?
|
|
881
|
+
return (this.currentNode ? Bt(this.currentNode) : null) ?? void 0;
|
|
889
882
|
}
|
|
890
883
|
_readInnerHtml(t) {
|
|
891
884
|
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : null;
|
|
892
885
|
}
|
|
893
886
|
_defaultTitleParagraph() {
|
|
894
|
-
return
|
|
887
|
+
return It.replace("{-{-TITLE-}-}", this.api.translate($t));
|
|
895
888
|
}
|
|
896
889
|
// ========================================================================
|
|
897
890
|
// Utilities
|
|
@@ -912,7 +905,7 @@ class ce extends ht {
|
|
|
912
905
|
return -1;
|
|
913
906
|
}
|
|
914
907
|
_getCurrentLayout() {
|
|
915
|
-
return this.store.recommendationConfigs.orientation ||
|
|
908
|
+
return this.store.recommendationConfigs.orientation || kt(this.currentNode);
|
|
916
909
|
}
|
|
917
910
|
/**
|
|
918
911
|
* Extracts background color properties from existing card elements.
|
|
@@ -964,9 +957,9 @@ class ce extends ht {
|
|
|
964
957
|
* or when all available filters have already been added (no unused attributes left).
|
|
965
958
|
*/
|
|
966
959
|
_updateAddButtonState() {
|
|
967
|
-
const t = this._readCustomAttributesFromNode(), e = t.length >=
|
|
960
|
+
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)));
|
|
968
961
|
this.api.setUIEAttribute(
|
|
969
|
-
|
|
962
|
+
tt.ADD_ATTRIBUTE,
|
|
970
963
|
O.BUTTON.disabled,
|
|
971
964
|
e || s ? "true" : "false"
|
|
972
965
|
);
|
|
@@ -996,8 +989,8 @@ class ce extends ht {
|
|
|
996
989
|
*/
|
|
997
990
|
_getAddableFilters() {
|
|
998
991
|
const t = /* @__PURE__ */ new Set();
|
|
999
|
-
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" &&
|
|
1000
|
-
const r =
|
|
992
|
+
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" && gt.has(e.attributeName))).filter((e) => {
|
|
993
|
+
const r = C(e);
|
|
1001
994
|
return t.has(r) ? !1 : (t.add(r), !0);
|
|
1002
995
|
});
|
|
1003
996
|
}
|
|
@@ -1007,8 +1000,8 @@ class ce extends ht {
|
|
|
1007
1000
|
* resolve to their own entry. Falls back to Title Case of the bare name.
|
|
1008
1001
|
*/
|
|
1009
1002
|
_getDisplayNameForAttribute(t) {
|
|
1010
|
-
const e = Object.values(this.store.filterList).find((r) =>
|
|
1011
|
-
return e ? e.displayName :
|
|
1003
|
+
const e = Object.values(this.store.filterList).find((r) => C(r) === t);
|
|
1004
|
+
return e ? e.displayName : vt(H(t));
|
|
1012
1005
|
}
|
|
1013
1006
|
/**
|
|
1014
1007
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -1016,29 +1009,29 @@ class ce extends ht {
|
|
|
1016
1009
|
*/
|
|
1017
1010
|
_resolveAttributeContent(t, e, r) {
|
|
1018
1011
|
var l;
|
|
1019
|
-
const s = this.store.recommendationProducts[r], o =
|
|
1020
|
-
return
|
|
1012
|
+
const s = this.store.recommendationProducts[r], o = H(t), n = Dt(t) ? s == null ? void 0 : s[o] : (l = s == null ? void 0 : s.product_attributes) == null ? void 0 : l[o];
|
|
1013
|
+
return Nt(n) ?? e;
|
|
1021
1014
|
}
|
|
1022
1015
|
_getGridCellHtml(t, e, r, i = "", s = "", o = "") {
|
|
1023
|
-
const n =
|
|
1016
|
+
const n = M(t), l = H(t), a = J(yt, [n], this.store.filterList), d = {
|
|
1024
1017
|
[l]: e,
|
|
1025
1018
|
product_attributes: { [l]: e }
|
|
1026
1019
|
};
|
|
1027
1020
|
let c = a[n](d);
|
|
1028
1021
|
return c = c.replace("<td", `<td width="${r}%"`), o && (c = c.replace(
|
|
1029
|
-
`padding: ${
|
|
1022
|
+
`padding: ${Tt}`,
|
|
1030
1023
|
`padding: ${o}`
|
|
1031
1024
|
)), i && (c = c.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${i}"`)), s && (c = c.replace(/border="0"/, `border="0" bgcolor="${s}"`)), c;
|
|
1032
1025
|
}
|
|
1033
1026
|
_getListRowHtml(t, e, r) {
|
|
1034
|
-
const i =
|
|
1027
|
+
const i = H(t), s = J(St, [r], this.store.filterList), o = {
|
|
1035
1028
|
[i]: e,
|
|
1036
1029
|
product_attributes: { [i]: e }
|
|
1037
1030
|
}, l = s[r](o).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
1038
|
-
return `<tr class="${
|
|
1031
|
+
return `<tr class="${z}" ${R}="${r}" ${D}="1">${l}</tr>`;
|
|
1039
1032
|
}
|
|
1040
1033
|
}
|
|
1041
1034
|
export {
|
|
1042
|
-
|
|
1043
|
-
|
|
1035
|
+
Ut as COMPOSITION_CONTROL_BLOCK_ID,
|
|
1036
|
+
oe as RecommendationCardCompositionControl
|
|
1044
1037
|
};
|