@useinsider/guido 3.17.0-beta.ec8eabb → 3.17.0-beta.edf4165
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/README.md +1 -0
- package/dist/@types/config/schemas.js +7 -6
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +100 -97
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
- package/dist/components/organisms/header/EditorActions.vue.js +1 -1
- package/dist/components/organisms/header/EditorActions.vue2.js +36 -44
- package/dist/composables/useActionsApi.js +67 -82
- package/dist/composables/useAutoSave.js +26 -31
- package/dist/composables/useCustomInterfaceAppearance.js +52 -38
- package/dist/composables/useGuidoStateBridge.js +30 -31
- package/dist/composables/useRecommendation.js +41 -34
- package/dist/composables/useSave.js +36 -40
- package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
- package/dist/config/migrator/recommendationMigrator.js +5 -4
- package/dist/enums/academy.js +2 -1
- package/dist/enums/date.js +5 -3
- package/dist/enums/extensions/recommendationBlock.js +3 -1
- package/dist/extensions/Blocks/Recommendation/block.js +26 -21
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +162 -166
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
- package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +165 -79
- package/dist/extensions/Blocks/common-control.js +22 -19
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +69 -30
- package/dist/src/@types/config/schemas.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
- package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/date.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +2 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +10 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +150 -10
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
- package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
- package/dist/src/services/recommendationApi.d.ts +4 -1
- package/dist/src/stores/config.d.ts +18 -0
- package/dist/src/stores/save-as-template.d.ts +4 -3
- package/dist/src/utils/genericUtil.d.ts +5 -0
- package/dist/static/assets/icons/line-change.svg.js +5 -0
- package/dist/static/assets/icons/line-delete.svg.js +5 -0
- package/dist/static/assets/icons/line-plus.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
- package/dist/utils/dateUtil.js +23 -10
- package/dist/utils/genericUtil.js +28 -27
- package/dist/utils/templatePreparation.js +35 -34
- package/package.json +2 -1
- package/dist/composables/useEditorLock.js +0 -18
- package/dist/src/composables/useEditorLock.d.ts +0 -11
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
var ot = Object.defineProperty;
|
|
2
2
|
var st = (h, p, t) => p in h ? ot(h, p, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[p] = t;
|
|
3
3
|
var $ = (h, p, t) => st(h, typeof p != "symbol" ? p + "" : p, t);
|
|
4
|
+
import { ACADEMY_LINKS as nt } from "../../../../../enums/academy.js";
|
|
4
5
|
import { UIElementType as g, UEAttr as N, ModificationDescription as A } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_PRODUCT_IMAGE as B, ATTR_PRODUCT_NAME as
|
|
6
|
+
import { CommonControl as lt } from "../../../common-control.js";
|
|
7
|
+
import { ATTR_PRODUCT_IMAGE as B, ATTR_PRODUCT_NAME as at, ATTR_PRODUCT_PRICE as C, ATTR_PRODUCT_OLD_PRICE as v, ATTR_PRODUCT_OMNIBUS_PRICE as ct, ATTR_PRODUCT_OMNIBUS_DISCOUNT as ut, ATTR_PRODUCT_BUTTON as q, ATTR_DATA_CARD_COMPOSITION as V, ATTR_DATA_CUSTOM_ATTRIBUTES as j, ATTR_CUSTOM_PREFIX as I, SELECTOR_ATTRIBUTE_ROW as E, ATTR_DATA_ATTRIBUTE_TYPE as R, BUILT_IN_DEFAULT_ATTRIBUTES as dt } from "../../constants/selectors.js";
|
|
7
8
|
import { DEFAULT_COMPOSITION as K, DEFAULT_VISIBILITY as W } from "../../constants/defaultConfig.js";
|
|
8
9
|
import { RecommendationConfigService as _ } from "../../services/configService.js";
|
|
9
|
-
import { useRecommendationExtensionStore as
|
|
10
|
-
import { ATTRIBUTE_CELL_CLASS as
|
|
10
|
+
import { useRecommendationExtensionStore as mt } from "../../store/recommendation.js";
|
|
11
|
+
import { ATTRIBUTE_CELL_CLASS as ht, gridElementRenderer as pt, DEFAULT_CELL_PADDING as gt, buildFillerCell as ft } from "../../templates/grid/elementRenderer.js";
|
|
11
12
|
import { listElementRenderer as bt } from "../../templates/list/elementRenderer.js";
|
|
12
|
-
import { resolveInlinePriceOrder as
|
|
13
|
-
import { normalizeCompositionKeys as
|
|
14
|
-
import { getTableDisplayValue as
|
|
15
|
-
import { isPartnerManagedBlock as
|
|
16
|
-
const
|
|
13
|
+
import { resolveInlinePriceOrder as _t, toDisplayName as yt, toDisplayableAttributeValue as Ct, buildElementRenderer as z } from "../../templates/utils.js";
|
|
14
|
+
import { normalizeCompositionKeys as St, normalizeCustomAttrValues as At, compositionKeyToProductAttr as w, resolveRowCompositionKey as Tt, filterToProductAttrValue as y, findAttributeRow as $t, rewriteLegacyRowKeyHtml as G, bareAttributeName as D, isDefaultProductAttr as It, productAttrToCompositionKey as U } from "../../utils/compositionKeys.js";
|
|
15
|
+
import { getTableDisplayValue as vt } from "../../utils/tagName.js";
|
|
16
|
+
import { isPartnerManagedBlock as Nt, regenerateProductRowsWithStyles as Et, getCurrentLayout as Rt } from "../main/utils.js";
|
|
17
|
+
const Dt = "ui-elements-recommendation-card-composition", k = ".product-card-wrapper > tbody", Y = ".product-info-cell > table > tbody", O = "data-visibility", X = {
|
|
17
18
|
ADD_ATTRIBUTE: "addAttribute"
|
|
18
|
-
},
|
|
19
|
+
}, f = 5, L = "reorderIcon_", Ot = '<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 = [
|
|
19
20
|
{ key: B, label: "Product Image" },
|
|
20
|
-
{ key:
|
|
21
|
+
{ key: at, label: "Product Name" },
|
|
21
22
|
{ key: C, label: "Product Price" },
|
|
22
23
|
{ key: v, label: "Product Original Price" },
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
24
|
+
{ key: ct, label: "Omnibus Price" },
|
|
25
|
+
{ key: ut, label: "Omnibus Discount" },
|
|
25
26
|
{ key: q, label: "Product Button" }
|
|
26
|
-
],
|
|
27
|
-
class
|
|
27
|
+
], Lt = new Set(m.map((h) => h.key)), T = "customAttr_", P = "deleteAttr_";
|
|
28
|
+
class Gt extends lt {
|
|
28
29
|
constructor() {
|
|
29
30
|
super(...arguments);
|
|
30
|
-
$(this, "store",
|
|
31
|
+
$(this, "store", mt());
|
|
31
32
|
$(this, "unsubscribeStore", null);
|
|
32
33
|
$(this, "eventController", null);
|
|
33
34
|
/**
|
|
@@ -37,19 +38,19 @@ class Wt extends nt {
|
|
|
37
38
|
$(this, "reorderInProgress", !1);
|
|
38
39
|
}
|
|
39
40
|
getId() {
|
|
40
|
-
return
|
|
41
|
+
return Dt;
|
|
41
42
|
}
|
|
42
43
|
// ========================================================================
|
|
43
44
|
// Lifecycle
|
|
44
45
|
// ========================================================================
|
|
45
46
|
getTemplate() {
|
|
46
|
-
const t = m.map((
|
|
47
|
-
<div data-toggle-key="${
|
|
48
|
-
${this._GuToggle(`visibility_${
|
|
47
|
+
const t = m.map((u) => `
|
|
48
|
+
<div data-toggle-key="${u.key}" style="display: none;">
|
|
49
|
+
${this._GuToggle(`visibility_${u.key}`)}
|
|
49
50
|
</div>
|
|
50
51
|
`).join(""), e = Array.from(
|
|
51
|
-
{ length:
|
|
52
|
-
(
|
|
52
|
+
{ length: f },
|
|
53
|
+
(u, c) => `
|
|
53
54
|
<div data-custom-select-key="${T}${c}" style="display: none;">
|
|
54
55
|
${this._GuSelect({
|
|
55
56
|
name: `${T}${c}`,
|
|
@@ -60,9 +61,9 @@ class Wt extends nt {
|
|
|
60
61
|
})}
|
|
61
62
|
</div>
|
|
62
63
|
`
|
|
63
|
-
).join(""), r = m.length +
|
|
64
|
+
).join(""), r = m.length + f, i = Array.from(
|
|
64
65
|
{ length: r },
|
|
65
|
-
(
|
|
66
|
+
(u, c) => `
|
|
66
67
|
<div data-reorder-icon-key="${L}${c}" style="display: none;">
|
|
67
68
|
<${g.BUTTON}
|
|
68
69
|
class="drag-handle-btn flat-inline flat-white"
|
|
@@ -76,8 +77,8 @@ class Wt extends nt {
|
|
|
76
77
|
</div>
|
|
77
78
|
`
|
|
78
79
|
).join(""), o = Array.from(
|
|
79
|
-
{ length:
|
|
80
|
-
(
|
|
80
|
+
{ length: f },
|
|
81
|
+
(u, c) => `
|
|
81
82
|
<div data-custom-delete-key="${P}${c}" style="display: none;">
|
|
82
83
|
<${g.BUTTON}
|
|
83
84
|
class="custom-attr-delete flat-inline flat-white"
|
|
@@ -90,7 +91,7 @@ class Wt extends nt {
|
|
|
90
91
|
</${g.BUTTON}>
|
|
91
92
|
</div>
|
|
92
93
|
`
|
|
93
|
-
).join(""), s =
|
|
94
|
+
).join(""), s = nt.EMAIL_RECOMMENDATION_BLOCK, n = this.api.translate(
|
|
94
95
|
"Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
|
|
95
96
|
), l = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
96
97
|
return `
|
|
@@ -144,7 +145,7 @@ class Wt extends nt {
|
|
|
144
145
|
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector("[data-card-composition-control]");
|
|
145
146
|
if (!t)
|
|
146
147
|
return;
|
|
147
|
-
const e =
|
|
148
|
+
const e = Nt(this.currentNode);
|
|
148
149
|
t.style.pointerEvents = e ? "none" : "", t.style.opacity = e ? "0.5" : "";
|
|
149
150
|
}
|
|
150
151
|
onTemplateNodeUpdated(t) {
|
|
@@ -166,7 +167,7 @@ class Wt extends nt {
|
|
|
166
167
|
this._applyVisibilityToBlock(t.key, e);
|
|
167
168
|
});
|
|
168
169
|
});
|
|
169
|
-
for (let t = 0; t <
|
|
170
|
+
for (let t = 0; t < f; t++) {
|
|
170
171
|
const e = `${T}${t}`, r = t;
|
|
171
172
|
this.api.onValueChanged(e, (i) => {
|
|
172
173
|
this._onCustomAttributeChanged(r, i);
|
|
@@ -187,7 +188,7 @@ class Wt extends nt {
|
|
|
187
188
|
}
|
|
188
189
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
189
190
|
_normalizeComposition(t) {
|
|
190
|
-
return
|
|
191
|
+
return St(t, this.currentNode, this.store.filterList);
|
|
191
192
|
}
|
|
192
193
|
_readCustomAttributesFromNode() {
|
|
193
194
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
@@ -195,7 +196,7 @@ class Wt extends nt {
|
|
|
195
196
|
const t = this.currentNode.getAttribute(j);
|
|
196
197
|
if (t)
|
|
197
198
|
try {
|
|
198
|
-
return
|
|
199
|
+
return At(
|
|
199
200
|
JSON.parse(t).map((e) => String(e)),
|
|
200
201
|
this.currentNode,
|
|
201
202
|
this.store.filterList
|
|
@@ -208,7 +209,7 @@ class Wt extends nt {
|
|
|
208
209
|
_readVisibilityFromRows() {
|
|
209
210
|
if (!this.currentNode)
|
|
210
211
|
return this._getDefaultVisibilities();
|
|
211
|
-
const t = Array.from(this.currentNode.querySelectorAll(
|
|
212
|
+
const t = Array.from(this.currentNode.querySelectorAll(E)), e = this._extractVisibilityFromRows(t);
|
|
212
213
|
if (Object.keys(e).length > 0)
|
|
213
214
|
return this._mergeWithDefaults(e);
|
|
214
215
|
const r = _.getConfig(this.currentNode).visibility;
|
|
@@ -222,7 +223,7 @@ class Wt extends nt {
|
|
|
222
223
|
return t.forEach((r) => {
|
|
223
224
|
if (!("getAttribute" in r))
|
|
224
225
|
return;
|
|
225
|
-
const i =
|
|
226
|
+
const i = Tt(r), o = r.getAttribute(O);
|
|
226
227
|
i && o !== null && (e[i] = this._parseVisibilityValue(o));
|
|
227
228
|
}), e;
|
|
228
229
|
}
|
|
@@ -256,23 +257,23 @@ class Wt extends nt {
|
|
|
256
257
|
if (!(i.dataset.inlinePrices !== String(o)) && this._tryReorderInPlace(i, t))
|
|
257
258
|
return !1;
|
|
258
259
|
i.dataset.inlinePrices = String(o);
|
|
259
|
-
const n = new Set(e), l =
|
|
260
|
-
let a = 0,
|
|
261
|
-
const c = t.map((
|
|
262
|
-
if (o && (
|
|
263
|
-
return
|
|
264
|
-
if (
|
|
265
|
-
const
|
|
266
|
-
return this._createBuiltInItemHtml(
|
|
260
|
+
const n = new Set(e), l = _t(t);
|
|
261
|
+
let a = 0, u = 0;
|
|
262
|
+
const c = t.map((d) => {
|
|
263
|
+
if (o && (d === C || d === v))
|
|
264
|
+
return d === l.anchor ? this._createPriceGroupItemHtml(u++, l.originalFirst) : "";
|
|
265
|
+
if (Lt.has(d)) {
|
|
266
|
+
const b = m.find((S) => S.key === d);
|
|
267
|
+
return this._createBuiltInItemHtml(b, u++);
|
|
267
268
|
}
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
270
|
-
if (n.has(
|
|
271
|
-
return this._createCustomItemHtml(
|
|
269
|
+
if (d.startsWith(I)) {
|
|
270
|
+
const b = w(d);
|
|
271
|
+
if (n.has(b))
|
|
272
|
+
return this._createCustomItemHtml(d, a++, u++);
|
|
272
273
|
}
|
|
273
274
|
return "";
|
|
274
275
|
}).join("");
|
|
275
|
-
return this._rescueTogglesToStore(r), this._rescueSelectsToStore(r), this._rescueDeleteButtonsToStore(r), this._rescueReorderIconsToStore(r), i.innerHTML = c, this._moveTogglesIntoItems(r), this._moveSelectsIntoItems(r, e.length), this._moveDeleteButtonsIntoItems(r, e.length), this._moveReorderIconsIntoItems(r,
|
|
276
|
+
return this._rescueTogglesToStore(r), this._rescueSelectsToStore(r), this._rescueDeleteButtonsToStore(r), this._rescueReorderIconsToStore(r), i.innerHTML = c, this._moveTogglesIntoItems(r), this._moveSelectsIntoItems(r, e.length), this._moveDeleteButtonsIntoItems(r, e.length), this._moveReorderIconsIntoItems(r, u), !0;
|
|
276
277
|
}
|
|
277
278
|
/**
|
|
278
279
|
* Attempts to reorder existing orderable-item elements to match the composition order.
|
|
@@ -292,19 +293,19 @@ class Wt extends nt {
|
|
|
292
293
|
return !1;
|
|
293
294
|
const n = /* @__PURE__ */ new Map();
|
|
294
295
|
r.forEach((a) => {
|
|
295
|
-
const { key:
|
|
296
|
-
if (
|
|
297
|
-
const c = n.get(
|
|
298
|
-
c.push(a), n.set(
|
|
296
|
+
const { key: u } = a.dataset;
|
|
297
|
+
if (u) {
|
|
298
|
+
const c = n.get(u) || [];
|
|
299
|
+
c.push(a), n.set(u, c);
|
|
299
300
|
}
|
|
300
301
|
});
|
|
301
302
|
const l = /* @__PURE__ */ new Map();
|
|
302
303
|
return e.forEach((a) => {
|
|
303
|
-
const
|
|
304
|
-
if (!
|
|
304
|
+
const u = n.get(a);
|
|
305
|
+
if (!u)
|
|
305
306
|
return;
|
|
306
307
|
const c = l.get(a) || 0;
|
|
307
|
-
l.set(a, c + 1),
|
|
308
|
+
l.set(a, c + 1), u[c] && t.appendChild(u[c]);
|
|
308
309
|
}), !0;
|
|
309
310
|
}
|
|
310
311
|
_createBuiltInItemHtml(t, e) {
|
|
@@ -326,10 +327,10 @@ class Wt extends nt {
|
|
|
326
327
|
*/
|
|
327
328
|
_createPriceGroupItemHtml(t, e) {
|
|
328
329
|
var n, l;
|
|
329
|
-
const r = ((n = m.find((a) => a.key === C)) == null ? void 0 : n.label) ?? "Product Price", i = ((l = m.find((a) => a.key === v)) == null ? void 0 : l.label) ?? "Product Original Price", o = (a,
|
|
330
|
+
const r = ((n = m.find((a) => a.key === C)) == null ? void 0 : n.label) ?? "Product Price", i = ((l = m.find((a) => a.key === v)) == null ? void 0 : l.label) ?? "Product Original Price", o = (a, u) => `
|
|
330
331
|
<div class="price-suborderable-item" draggable="true" data-subkey="${a}">
|
|
331
|
-
<span class="sub-drag-handle">${
|
|
332
|
-
<span class="item-label">${this.api.translate(
|
|
332
|
+
<span class="sub-drag-handle">${Ot}</span>
|
|
333
|
+
<span class="item-label">${this.api.translate(u)}</span>
|
|
333
334
|
</div>`, s = e ? o(v, i) + o(C, r) : o(C, r) + o(v, i);
|
|
334
335
|
return `
|
|
335
336
|
<div class="orderable-item price-group-item" draggable="true"
|
|
@@ -445,7 +446,7 @@ class Wt extends nt {
|
|
|
445
446
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
446
447
|
*/
|
|
447
448
|
_rescueSelectsToStore(t) {
|
|
448
|
-
for (let e = 0; e <
|
|
449
|
+
for (let e = 0; e < f; e++) {
|
|
449
450
|
const r = `${T}${e}`, i = t.querySelector(`[data-custom-select-key="${r}"]`), o = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
450
451
|
if (o) {
|
|
451
452
|
const s = o.querySelector("ue-select");
|
|
@@ -471,7 +472,7 @@ class Wt extends nt {
|
|
|
471
472
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
472
473
|
*/
|
|
473
474
|
_rescueDeleteButtonsToStore(t) {
|
|
474
|
-
for (let e = 0; e <
|
|
475
|
+
for (let e = 0; e < f; e++) {
|
|
475
476
|
const r = `${P}${e}`, i = t.querySelector(`[data-custom-delete-key="${r}"]`), o = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
476
477
|
if (o) {
|
|
477
478
|
const s = o.querySelector("ue-button");
|
|
@@ -497,7 +498,7 @@ class Wt extends nt {
|
|
|
497
498
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
498
499
|
*/
|
|
499
500
|
_rescueReorderIconsToStore(t) {
|
|
500
|
-
const e = m.length +
|
|
501
|
+
const e = m.length + f;
|
|
501
502
|
for (let r = 0; r < e; r++) {
|
|
502
503
|
const i = `${L}${r}`, o = t.querySelector(`[data-reorder-icon-key="${i}"]`), s = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
503
504
|
if (s) {
|
|
@@ -558,12 +559,12 @@ class Wt extends nt {
|
|
|
558
559
|
let i = null, o = null;
|
|
559
560
|
const s = (n) => n.target.closest(r.itemSelector);
|
|
560
561
|
t.addEventListener("dragstart", (n) => {
|
|
561
|
-
var
|
|
562
|
+
var u;
|
|
562
563
|
const l = n.target;
|
|
563
564
|
if (r.ignoreSelector && l.closest(r.ignoreSelector))
|
|
564
565
|
return;
|
|
565
566
|
const a = s(n);
|
|
566
|
-
a && (i = a, a.classList.add("dragging"), (
|
|
567
|
+
a && (i = a, a.classList.add("dragging"), (u = n.dataTransfer) == null || u.setData("text/plain", a.dataset.key ?? a.dataset.subkey ?? ""));
|
|
567
568
|
}, { signal: e }), t.addEventListener("dragend", () => {
|
|
568
569
|
i == null || i.classList.remove("dragging"), o == null || o.classList.remove("drag-over"), i = null, o = null;
|
|
569
570
|
}, { signal: e }), t.addEventListener("dragover", (n) => {
|
|
@@ -581,8 +582,8 @@ class Wt extends nt {
|
|
|
581
582
|
if (!i || !l || l === i)
|
|
582
583
|
return;
|
|
583
584
|
n.preventDefault();
|
|
584
|
-
const a = l.getBoundingClientRect(),
|
|
585
|
-
(c = r.getDropParent(l)) == null || c.insertBefore(i,
|
|
585
|
+
const a = l.getBoundingClientRect(), u = n.clientY < a.top + a.height / 2;
|
|
586
|
+
(c = r.getDropParent(l)) == null || c.insertBefore(i, u ? l : l.nextSibling), o == null || o.classList.remove("drag-over"), i.classList.remove("dragging"), i = null, o = null, this._onReorder(this._extractCompositionOrder(t));
|
|
586
587
|
}, { signal: e });
|
|
587
588
|
}
|
|
588
589
|
_setupDeleteHandler(t, e) {
|
|
@@ -598,7 +599,7 @@ class Wt extends nt {
|
|
|
598
599
|
// Actions (Add, Delete, Reorder)
|
|
599
600
|
// ========================================================================
|
|
600
601
|
_onAddAttribute(t, e) {
|
|
601
|
-
const r =
|
|
602
|
+
const r = U(t), i = this._readCompositionFromNode();
|
|
602
603
|
i.push(r);
|
|
603
604
|
const o = [...this._readCustomAttributesFromNode(), t];
|
|
604
605
|
this._updateBothAttributes(i, o), this._injectCustomAttributeHtml(t, e, r, i), this._renderOrderableItems(i, o), this._initializeCustomSelects(o), this._updateAddButtonState();
|
|
@@ -622,7 +623,7 @@ class Wt extends nt {
|
|
|
622
623
|
const r = this._readCustomAttributesFromNode(), i = r[t];
|
|
623
624
|
if (i === void 0 || i === e)
|
|
624
625
|
return;
|
|
625
|
-
const o =
|
|
626
|
+
const o = U(e), s = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(s, t);
|
|
626
627
|
n !== -1 && (s[n] = o), r[t] = e;
|
|
627
628
|
const l = this._getDisplayNameForAttribute(e);
|
|
628
629
|
this._updateBothAttributes(s, r), this._injectCustomAttributeHtml(e, l, o, s), this._renderOrderableItems(s, r), this._initializeCustomSelects(r);
|
|
@@ -633,7 +634,7 @@ class Wt extends nt {
|
|
|
633
634
|
try {
|
|
634
635
|
this._updateBothAttributes(t, e);
|
|
635
636
|
const r = !_.getConfig(this.currentNode).priceMovedToNextLine;
|
|
636
|
-
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode &&
|
|
637
|
+
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && Et({
|
|
637
638
|
currentNode: this.currentNode,
|
|
638
639
|
documentModifier: this.api.getDocumentModifier()
|
|
639
640
|
});
|
|
@@ -651,11 +652,11 @@ class Wt extends nt {
|
|
|
651
652
|
* DOM converge on the next composition change without writing on open.
|
|
652
653
|
*/
|
|
653
654
|
_getExistingRowHtml(t, e) {
|
|
654
|
-
const r =
|
|
655
|
+
const r = $t(t, e);
|
|
655
656
|
if (r && "getOuterHTML" in r)
|
|
656
657
|
return G(r.getOuterHTML(), e);
|
|
657
658
|
const i = t.querySelector(
|
|
658
|
-
`${
|
|
659
|
+
`${E}[${R}="${e}"]`
|
|
659
660
|
);
|
|
660
661
|
return i && "getOuterHTML" in i ? G(i.getOuterHTML(), e) : "";
|
|
661
662
|
}
|
|
@@ -665,18 +666,18 @@ class Wt extends nt {
|
|
|
665
666
|
this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, e, r, i) : this._injectListAttributeRow(t, e, r, i);
|
|
666
667
|
}
|
|
667
668
|
_injectGridAttributeRow(t, e, r, i) {
|
|
668
|
-
const o = this.currentNode.querySelectorAll(
|
|
669
|
+
const o = this.currentNode.querySelectorAll(k);
|
|
669
670
|
if (!(o != null && o.length))
|
|
670
671
|
return;
|
|
671
|
-
const s = _.getConfig(this.currentNode), l = `0 ${Math.floor(s.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(),
|
|
672
|
+
const s = _.getConfig(this.currentNode), l = `0 ${Math.floor(s.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), u = this.store.recommendationProducts.length;
|
|
672
673
|
let c = 0;
|
|
673
|
-
o.forEach((
|
|
674
|
+
o.forEach((d) => {
|
|
674
675
|
var F;
|
|
675
|
-
const
|
|
676
|
+
const b = d.querySelector(E), S = ((F = b == null ? void 0 : b.querySelectorAll(`.${ht}`)) == null ? void 0 : F.length) || 1, x = (100 / S).toFixed(2), { bgStyle: J, bgAttr: Q } = this._extractSegmentBgFromCard(d), H = u > 0 ? Math.min(S, u - c) : S, Z = i.map((M) => {
|
|
676
677
|
if (M === r) {
|
|
677
678
|
const tt = Array.from(
|
|
678
679
|
{ length: H },
|
|
679
|
-
(
|
|
680
|
+
(Pt, rt) => {
|
|
680
681
|
const it = this._resolveAttributeContent(
|
|
681
682
|
t,
|
|
682
683
|
e,
|
|
@@ -691,12 +692,12 @@ class Wt extends nt {
|
|
|
691
692
|
l
|
|
692
693
|
);
|
|
693
694
|
}
|
|
694
|
-
).join(""), et =
|
|
695
|
-
return `<tr class="recommendation-attribute-row" ${
|
|
695
|
+
).join(""), et = ft(x, l).repeat(S - H);
|
|
696
|
+
return `<tr class="recommendation-attribute-row" ${R}="${r}" ${O}="1">${tt}${et}</tr>`;
|
|
696
697
|
}
|
|
697
|
-
return this._getExistingRowHtml(
|
|
698
|
+
return this._getExistingRowHtml(d, M);
|
|
698
699
|
}).join("");
|
|
699
|
-
c += H,
|
|
700
|
+
c += H, u > 0 && c >= u && (c = 0), a.modifyHtml(d).setInnerHtml(Z);
|
|
700
701
|
}), a.apply(new A(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
701
702
|
}
|
|
702
703
|
_injectListAttributeRow(t, e, r, i) {
|
|
@@ -705,14 +706,14 @@ class Wt extends nt {
|
|
|
705
706
|
return;
|
|
706
707
|
const s = i.filter((l) => l !== B && l !== q), n = this.api.getDocumentModifier();
|
|
707
708
|
o.forEach((l, a) => {
|
|
708
|
-
const
|
|
709
|
+
const u = s.map((c) => {
|
|
709
710
|
if (c === r) {
|
|
710
|
-
const
|
|
711
|
-
return this._getListRowHtml(t,
|
|
711
|
+
const d = this._resolveAttributeContent(t, e, a);
|
|
712
|
+
return this._getListRowHtml(t, d, r);
|
|
712
713
|
}
|
|
713
714
|
return this._getExistingRowHtml(l, c);
|
|
714
715
|
}).join("");
|
|
715
|
-
n.modifyHtml(l).setInnerHtml(
|
|
716
|
+
n.modifyHtml(l).setInnerHtml(u);
|
|
716
717
|
}), n.apply(new A(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
717
718
|
}
|
|
718
719
|
/**
|
|
@@ -724,7 +725,7 @@ class Wt extends nt {
|
|
|
724
725
|
return;
|
|
725
726
|
const e = this._getCurrentLayout(), r = this.api.getDocumentModifier();
|
|
726
727
|
if (e === "grid") {
|
|
727
|
-
const i = this.currentNode.querySelectorAll(
|
|
728
|
+
const i = this.currentNode.querySelectorAll(k);
|
|
728
729
|
i == null || i.forEach((o) => {
|
|
729
730
|
const s = this._buildCompositionHtml(o, t);
|
|
730
731
|
r.modifyHtml(o).setInnerHtml(s);
|
|
@@ -764,7 +765,7 @@ class Wt extends nt {
|
|
|
764
765
|
_reorderProductAttributes(t) {
|
|
765
766
|
if (!this.currentNode)
|
|
766
767
|
return;
|
|
767
|
-
const e = this.currentNode.querySelectorAll(
|
|
768
|
+
const e = this.currentNode.querySelectorAll(k);
|
|
768
769
|
if (!(e != null && e.length))
|
|
769
770
|
return;
|
|
770
771
|
const r = this.api.getDocumentModifier();
|
|
@@ -786,12 +787,12 @@ class Wt extends nt {
|
|
|
786
787
|
_applyVisibilityToBlock(t, e) {
|
|
787
788
|
if (!this.currentNode)
|
|
788
789
|
return;
|
|
789
|
-
const r = this.currentNode.querySelectorAll(`${
|
|
790
|
+
const r = this.currentNode.querySelectorAll(`${E}[${R}="${t}"]`);
|
|
790
791
|
if (!(r != null && r.length))
|
|
791
792
|
return;
|
|
792
793
|
const i = e ? "1" : "0", o = e ? this.api.translate("visible") : this.api.translate("hidden"), s = `${this.api.translate("Set visibility")}: ${t} → ${o}`, n = this.api.getDocumentModifier();
|
|
793
794
|
r.forEach((a) => {
|
|
794
|
-
const
|
|
795
|
+
const u = vt(a), c = e ? u : "none";
|
|
795
796
|
n.modifyHtml(a).setStyle("display", c).setAttribute(O, i);
|
|
796
797
|
});
|
|
797
798
|
const l = {
|
|
@@ -871,7 +872,7 @@ class Wt extends nt {
|
|
|
871
872
|
* or when all available filters have already been added (no unused attributes left).
|
|
872
873
|
*/
|
|
873
874
|
_updateAddButtonState() {
|
|
874
|
-
const t = this._readCustomAttributesFromNode(), e = t.length >=
|
|
875
|
+
const t = this._readCustomAttributesFromNode(), e = t.length >= f, r = new Set(t), i = this._getAddableFilters(), o = i.length > 0 && i.every((s) => r.has(y(s)));
|
|
875
876
|
this.api.setUIEAttribute(
|
|
876
877
|
X.ADD_ATTRIBUTE,
|
|
877
878
|
N.BUTTON.disabled,
|
|
@@ -915,7 +916,7 @@ class Wt extends nt {
|
|
|
915
916
|
*/
|
|
916
917
|
_getDisplayNameForAttribute(t) {
|
|
917
918
|
const e = Object.values(this.store.filterList).find((r) => y(r) === t);
|
|
918
|
-
return e ? e.displayName :
|
|
919
|
+
return e ? e.displayName : yt(D(t));
|
|
919
920
|
}
|
|
920
921
|
/**
|
|
921
922
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -923,17 +924,17 @@ class Wt extends nt {
|
|
|
923
924
|
*/
|
|
924
925
|
_resolveAttributeContent(t, e, r) {
|
|
925
926
|
var l;
|
|
926
|
-
const o = this.store.recommendationProducts[r], s = D(t), n =
|
|
927
|
-
return
|
|
927
|
+
const o = this.store.recommendationProducts[r], s = D(t), n = It(t) ? o == null ? void 0 : o[s] : (l = o == null ? void 0 : o.product_attributes) == null ? void 0 : l[s];
|
|
928
|
+
return Ct(n) ?? e;
|
|
928
929
|
}
|
|
929
930
|
_getGridCellHtml(t, e, r, i = "", o = "", s = "") {
|
|
930
|
-
const n =
|
|
931
|
+
const n = U(t), l = D(t), a = z(pt, [n], this.store.filterList), u = {
|
|
931
932
|
[l]: e,
|
|
932
933
|
product_attributes: { [l]: e }
|
|
933
934
|
};
|
|
934
|
-
let c = a[n](
|
|
935
|
+
let c = a[n](u);
|
|
935
936
|
return c = c.replace("<td", `<td width="${r}%"`), s && (c = c.replace(
|
|
936
|
-
`padding: ${
|
|
937
|
+
`padding: ${gt}`,
|
|
937
938
|
`padding: ${s}`
|
|
938
939
|
)), i && (c = c.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${i}"`)), o && (c = c.replace(/border="0"/, `border="0" bgcolor="${o}"`)), c;
|
|
939
940
|
}
|
|
@@ -942,10 +943,10 @@ class Wt extends nt {
|
|
|
942
943
|
[i]: e,
|
|
943
944
|
product_attributes: { [i]: e }
|
|
944
945
|
}, l = o[r](s).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
945
|
-
return `<tr class="recommendation-attribute-row" ${
|
|
946
|
+
return `<tr class="recommendation-attribute-row" ${R}="${r}" ${O}="1">${l}</tr>`;
|
|
946
947
|
}
|
|
947
948
|
}
|
|
948
949
|
export {
|
|
949
|
-
|
|
950
|
-
|
|
950
|
+
Dt as COMPOSITION_CONTROL_BLOCK_ID,
|
|
951
|
+
Gt as RecommendationCardCompositionControl
|
|
951
952
|
};
|