@useinsider/guido 3.8.1-beta.34bf80d → 3.8.1-beta.6c0ee3f
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 +8 -8
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +12 -15
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +15 -16
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +37 -42
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +37 -40
- package/dist/composables/useSave.js +14 -14
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +17 -26
- package/dist/extensions/Blocks/Recommendation/block.js +4 -1
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +154 -137
- package/dist/extensions/Blocks/Unsubscribe/block.js +37 -40
- package/dist/extensions/Blocks/Unsubscribe/control.js +16 -19
- package/dist/extensions/Blocks/controlFactories.js +76 -57
- package/dist/guido.css +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -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/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/controlFactories.d.ts +10 -1
- package/dist/src/stores/unsubscribe.d.ts +1 -11
- package/dist/stores/unsubscribe.js +7 -8
- package/package.json +1 -1
- package/dist/composables/usePreviewInteractionGuard.js +0 -17
- package/dist/src/composables/usePreviewInteractionGuard.d.ts +0 -3
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (p,
|
|
4
|
-
import { UIElementType as f, UEAttr as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_PRODUCT_IMAGE as
|
|
7
|
-
import { DEFAULT_COMPOSITION as P, DEFAULT_VISIBILITY 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
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 { toDisplayName as ht, isDefaultAttribute as pt, toDisplayableAttributeValue as
|
|
12
|
+
import { toDisplayName as ht, isDefaultAttribute as pt, toDisplayableAttributeValue as gt, buildElementRenderer as M } from "../../templates/utils.js";
|
|
13
13
|
import { getTableDisplayValue as ft } from "../../utils/tagName.js";
|
|
14
|
-
import { isPartnerManagedBlock as
|
|
15
|
-
const yt = "ui-elements-recommendation-card-composition",
|
|
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
29
|
T(this, "store", lt());
|
|
@@ -47,23 +47,23 @@ class Ut extends Z {
|
|
|
47
47
|
${this._GuToggle(`visibility_${l.key}`)}
|
|
48
48
|
</div>
|
|
49
49
|
`).join(""), r = Array.from(
|
|
50
|
-
{ length:
|
|
50
|
+
{ length: _ },
|
|
51
51
|
(l, u) => `
|
|
52
|
-
<div data-custom-select-key="${
|
|
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 = h.length +
|
|
60
|
+
).join(""), e = h.length + _, o = Array.from(
|
|
61
61
|
{ length: e },
|
|
62
62
|
(l, u) => `
|
|
63
63
|
<div data-reorder-icon-key="${E}${u}" style="display: none;">
|
|
64
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"
|
|
@@ -73,12 +73,12 @@ class Ut extends Z {
|
|
|
73
73
|
</div>
|
|
74
74
|
`
|
|
75
75
|
).join(""), s = Array.from(
|
|
76
|
-
{ length:
|
|
76
|
+
{ length: _ },
|
|
77
77
|
(l, u) => `
|
|
78
78
|
<div data-custom-delete-key="${R}${u}" style="display: none;">
|
|
79
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"
|
|
@@ -89,15 +89,15 @@ class Ut extends Z {
|
|
|
89
89
|
`
|
|
90
90
|
).join(""), i = "https://academy.insiderone.com/docs/new-editor-email-recommendation-block", n = this.api.translate(
|
|
91
91
|
"Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
|
|
92
|
-
),
|
|
92
|
+
), c = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
93
93
|
return `
|
|
94
94
|
<div class="recommendation-controls-container" data-card-composition-control>
|
|
95
95
|
<div class="container">
|
|
96
96
|
<p class="card-composition-description">
|
|
97
97
|
${n}
|
|
98
|
-
${
|
|
98
|
+
${c}
|
|
99
99
|
<!-- cspell:disable-next-line -->
|
|
100
|
-
<a href="${i}" target="_blank" rel="noopener noreferrer">${
|
|
100
|
+
<a href="${i}" target="_blank" rel="noopener noreferrer">${a}</a>.
|
|
101
101
|
</p>
|
|
102
102
|
</div>
|
|
103
103
|
|
|
@@ -120,7 +120,7 @@ class Ut extends Z {
|
|
|
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 Ut extends Z {
|
|
|
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) {
|
|
@@ -163,8 +163,8 @@ class Ut extends Z {
|
|
|
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
|
});
|
|
@@ -176,36 +176,42 @@ class Ut extends Z {
|
|
|
176
176
|
_readCompositionFromNode() {
|
|
177
177
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
178
178
|
return [...P];
|
|
179
|
-
const t = this.currentNode.getAttribute(
|
|
180
|
-
|
|
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
|
-
const t = this.currentNode.getAttribute(
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
const t = this.currentNode.getAttribute(F);
|
|
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), s = e.getAttribute(
|
|
214
|
+
const o = e.getAttribute(y), s = e.getAttribute(N);
|
|
209
215
|
o && s !== null && (r[o] = this._parseVisibilityValue(s));
|
|
210
216
|
}), r;
|
|
211
217
|
}
|
|
@@ -213,7 +219,7 @@ class Ut extends Z {
|
|
|
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
|
}
|
|
@@ -237,19 +243,19 @@ class Ut extends Z {
|
|
|
237
243
|
return !1;
|
|
238
244
|
const s = new Set(r);
|
|
239
245
|
let i = 0, n = 0;
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
const l = h.find((u) => u.key ===
|
|
246
|
+
const c = t.map((a) => {
|
|
247
|
+
if (Ct.has(a)) {
|
|
248
|
+
const l = h.find((u) => u.key === a);
|
|
243
249
|
return this._createBuiltInItemHtml(l, n++);
|
|
244
250
|
}
|
|
245
|
-
if (
|
|
246
|
-
const l =
|
|
251
|
+
if (a.startsWith(d)) {
|
|
252
|
+
const l = a.substring(d.length);
|
|
247
253
|
if (s.has(l))
|
|
248
|
-
return this._createCustomItemHtml(
|
|
254
|
+
return this._createCustomItemHtml(a, i++, n++);
|
|
249
255
|
}
|
|
250
256
|
return "";
|
|
251
257
|
}).join("");
|
|
252
|
-
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;
|
|
253
259
|
}
|
|
254
260
|
/**
|
|
255
261
|
* Attempts to reorder existing orderable-item elements to match the composition order.
|
|
@@ -261,27 +267,27 @@ class Ut extends Z {
|
|
|
261
267
|
const e = Array.from(t.querySelectorAll(".orderable-item"));
|
|
262
268
|
if (e.length !== r.length)
|
|
263
269
|
return !1;
|
|
264
|
-
const o = e.map((
|
|
270
|
+
const o = e.map((a) => a.dataset.key).filter(Boolean);
|
|
265
271
|
if (o.length !== r.length)
|
|
266
272
|
return !1;
|
|
267
273
|
const s = [...o].sort().join(","), i = [...r].sort().join(",");
|
|
268
|
-
if (s !== i || r.some((
|
|
274
|
+
if (s !== i || r.some((a) => a.startsWith(d)))
|
|
269
275
|
return !1;
|
|
270
276
|
const n = /* @__PURE__ */ new Map();
|
|
271
|
-
e.forEach((
|
|
272
|
-
const { key: l } =
|
|
277
|
+
e.forEach((a) => {
|
|
278
|
+
const { key: l } = a.dataset;
|
|
273
279
|
if (l) {
|
|
274
280
|
const u = n.get(l) || [];
|
|
275
|
-
u.push(
|
|
281
|
+
u.push(a), n.set(l, u);
|
|
276
282
|
}
|
|
277
283
|
});
|
|
278
|
-
const
|
|
279
|
-
return r.forEach((
|
|
280
|
-
const l = n.get(
|
|
284
|
+
const c = /* @__PURE__ */ new Map();
|
|
285
|
+
return r.forEach((a) => {
|
|
286
|
+
const l = n.get(a);
|
|
281
287
|
if (!l)
|
|
282
288
|
return;
|
|
283
|
-
const u =
|
|
284
|
-
|
|
289
|
+
const u = c.get(a) || 0;
|
|
290
|
+
c.set(a, u + 1), l[u] && t.appendChild(l[u]);
|
|
285
291
|
}), !0;
|
|
286
292
|
}
|
|
287
293
|
_createBuiltInItemHtml(t, r) {
|
|
@@ -329,8 +335,8 @@ class Ut extends Z {
|
|
|
329
335
|
_initializeCustomSelects(t) {
|
|
330
336
|
t.length !== 0 && setTimeout(() => {
|
|
331
337
|
t.forEach((r, e) => {
|
|
332
|
-
const o = `${
|
|
333
|
-
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 });
|
|
334
340
|
});
|
|
335
341
|
}, 0);
|
|
336
342
|
}
|
|
@@ -353,7 +359,7 @@ class Ut extends Z {
|
|
|
353
359
|
*/
|
|
354
360
|
_moveSelectsIntoItems(t, r) {
|
|
355
361
|
for (let e = 0; e < r; e++) {
|
|
356
|
-
const o = `${
|
|
362
|
+
const o = `${S}${e}`, s = t.querySelector(`[data-custom-select-key="${o}"]`), i = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
357
363
|
if (s && i) {
|
|
358
364
|
const n = s.querySelector("ue-select");
|
|
359
365
|
n && i.appendChild(n);
|
|
@@ -380,8 +386,8 @@ class Ut extends Z {
|
|
|
380
386
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
381
387
|
*/
|
|
382
388
|
_rescueSelectsToStore(t) {
|
|
383
|
-
for (let r = 0; r <
|
|
384
|
-
const e = `${
|
|
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}"]`);
|
|
385
391
|
if (s) {
|
|
386
392
|
const i = s.querySelector("ue-select");
|
|
387
393
|
i && o && o.appendChild(i);
|
|
@@ -406,7 +412,7 @@ class Ut extends Z {
|
|
|
406
412
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
407
413
|
*/
|
|
408
414
|
_rescueDeleteButtonsToStore(t) {
|
|
409
|
-
for (let r = 0; r <
|
|
415
|
+
for (let r = 0; r < _; r++) {
|
|
410
416
|
const e = `${R}${r}`, o = t.querySelector(`[data-custom-delete-key="${e}"]`), s = t.querySelector(`[data-custom-delete-slot="${r}"]`);
|
|
411
417
|
if (s) {
|
|
412
418
|
const i = s.querySelector("ue-button");
|
|
@@ -432,7 +438,7 @@ class Ut extends Z {
|
|
|
432
438
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
433
439
|
*/
|
|
434
440
|
_rescueReorderIconsToStore(t) {
|
|
435
|
-
const r = h.length +
|
|
441
|
+
const r = h.length + _;
|
|
436
442
|
for (let e = 0; e < r; e++) {
|
|
437
443
|
const o = `${E}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
|
|
438
444
|
if (i) {
|
|
@@ -458,24 +464,24 @@ class Ut extends Z {
|
|
|
458
464
|
_setupDragAndDrop(t, r) {
|
|
459
465
|
let e = null, o = null;
|
|
460
466
|
t.addEventListener("dragstart", (s) => {
|
|
461
|
-
var
|
|
467
|
+
var c;
|
|
462
468
|
const n = s.target.closest(".orderable-item");
|
|
463
|
-
n && (e = n, n.classList.add("dragging"), (
|
|
469
|
+
n && (e = n, n.classList.add("dragging"), (c = s.dataTransfer) == null || c.setData("text/plain", n.dataset.key || ""));
|
|
464
470
|
}, { signal: r }), t.addEventListener("dragend", () => {
|
|
465
471
|
e && e.classList.remove("dragging"), e = null, o == null || o.classList.remove("drag-over"), o = null;
|
|
466
472
|
}, { signal: r }), t.addEventListener("dragover", (s) => {
|
|
467
473
|
s.preventDefault();
|
|
468
|
-
const n = s.target.closest(".orderable-item"),
|
|
469
|
-
|
|
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"));
|
|
470
476
|
}, { signal: r }), t.addEventListener("drop", (s) => {
|
|
471
477
|
s.preventDefault();
|
|
472
478
|
const n = s.target.closest(".orderable-item");
|
|
473
479
|
if (!n || !e || n === e)
|
|
474
480
|
return;
|
|
475
|
-
const
|
|
476
|
-
s.clientY <
|
|
477
|
-
const u = t.querySelectorAll(".orderable-item"),
|
|
478
|
-
this._onReorder(
|
|
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;
|
|
479
485
|
}, { signal: r });
|
|
480
486
|
}
|
|
481
487
|
_setupDeleteHandler(t, r) {
|
|
@@ -491,7 +497,7 @@ class Ut extends Z {
|
|
|
491
497
|
// Actions (Add, Delete, Reorder)
|
|
492
498
|
// ========================================================================
|
|
493
499
|
_onAddAttribute(t, r) {
|
|
494
|
-
const e = `${
|
|
500
|
+
const e = `${d}${t}`, o = this._readCompositionFromNode();
|
|
495
501
|
o.push(e);
|
|
496
502
|
const s = [...this._readCustomAttributesFromNode(), t];
|
|
497
503
|
this._updateBothAttributes(o, s), this._injectCustomAttributeHtml(t, r, e, o), this._renderOrderableItems(o, s), this._initializeCustomSelects(s), this._updateAddButtonState();
|
|
@@ -504,7 +510,7 @@ class Ut extends Z {
|
|
|
504
510
|
const r = this._readCustomAttributesFromNode();
|
|
505
511
|
if (r[t] === void 0)
|
|
506
512
|
return;
|
|
507
|
-
const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((
|
|
513
|
+
const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((c, a) => a !== s), n = r.filter((c, a) => a !== t);
|
|
508
514
|
this._updateBothAttributes(i, n), this._removeCustomAttributeHtml(i), this._renderOrderableItems(i, n), this._initializeCustomSelects(n), this._updateAddButtonState();
|
|
509
515
|
}
|
|
510
516
|
/**
|
|
@@ -515,13 +521,13 @@ class Ut extends Z {
|
|
|
515
521
|
const e = this._readCustomAttributesFromNode(), o = e[t];
|
|
516
522
|
if (o === void 0 || o === r)
|
|
517
523
|
return;
|
|
518
|
-
const s = `${
|
|
524
|
+
const s = `${d}${r}`, i = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(i, t);
|
|
519
525
|
n !== -1 && (i[n] = s), e[t] = r;
|
|
520
|
-
const
|
|
521
|
-
this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r,
|
|
526
|
+
const c = this._getDisplayNameForAttribute(r);
|
|
527
|
+
this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r, c, s, i), this._renderOrderableItems(i, e), this._initializeCustomSelects(e);
|
|
522
528
|
}
|
|
523
529
|
_onReorder(t) {
|
|
524
|
-
const r = t.filter((e) => e.startsWith(
|
|
530
|
+
const r = t.filter((e) => e.startsWith(d)).map((e) => e.substring(d.length));
|
|
525
531
|
this.reorderInProgress = !0;
|
|
526
532
|
try {
|
|
527
533
|
this._updateBothAttributes(t, r), this._getCurrentLayout() === "grid" && this._reorderProductAttributes(t);
|
|
@@ -539,61 +545,61 @@ class Ut extends Z {
|
|
|
539
545
|
this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, r, e, o) : this._injectListAttributeRow(t, r, e, o);
|
|
540
546
|
}
|
|
541
547
|
_injectGridAttributeRow(t, r, e, o) {
|
|
542
|
-
const s = this.currentNode.querySelectorAll(
|
|
548
|
+
const s = this.currentNode.querySelectorAll(L);
|
|
543
549
|
if (!(s != null && s.length))
|
|
544
550
|
return;
|
|
545
|
-
const i =
|
|
551
|
+
const i = $.getConfig(this.currentNode), c = `0 ${Math.floor(i.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), l = this.store.recommendationProducts.length;
|
|
546
552
|
let u = 0;
|
|
547
|
-
s.forEach((
|
|
553
|
+
s.forEach((m) => {
|
|
548
554
|
var k;
|
|
549
|
-
const b =
|
|
550
|
-
if (
|
|
551
|
-
const
|
|
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(
|
|
552
558
|
{ length: O },
|
|
553
|
-
(
|
|
554
|
-
const
|
|
559
|
+
(At, X) => {
|
|
560
|
+
const J = this._resolveAttributeContent(
|
|
555
561
|
t,
|
|
556
562
|
r,
|
|
557
|
-
u +
|
|
563
|
+
u + X
|
|
558
564
|
);
|
|
559
565
|
return this._getGridCellHtml(
|
|
560
566
|
t,
|
|
561
|
-
|
|
567
|
+
J,
|
|
562
568
|
U,
|
|
563
|
-
j,
|
|
564
569
|
W,
|
|
565
|
-
|
|
570
|
+
K,
|
|
571
|
+
c
|
|
566
572
|
);
|
|
567
573
|
}
|
|
568
|
-
).join(""),
|
|
569
|
-
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>`;
|
|
570
576
|
}
|
|
571
|
-
const D =
|
|
572
|
-
`${
|
|
577
|
+
const D = m.querySelector(
|
|
578
|
+
`${A}[${y}="${q}"]`
|
|
573
579
|
);
|
|
574
580
|
return D && "getOuterHTML" in D ? D.getOuterHTML() : "";
|
|
575
581
|
}).join("");
|
|
576
|
-
u += O, l > 0 && u >= l && (u = 0),
|
|
577
|
-
}),
|
|
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}`));
|
|
578
584
|
}
|
|
579
585
|
_injectListAttributeRow(t, r, e, o) {
|
|
580
|
-
const s = this.currentNode.querySelectorAll(
|
|
586
|
+
const s = this.currentNode.querySelectorAll(V);
|
|
581
587
|
if (!(s != null && s.length))
|
|
582
588
|
return;
|
|
583
|
-
const i = o.filter((
|
|
584
|
-
s.forEach((
|
|
589
|
+
const i = o.filter((c) => c !== B && c !== H), n = this.api.getDocumentModifier();
|
|
590
|
+
s.forEach((c, a) => {
|
|
585
591
|
const l = i.map((u) => {
|
|
586
592
|
if (u === e) {
|
|
587
|
-
const b = this._resolveAttributeContent(t, r,
|
|
593
|
+
const b = this._resolveAttributeContent(t, r, a);
|
|
588
594
|
return this._getListRowHtml(t, b, e);
|
|
589
595
|
}
|
|
590
|
-
const
|
|
591
|
-
`${
|
|
596
|
+
const m = c.querySelector(
|
|
597
|
+
`${A}[${y}="${u}"]`
|
|
592
598
|
);
|
|
593
|
-
return
|
|
599
|
+
return m && "getOuterHTML" in m ? m.getOuterHTML() : "";
|
|
594
600
|
}).join("");
|
|
595
|
-
n.modifyHtml(
|
|
596
|
-
}), n.apply(new
|
|
601
|
+
n.modifyHtml(c).setInnerHtml(l);
|
|
602
|
+
}), n.apply(new C(`${this.api.translate("Add custom attribute")}: ${r}`));
|
|
597
603
|
}
|
|
598
604
|
/**
|
|
599
605
|
* Removes a custom attribute by rebuilding product card content without it.
|
|
@@ -604,19 +610,19 @@ class Ut extends Z {
|
|
|
604
610
|
return;
|
|
605
611
|
const r = this._getCurrentLayout(), e = this.api.getDocumentModifier();
|
|
606
612
|
if (r === "grid") {
|
|
607
|
-
const o = this.currentNode.querySelectorAll(
|
|
613
|
+
const o = this.currentNode.querySelectorAll(L);
|
|
608
614
|
o == null || o.forEach((s) => {
|
|
609
615
|
const i = this._buildCompositionHtml(s, t);
|
|
610
616
|
e.modifyHtml(s).setInnerHtml(i);
|
|
611
617
|
});
|
|
612
618
|
} else {
|
|
613
|
-
const o = t.filter((i) => i !==
|
|
619
|
+
const o = t.filter((i) => i !== B && i !== H), s = this.currentNode.querySelectorAll(V);
|
|
614
620
|
s == null || s.forEach((i) => {
|
|
615
621
|
const n = this._buildCompositionHtml(i, o);
|
|
616
622
|
e.modifyHtml(i).setInnerHtml(n);
|
|
617
623
|
});
|
|
618
624
|
}
|
|
619
|
-
e.apply(new
|
|
625
|
+
e.apply(new C(this.api.translate("Remove custom attribute")));
|
|
620
626
|
}
|
|
621
627
|
// ========================================================================
|
|
622
628
|
// DOM Mutation (Block Root Attributes, Reorder)
|
|
@@ -629,7 +635,13 @@ class Ut extends Z {
|
|
|
629
635
|
* producing a flicker on the custom attribute dropdowns.
|
|
630
636
|
*/
|
|
631
637
|
_updateBothAttributes(t, r) {
|
|
632
|
-
|
|
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")));
|
|
633
645
|
}
|
|
634
646
|
/**
|
|
635
647
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -638,14 +650,14 @@ class Ut extends Z {
|
|
|
638
650
|
_reorderProductAttributes(t) {
|
|
639
651
|
if (!this.currentNode)
|
|
640
652
|
return;
|
|
641
|
-
const r = this.currentNode.querySelectorAll(
|
|
653
|
+
const r = this.currentNode.querySelectorAll(L);
|
|
642
654
|
if (!(r != null && r.length))
|
|
643
655
|
return;
|
|
644
656
|
const e = this.api.getDocumentModifier();
|
|
645
657
|
r.forEach((o) => {
|
|
646
658
|
const s = this._buildCompositionHtml(o, t);
|
|
647
659
|
e.modifyHtml(o).setInnerHtml(s);
|
|
648
|
-
}), e.apply(new
|
|
660
|
+
}), e.apply(new C(this.api.translate("Reorder product attributes")));
|
|
649
661
|
}
|
|
650
662
|
/**
|
|
651
663
|
* Builds HTML string with attributes ordered according to composition.
|
|
@@ -653,7 +665,7 @@ class Ut extends Z {
|
|
|
653
665
|
*/
|
|
654
666
|
_buildCompositionHtml(t, r) {
|
|
655
667
|
return r.reduce((e, o) => {
|
|
656
|
-
const s = t.querySelector(`${
|
|
668
|
+
const s = t.querySelector(`${A}[${y}="${o}"]`);
|
|
657
669
|
return s && "getOuterHTML" in s ? e + s.getOuterHTML() : e;
|
|
658
670
|
}, "");
|
|
659
671
|
}
|
|
@@ -663,14 +675,19 @@ class Ut extends Z {
|
|
|
663
675
|
_applyVisibilityToBlock(t, r) {
|
|
664
676
|
if (!this.currentNode)
|
|
665
677
|
return;
|
|
666
|
-
const e = this.currentNode.querySelectorAll(`${
|
|
678
|
+
const e = this.currentNode.querySelectorAll(`${A}[${y}="${t}"]`);
|
|
667
679
|
if (!(e != null && e.length))
|
|
668
680
|
return;
|
|
669
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();
|
|
670
682
|
e.forEach((a) => {
|
|
671
|
-
const
|
|
672
|
-
n.modifyHtml(a).setStyle("display",
|
|
673
|
-
})
|
|
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));
|
|
674
691
|
}
|
|
675
692
|
// ========================================================================
|
|
676
693
|
// Utilities
|
|
@@ -683,7 +700,7 @@ class Ut extends Z {
|
|
|
683
700
|
_findNthCustomKeyIndex(t, r) {
|
|
684
701
|
let e = 0;
|
|
685
702
|
for (let o = 0; o < t.length; o++)
|
|
686
|
-
if (t[o].startsWith(
|
|
703
|
+
if (t[o].startsWith(d)) {
|
|
687
704
|
if (e === r)
|
|
688
705
|
return o;
|
|
689
706
|
e++;
|
|
@@ -742,10 +759,10 @@ class Ut extends Z {
|
|
|
742
759
|
* or when all available filters have already been added (no unused attributes left).
|
|
743
760
|
*/
|
|
744
761
|
_updateAddButtonState() {
|
|
745
|
-
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));
|
|
746
763
|
this.api.setUIEAttribute(
|
|
747
|
-
|
|
748
|
-
|
|
764
|
+
j.ADD_ATTRIBUTE,
|
|
765
|
+
v.BUTTON.disabled,
|
|
749
766
|
r || s ? "true" : "false"
|
|
750
767
|
);
|
|
751
768
|
}
|
|
@@ -768,7 +785,7 @@ class Ut extends Z {
|
|
|
768
785
|
* excluding default attributes already covered by built-in toggle items.
|
|
769
786
|
*/
|
|
770
787
|
_getAddableFilters() {
|
|
771
|
-
return Object.values(this.store.filterList).filter((t) => !(t.type === "defaultAttribute" &&
|
|
788
|
+
return Object.values(this.store.filterList).filter((t) => !(t.type === "defaultAttribute" && nt.has(t.attributeName)));
|
|
772
789
|
}
|
|
773
790
|
/**
|
|
774
791
|
* Looks up the display name for an attribute from the store's filterList.
|
|
@@ -785,28 +802,28 @@ class Ut extends Z {
|
|
|
785
802
|
_resolveAttributeContent(t, r, e) {
|
|
786
803
|
var n;
|
|
787
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];
|
|
788
|
-
return
|
|
805
|
+
return gt(i) ?? r;
|
|
789
806
|
}
|
|
790
807
|
_getGridCellHtml(t, r, e, o = "", s = "", i = "") {
|
|
791
|
-
const n = `${
|
|
808
|
+
const n = `${d}${t}`, c = M(ct, [n], this.store.filterList), a = {
|
|
792
809
|
[t]: r,
|
|
793
810
|
product_attributes: { [t]: r }
|
|
794
811
|
};
|
|
795
|
-
let l =
|
|
812
|
+
let l = c[n](a);
|
|
796
813
|
return l = l.replace("<td", `<td width="${e}%"`), i && (l = l.replace(
|
|
797
814
|
`padding: ${ut}`,
|
|
798
815
|
`padding: ${i}`
|
|
799
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;
|
|
800
817
|
}
|
|
801
818
|
_getListRowHtml(t, r, e) {
|
|
802
|
-
const o =
|
|
819
|
+
const o = M(mt, [e], this.store.filterList), s = {
|
|
803
820
|
[t]: r,
|
|
804
821
|
product_attributes: { [t]: r }
|
|
805
822
|
}, n = o[e](s).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
806
|
-
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${
|
|
823
|
+
return `<tr class="recommendation-attribute-row" ${y}="${e}" ${N}="1">${n}</tr>`;
|
|
807
824
|
}
|
|
808
825
|
}
|
|
809
826
|
export {
|
|
810
827
|
yt as COMPOSITION_CONTROL_BLOCK_ID,
|
|
811
|
-
|
|
828
|
+
Ht as RecommendationCardCompositionControl
|
|
812
829
|
};
|