@useinsider/guido 3.8.2-beta.3ad29fb → 3.8.2-beta.6bfa66f
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/@types/config/schemas.js +66 -70
- package/dist/composables/usePreviewMode.js +14 -15
- package/dist/config/compiler/recommendationCompilerRules.js +1 -1
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +80 -88
- package/dist/config/migrator/recommendation/htmlBuilder.js +52 -53
- package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
- package/dist/extensions/Blocks/Recommendation/block.js +45 -61
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +289 -353
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +87 -99
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +160 -162
- package/dist/extensions/Blocks/Recommendation/extension.js +29 -30
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +96 -130
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +54 -43
- package/dist/extensions/Blocks/Recommendation/templates/index.js +14 -17
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +80 -86
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +40 -31
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +102 -155
- package/dist/extensions/Blocks/controlFactories.js +76 -57
- package/dist/src/@types/config/schemas.d.ts +0 -16
- package/dist/src/composables/useConfig.d.ts +0 -4
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +1 -13
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +1 -10
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -51
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
- package/dist/src/extensions/Blocks/controlFactories.d.ts +10 -1
- package/dist/src/stores/config.d.ts +0 -36
- package/package.json +1 -1
- package/dist/composables/useRecommendationPreview.js +0 -111
- package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +0 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
- package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UIElementType as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_PRODUCT_IMAGE as
|
|
7
|
-
import { DEFAULT_COMPOSITION as
|
|
8
|
-
import { RecommendationConfigService as
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var Z = (p, g, t) => g in p ? Q(p, g, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[g] = t;
|
|
3
|
+
var T = (p, g, t) => Z(p, typeof g != "symbol" ? g + "" : g, t);
|
|
4
|
+
import { UIElementType as f, UEAttr as v, ModificationDescription as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as tt } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_IMAGE as B, ATTR_PRODUCT_NAME as et, ATTR_PRODUCT_PRICE as rt, ATTR_PRODUCT_OLD_PRICE as ot, ATTR_PRODUCT_OMNIBUS_PRICE as st, ATTR_PRODUCT_OMNIBUS_DISCOUNT as it, ATTR_PRODUCT_BUTTON as H, ATTR_DATA_CUSTOM_ATTRIBUTES as F, ATTR_CUSTOM_PREFIX as d, BUILT_IN_DEFAULT_ATTRIBUTES as nt } from "../../constants/selectors.js";
|
|
7
|
+
import { DEFAULT_COMPOSITION as P, DEFAULT_VISIBILITY as w } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RecommendationConfigService as $ } from "../../services/configService.js";
|
|
9
9
|
import { useRecommendationExtensionStore as lt } from "../../store/recommendation.js";
|
|
10
|
-
import { ATTRIBUTE_CELL_CLASS as at, gridElementRenderer as ct, DEFAULT_CELL_PADDING as
|
|
10
|
+
import { ATTRIBUTE_CELL_CLASS as at, gridElementRenderer as ct, DEFAULT_CELL_PADDING as ut, buildFillerCell as dt } from "../../templates/grid/elementRenderer.js";
|
|
11
11
|
import { listElementRenderer as mt } from "../../templates/list/elementRenderer.js";
|
|
12
|
-
import {
|
|
13
|
-
import { getTableDisplayValue as
|
|
14
|
-
import { isPartnerManagedBlock as
|
|
15
|
-
const
|
|
12
|
+
import { toDisplayName as ht, isDefaultAttribute as pt, toDisplayableAttributeValue as gt, buildElementRenderer as M } from "../../templates/utils.js";
|
|
13
|
+
import { getTableDisplayValue as ft } from "../../utils/tagName.js";
|
|
14
|
+
import { isPartnerManagedBlock as _t, getCurrentLayout as bt } from "../main/utils.js";
|
|
15
|
+
const yt = "ui-elements-recommendation-card-composition", A = ".recommendation-attribute-row", L = ".product-card-wrapper > tbody", V = ".product-info-cell > table > tbody", x = "data-card-composition", y = "data-attribute-type", N = "data-visibility", j = {
|
|
16
16
|
ADD_ATTRIBUTE: "addAttribute"
|
|
17
|
-
},
|
|
18
|
-
{ key:
|
|
19
|
-
{ key:
|
|
20
|
-
{ key:
|
|
21
|
-
{ key:
|
|
22
|
-
{ key:
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
25
|
-
],
|
|
26
|
-
class
|
|
17
|
+
}, _ = 5, E = "reorderIcon_", h = [
|
|
18
|
+
{ key: B, label: "Product Image" },
|
|
19
|
+
{ key: et, label: "Product Name" },
|
|
20
|
+
{ key: rt, label: "Product Price" },
|
|
21
|
+
{ key: ot, label: "Product Original Price" },
|
|
22
|
+
{ key: st, label: "Omnibus Price" },
|
|
23
|
+
{ key: it, label: "Omnibus Discount" },
|
|
24
|
+
{ key: H, label: "Product Button" }
|
|
25
|
+
], Ct = new Set(h.map((p) => p.key)), S = "customAttr_", R = "deleteAttr_";
|
|
26
|
+
class Ht extends tt {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
T(this, "store", lt());
|
|
30
|
+
T(this, "unsubscribeStore", null);
|
|
31
|
+
T(this, "eventController", null);
|
|
32
32
|
/**
|
|
33
33
|
* Guard flag: when true, onTemplateNodeUpdated skips _initializeComposition.
|
|
34
34
|
* Used during _onReorder to prevent multiple intermediate rebuilds.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
T(this, "reorderInProgress", !1);
|
|
37
37
|
}
|
|
38
38
|
getId() {
|
|
39
|
-
return
|
|
39
|
+
return yt;
|
|
40
40
|
}
|
|
41
41
|
// ========================================================================
|
|
42
42
|
// Lifecycle
|
|
43
43
|
// ========================================================================
|
|
44
44
|
getTemplate() {
|
|
45
|
-
const t =
|
|
46
|
-
<div data-toggle-key="${
|
|
47
|
-
${this._GuToggle(`visibility_${
|
|
45
|
+
const t = h.map((l) => `
|
|
46
|
+
<div data-toggle-key="${l.key}" style="display: none;">
|
|
47
|
+
${this._GuToggle(`visibility_${l.key}`)}
|
|
48
48
|
</div>
|
|
49
49
|
`).join(""), r = Array.from(
|
|
50
|
-
{ length:
|
|
51
|
-
(
|
|
52
|
-
<div data-custom-select-key="${
|
|
50
|
+
{ length: _ },
|
|
51
|
+
(l, u) => `
|
|
52
|
+
<div data-custom-select-key="${S}${u}" style="display: none;">
|
|
53
53
|
${this._GuSelect({
|
|
54
|
-
name: `${
|
|
54
|
+
name: `${S}${u}`,
|
|
55
55
|
placeholder: this.api.translate("Select Attribute"),
|
|
56
56
|
options: []
|
|
57
57
|
})}
|
|
58
58
|
</div>
|
|
59
59
|
`
|
|
60
|
-
).join(""), e =
|
|
60
|
+
).join(""), e = h.length + _, o = Array.from(
|
|
61
61
|
{ length: e },
|
|
62
|
-
(
|
|
63
|
-
<div data-reorder-icon-key="${
|
|
64
|
-
<${
|
|
62
|
+
(l, u) => `
|
|
63
|
+
<div data-reorder-icon-key="${E}${u}" style="display: none;">
|
|
64
|
+
<${f.BUTTON}
|
|
65
65
|
class="drag-handle-btn flat-inline flat-white"
|
|
66
|
-
${
|
|
66
|
+
${v.BUTTON.name}="${E}${u}"
|
|
67
67
|
>
|
|
68
|
-
<${
|
|
68
|
+
<${f.ICON}
|
|
69
69
|
src="reorder"
|
|
70
70
|
class="icon-button"
|
|
71
|
-
></${
|
|
72
|
-
</${
|
|
71
|
+
></${f.ICON}>
|
|
72
|
+
</${f.BUTTON}>
|
|
73
73
|
</div>
|
|
74
74
|
`
|
|
75
|
-
).join(""),
|
|
76
|
-
{ length:
|
|
77
|
-
(
|
|
78
|
-
<div data-custom-delete-key="${
|
|
79
|
-
<${
|
|
75
|
+
).join(""), s = Array.from(
|
|
76
|
+
{ length: _ },
|
|
77
|
+
(l, u) => `
|
|
78
|
+
<div data-custom-delete-key="${R}${u}" style="display: none;">
|
|
79
|
+
<${f.BUTTON}
|
|
80
80
|
class="custom-attr-delete flat-inline flat-white"
|
|
81
|
-
${
|
|
81
|
+
${v.BUTTON.name}="${R}${u}"
|
|
82
82
|
>
|
|
83
|
-
<${
|
|
83
|
+
<${f.ICON}
|
|
84
84
|
src="delete"
|
|
85
85
|
class="icon-button"
|
|
86
|
-
></${
|
|
87
|
-
</${
|
|
86
|
+
></${f.ICON}>
|
|
87
|
+
</${f.BUTTON}>
|
|
88
88
|
</div>
|
|
89
89
|
`
|
|
90
|
-
).join(""),
|
|
90
|
+
).join(""), i = "https://academy.insiderone.com/docs/new-editor-email-recommendation-block", n = this.api.translate(
|
|
91
91
|
"Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
|
|
92
|
-
), c = this.api.translate("For more information, you can"),
|
|
92
|
+
), c = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
93
93
|
return `
|
|
94
94
|
<div class="recommendation-controls-container" data-card-composition-control>
|
|
95
95
|
<div class="container">
|
|
@@ -97,7 +97,7 @@ class qt extends rt {
|
|
|
97
97
|
${n}
|
|
98
98
|
${c}
|
|
99
99
|
<!-- cspell:disable-next-line -->
|
|
100
|
-
<a href="${
|
|
100
|
+
<a href="${i}" target="_blank" rel="noopener noreferrer">${a}</a>.
|
|
101
101
|
</p>
|
|
102
102
|
</div>
|
|
103
103
|
|
|
@@ -110,7 +110,7 @@ class qt extends rt {
|
|
|
110
110
|
</div>
|
|
111
111
|
|
|
112
112
|
<div class="custom-delete-store" style="display: none;">
|
|
113
|
-
${
|
|
113
|
+
${s}
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<div class="reorder-icon-store" style="display: none;">
|
|
@@ -120,7 +120,7 @@ class qt extends rt {
|
|
|
120
120
|
<div class="orderable-list" data-composition-list></div>
|
|
121
121
|
|
|
122
122
|
${this._GuButton({
|
|
123
|
-
name:
|
|
123
|
+
name: j.ADD_ATTRIBUTE,
|
|
124
124
|
label: this.api.translate("Add Attribute"),
|
|
125
125
|
id: "guido__btn-add-attribute"
|
|
126
126
|
})}
|
|
@@ -141,7 +141,7 @@ class qt extends rt {
|
|
|
141
141
|
const t = (e = this.getContainer()) == null ? void 0 : e.querySelector("[data-card-composition-control]");
|
|
142
142
|
if (!t)
|
|
143
143
|
return;
|
|
144
|
-
const r =
|
|
144
|
+
const r = _t(this.currentNode);
|
|
145
145
|
t.style.pointerEvents = r ? "none" : "", t.style.opacity = r ? "0.5" : "";
|
|
146
146
|
}
|
|
147
147
|
onTemplateNodeUpdated(t) {
|
|
@@ -154,17 +154,17 @@ class qt extends rt {
|
|
|
154
154
|
// Initialization
|
|
155
155
|
// ========================================================================
|
|
156
156
|
_initializeComposition() {
|
|
157
|
-
const t = this._readCompositionFromNode(), r = this._readCustomAttributesFromNode(), e = this._readVisibilityFromRows(), o = this._renderOrderableItems(t, r),
|
|
158
|
-
this.api.updateValues(
|
|
157
|
+
const t = this._readCompositionFromNode(), r = this._readCustomAttributesFromNode(), e = this._readVisibilityFromRows(), o = this._renderOrderableItems(t, r), s = this._buildVisibilityValues(e);
|
|
158
|
+
this.api.updateValues(s), o && this._initializeCustomSelects(r), this._updateAddButtonState();
|
|
159
159
|
}
|
|
160
160
|
_registerValueChangeListeners() {
|
|
161
|
-
|
|
161
|
+
h.forEach((t) => {
|
|
162
162
|
this.api.onValueChanged(`visibility_${t.key}`, (r) => {
|
|
163
163
|
this._applyVisibilityToBlock(t.key, r);
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
|
-
for (let t = 0; t <
|
|
167
|
-
const r = `${
|
|
166
|
+
for (let t = 0; t < _; t++) {
|
|
167
|
+
const r = `${S}${t}`, e = t;
|
|
168
168
|
this.api.onValueChanged(r, (o) => {
|
|
169
169
|
this._onCustomAttributeChanged(e, o);
|
|
170
170
|
});
|
|
@@ -175,50 +175,56 @@ class qt extends rt {
|
|
|
175
175
|
// ========================================================================
|
|
176
176
|
_readCompositionFromNode() {
|
|
177
177
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
178
|
-
return [...
|
|
179
|
-
const t = this.currentNode.getAttribute(
|
|
180
|
-
|
|
178
|
+
return [...P];
|
|
179
|
+
const t = this.currentNode.getAttribute(x);
|
|
180
|
+
if (t)
|
|
181
|
+
return t.split(",").filter(Boolean);
|
|
182
|
+
const { composition: r } = $.getConfig(this.currentNode);
|
|
183
|
+
return r != null && r.length ? [...r] : [...P];
|
|
181
184
|
}
|
|
182
185
|
_readCustomAttributesFromNode() {
|
|
183
186
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
184
187
|
return [];
|
|
185
188
|
const t = this.currentNode.getAttribute(F);
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
if (t)
|
|
190
|
+
try {
|
|
191
|
+
return JSON.parse(t);
|
|
192
|
+
} catch {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
return this._readCompositionFromNode().filter((r) => r.startsWith(d)).map((r) => r.substring(d.length));
|
|
193
196
|
}
|
|
194
197
|
_readVisibilityFromRows() {
|
|
195
198
|
if (!this.currentNode)
|
|
196
199
|
return this._getDefaultVisibilities();
|
|
197
|
-
const t = Array.from(this.currentNode.querySelectorAll(
|
|
198
|
-
|
|
200
|
+
const t = Array.from(this.currentNode.querySelectorAll(A)), r = this._extractVisibilityFromRows(t);
|
|
201
|
+
if (Object.keys(r).length > 0)
|
|
202
|
+
return this._mergeWithDefaults(r);
|
|
203
|
+
const e = $.getConfig(this.currentNode).visibility;
|
|
204
|
+
return this._mergeWithDefaults({ ...e });
|
|
199
205
|
}
|
|
200
206
|
_getDefaultVisibilities() {
|
|
201
|
-
return { ...
|
|
207
|
+
return { ...w };
|
|
202
208
|
}
|
|
203
209
|
_extractVisibilityFromRows(t) {
|
|
204
210
|
const r = {};
|
|
205
211
|
return t.forEach((e) => {
|
|
206
212
|
if (!("getAttribute" in e))
|
|
207
213
|
return;
|
|
208
|
-
const o = e.getAttribute(y),
|
|
209
|
-
o &&
|
|
214
|
+
const o = e.getAttribute(y), s = e.getAttribute(N);
|
|
215
|
+
o && s !== null && (r[o] = this._parseVisibilityValue(s));
|
|
210
216
|
}), r;
|
|
211
217
|
}
|
|
212
218
|
_parseVisibilityValue(t) {
|
|
213
219
|
return t === "1" || t === "true";
|
|
214
220
|
}
|
|
215
221
|
_mergeWithDefaults(t) {
|
|
216
|
-
return Object.entries(
|
|
222
|
+
return Object.entries(w).forEach(([r, e]) => {
|
|
217
223
|
r in t || (t[r] = e);
|
|
218
224
|
}), t;
|
|
219
225
|
}
|
|
220
226
|
_buildVisibilityValues(t) {
|
|
221
|
-
return
|
|
227
|
+
return h.reduce((r, e) => (r[`visibility_${e.key}`] = t[e.key] ?? !0, r), {});
|
|
222
228
|
}
|
|
223
229
|
// ========================================================================
|
|
224
230
|
// UI Rendering (Orderable List)
|
|
@@ -233,29 +239,23 @@ class qt extends rt {
|
|
|
233
239
|
if (!e)
|
|
234
240
|
return !1;
|
|
235
241
|
const o = e.querySelector("[data-composition-list]");
|
|
236
|
-
if (!o)
|
|
242
|
+
if (!o || this._tryReorderInPlace(o, t))
|
|
237
243
|
return !1;
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const d = t.map((u) => {
|
|
245
|
-
if (i && (u === S || u === v))
|
|
246
|
-
return u === c.anchor ? this._createPriceGroupItemHtml(a++, c.originalFirst) : "";
|
|
247
|
-
if (Tt.has(u)) {
|
|
248
|
-
const h = m.find((C) => C.key === u);
|
|
249
|
-
return this._createBuiltInItemHtml(h, a++);
|
|
244
|
+
const s = new Set(r);
|
|
245
|
+
let i = 0, n = 0;
|
|
246
|
+
const c = t.map((a) => {
|
|
247
|
+
if (Ct.has(a)) {
|
|
248
|
+
const l = h.find((u) => u.key === a);
|
|
249
|
+
return this._createBuiltInItemHtml(l, n++);
|
|
250
250
|
}
|
|
251
|
-
if (
|
|
252
|
-
const
|
|
253
|
-
if (
|
|
254
|
-
return this._createCustomItemHtml(
|
|
251
|
+
if (a.startsWith(d)) {
|
|
252
|
+
const l = a.substring(d.length);
|
|
253
|
+
if (s.has(l))
|
|
254
|
+
return this._createCustomItemHtml(a, i++, n++);
|
|
255
255
|
}
|
|
256
256
|
return "";
|
|
257
257
|
}).join("");
|
|
258
|
-
return this._rescueTogglesToStore(e), this._rescueSelectsToStore(e), this._rescueDeleteButtonsToStore(e), this._rescueReorderIconsToStore(e), o.innerHTML =
|
|
258
|
+
return this._rescueTogglesToStore(e), this._rescueSelectsToStore(e), this._rescueDeleteButtonsToStore(e), this._rescueReorderIconsToStore(e), o.innerHTML = c, this._moveTogglesIntoItems(e), this._moveSelectsIntoItems(e, r.length), this._moveDeleteButtonsIntoItems(e, r.length), this._moveReorderIconsIntoItems(e, n), !0;
|
|
259
259
|
}
|
|
260
260
|
/**
|
|
261
261
|
* Attempts to reorder existing orderable-item elements to match the composition order.
|
|
@@ -267,27 +267,27 @@ class qt extends rt {
|
|
|
267
267
|
const e = Array.from(t.querySelectorAll(".orderable-item"));
|
|
268
268
|
if (e.length !== r.length)
|
|
269
269
|
return !1;
|
|
270
|
-
const o = e.map((
|
|
270
|
+
const o = e.map((a) => a.dataset.key).filter(Boolean);
|
|
271
271
|
if (o.length !== r.length)
|
|
272
272
|
return !1;
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
273
|
+
const s = [...o].sort().join(","), i = [...r].sort().join(",");
|
|
274
|
+
if (s !== i || r.some((a) => a.startsWith(d)))
|
|
275
275
|
return !1;
|
|
276
276
|
const n = /* @__PURE__ */ new Map();
|
|
277
|
-
e.forEach((
|
|
278
|
-
const { key:
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
277
|
+
e.forEach((a) => {
|
|
278
|
+
const { key: l } = a.dataset;
|
|
279
|
+
if (l) {
|
|
280
|
+
const u = n.get(l) || [];
|
|
281
|
+
u.push(a), n.set(l, u);
|
|
282
282
|
}
|
|
283
283
|
});
|
|
284
284
|
const c = /* @__PURE__ */ new Map();
|
|
285
|
-
return r.forEach((
|
|
286
|
-
const
|
|
287
|
-
if (!
|
|
285
|
+
return r.forEach((a) => {
|
|
286
|
+
const l = n.get(a);
|
|
287
|
+
if (!l)
|
|
288
288
|
return;
|
|
289
|
-
const
|
|
290
|
-
c.set(
|
|
289
|
+
const u = c.get(a) || 0;
|
|
290
|
+
c.set(a, u + 1), l[u] && t.appendChild(l[u]);
|
|
291
291
|
}), !0;
|
|
292
292
|
}
|
|
293
293
|
_createBuiltInItemHtml(t, r) {
|
|
@@ -299,33 +299,6 @@ class qt extends rt {
|
|
|
299
299
|
</div>
|
|
300
300
|
`;
|
|
301
301
|
}
|
|
302
|
-
/**
|
|
303
|
-
* Inline mode: the merged "Product Prices" group item. It moves as a unit in
|
|
304
|
-
* the main list (both keys stay adjacent) and contains a nested 2-item drag
|
|
305
|
-
* to reorder Product Price ↔ Product Original Price — which flips the inline
|
|
306
|
-
* render order via `resolveInlinePriceOrder`. The group keeps a single
|
|
307
|
-
* visibility toggle (`data-action-for="productPrice"`). Nested sub-items use a
|
|
308
|
-
* plain drag handle (no UE button → untouched by the reorder-icon rescue).
|
|
309
|
-
*/
|
|
310
|
-
_createPriceGroupItemHtml(t, r) {
|
|
311
|
-
var n, c;
|
|
312
|
-
const e = ((n = m.find((l) => l.key === S)) == null ? void 0 : n.label) ?? "Product Price", o = ((c = m.find((l) => l.key === v)) == null ? void 0 : c.label) ?? "Product Original Price", i = (l, a) => `
|
|
313
|
-
<div class="price-suborderable-item" draggable="true" data-subkey="${l}">
|
|
314
|
-
<span class="sub-drag-handle">${At}</span>
|
|
315
|
-
<span class="item-label">${this.api.translate(a)}</span>
|
|
316
|
-
</div>`, s = r ? i(v, o) + i(S, e) : i(S, e) + i(v, o);
|
|
317
|
-
return `
|
|
318
|
-
<div class="orderable-item price-group-item" draggable="true"
|
|
319
|
-
data-key="${S}" data-group="prices">
|
|
320
|
-
<div class="price-group-header">
|
|
321
|
-
<span class="drag-handle" data-reorder-icon-slot="${t}"></span>
|
|
322
|
-
<span class="item-label">${this.api.translate("Product Prices")}</span>
|
|
323
|
-
<div class="item-action" data-action-for="${S}"></div>
|
|
324
|
-
</div>
|
|
325
|
-
<div class="price-suborderable-list">${s}</div>
|
|
326
|
-
</div>
|
|
327
|
-
`;
|
|
328
|
-
}
|
|
329
302
|
_createCustomItemHtml(t, r, e) {
|
|
330
303
|
return `
|
|
331
304
|
<div class="orderable-item" draggable="true"
|
|
@@ -346,10 +319,10 @@ class qt extends rt {
|
|
|
346
319
|
_getSelectOptions(t, r = []) {
|
|
347
320
|
const e = this._getAddableFilters();
|
|
348
321
|
if (e.length > 0) {
|
|
349
|
-
const
|
|
350
|
-
return
|
|
351
|
-
text:
|
|
352
|
-
value:
|
|
322
|
+
const s = new Set(r);
|
|
323
|
+
return s.delete(t), e.filter((i) => !s.has(i.attributeName)).map((i) => ({
|
|
324
|
+
text: i.displayName,
|
|
325
|
+
value: i.attributeName
|
|
353
326
|
}));
|
|
354
327
|
}
|
|
355
328
|
return [{ text: this._getDisplayNameForAttribute(t), value: t }];
|
|
@@ -362,8 +335,8 @@ class qt extends rt {
|
|
|
362
335
|
_initializeCustomSelects(t) {
|
|
363
336
|
t.length !== 0 && setTimeout(() => {
|
|
364
337
|
t.forEach((r, e) => {
|
|
365
|
-
const o = `${
|
|
366
|
-
this.api.setUIEAttribute(o,
|
|
338
|
+
const o = `${S}${e}`, s = this._getSelectOptions(r, t);
|
|
339
|
+
this.api.setUIEAttribute(o, v.SELECTPICKER.items, s), this.api.updateValues({ [o]: r });
|
|
367
340
|
});
|
|
368
341
|
}, 0);
|
|
369
342
|
}
|
|
@@ -372,11 +345,11 @@ class qt extends rt {
|
|
|
372
345
|
* Stripo initializes toggles at template parse time; moving the DOM node preserves bindings.
|
|
373
346
|
*/
|
|
374
347
|
_moveTogglesIntoItems(t) {
|
|
375
|
-
|
|
348
|
+
h.forEach((r) => {
|
|
376
349
|
const e = t.querySelector(`[data-toggle-key="${r.key}"]`), o = t.querySelector(`[data-action-for="${r.key}"]`);
|
|
377
350
|
if (e && o) {
|
|
378
|
-
const
|
|
379
|
-
|
|
351
|
+
const s = e.querySelector("ue-switcher");
|
|
352
|
+
s && o.appendChild(s);
|
|
380
353
|
}
|
|
381
354
|
});
|
|
382
355
|
}
|
|
@@ -386,10 +359,10 @@ class qt extends rt {
|
|
|
386
359
|
*/
|
|
387
360
|
_moveSelectsIntoItems(t, r) {
|
|
388
361
|
for (let e = 0; e < r; e++) {
|
|
389
|
-
const o = `${
|
|
390
|
-
if (
|
|
391
|
-
const n =
|
|
392
|
-
n &&
|
|
362
|
+
const o = `${S}${e}`, s = t.querySelector(`[data-custom-select-key="${o}"]`), i = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
363
|
+
if (s && i) {
|
|
364
|
+
const n = s.querySelector("ue-select");
|
|
365
|
+
n && i.appendChild(n);
|
|
393
366
|
}
|
|
394
367
|
}
|
|
395
368
|
}
|
|
@@ -400,11 +373,11 @@ class qt extends rt {
|
|
|
400
373
|
* previously-moved toggles, making them permanently lost.
|
|
401
374
|
*/
|
|
402
375
|
_rescueTogglesToStore(t) {
|
|
403
|
-
|
|
376
|
+
h.forEach((r) => {
|
|
404
377
|
const e = t.querySelector(`[data-toggle-key="${r.key}"]`), o = t.querySelector(`[data-action-for="${r.key}"]`);
|
|
405
378
|
if (o) {
|
|
406
|
-
const
|
|
407
|
-
|
|
379
|
+
const s = o.querySelector("ue-switcher");
|
|
380
|
+
s && e && e.appendChild(s);
|
|
408
381
|
}
|
|
409
382
|
});
|
|
410
383
|
}
|
|
@@ -413,11 +386,11 @@ class qt extends rt {
|
|
|
413
386
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
414
387
|
*/
|
|
415
388
|
_rescueSelectsToStore(t) {
|
|
416
|
-
for (let r = 0; r <
|
|
417
|
-
const e = `${
|
|
418
|
-
if (
|
|
419
|
-
const
|
|
420
|
-
|
|
389
|
+
for (let r = 0; r < _; r++) {
|
|
390
|
+
const e = `${S}${r}`, o = t.querySelector(`[data-custom-select-key="${e}"]`), s = t.querySelector(`[data-custom-select-slot="${r}"]`);
|
|
391
|
+
if (s) {
|
|
392
|
+
const i = s.querySelector("ue-select");
|
|
393
|
+
i && o && o.appendChild(i);
|
|
421
394
|
}
|
|
422
395
|
}
|
|
423
396
|
}
|
|
@@ -427,10 +400,10 @@ class qt extends rt {
|
|
|
427
400
|
*/
|
|
428
401
|
_moveDeleteButtonsIntoItems(t, r) {
|
|
429
402
|
for (let e = 0; e < r; e++) {
|
|
430
|
-
const o = `${
|
|
431
|
-
if (
|
|
432
|
-
const n =
|
|
433
|
-
n &&
|
|
403
|
+
const o = `${R}${e}`, s = t.querySelector(`[data-custom-delete-key="${o}"]`), i = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
404
|
+
if (s && i) {
|
|
405
|
+
const n = s.querySelector("ue-button");
|
|
406
|
+
n && i.appendChild(n);
|
|
434
407
|
}
|
|
435
408
|
}
|
|
436
409
|
}
|
|
@@ -439,11 +412,11 @@ class qt extends rt {
|
|
|
439
412
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
440
413
|
*/
|
|
441
414
|
_rescueDeleteButtonsToStore(t) {
|
|
442
|
-
for (let r = 0; r <
|
|
443
|
-
const e = `${
|
|
444
|
-
if (
|
|
445
|
-
const
|
|
446
|
-
|
|
415
|
+
for (let r = 0; r < _; r++) {
|
|
416
|
+
const e = `${R}${r}`, o = t.querySelector(`[data-custom-delete-key="${e}"]`), s = t.querySelector(`[data-custom-delete-slot="${r}"]`);
|
|
417
|
+
if (s) {
|
|
418
|
+
const i = s.querySelector("ue-button");
|
|
419
|
+
i && o && o.appendChild(i);
|
|
447
420
|
}
|
|
448
421
|
}
|
|
449
422
|
}
|
|
@@ -453,10 +426,10 @@ class qt extends rt {
|
|
|
453
426
|
*/
|
|
454
427
|
_moveReorderIconsIntoItems(t, r) {
|
|
455
428
|
for (let e = 0; e < r; e++) {
|
|
456
|
-
const o = `${
|
|
457
|
-
if (
|
|
458
|
-
const n =
|
|
459
|
-
n &&
|
|
429
|
+
const o = `${E}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
|
|
430
|
+
if (s && i) {
|
|
431
|
+
const n = s.querySelector("ue-button");
|
|
432
|
+
n && i.appendChild(n);
|
|
460
433
|
}
|
|
461
434
|
}
|
|
462
435
|
}
|
|
@@ -465,12 +438,12 @@ class qt extends rt {
|
|
|
465
438
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
466
439
|
*/
|
|
467
440
|
_rescueReorderIconsToStore(t) {
|
|
468
|
-
const r =
|
|
441
|
+
const r = h.length + _;
|
|
469
442
|
for (let e = 0; e < r; e++) {
|
|
470
|
-
const o = `${
|
|
471
|
-
if (
|
|
472
|
-
const n =
|
|
473
|
-
n &&
|
|
443
|
+
const o = `${E}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
|
|
444
|
+
if (i) {
|
|
445
|
+
const n = i.querySelector("ue-button");
|
|
446
|
+
n && s && s.appendChild(n);
|
|
474
447
|
}
|
|
475
448
|
}
|
|
476
449
|
}
|
|
@@ -484,81 +457,39 @@ class qt extends rt {
|
|
|
484
457
|
return;
|
|
485
458
|
const e = r.querySelector("[data-composition-list]"), o = r.querySelector("#guido__btn-add-attribute");
|
|
486
459
|
e && (this._setupDragAndDrop(e, t), this._setupDeleteHandler(e, t)), o && o.addEventListener("click", () => {
|
|
487
|
-
const
|
|
488
|
-
|
|
460
|
+
const s = new Set(this._readCustomAttributesFromNode()), i = this._getAddableFilters().find((n) => !s.has(n.attributeName));
|
|
461
|
+
i && this._onAddAttribute(i.attributeName, i.displayName);
|
|
489
462
|
}, { signal: t });
|
|
490
463
|
}
|
|
491
|
-
/**
|
|
492
|
-
* Builds the composition key order from the orderable list, expanding the
|
|
493
|
-
* inline "Product Prices" group into its two sub-keys (in nested DOM order)
|
|
494
|
-
* so both price keys stay adjacent and in the user-chosen order.
|
|
495
|
-
*/
|
|
496
|
-
_extractCompositionOrder(t) {
|
|
497
|
-
const r = [];
|
|
498
|
-
return t.querySelectorAll(".orderable-item").forEach((e) => {
|
|
499
|
-
const o = e;
|
|
500
|
-
o.dataset.group === "prices" ? o.querySelectorAll(".price-suborderable-item").forEach((i) => {
|
|
501
|
-
const s = i.dataset.subkey;
|
|
502
|
-
s && r.push(s);
|
|
503
|
-
}) : o.dataset.key && r.push(o.dataset.key);
|
|
504
|
-
}), r;
|
|
505
|
-
}
|
|
506
464
|
_setupDragAndDrop(t, r) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
itemSelector: ".price-suborderable-item",
|
|
513
|
-
getDropParent: (e) => e.parentElement
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Wires drag/drop reordering for one item level on the shared list. Both the
|
|
518
|
-
* top-level items and the nested price sub-items use this; they never fight
|
|
519
|
-
* because each only sets its `dragged` ref when its own `itemSelector` matches
|
|
520
|
-
* at dragstart (and the top-level one additionally ignores drags originating
|
|
521
|
-
* inside `ignoreSelector`). Every drop re-reads the full composition via
|
|
522
|
-
* `_extractCompositionOrder`, so both levels commit through `_onReorder`
|
|
523
|
-
* identically.
|
|
524
|
-
*/
|
|
525
|
-
_registerDragHandlers(t, r, e) {
|
|
526
|
-
let o = null, i = null;
|
|
527
|
-
const s = (n) => n.target.closest(e.itemSelector);
|
|
528
|
-
t.addEventListener("dragstart", (n) => {
|
|
529
|
-
var a;
|
|
530
|
-
const c = n.target;
|
|
531
|
-
if (e.ignoreSelector && c.closest(e.ignoreSelector))
|
|
532
|
-
return;
|
|
533
|
-
const l = s(n);
|
|
534
|
-
l && (o = l, l.classList.add("dragging"), (a = n.dataTransfer) == null || a.setData("text/plain", l.dataset.key ?? l.dataset.subkey ?? ""));
|
|
465
|
+
let e = null, o = null;
|
|
466
|
+
t.addEventListener("dragstart", (s) => {
|
|
467
|
+
var c;
|
|
468
|
+
const n = s.target.closest(".orderable-item");
|
|
469
|
+
n && (e = n, n.classList.add("dragging"), (c = s.dataTransfer) == null || c.setData("text/plain", n.dataset.key || ""));
|
|
535
470
|
}, { signal: r }), t.addEventListener("dragend", () => {
|
|
536
|
-
|
|
537
|
-
}, { signal: r }), t.addEventListener("dragover", (
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
471
|
+
e && e.classList.remove("dragging"), e = null, o == null || o.classList.remove("drag-over"), o = null;
|
|
472
|
+
}, { signal: r }), t.addEventListener("dragover", (s) => {
|
|
473
|
+
s.preventDefault();
|
|
474
|
+
const n = s.target.closest(".orderable-item"), c = n && n !== e ? n : null;
|
|
475
|
+
c !== o && (o == null || o.classList.remove("drag-over"), o = c, o == null || o.classList.add("drag-over"));
|
|
476
|
+
}, { signal: r }), t.addEventListener("drop", (s) => {
|
|
477
|
+
s.preventDefault();
|
|
478
|
+
const n = s.target.closest(".orderable-item");
|
|
479
|
+
if (!n || !e || n === e)
|
|
542
480
|
return;
|
|
543
|
-
n.
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
var d;
|
|
548
|
-
const c = o && s(n);
|
|
549
|
-
if (!o || !c || c === o)
|
|
550
|
-
return;
|
|
551
|
-
n.preventDefault();
|
|
552
|
-
const l = c.getBoundingClientRect(), a = n.clientY < l.top + l.height / 2;
|
|
553
|
-
(d = e.getDropParent(c)) == null || d.insertBefore(o, a ? c : c.nextSibling), i == null || i.classList.remove("drag-over"), o.classList.remove("dragging"), o = null, i = null, this._onReorder(this._extractCompositionOrder(t));
|
|
481
|
+
const c = n.getBoundingClientRect(), a = c.top + c.height / 2;
|
|
482
|
+
s.clientY < a ? t.insertBefore(e, n) : t.insertBefore(e, n.nextSibling), o == null || o.classList.remove("drag-over"), o = null, e.classList.remove("dragging");
|
|
483
|
+
const u = t.querySelectorAll(".orderable-item"), m = Array.from(u).map((b) => b.dataset.key).filter(Boolean);
|
|
484
|
+
this._onReorder(m), e = null;
|
|
554
485
|
}, { signal: r });
|
|
555
486
|
}
|
|
556
487
|
_setupDeleteHandler(t, r) {
|
|
557
488
|
t.addEventListener("click", (e) => {
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
489
|
+
const s = e.target.closest(".custom-attr-delete");
|
|
490
|
+
if (!s)
|
|
560
491
|
return;
|
|
561
|
-
const
|
|
492
|
+
const i = s.closest("[data-custom-index]"), n = i == null ? void 0 : i.dataset.customIndex;
|
|
562
493
|
n !== void 0 && this._onDeleteCustomAttribute(Number(n));
|
|
563
494
|
}, { signal: r });
|
|
564
495
|
}
|
|
@@ -566,10 +497,10 @@ class qt extends rt {
|
|
|
566
497
|
// Actions (Add, Delete, Reorder)
|
|
567
498
|
// ========================================================================
|
|
568
499
|
_onAddAttribute(t, r) {
|
|
569
|
-
const e = `${
|
|
500
|
+
const e = `${d}${t}`, o = this._readCompositionFromNode();
|
|
570
501
|
o.push(e);
|
|
571
|
-
const
|
|
572
|
-
this._updateBothAttributes(o,
|
|
502
|
+
const s = [...this._readCustomAttributesFromNode(), t];
|
|
503
|
+
this._updateBothAttributes(o, s), this._injectCustomAttributeHtml(t, r, e, o), this._renderOrderableItems(o, s), this._initializeCustomSelects(s), this._updateAddButtonState();
|
|
573
504
|
}
|
|
574
505
|
/**
|
|
575
506
|
* Removes a single custom attribute by its index in the customAttrs array.
|
|
@@ -579,8 +510,8 @@ class qt extends rt {
|
|
|
579
510
|
const r = this._readCustomAttributesFromNode();
|
|
580
511
|
if (r[t] === void 0)
|
|
581
512
|
return;
|
|
582
|
-
const o = this._readCompositionFromNode(),
|
|
583
|
-
this._updateBothAttributes(
|
|
513
|
+
const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((c, a) => a !== s), n = r.filter((c, a) => a !== t);
|
|
514
|
+
this._updateBothAttributes(i, n), this._removeCustomAttributeHtml(i), this._renderOrderableItems(i, n), this._initializeCustomSelects(n), this._updateAddButtonState();
|
|
584
515
|
}
|
|
585
516
|
/**
|
|
586
517
|
* Handles changing a custom attribute's selection via its inline _GuSelect.
|
|
@@ -590,21 +521,16 @@ class qt extends rt {
|
|
|
590
521
|
const e = this._readCustomAttributesFromNode(), o = e[t];
|
|
591
522
|
if (o === void 0 || o === r)
|
|
592
523
|
return;
|
|
593
|
-
const
|
|
594
|
-
n !== -1 && (
|
|
524
|
+
const s = `${d}${r}`, i = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(i, t);
|
|
525
|
+
n !== -1 && (i[n] = s), e[t] = r;
|
|
595
526
|
const c = this._getDisplayNameForAttribute(r);
|
|
596
|
-
this._updateBothAttributes(
|
|
527
|
+
this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r, c, s, i), this._renderOrderableItems(i, e), this._initializeCustomSelects(e);
|
|
597
528
|
}
|
|
598
529
|
_onReorder(t) {
|
|
599
|
-
const r = t.filter((e) => e.startsWith(
|
|
530
|
+
const r = t.filter((e) => e.startsWith(d)).map((e) => e.substring(d.length));
|
|
600
531
|
this.reorderInProgress = !0;
|
|
601
532
|
try {
|
|
602
|
-
this._updateBothAttributes(t, r);
|
|
603
|
-
const e = !P.getConfig(this.currentNode).priceMovedToNextLine;
|
|
604
|
-
this._getCurrentLayout() === "grid" && !e ? this._reorderProductAttributes(t) : this.currentNode && yt({
|
|
605
|
-
currentNode: this.currentNode,
|
|
606
|
-
documentModifier: this.api.getDocumentModifier()
|
|
607
|
-
});
|
|
533
|
+
this._updateBothAttributes(t, r), this._getCurrentLayout() === "grid" && this._reorderProductAttributes(t);
|
|
608
534
|
} finally {
|
|
609
535
|
this.reorderInProgress = !1;
|
|
610
536
|
}
|
|
@@ -619,61 +545,61 @@ class qt extends rt {
|
|
|
619
545
|
this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, r, e, o) : this._injectListAttributeRow(t, r, e, o);
|
|
620
546
|
}
|
|
621
547
|
_injectGridAttributeRow(t, r, e, o) {
|
|
622
|
-
const
|
|
623
|
-
if (!(
|
|
548
|
+
const s = this.currentNode.querySelectorAll(L);
|
|
549
|
+
if (!(s != null && s.length))
|
|
624
550
|
return;
|
|
625
|
-
const
|
|
626
|
-
let
|
|
627
|
-
|
|
628
|
-
var
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
631
|
-
const
|
|
632
|
-
{ length:
|
|
633
|
-
(
|
|
634
|
-
const
|
|
551
|
+
const i = $.getConfig(this.currentNode), c = `0 ${Math.floor(i.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), l = this.store.recommendationProducts.length;
|
|
552
|
+
let u = 0;
|
|
553
|
+
s.forEach((m) => {
|
|
554
|
+
var k;
|
|
555
|
+
const b = m.querySelector(A), I = ((k = b == null ? void 0 : b.querySelectorAll(`.${at}`)) == null ? void 0 : k.length) || 1, U = (100 / I).toFixed(2), { bgStyle: W, bgAttr: K } = this._extractSegmentBgFromCard(m), O = l > 0 ? Math.min(I, l - u) : I, z = o.map((q) => {
|
|
556
|
+
if (q === e) {
|
|
557
|
+
const G = Array.from(
|
|
558
|
+
{ length: O },
|
|
559
|
+
(At, X) => {
|
|
560
|
+
const J = this._resolveAttributeContent(
|
|
635
561
|
t,
|
|
636
562
|
r,
|
|
637
|
-
|
|
563
|
+
u + X
|
|
638
564
|
);
|
|
639
565
|
return this._getGridCellHtml(
|
|
640
566
|
t,
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
567
|
+
J,
|
|
568
|
+
U,
|
|
569
|
+
W,
|
|
570
|
+
K,
|
|
645
571
|
c
|
|
646
572
|
);
|
|
647
573
|
}
|
|
648
|
-
).join(""),
|
|
649
|
-
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${
|
|
574
|
+
).join(""), Y = dt(U, c).repeat(I - O);
|
|
575
|
+
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${N}="1">${G}${Y}</tr>`;
|
|
650
576
|
}
|
|
651
|
-
const
|
|
652
|
-
`${
|
|
577
|
+
const D = m.querySelector(
|
|
578
|
+
`${A}[${y}="${q}"]`
|
|
653
579
|
);
|
|
654
|
-
return
|
|
580
|
+
return D && "getOuterHTML" in D ? D.getOuterHTML() : "";
|
|
655
581
|
}).join("");
|
|
656
|
-
|
|
657
|
-
}),
|
|
582
|
+
u += O, l > 0 && u >= l && (u = 0), a.modifyHtml(m).setInnerHtml(z);
|
|
583
|
+
}), a.apply(new C(`${this.api.translate("Add custom attribute")}: ${r}`));
|
|
658
584
|
}
|
|
659
585
|
_injectListAttributeRow(t, r, e, o) {
|
|
660
|
-
const
|
|
661
|
-
if (!(
|
|
586
|
+
const s = this.currentNode.querySelectorAll(V);
|
|
587
|
+
if (!(s != null && s.length))
|
|
662
588
|
return;
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
667
|
-
const
|
|
668
|
-
return this._getListRowHtml(t,
|
|
589
|
+
const i = o.filter((c) => c !== B && c !== H), n = this.api.getDocumentModifier();
|
|
590
|
+
s.forEach((c, a) => {
|
|
591
|
+
const l = i.map((u) => {
|
|
592
|
+
if (u === e) {
|
|
593
|
+
const b = this._resolveAttributeContent(t, r, a);
|
|
594
|
+
return this._getListRowHtml(t, b, e);
|
|
669
595
|
}
|
|
670
|
-
const
|
|
671
|
-
`${
|
|
596
|
+
const m = c.querySelector(
|
|
597
|
+
`${A}[${y}="${u}"]`
|
|
672
598
|
);
|
|
673
|
-
return
|
|
599
|
+
return m && "getOuterHTML" in m ? m.getOuterHTML() : "";
|
|
674
600
|
}).join("");
|
|
675
|
-
n.modifyHtml(c).setInnerHtml(
|
|
676
|
-
}), n.apply(new
|
|
601
|
+
n.modifyHtml(c).setInnerHtml(l);
|
|
602
|
+
}), n.apply(new C(`${this.api.translate("Add custom attribute")}: ${r}`));
|
|
677
603
|
}
|
|
678
604
|
/**
|
|
679
605
|
* Removes a custom attribute by rebuilding product card content without it.
|
|
@@ -684,19 +610,19 @@ class qt extends rt {
|
|
|
684
610
|
return;
|
|
685
611
|
const r = this._getCurrentLayout(), e = this.api.getDocumentModifier();
|
|
686
612
|
if (r === "grid") {
|
|
687
|
-
const o = this.currentNode.querySelectorAll(
|
|
688
|
-
o == null || o.forEach((
|
|
689
|
-
const
|
|
690
|
-
e.modifyHtml(
|
|
613
|
+
const o = this.currentNode.querySelectorAll(L);
|
|
614
|
+
o == null || o.forEach((s) => {
|
|
615
|
+
const i = this._buildCompositionHtml(s, t);
|
|
616
|
+
e.modifyHtml(s).setInnerHtml(i);
|
|
691
617
|
});
|
|
692
618
|
} else {
|
|
693
|
-
const o = t.filter((
|
|
694
|
-
|
|
695
|
-
const n = this._buildCompositionHtml(
|
|
696
|
-
e.modifyHtml(
|
|
619
|
+
const o = t.filter((i) => i !== B && i !== H), s = this.currentNode.querySelectorAll(V);
|
|
620
|
+
s == null || s.forEach((i) => {
|
|
621
|
+
const n = this._buildCompositionHtml(i, o);
|
|
622
|
+
e.modifyHtml(i).setInnerHtml(n);
|
|
697
623
|
});
|
|
698
624
|
}
|
|
699
|
-
e.apply(new
|
|
625
|
+
e.apply(new C(this.api.translate("Remove custom attribute")));
|
|
700
626
|
}
|
|
701
627
|
// ========================================================================
|
|
702
628
|
// DOM Mutation (Block Root Attributes, Reorder)
|
|
@@ -709,7 +635,13 @@ class qt extends rt {
|
|
|
709
635
|
* producing a flicker on the custom attribute dropdowns.
|
|
710
636
|
*/
|
|
711
637
|
_updateBothAttributes(t, r) {
|
|
712
|
-
|
|
638
|
+
if (!this.currentNode)
|
|
639
|
+
return;
|
|
640
|
+
const e = {
|
|
641
|
+
...$.getConfig(this.currentNode),
|
|
642
|
+
composition: t
|
|
643
|
+
};
|
|
644
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(x, t.join(",")).setAttribute(F, JSON.stringify(r)).setNodeConfig(e).apply(new C(this.api.translate("Update card composition")));
|
|
713
645
|
}
|
|
714
646
|
/**
|
|
715
647
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -718,14 +650,14 @@ class qt extends rt {
|
|
|
718
650
|
_reorderProductAttributes(t) {
|
|
719
651
|
if (!this.currentNode)
|
|
720
652
|
return;
|
|
721
|
-
const r = this.currentNode.querySelectorAll(
|
|
653
|
+
const r = this.currentNode.querySelectorAll(L);
|
|
722
654
|
if (!(r != null && r.length))
|
|
723
655
|
return;
|
|
724
656
|
const e = this.api.getDocumentModifier();
|
|
725
657
|
r.forEach((o) => {
|
|
726
|
-
const
|
|
727
|
-
e.modifyHtml(o).setInnerHtml(
|
|
728
|
-
}), e.apply(new
|
|
658
|
+
const s = this._buildCompositionHtml(o, t);
|
|
659
|
+
e.modifyHtml(o).setInnerHtml(s);
|
|
660
|
+
}), e.apply(new C(this.api.translate("Reorder product attributes")));
|
|
729
661
|
}
|
|
730
662
|
/**
|
|
731
663
|
* Builds HTML string with attributes ordered according to composition.
|
|
@@ -733,8 +665,8 @@ class qt extends rt {
|
|
|
733
665
|
*/
|
|
734
666
|
_buildCompositionHtml(t, r) {
|
|
735
667
|
return r.reduce((e, o) => {
|
|
736
|
-
const
|
|
737
|
-
return
|
|
668
|
+
const s = t.querySelector(`${A}[${y}="${o}"]`);
|
|
669
|
+
return s && "getOuterHTML" in s ? e + s.getOuterHTML() : e;
|
|
738
670
|
}, "");
|
|
739
671
|
}
|
|
740
672
|
// ========================================================================
|
|
@@ -743,14 +675,19 @@ class qt extends rt {
|
|
|
743
675
|
_applyVisibilityToBlock(t, r) {
|
|
744
676
|
if (!this.currentNode)
|
|
745
677
|
return;
|
|
746
|
-
const e = this.currentNode.querySelectorAll(`${
|
|
678
|
+
const e = this.currentNode.querySelectorAll(`${A}[${y}="${t}"]`);
|
|
747
679
|
if (!(e != null && e.length))
|
|
748
680
|
return;
|
|
749
|
-
const o = r ? "1" : "0",
|
|
750
|
-
e.forEach((
|
|
751
|
-
const l =
|
|
752
|
-
n.modifyHtml(
|
|
753
|
-
})
|
|
681
|
+
const o = r ? "1" : "0", s = r ? this.api.translate("visible") : this.api.translate("hidden"), i = `${this.api.translate("Set visibility")}: ${t} → ${s}`, n = this.api.getDocumentModifier();
|
|
682
|
+
e.forEach((a) => {
|
|
683
|
+
const l = ft(a), u = r ? l : "none";
|
|
684
|
+
n.modifyHtml(a).setStyle("display", u).setAttribute(N, o);
|
|
685
|
+
});
|
|
686
|
+
const c = {
|
|
687
|
+
...$.getConfig(this.currentNode),
|
|
688
|
+
visibility: { ...this._readVisibilityFromRows(), [t]: r }
|
|
689
|
+
};
|
|
690
|
+
n.modifyHtml(this.currentNode).setNodeConfig(c), n.apply(new C(i));
|
|
754
691
|
}
|
|
755
692
|
// ========================================================================
|
|
756
693
|
// Utilities
|
|
@@ -763,7 +700,7 @@ class qt extends rt {
|
|
|
763
700
|
_findNthCustomKeyIndex(t, r) {
|
|
764
701
|
let e = 0;
|
|
765
702
|
for (let o = 0; o < t.length; o++)
|
|
766
|
-
if (t[o].startsWith(
|
|
703
|
+
if (t[o].startsWith(d)) {
|
|
767
704
|
if (e === r)
|
|
768
705
|
return o;
|
|
769
706
|
e++;
|
|
@@ -771,7 +708,7 @@ class qt extends rt {
|
|
|
771
708
|
return -1;
|
|
772
709
|
}
|
|
773
710
|
_getCurrentLayout() {
|
|
774
|
-
return this.store.recommendationConfigs.orientation ||
|
|
711
|
+
return this.store.recommendationConfigs.orientation || bt(this.currentNode);
|
|
775
712
|
}
|
|
776
713
|
/**
|
|
777
714
|
* Extracts background color properties from existing card elements.
|
|
@@ -783,18 +720,18 @@ class qt extends rt {
|
|
|
783
720
|
var o;
|
|
784
721
|
const r = t.querySelector(".product-card-segment");
|
|
785
722
|
if (r && "getAttribute" in r) {
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
723
|
+
const i = (r.getAttribute("style") || "").match(/background-color:\s*([^;]+)/);
|
|
724
|
+
if (i) {
|
|
788
725
|
const n = r.getAttribute("bgcolor") || "";
|
|
789
|
-
return { bgStyle: `background-color: ${
|
|
726
|
+
return { bgStyle: `background-color: ${i[1].trim()};`, bgAttr: n };
|
|
790
727
|
}
|
|
791
728
|
}
|
|
792
729
|
const e = (o = this.currentNode) == null ? void 0 : o.querySelector(".product-card-wrapper");
|
|
793
730
|
if (e && "getStyle" in e) {
|
|
794
|
-
const
|
|
795
|
-
if (
|
|
796
|
-
const
|
|
797
|
-
return { bgStyle: `background-color: ${
|
|
731
|
+
const s = e.getStyle("background-color");
|
|
732
|
+
if (s && s !== "transparent") {
|
|
733
|
+
const i = "getAttribute" in e && e.getAttribute("bgcolor") || "";
|
|
734
|
+
return { bgStyle: `background-color: ${s};`, bgAttr: i };
|
|
798
735
|
}
|
|
799
736
|
}
|
|
800
737
|
return { bgStyle: "", bgAttr: "" };
|
|
@@ -804,18 +741,17 @@ class qt extends rt {
|
|
|
804
741
|
return t ? t.querySelector("[data-card-composition-control]") : null;
|
|
805
742
|
}
|
|
806
743
|
/**
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
* disabled state.)
|
|
744
|
+
* Adds/removes orderable-disabled class based on layout orientation.
|
|
745
|
+
* List layout hides drag handles via CSS and disables draggable attribute
|
|
746
|
+
* to prevent native browser drag-and-drop from working without the handle.
|
|
811
747
|
*/
|
|
812
748
|
_updateOrderableState() {
|
|
813
|
-
const
|
|
814
|
-
if (!
|
|
749
|
+
const r = this._getCurrentLayout() === "list", e = this._getControlContainer();
|
|
750
|
+
if (!e)
|
|
815
751
|
return;
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
|
|
752
|
+
const o = e.querySelector("[data-composition-list]");
|
|
753
|
+
o && (o.classList.toggle("orderable-disabled", r), o.querySelectorAll(".orderable-item").forEach((s) => {
|
|
754
|
+
s.setAttribute("draggable", r ? "false" : "true");
|
|
819
755
|
}));
|
|
820
756
|
}
|
|
821
757
|
/**
|
|
@@ -823,11 +759,11 @@ class qt extends rt {
|
|
|
823
759
|
* or when all available filters have already been added (no unused attributes left).
|
|
824
760
|
*/
|
|
825
761
|
_updateAddButtonState() {
|
|
826
|
-
const t = this._readCustomAttributesFromNode(), r = t.length >=
|
|
762
|
+
const t = this._readCustomAttributesFromNode(), r = t.length >= _, e = new Set(t), o = this._getAddableFilters(), s = o.length > 0 && o.every((i) => e.has(i.attributeName));
|
|
827
763
|
this.api.setUIEAttribute(
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
r ||
|
|
764
|
+
j.ADD_ATTRIBUTE,
|
|
765
|
+
v.BUTTON.disabled,
|
|
766
|
+
r || s ? "true" : "false"
|
|
831
767
|
);
|
|
832
768
|
}
|
|
833
769
|
/**
|
|
@@ -857,7 +793,7 @@ class qt extends rt {
|
|
|
857
793
|
*/
|
|
858
794
|
_getDisplayNameForAttribute(t) {
|
|
859
795
|
const r = Object.values(this.store.filterList).find((e) => e.attributeName === t);
|
|
860
|
-
return r ? r.displayName :
|
|
796
|
+
return r ? r.displayName : ht(t);
|
|
861
797
|
}
|
|
862
798
|
/**
|
|
863
799
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -865,29 +801,29 @@ class qt extends rt {
|
|
|
865
801
|
*/
|
|
866
802
|
_resolveAttributeContent(t, r, e) {
|
|
867
803
|
var n;
|
|
868
|
-
const
|
|
869
|
-
return
|
|
804
|
+
const s = this.store.recommendationProducts[e], i = pt(t, this.store.filterList) ? s == null ? void 0 : s[t] : (n = s == null ? void 0 : s.product_attributes) == null ? void 0 : n[t];
|
|
805
|
+
return gt(i) ?? r;
|
|
870
806
|
}
|
|
871
|
-
_getGridCellHtml(t, r, e, o = "",
|
|
872
|
-
const n = `${
|
|
807
|
+
_getGridCellHtml(t, r, e, o = "", s = "", i = "") {
|
|
808
|
+
const n = `${d}${t}`, c = M(ct, [n], this.store.filterList), a = {
|
|
873
809
|
[t]: r,
|
|
874
810
|
product_attributes: { [t]: r }
|
|
875
811
|
};
|
|
876
|
-
let
|
|
877
|
-
return
|
|
878
|
-
`padding: ${
|
|
879
|
-
`padding: ${
|
|
880
|
-
)), o && (
|
|
812
|
+
let l = c[n](a);
|
|
813
|
+
return l = l.replace("<td", `<td width="${e}%"`), i && (l = l.replace(
|
|
814
|
+
`padding: ${ut}`,
|
|
815
|
+
`padding: ${i}`
|
|
816
|
+
)), o && (l = l.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${o}"`)), s && (l = l.replace(/border="0"/, `border="0" bgcolor="${s}"`)), l;
|
|
881
817
|
}
|
|
882
818
|
_getListRowHtml(t, r, e) {
|
|
883
|
-
const o =
|
|
819
|
+
const o = M(mt, [e], this.store.filterList), s = {
|
|
884
820
|
[t]: r,
|
|
885
821
|
product_attributes: { [t]: r }
|
|
886
|
-
}, n = o[e](
|
|
887
|
-
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${
|
|
822
|
+
}, n = o[e](s).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
823
|
+
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${N}="1">${n}</tr>`;
|
|
888
824
|
}
|
|
889
825
|
}
|
|
890
826
|
export {
|
|
891
|
-
|
|
892
|
-
|
|
827
|
+
yt as COMPOSITION_CONTROL_BLOCK_ID,
|
|
828
|
+
Ht as RecommendationCardCompositionControl
|
|
893
829
|
};
|