@useinsider/guido 3.17.0-beta.db80c84 → 3.17.0-beta.ddd4dde
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 +5 -5
- package/dist/composables/useStripo.js +14 -14
- package/dist/config/migrator/index.js +8 -9
- package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
- package/dist/config/migrator/recommendation/extractors.js +24 -29
- package/dist/config/migrator/recommendation/htmlBuilder.js +130 -116
- package/dist/config/migrator/recommendationMigrator.js +15 -18
- package/dist/extensions/Blocks/Items/block.js +98 -49
- package/dist/extensions/Blocks/Items/constants/currency.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
- package/dist/extensions/Blocks/Items/template.js +153 -152
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +22 -23
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +28 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +238 -306
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +8 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -1
- package/dist/extensions/Blocks/Recommendation/extension.js +29 -31
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -23
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +107 -85
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -8
- package/dist/src/extensions/Blocks/Items/block.d.ts +21 -0
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +1 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -1
- package/dist/static/styles/customEditorStyle.css.js +1 -3
- package/dist/utils/pairProductVariables.js +60 -59
- package/package.json +2 -2
- package/dist/config/migrator/recommendationTitleMigrator.js +0 -119
- package/dist/extensions/Blocks/Recommendation/controls/title/index.js +0 -44
- package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +0 -33
- package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -86
- package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +0 -13
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var $ = (h, p, t) =>
|
|
4
|
-
import { UIElementType as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ATTR_PRODUCT_IMAGE as
|
|
7
|
-
import { DEFAULT_COMPOSITION as
|
|
8
|
-
import { RecommendationConfigService as
|
|
9
|
-
import { useRecommendationExtensionStore as
|
|
10
|
-
import { ATTRIBUTE_CELL_CLASS as
|
|
11
|
-
import { listElementRenderer as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
const Ut = "ui-elements-recommendation-card-composition", q = ".product-card-wrapper > tbody", Z = ".product-info-cell > table > tbody", tt = {
|
|
1
|
+
var ot = Object.defineProperty;
|
|
2
|
+
var st = (h, p, t) => p in h ? ot(h, p, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[p] = t;
|
|
3
|
+
var $ = (h, p, t) => st(h, typeof p != "symbol" ? p + "" : p, t);
|
|
4
|
+
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 nt } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_IMAGE as B, ATTR_PRODUCT_NAME as lt, ATTR_PRODUCT_PRICE as C, ATTR_PRODUCT_OLD_PRICE as v, ATTR_PRODUCT_OMNIBUS_PRICE as at, ATTR_PRODUCT_OMNIBUS_DISCOUNT as ct, 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 R, ATTR_DATA_ATTRIBUTE_TYPE as E, BUILT_IN_DEFAULT_ATTRIBUTES as dt } from "../../constants/selectors.js";
|
|
7
|
+
import { DEFAULT_COMPOSITION as K, DEFAULT_VISIBILITY as W } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RecommendationConfigService as _ } from "../../services/configService.js";
|
|
9
|
+
import { useRecommendationExtensionStore as ut } from "../../store/recommendation.js";
|
|
10
|
+
import { ATTRIBUTE_CELL_CLASS as mt, gridElementRenderer as ht, DEFAULT_CELL_PADDING as pt, buildFillerCell as gt } from "../../templates/grid/elementRenderer.js";
|
|
11
|
+
import { listElementRenderer as bt } from "../../templates/list/elementRenderer.js";
|
|
12
|
+
import { resolveInlinePriceOrder as ft, toDisplayName as _t, toDisplayableAttributeValue as yt, buildElementRenderer as z } from "../../templates/utils.js";
|
|
13
|
+
import { normalizeCompositionKeys as Ct, normalizeCustomAttrValues as St, compositionKeyToProductAttr as w, resolveRowCompositionKey as At, filterToProductAttrValue as y, findAttributeRow as Tt, rewriteLegacyRowKeyHtml as G, bareAttributeName as D, isDefaultProductAttr as $t, productAttrToCompositionKey as k } from "../../utils/compositionKeys.js";
|
|
14
|
+
import { getTableDisplayValue as It } from "../../utils/tagName.js";
|
|
15
|
+
import { isPartnerManagedBlock as vt, regenerateProductRowsWithStyles as Nt, getCurrentLayout as Rt } from "../main/utils.js";
|
|
16
|
+
const Et = "ui-elements-recommendation-card-composition", U = ".product-card-wrapper > tbody", Y = ".product-info-cell > table > tbody", O = "data-visibility", X = {
|
|
18
17
|
ADD_ATTRIBUTE: "addAttribute"
|
|
19
|
-
},
|
|
20
|
-
{ key:
|
|
21
|
-
{ key:
|
|
18
|
+
}, b = 5, L = "reorderIcon_", Dt = '<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
|
+
{ key: B, label: "Product Image" },
|
|
20
|
+
{ key: lt, label: "Product Name" },
|
|
22
21
|
{ key: C, label: "Product Price" },
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
25
|
-
{ key:
|
|
26
|
-
{ key:
|
|
27
|
-
],
|
|
28
|
-
class
|
|
22
|
+
{ key: v, label: "Product Original Price" },
|
|
23
|
+
{ key: at, label: "Omnibus Price" },
|
|
24
|
+
{ key: ct, label: "Omnibus Discount" },
|
|
25
|
+
{ key: q, label: "Product Button" }
|
|
26
|
+
], Ot = new Set(m.map((h) => h.key)), T = "customAttr_", P = "deleteAttr_";
|
|
27
|
+
class Wt extends nt {
|
|
29
28
|
constructor() {
|
|
30
29
|
super(...arguments);
|
|
31
|
-
$(this, "store",
|
|
30
|
+
$(this, "store", ut());
|
|
32
31
|
$(this, "unsubscribeStore", null);
|
|
33
32
|
$(this, "eventController", null);
|
|
34
33
|
/**
|
|
@@ -38,7 +37,7 @@ class re extends dt {
|
|
|
38
37
|
$(this, "reorderInProgress", !1);
|
|
39
38
|
}
|
|
40
39
|
getId() {
|
|
41
|
-
return
|
|
40
|
+
return Et;
|
|
42
41
|
}
|
|
43
42
|
// ========================================================================
|
|
44
43
|
// Lifecycle
|
|
@@ -49,11 +48,11 @@ class re extends dt {
|
|
|
49
48
|
${this._GuToggle(`visibility_${d.key}`)}
|
|
50
49
|
</div>
|
|
51
50
|
`).join(""), e = Array.from(
|
|
52
|
-
{ length:
|
|
51
|
+
{ length: b },
|
|
53
52
|
(d, c) => `
|
|
54
|
-
<div data-custom-select-key="${
|
|
53
|
+
<div data-custom-select-key="${T}${c}" style="display: none;">
|
|
55
54
|
${this._GuSelect({
|
|
56
|
-
name: `${
|
|
55
|
+
name: `${T}${c}`,
|
|
57
56
|
placeholder: this.api.translate("Select Attribute"),
|
|
58
57
|
options: [],
|
|
59
58
|
// A partner's attribute list runs long; search beats scrolling.
|
|
@@ -61,37 +60,37 @@ class re extends dt {
|
|
|
61
60
|
})}
|
|
62
61
|
</div>
|
|
63
62
|
`
|
|
64
|
-
).join(""), r = m.length +
|
|
63
|
+
).join(""), r = m.length + b, i = Array.from(
|
|
65
64
|
{ length: r },
|
|
66
65
|
(d, c) => `
|
|
67
|
-
<div data-reorder-icon-key="${
|
|
68
|
-
<${
|
|
66
|
+
<div data-reorder-icon-key="${L}${c}" style="display: none;">
|
|
67
|
+
<${g.BUTTON}
|
|
69
68
|
class="drag-handle-btn flat-inline flat-white"
|
|
70
|
-
${
|
|
69
|
+
${N.BUTTON.name}="${L}${c}"
|
|
71
70
|
>
|
|
72
|
-
<${
|
|
71
|
+
<${g.ICON}
|
|
73
72
|
src="reorder"
|
|
74
73
|
class="icon-button"
|
|
75
|
-
></${
|
|
76
|
-
</${
|
|
74
|
+
></${g.ICON}>
|
|
75
|
+
</${g.BUTTON}>
|
|
77
76
|
</div>
|
|
78
77
|
`
|
|
79
|
-
).join(""),
|
|
80
|
-
{ length:
|
|
78
|
+
).join(""), o = Array.from(
|
|
79
|
+
{ length: b },
|
|
81
80
|
(d, c) => `
|
|
82
|
-
<div data-custom-delete-key="${
|
|
83
|
-
<${
|
|
81
|
+
<div data-custom-delete-key="${P}${c}" style="display: none;">
|
|
82
|
+
<${g.BUTTON}
|
|
84
83
|
class="custom-attr-delete flat-inline flat-white"
|
|
85
|
-
${
|
|
84
|
+
${N.BUTTON.name}="${P}${c}"
|
|
86
85
|
>
|
|
87
|
-
<${
|
|
86
|
+
<${g.ICON}
|
|
88
87
|
src="delete"
|
|
89
88
|
class="icon-button"
|
|
90
|
-
></${
|
|
91
|
-
</${
|
|
89
|
+
></${g.ICON}>
|
|
90
|
+
</${g.BUTTON}>
|
|
92
91
|
</div>
|
|
93
92
|
`
|
|
94
|
-
).join(""),
|
|
93
|
+
).join(""), s = "https://academy.insiderone.com/docs/new-editor-email-recommendation-block", n = this.api.translate(
|
|
95
94
|
"Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
|
|
96
95
|
), l = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
97
96
|
return `
|
|
@@ -101,7 +100,7 @@ class re extends dt {
|
|
|
101
100
|
${n}
|
|
102
101
|
${l}
|
|
103
102
|
<!-- cspell:disable-next-line -->
|
|
104
|
-
<a href="${
|
|
103
|
+
<a href="${s}" target="_blank" rel="noopener noreferrer">${a}</a>.
|
|
105
104
|
</p>
|
|
106
105
|
</div>
|
|
107
106
|
|
|
@@ -114,26 +113,17 @@ class re extends dt {
|
|
|
114
113
|
</div>
|
|
115
114
|
|
|
116
115
|
<div class="custom-delete-store" style="display: none;">
|
|
117
|
-
${
|
|
116
|
+
${o}
|
|
118
117
|
</div>
|
|
119
118
|
|
|
120
119
|
<div class="reorder-icon-store" style="display: none;">
|
|
121
120
|
${i}
|
|
122
121
|
</div>
|
|
123
122
|
|
|
124
|
-
<div class="orderable-list">
|
|
125
|
-
<div class="orderable-item title-item" data-key="${E.key}">
|
|
126
|
-
<span class="item-label">${this.api.translate(E.label)}</span>
|
|
127
|
-
<div class="item-action">
|
|
128
|
-
${this._GuToggle(`visibility_${E.key}`)}
|
|
129
|
-
</div>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
123
|
<div class="orderable-list" data-composition-list></div>
|
|
134
124
|
|
|
135
125
|
${this._GuButton({
|
|
136
|
-
name:
|
|
126
|
+
name: X.ADD_ATTRIBUTE,
|
|
137
127
|
label: this.api.translate("Add Attribute"),
|
|
138
128
|
id: "guido__btn-add-attribute"
|
|
139
129
|
})}
|
|
@@ -154,7 +144,7 @@ class re extends dt {
|
|
|
154
144
|
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector("[data-card-composition-control]");
|
|
155
145
|
if (!t)
|
|
156
146
|
return;
|
|
157
|
-
const e =
|
|
147
|
+
const e = vt(this.currentNode);
|
|
158
148
|
t.style.pointerEvents = e ? "none" : "", t.style.opacity = e ? "0.5" : "";
|
|
159
149
|
}
|
|
160
150
|
onTemplateNodeUpdated(t) {
|
|
@@ -167,17 +157,17 @@ class re extends dt {
|
|
|
167
157
|
// Initialization
|
|
168
158
|
// ========================================================================
|
|
169
159
|
_initializeComposition() {
|
|
170
|
-
const t = this._readCompositionFromNode(), e = this._readCustomAttributesFromNode(), r = this._readVisibilityFromRows(), i = this._renderOrderableItems(t, e),
|
|
171
|
-
this.api.updateValues(
|
|
160
|
+
const t = this._readCompositionFromNode(), e = this._readCustomAttributesFromNode(), r = this._readVisibilityFromRows(), i = this._renderOrderableItems(t, e), o = this._buildVisibilityValues(r);
|
|
161
|
+
this.api.updateValues(o), i && this._initializeCustomSelects(e), this._updateAddButtonState();
|
|
172
162
|
}
|
|
173
163
|
_registerValueChangeListeners() {
|
|
174
|
-
|
|
164
|
+
m.forEach((t) => {
|
|
175
165
|
this.api.onValueChanged(`visibility_${t.key}`, (e) => {
|
|
176
166
|
this._applyVisibilityToBlock(t.key, e);
|
|
177
167
|
});
|
|
178
168
|
});
|
|
179
|
-
for (let t = 0; t <
|
|
180
|
-
const e = `${
|
|
169
|
+
for (let t = 0; t < b; t++) {
|
|
170
|
+
const e = `${T}${t}`, r = t;
|
|
181
171
|
this.api.onValueChanged(e, (i) => {
|
|
182
172
|
this._onCustomAttributeChanged(r, i);
|
|
183
173
|
});
|
|
@@ -188,24 +178,24 @@ class re extends dt {
|
|
|
188
178
|
// ========================================================================
|
|
189
179
|
_readCompositionFromNode() {
|
|
190
180
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
191
|
-
return [...
|
|
192
|
-
const t = this.currentNode.getAttribute(
|
|
181
|
+
return [...K];
|
|
182
|
+
const t = this.currentNode.getAttribute(V);
|
|
193
183
|
if (t)
|
|
194
184
|
return this._normalizeComposition(t.split(",").filter(Boolean));
|
|
195
|
-
const { composition: e } =
|
|
196
|
-
return e != null && e.length ? this._normalizeComposition([...e]) : [...
|
|
185
|
+
const { composition: e } = _.getConfig(this.currentNode);
|
|
186
|
+
return e != null && e.length ? this._normalizeComposition([...e]) : [...K];
|
|
197
187
|
}
|
|
198
188
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
199
189
|
_normalizeComposition(t) {
|
|
200
|
-
return
|
|
190
|
+
return Ct(t, this.currentNode, this.store.filterList);
|
|
201
191
|
}
|
|
202
192
|
_readCustomAttributesFromNode() {
|
|
203
193
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
204
194
|
return [];
|
|
205
|
-
const t = this.currentNode.getAttribute(
|
|
195
|
+
const t = this.currentNode.getAttribute(j);
|
|
206
196
|
if (t)
|
|
207
197
|
try {
|
|
208
|
-
return
|
|
198
|
+
return St(
|
|
209
199
|
JSON.parse(t).map((e) => String(e)),
|
|
210
200
|
this.currentNode,
|
|
211
201
|
this.store.filterList
|
|
@@ -213,46 +203,39 @@ class re extends dt {
|
|
|
213
203
|
} catch {
|
|
214
204
|
return [];
|
|
215
205
|
}
|
|
216
|
-
return this._readCompositionFromNode().filter((e) => e.startsWith(
|
|
206
|
+
return this._readCompositionFromNode().filter((e) => e.startsWith(I)).map(w);
|
|
217
207
|
}
|
|
218
208
|
_readVisibilityFromRows() {
|
|
219
209
|
if (!this.currentNode)
|
|
220
210
|
return this._getDefaultVisibilities();
|
|
221
|
-
const t = Array.from(this.currentNode.querySelectorAll(
|
|
211
|
+
const t = Array.from(this.currentNode.querySelectorAll(R)), e = this._extractVisibilityFromRows(t);
|
|
222
212
|
if (Object.keys(e).length > 0)
|
|
223
|
-
return this.
|
|
224
|
-
const r =
|
|
225
|
-
return this.
|
|
226
|
-
}
|
|
227
|
-
_withTitlePresence(t) {
|
|
228
|
-
return t[I] = this._hasTitle(), t;
|
|
229
|
-
}
|
|
230
|
-
_hasTitle() {
|
|
231
|
-
var t;
|
|
232
|
-
return !!((t = this.currentNode) != null && t.querySelector(z));
|
|
213
|
+
return this._mergeWithDefaults(e);
|
|
214
|
+
const r = _.getConfig(this.currentNode).visibility;
|
|
215
|
+
return this._mergeWithDefaults({ ...r });
|
|
233
216
|
}
|
|
234
217
|
_getDefaultVisibilities() {
|
|
235
|
-
return { ...
|
|
218
|
+
return { ...W };
|
|
236
219
|
}
|
|
237
220
|
_extractVisibilityFromRows(t) {
|
|
238
221
|
const e = {};
|
|
239
222
|
return t.forEach((r) => {
|
|
240
223
|
if (!("getAttribute" in r))
|
|
241
224
|
return;
|
|
242
|
-
const i =
|
|
243
|
-
i &&
|
|
225
|
+
const i = At(r), o = r.getAttribute(O);
|
|
226
|
+
i && o !== null && (e[i] = this._parseVisibilityValue(o));
|
|
244
227
|
}), e;
|
|
245
228
|
}
|
|
246
229
|
_parseVisibilityValue(t) {
|
|
247
230
|
return t === "1" || t === "true";
|
|
248
231
|
}
|
|
249
232
|
_mergeWithDefaults(t) {
|
|
250
|
-
return Object.entries(
|
|
233
|
+
return Object.entries(W).forEach(([e, r]) => {
|
|
251
234
|
e in t || (t[e] = r);
|
|
252
235
|
}), t;
|
|
253
236
|
}
|
|
254
237
|
_buildVisibilityValues(t) {
|
|
255
|
-
return
|
|
238
|
+
return m.reduce((e, r) => (e[`visibility_${r.key}`] = t[r.key] ?? !0, e), {});
|
|
256
239
|
}
|
|
257
240
|
// ========================================================================
|
|
258
241
|
// UI Rendering (Orderable List)
|
|
@@ -269,22 +252,22 @@ class re extends dt {
|
|
|
269
252
|
const i = r.querySelector("[data-composition-list]");
|
|
270
253
|
if (!i)
|
|
271
254
|
return !1;
|
|
272
|
-
const
|
|
273
|
-
if (!(i.dataset.inlinePrices !== String(
|
|
255
|
+
const o = !_.getConfig(this.currentNode).priceMovedToNextLine;
|
|
256
|
+
if (!(i.dataset.inlinePrices !== String(o)) && this._tryReorderInPlace(i, t))
|
|
274
257
|
return !1;
|
|
275
|
-
i.dataset.inlinePrices = String(
|
|
276
|
-
const n = new Set(e), l =
|
|
258
|
+
i.dataset.inlinePrices = String(o);
|
|
259
|
+
const n = new Set(e), l = ft(t);
|
|
277
260
|
let a = 0, d = 0;
|
|
278
261
|
const c = t.map((u) => {
|
|
279
|
-
if (
|
|
262
|
+
if (o && (u === C || u === v))
|
|
280
263
|
return u === l.anchor ? this._createPriceGroupItemHtml(d++, l.originalFirst) : "";
|
|
281
|
-
if (
|
|
282
|
-
const
|
|
283
|
-
return this._createBuiltInItemHtml(
|
|
264
|
+
if (Ot.has(u)) {
|
|
265
|
+
const f = m.find((S) => S.key === u);
|
|
266
|
+
return this._createBuiltInItemHtml(f, d++);
|
|
284
267
|
}
|
|
285
|
-
if (u.startsWith(
|
|
286
|
-
const
|
|
287
|
-
if (n.has(
|
|
268
|
+
if (u.startsWith(I)) {
|
|
269
|
+
const f = w(u);
|
|
270
|
+
if (n.has(f))
|
|
288
271
|
return this._createCustomItemHtml(u, a++, d++);
|
|
289
272
|
}
|
|
290
273
|
return "";
|
|
@@ -304,8 +287,8 @@ class re extends dt {
|
|
|
304
287
|
const i = r.map((a) => a.dataset.key).filter(Boolean);
|
|
305
288
|
if (i.length !== e.length)
|
|
306
289
|
return !1;
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
290
|
+
const o = [...i].sort().join(","), s = [...e].sort().join(",");
|
|
291
|
+
if (o !== s || e.some((a) => a.startsWith(I)))
|
|
309
292
|
return !1;
|
|
310
293
|
const n = /* @__PURE__ */ new Map();
|
|
311
294
|
r.forEach((a) => {
|
|
@@ -343,11 +326,11 @@ class re extends dt {
|
|
|
343
326
|
*/
|
|
344
327
|
_createPriceGroupItemHtml(t, e) {
|
|
345
328
|
var n, l;
|
|
346
|
-
const r = ((n = m.find((a) => a.key === C)) == null ? void 0 : n.label) ?? "Product Price", i = ((l = m.find((a) => a.key ===
|
|
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, d) => `
|
|
347
330
|
<div class="price-suborderable-item" draggable="true" data-subkey="${a}">
|
|
348
|
-
<span class="sub-drag-handle">${
|
|
331
|
+
<span class="sub-drag-handle">${Dt}</span>
|
|
349
332
|
<span class="item-label">${this.api.translate(d)}</span>
|
|
350
|
-
</div>`,
|
|
333
|
+
</div>`, s = e ? o(v, i) + o(C, r) : o(C, r) + o(v, i);
|
|
351
334
|
return `
|
|
352
335
|
<div class="orderable-item price-group-item" draggable="true"
|
|
353
336
|
data-key="${C}" data-group="prices">
|
|
@@ -356,7 +339,7 @@ class re extends dt {
|
|
|
356
339
|
<span class="item-label">${this.api.translate("Product Prices")}</span>
|
|
357
340
|
<div class="item-action" data-action-for="${C}"></div>
|
|
358
341
|
</div>
|
|
359
|
-
<div class="price-suborderable-list">${
|
|
342
|
+
<div class="price-suborderable-list">${s}</div>
|
|
360
343
|
</div>
|
|
361
344
|
`;
|
|
362
345
|
}
|
|
@@ -392,15 +375,15 @@ class re extends dt {
|
|
|
392
375
|
if (r.length === 0)
|
|
393
376
|
return [{ text: this._getDisplayNameForAttribute(t), value: t }];
|
|
394
377
|
const i = /* @__PURE__ */ new Map();
|
|
395
|
-
r.forEach((
|
|
396
|
-
const
|
|
397
|
-
return
|
|
378
|
+
r.forEach((s) => i.set(s.attributeName, (i.get(s.attributeName) ?? 0) + 1));
|
|
379
|
+
const o = new Set(e);
|
|
380
|
+
return o.delete(t), r.filter((s) => !o.has(y(s))).map((s) => ({
|
|
398
381
|
text: this._toOptionLabel(
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
(i.get(
|
|
382
|
+
s.displayName,
|
|
383
|
+
s.type === "defaultAttribute",
|
|
384
|
+
(i.get(s.attributeName) ?? 0) > 1
|
|
402
385
|
),
|
|
403
|
-
value:
|
|
386
|
+
value: y(s)
|
|
404
387
|
}));
|
|
405
388
|
}
|
|
406
389
|
/**
|
|
@@ -411,8 +394,8 @@ class re extends dt {
|
|
|
411
394
|
_initializeCustomSelects(t) {
|
|
412
395
|
t.length !== 0 && setTimeout(() => {
|
|
413
396
|
t.forEach((e, r) => {
|
|
414
|
-
const i = `${
|
|
415
|
-
this.api.setUIEAttribute(i,
|
|
397
|
+
const i = `${T}${r}`, o = this._getSelectOptions(e, t);
|
|
398
|
+
this.api.setUIEAttribute(i, N.SELECTPICKER.items, o), this.api.updateValues({ [i]: e });
|
|
416
399
|
});
|
|
417
400
|
}, 0);
|
|
418
401
|
}
|
|
@@ -424,8 +407,8 @@ class re extends dt {
|
|
|
424
407
|
m.forEach((e) => {
|
|
425
408
|
const r = t.querySelector(`[data-toggle-key="${e.key}"]`), i = t.querySelector(`[data-action-for="${e.key}"]`);
|
|
426
409
|
if (r && i) {
|
|
427
|
-
const
|
|
428
|
-
|
|
410
|
+
const o = r.querySelector("ue-switcher");
|
|
411
|
+
o && i.appendChild(o);
|
|
429
412
|
}
|
|
430
413
|
});
|
|
431
414
|
}
|
|
@@ -435,10 +418,10 @@ class re extends dt {
|
|
|
435
418
|
*/
|
|
436
419
|
_moveSelectsIntoItems(t, e) {
|
|
437
420
|
for (let r = 0; r < e; r++) {
|
|
438
|
-
const i = `${
|
|
439
|
-
if (
|
|
440
|
-
const n =
|
|
441
|
-
n &&
|
|
421
|
+
const i = `${T}${r}`, o = t.querySelector(`[data-custom-select-key="${i}"]`), s = t.querySelector(`[data-custom-select-slot="${r}"]`);
|
|
422
|
+
if (o && s) {
|
|
423
|
+
const n = o.querySelector("ue-select");
|
|
424
|
+
n && s.appendChild(n);
|
|
442
425
|
}
|
|
443
426
|
}
|
|
444
427
|
}
|
|
@@ -452,8 +435,8 @@ class re extends dt {
|
|
|
452
435
|
m.forEach((e) => {
|
|
453
436
|
const r = t.querySelector(`[data-toggle-key="${e.key}"]`), i = t.querySelector(`[data-action-for="${e.key}"]`);
|
|
454
437
|
if (i) {
|
|
455
|
-
const
|
|
456
|
-
|
|
438
|
+
const o = i.querySelector("ue-switcher");
|
|
439
|
+
o && r && r.appendChild(o);
|
|
457
440
|
}
|
|
458
441
|
});
|
|
459
442
|
}
|
|
@@ -462,11 +445,11 @@ class re extends dt {
|
|
|
462
445
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
463
446
|
*/
|
|
464
447
|
_rescueSelectsToStore(t) {
|
|
465
|
-
for (let e = 0; e <
|
|
466
|
-
const r = `${
|
|
467
|
-
if (
|
|
468
|
-
const
|
|
469
|
-
|
|
448
|
+
for (let e = 0; e < b; e++) {
|
|
449
|
+
const r = `${T}${e}`, i = t.querySelector(`[data-custom-select-key="${r}"]`), o = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
450
|
+
if (o) {
|
|
451
|
+
const s = o.querySelector("ue-select");
|
|
452
|
+
s && i && i.appendChild(s);
|
|
470
453
|
}
|
|
471
454
|
}
|
|
472
455
|
}
|
|
@@ -476,10 +459,10 @@ class re extends dt {
|
|
|
476
459
|
*/
|
|
477
460
|
_moveDeleteButtonsIntoItems(t, e) {
|
|
478
461
|
for (let r = 0; r < e; r++) {
|
|
479
|
-
const i = `${
|
|
480
|
-
if (
|
|
481
|
-
const n =
|
|
482
|
-
n &&
|
|
462
|
+
const i = `${P}${r}`, o = t.querySelector(`[data-custom-delete-key="${i}"]`), s = t.querySelector(`[data-custom-delete-slot="${r}"]`);
|
|
463
|
+
if (o && s) {
|
|
464
|
+
const n = o.querySelector("ue-button");
|
|
465
|
+
n && s.appendChild(n);
|
|
483
466
|
}
|
|
484
467
|
}
|
|
485
468
|
}
|
|
@@ -488,11 +471,11 @@ class re extends dt {
|
|
|
488
471
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
489
472
|
*/
|
|
490
473
|
_rescueDeleteButtonsToStore(t) {
|
|
491
|
-
for (let e = 0; e <
|
|
492
|
-
const r = `${
|
|
493
|
-
if (
|
|
494
|
-
const
|
|
495
|
-
|
|
474
|
+
for (let e = 0; e < b; e++) {
|
|
475
|
+
const r = `${P}${e}`, i = t.querySelector(`[data-custom-delete-key="${r}"]`), o = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
476
|
+
if (o) {
|
|
477
|
+
const s = o.querySelector("ue-button");
|
|
478
|
+
s && i && i.appendChild(s);
|
|
496
479
|
}
|
|
497
480
|
}
|
|
498
481
|
}
|
|
@@ -502,10 +485,10 @@ class re extends dt {
|
|
|
502
485
|
*/
|
|
503
486
|
_moveReorderIconsIntoItems(t, e) {
|
|
504
487
|
for (let r = 0; r < e; r++) {
|
|
505
|
-
const i = `${
|
|
506
|
-
if (
|
|
507
|
-
const n =
|
|
508
|
-
n &&
|
|
488
|
+
const i = `${L}${r}`, o = t.querySelector(`[data-reorder-icon-key="${i}"]`), s = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
489
|
+
if (o && s) {
|
|
490
|
+
const n = o.querySelector("ue-button");
|
|
491
|
+
n && s.appendChild(n);
|
|
509
492
|
}
|
|
510
493
|
}
|
|
511
494
|
}
|
|
@@ -514,12 +497,12 @@ class re extends dt {
|
|
|
514
497
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
515
498
|
*/
|
|
516
499
|
_rescueReorderIconsToStore(t) {
|
|
517
|
-
const e = m.length +
|
|
500
|
+
const e = m.length + b;
|
|
518
501
|
for (let r = 0; r < e; r++) {
|
|
519
|
-
const i = `${
|
|
520
|
-
if (
|
|
521
|
-
const n =
|
|
522
|
-
n &&
|
|
502
|
+
const i = `${L}${r}`, o = t.querySelector(`[data-reorder-icon-key="${i}"]`), s = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
503
|
+
if (s) {
|
|
504
|
+
const n = s.querySelector("ue-button");
|
|
505
|
+
n && o && o.appendChild(n);
|
|
523
506
|
}
|
|
524
507
|
}
|
|
525
508
|
}
|
|
@@ -533,8 +516,8 @@ class re extends dt {
|
|
|
533
516
|
return;
|
|
534
517
|
const r = e.querySelector("[data-composition-list]"), i = e.querySelector("#guido__btn-add-attribute");
|
|
535
518
|
r && (this._setupDragAndDrop(r, t), this._setupDeleteHandler(r, t)), i && i.addEventListener("click", () => {
|
|
536
|
-
const
|
|
537
|
-
|
|
519
|
+
const o = new Set(this._readCustomAttributesFromNode()), s = this._getAddableFilters().find((n) => !o.has(y(n)));
|
|
520
|
+
s && this._onAddAttribute(y(s), s.displayName);
|
|
538
521
|
}, { signal: t });
|
|
539
522
|
}
|
|
540
523
|
/**
|
|
@@ -546,9 +529,9 @@ class re extends dt {
|
|
|
546
529
|
const e = [];
|
|
547
530
|
return t.querySelectorAll(".orderable-item").forEach((r) => {
|
|
548
531
|
const i = r;
|
|
549
|
-
i.dataset.group === "prices" ? i.querySelectorAll(".price-suborderable-item").forEach((
|
|
550
|
-
const
|
|
551
|
-
|
|
532
|
+
i.dataset.group === "prices" ? i.querySelectorAll(".price-suborderable-item").forEach((o) => {
|
|
533
|
+
const s = o.dataset.subkey;
|
|
534
|
+
s && e.push(s);
|
|
552
535
|
}) : i.dataset.key && e.push(i.dataset.key);
|
|
553
536
|
}), e;
|
|
554
537
|
}
|
|
@@ -572,42 +555,42 @@ class re extends dt {
|
|
|
572
555
|
* identically.
|
|
573
556
|
*/
|
|
574
557
|
_registerDragHandlers(t, e, r) {
|
|
575
|
-
let i = null,
|
|
576
|
-
const
|
|
558
|
+
let i = null, o = null;
|
|
559
|
+
const s = (n) => n.target.closest(r.itemSelector);
|
|
577
560
|
t.addEventListener("dragstart", (n) => {
|
|
578
561
|
var d;
|
|
579
562
|
const l = n.target;
|
|
580
563
|
if (r.ignoreSelector && l.closest(r.ignoreSelector))
|
|
581
564
|
return;
|
|
582
|
-
const a =
|
|
565
|
+
const a = s(n);
|
|
583
566
|
a && (i = a, a.classList.add("dragging"), (d = n.dataTransfer) == null || d.setData("text/plain", a.dataset.key ?? a.dataset.subkey ?? ""));
|
|
584
567
|
}, { signal: e }), t.addEventListener("dragend", () => {
|
|
585
|
-
i == null || i.classList.remove("dragging"),
|
|
568
|
+
i == null || i.classList.remove("dragging"), o == null || o.classList.remove("drag-over"), i = null, o = null;
|
|
586
569
|
}, { signal: e }), t.addEventListener("dragover", (n) => {
|
|
587
570
|
if (!i)
|
|
588
571
|
return;
|
|
589
|
-
const l =
|
|
572
|
+
const l = s(n);
|
|
590
573
|
if (!l)
|
|
591
574
|
return;
|
|
592
575
|
n.preventDefault();
|
|
593
576
|
const a = l !== i ? l : null;
|
|
594
|
-
a !==
|
|
577
|
+
a !== o && (o == null || o.classList.remove("drag-over"), o = a, o == null || o.classList.add("drag-over"));
|
|
595
578
|
}, { signal: e }), t.addEventListener("drop", (n) => {
|
|
596
579
|
var c;
|
|
597
|
-
const l = i &&
|
|
580
|
+
const l = i && s(n);
|
|
598
581
|
if (!i || !l || l === i)
|
|
599
582
|
return;
|
|
600
583
|
n.preventDefault();
|
|
601
584
|
const a = l.getBoundingClientRect(), d = n.clientY < a.top + a.height / 2;
|
|
602
|
-
(c = r.getDropParent(l)) == null || c.insertBefore(i, d ? l : l.nextSibling),
|
|
585
|
+
(c = r.getDropParent(l)) == null || c.insertBefore(i, d ? l : l.nextSibling), o == null || o.classList.remove("drag-over"), i.classList.remove("dragging"), i = null, o = null, this._onReorder(this._extractCompositionOrder(t));
|
|
603
586
|
}, { signal: e });
|
|
604
587
|
}
|
|
605
588
|
_setupDeleteHandler(t, e) {
|
|
606
589
|
t.addEventListener("click", (r) => {
|
|
607
|
-
const
|
|
608
|
-
if (!
|
|
590
|
+
const o = r.target.closest(".custom-attr-delete");
|
|
591
|
+
if (!o)
|
|
609
592
|
return;
|
|
610
|
-
const
|
|
593
|
+
const s = o.closest("[data-custom-index]"), n = s == null ? void 0 : s.dataset.customIndex;
|
|
611
594
|
n !== void 0 && this._onDeleteCustomAttribute(Number(n));
|
|
612
595
|
}, { signal: e });
|
|
613
596
|
}
|
|
@@ -615,10 +598,10 @@ class re extends dt {
|
|
|
615
598
|
// Actions (Add, Delete, Reorder)
|
|
616
599
|
// ========================================================================
|
|
617
600
|
_onAddAttribute(t, e) {
|
|
618
|
-
const r =
|
|
601
|
+
const r = k(t), i = this._readCompositionFromNode();
|
|
619
602
|
i.push(r);
|
|
620
|
-
const
|
|
621
|
-
this._updateBothAttributes(i,
|
|
603
|
+
const o = [...this._readCustomAttributesFromNode(), t];
|
|
604
|
+
this._updateBothAttributes(i, o), this._injectCustomAttributeHtml(t, e, r, i), this._renderOrderableItems(i, o), this._initializeCustomSelects(o), this._updateAddButtonState();
|
|
622
605
|
}
|
|
623
606
|
/**
|
|
624
607
|
* Removes a single custom attribute by its index in the customAttrs array.
|
|
@@ -628,8 +611,8 @@ class re extends dt {
|
|
|
628
611
|
const e = this._readCustomAttributesFromNode();
|
|
629
612
|
if (e[t] === void 0)
|
|
630
613
|
return;
|
|
631
|
-
const i = this._readCompositionFromNode(),
|
|
632
|
-
this._updateBothAttributes(
|
|
614
|
+
const i = this._readCompositionFromNode(), o = this._findNthCustomKeyIndex(i, t), s = i.filter((l, a) => a !== o), n = e.filter((l, a) => a !== t);
|
|
615
|
+
this._updateBothAttributes(s, n), this._removeCustomAttributeHtml(s), this._renderOrderableItems(s, n), this._initializeCustomSelects(n), this._updateAddButtonState();
|
|
633
616
|
}
|
|
634
617
|
/**
|
|
635
618
|
* Handles changing a custom attribute's selection via its inline _GuSelect.
|
|
@@ -639,18 +622,18 @@ class re extends dt {
|
|
|
639
622
|
const r = this._readCustomAttributesFromNode(), i = r[t];
|
|
640
623
|
if (i === void 0 || i === e)
|
|
641
624
|
return;
|
|
642
|
-
const
|
|
643
|
-
n !== -1 && (
|
|
625
|
+
const o = k(e), s = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(s, t);
|
|
626
|
+
n !== -1 && (s[n] = o), r[t] = e;
|
|
644
627
|
const l = this._getDisplayNameForAttribute(e);
|
|
645
|
-
this._updateBothAttributes(
|
|
628
|
+
this._updateBothAttributes(s, r), this._injectCustomAttributeHtml(e, l, o, s), this._renderOrderableItems(s, r), this._initializeCustomSelects(r);
|
|
646
629
|
}
|
|
647
630
|
_onReorder(t) {
|
|
648
|
-
const e = t.filter((r) => r.startsWith(
|
|
631
|
+
const e = t.filter((r) => r.startsWith(I)).map(w);
|
|
649
632
|
this.reorderInProgress = !0;
|
|
650
633
|
try {
|
|
651
634
|
this._updateBothAttributes(t, e);
|
|
652
|
-
const r = !
|
|
653
|
-
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode &&
|
|
635
|
+
const r = !_.getConfig(this.currentNode).priceMovedToNextLine;
|
|
636
|
+
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && Nt({
|
|
654
637
|
currentNode: this.currentNode,
|
|
655
638
|
documentModifier: this.api.getDocumentModifier()
|
|
656
639
|
});
|
|
@@ -668,13 +651,13 @@ class re extends dt {
|
|
|
668
651
|
* DOM converge on the next composition change without writing on open.
|
|
669
652
|
*/
|
|
670
653
|
_getExistingRowHtml(t, e) {
|
|
671
|
-
const r =
|
|
654
|
+
const r = Tt(t, e);
|
|
672
655
|
if (r && "getOuterHTML" in r)
|
|
673
|
-
return
|
|
656
|
+
return G(r.getOuterHTML(), e);
|
|
674
657
|
const i = t.querySelector(
|
|
675
|
-
`${
|
|
658
|
+
`${R}[${E}="${e}"]`
|
|
676
659
|
);
|
|
677
|
-
return i && "getOuterHTML" in i ?
|
|
660
|
+
return i && "getOuterHTML" in i ? G(i.getOuterHTML(), e) : "";
|
|
678
661
|
}
|
|
679
662
|
_injectCustomAttributeHtml(t, e, r, i) {
|
|
680
663
|
if (!this.currentNode)
|
|
@@ -682,47 +665,47 @@ class re extends dt {
|
|
|
682
665
|
this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, e, r, i) : this._injectListAttributeRow(t, e, r, i);
|
|
683
666
|
}
|
|
684
667
|
_injectGridAttributeRow(t, e, r, i) {
|
|
685
|
-
const
|
|
686
|
-
if (!(
|
|
668
|
+
const o = this.currentNode.querySelectorAll(U);
|
|
669
|
+
if (!(o != null && o.length))
|
|
687
670
|
return;
|
|
688
|
-
const
|
|
671
|
+
const s = _.getConfig(this.currentNode), l = `0 ${Math.floor(s.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), d = this.store.recommendationProducts.length;
|
|
689
672
|
let c = 0;
|
|
690
|
-
|
|
691
|
-
var
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
{ length:
|
|
696
|
-
(
|
|
697
|
-
const
|
|
673
|
+
o.forEach((u) => {
|
|
674
|
+
var F;
|
|
675
|
+
const f = u.querySelector(R), S = ((F = f == null ? void 0 : f.querySelectorAll(`.${mt}`)) == null ? void 0 : F.length) || 1, x = (100 / S).toFixed(2), { bgStyle: J, bgAttr: Q } = this._extractSegmentBgFromCard(u), H = d > 0 ? Math.min(S, d - c) : S, Z = i.map((M) => {
|
|
676
|
+
if (M === r) {
|
|
677
|
+
const tt = Array.from(
|
|
678
|
+
{ length: H },
|
|
679
|
+
(Lt, rt) => {
|
|
680
|
+
const it = this._resolveAttributeContent(
|
|
698
681
|
t,
|
|
699
682
|
e,
|
|
700
|
-
c +
|
|
683
|
+
c + rt
|
|
701
684
|
);
|
|
702
685
|
return this._getGridCellHtml(
|
|
703
686
|
t,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
687
|
+
it,
|
|
688
|
+
x,
|
|
689
|
+
J,
|
|
690
|
+
Q,
|
|
708
691
|
l
|
|
709
692
|
);
|
|
710
693
|
}
|
|
711
|
-
).join(""),
|
|
712
|
-
return `<tr class="
|
|
694
|
+
).join(""), et = gt(x, l).repeat(S - H);
|
|
695
|
+
return `<tr class="recommendation-attribute-row" ${E}="${r}" ${O}="1">${tt}${et}</tr>`;
|
|
713
696
|
}
|
|
714
|
-
return this._getExistingRowHtml(u,
|
|
697
|
+
return this._getExistingRowHtml(u, M);
|
|
715
698
|
}).join("");
|
|
716
|
-
c +=
|
|
717
|
-
}), a.apply(new
|
|
699
|
+
c += H, d > 0 && c >= d && (c = 0), a.modifyHtml(u).setInnerHtml(Z);
|
|
700
|
+
}), a.apply(new A(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
718
701
|
}
|
|
719
702
|
_injectListAttributeRow(t, e, r, i) {
|
|
720
|
-
const
|
|
721
|
-
if (!(
|
|
703
|
+
const o = this.currentNode.querySelectorAll(Y);
|
|
704
|
+
if (!(o != null && o.length))
|
|
722
705
|
return;
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
const d =
|
|
706
|
+
const s = i.filter((l) => l !== B && l !== q), n = this.api.getDocumentModifier();
|
|
707
|
+
o.forEach((l, a) => {
|
|
708
|
+
const d = s.map((c) => {
|
|
726
709
|
if (c === r) {
|
|
727
710
|
const u = this._resolveAttributeContent(t, e, a);
|
|
728
711
|
return this._getListRowHtml(t, u, r);
|
|
@@ -730,7 +713,7 @@ class re extends dt {
|
|
|
730
713
|
return this._getExistingRowHtml(l, c);
|
|
731
714
|
}).join("");
|
|
732
715
|
n.modifyHtml(l).setInnerHtml(d);
|
|
733
|
-
}), n.apply(new
|
|
716
|
+
}), n.apply(new A(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
734
717
|
}
|
|
735
718
|
/**
|
|
736
719
|
* Removes a custom attribute by rebuilding product card content without it.
|
|
@@ -741,19 +724,19 @@ class re extends dt {
|
|
|
741
724
|
return;
|
|
742
725
|
const e = this._getCurrentLayout(), r = this.api.getDocumentModifier();
|
|
743
726
|
if (e === "grid") {
|
|
744
|
-
const i = this.currentNode.querySelectorAll(
|
|
745
|
-
i == null || i.forEach((
|
|
746
|
-
const
|
|
747
|
-
r.modifyHtml(
|
|
727
|
+
const i = this.currentNode.querySelectorAll(U);
|
|
728
|
+
i == null || i.forEach((o) => {
|
|
729
|
+
const s = this._buildCompositionHtml(o, t);
|
|
730
|
+
r.modifyHtml(o).setInnerHtml(s);
|
|
748
731
|
});
|
|
749
732
|
} else {
|
|
750
|
-
const i = t.filter((
|
|
751
|
-
|
|
752
|
-
const n = this._buildCompositionHtml(
|
|
753
|
-
r.modifyHtml(
|
|
733
|
+
const i = t.filter((s) => s !== B && s !== q), o = this.currentNode.querySelectorAll(Y);
|
|
734
|
+
o == null || o.forEach((s) => {
|
|
735
|
+
const n = this._buildCompositionHtml(s, i);
|
|
736
|
+
r.modifyHtml(s).setInnerHtml(n);
|
|
754
737
|
});
|
|
755
738
|
}
|
|
756
|
-
r.apply(new
|
|
739
|
+
r.apply(new A(this.api.translate("Remove custom attribute")));
|
|
757
740
|
}
|
|
758
741
|
// ========================================================================
|
|
759
742
|
// DOM Mutation (Block Root Attributes, Reorder)
|
|
@@ -769,10 +752,10 @@ class re extends dt {
|
|
|
769
752
|
if (!this.currentNode)
|
|
770
753
|
return;
|
|
771
754
|
const r = {
|
|
772
|
-
...
|
|
755
|
+
..._.getConfig(this.currentNode),
|
|
773
756
|
composition: t
|
|
774
757
|
};
|
|
775
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(
|
|
758
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(V, t.join(",")).setAttribute(j, JSON.stringify(e)).setNodeConfig(r).apply(new A(this.api.translate("Update card composition")));
|
|
776
759
|
}
|
|
777
760
|
/**
|
|
778
761
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -781,14 +764,14 @@ class re extends dt {
|
|
|
781
764
|
_reorderProductAttributes(t) {
|
|
782
765
|
if (!this.currentNode)
|
|
783
766
|
return;
|
|
784
|
-
const e = this.currentNode.querySelectorAll(
|
|
767
|
+
const e = this.currentNode.querySelectorAll(U);
|
|
785
768
|
if (!(e != null && e.length))
|
|
786
769
|
return;
|
|
787
770
|
const r = this.api.getDocumentModifier();
|
|
788
771
|
e.forEach((i) => {
|
|
789
|
-
const
|
|
790
|
-
r.modifyHtml(i).setInnerHtml(
|
|
791
|
-
}), r.apply(new
|
|
772
|
+
const o = this._buildCompositionHtml(i, t);
|
|
773
|
+
r.modifyHtml(i).setInnerHtml(o);
|
|
774
|
+
}), r.apply(new A(this.api.translate("Reorder product attributes")));
|
|
792
775
|
}
|
|
793
776
|
/**
|
|
794
777
|
* Builds HTML string with attributes ordered according to composition.
|
|
@@ -803,70 +786,19 @@ class re extends dt {
|
|
|
803
786
|
_applyVisibilityToBlock(t, e) {
|
|
804
787
|
if (!this.currentNode)
|
|
805
788
|
return;
|
|
806
|
-
|
|
807
|
-
this._applyTitleVisibilityToBlock(e);
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
const r = this.currentNode.querySelectorAll(`${N}[${R}="${t}"]`);
|
|
789
|
+
const r = this.currentNode.querySelectorAll(`${R}[${E}="${t}"]`);
|
|
811
790
|
if (!(r != null && r.length))
|
|
812
791
|
return;
|
|
813
|
-
const i = e ? "1" : "0",
|
|
792
|
+
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();
|
|
814
793
|
r.forEach((a) => {
|
|
815
|
-
const d =
|
|
816
|
-
n.modifyHtml(a).setStyle("display", c).setAttribute(
|
|
794
|
+
const d = It(a), c = e ? d : "none";
|
|
795
|
+
n.modifyHtml(a).setStyle("display", c).setAttribute(O, i);
|
|
817
796
|
});
|
|
818
797
|
const l = {
|
|
819
|
-
...
|
|
798
|
+
..._.getConfig(this.currentNode),
|
|
820
799
|
visibility: { ...this._readVisibilityFromRows(), [t]: e }
|
|
821
800
|
};
|
|
822
|
-
n.modifyHtml(this.currentNode).setNodeConfig(l), n.apply(new
|
|
823
|
-
}
|
|
824
|
-
_applyTitleVisibilityToBlock(t) {
|
|
825
|
-
const e = g.getConfig(this.currentNode), r = t ? this._resolveTitleInjection(e.rowSpacing) : null, i = t ? [] : this._findTitleRows(), s = t ? this._hasTitle() || !r : i.length === 0;
|
|
826
|
-
if (!this.currentNode || s)
|
|
827
|
-
return;
|
|
828
|
-
const o = this.api.getDocumentModifier();
|
|
829
|
-
r ? o.modifyHtml(r.containerBody).setInnerHtml(r.html) : i.forEach((l) => o.modifyHtml(l).delete()), o.modifyHtml(this.currentNode).setNodeConfig({
|
|
830
|
-
...e,
|
|
831
|
-
visibility: { ...this._readVisibilityFromRows(), [I]: t }
|
|
832
|
-
});
|
|
833
|
-
const n = t ? this.api.translate("visible") : this.api.translate("hidden");
|
|
834
|
-
o.apply(new y(
|
|
835
|
-
`${this.api.translate("Set visibility")}: ${I} → ${n}`
|
|
836
|
-
));
|
|
837
|
-
}
|
|
838
|
-
_resolveTitleInjection(t) {
|
|
839
|
-
const e = this._findTitleContainerBody(), r = e ? this._readInnerHtml(e) : null;
|
|
840
|
-
return !e || r === null ? null : {
|
|
841
|
-
containerBody: e,
|
|
842
|
-
html: St(this._defaultTitleParagraph(), !0, t) + r
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
_findTitleRows() {
|
|
846
|
-
var e;
|
|
847
|
-
const t = Array.from(((e = this.currentNode) == null ? void 0 : e.querySelectorAll(
|
|
848
|
-
`${N}[${R}="${I}"]`
|
|
849
|
-
)) ?? []);
|
|
850
|
-
return t.length > 0 ? t : this._findTitleRowsByClass();
|
|
851
|
-
}
|
|
852
|
-
_findTitleRowsByClass() {
|
|
853
|
-
const t = this._findTitleContainerBody(), e = t && "children" in t ? t.children() : [], r = e.findIndex((s) => !!s.querySelector(z));
|
|
854
|
-
if (r === -1)
|
|
855
|
-
return [];
|
|
856
|
-
const i = e[r + 1];
|
|
857
|
-
return i && this._isSpacerRow(i) ? [e[r], i] : [e[r]];
|
|
858
|
-
}
|
|
859
|
-
_isSpacerRow(t) {
|
|
860
|
-
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(pt));
|
|
861
|
-
}
|
|
862
|
-
_findTitleContainerBody() {
|
|
863
|
-
return (this.currentNode ? Bt(this.currentNode) : null) ?? void 0;
|
|
864
|
-
}
|
|
865
|
-
_readInnerHtml(t) {
|
|
866
|
-
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : null;
|
|
867
|
-
}
|
|
868
|
-
_defaultTitleParagraph() {
|
|
869
|
-
return At.replace("{-{-TITLE-}-}", this.api.translate(It));
|
|
801
|
+
n.modifyHtml(this.currentNode).setNodeConfig(l), n.apply(new A(s));
|
|
870
802
|
}
|
|
871
803
|
// ========================================================================
|
|
872
804
|
// Utilities
|
|
@@ -879,7 +811,7 @@ class re extends dt {
|
|
|
879
811
|
_findNthCustomKeyIndex(t, e) {
|
|
880
812
|
let r = 0;
|
|
881
813
|
for (let i = 0; i < t.length; i++)
|
|
882
|
-
if (t[i].startsWith(
|
|
814
|
+
if (t[i].startsWith(I)) {
|
|
883
815
|
if (r === e)
|
|
884
816
|
return i;
|
|
885
817
|
r++;
|
|
@@ -887,7 +819,7 @@ class re extends dt {
|
|
|
887
819
|
return -1;
|
|
888
820
|
}
|
|
889
821
|
_getCurrentLayout() {
|
|
890
|
-
return this.store.recommendationConfigs.orientation ||
|
|
822
|
+
return this.store.recommendationConfigs.orientation || Rt(this.currentNode);
|
|
891
823
|
}
|
|
892
824
|
/**
|
|
893
825
|
* Extracts background color properties from existing card elements.
|
|
@@ -899,18 +831,18 @@ class re extends dt {
|
|
|
899
831
|
var i;
|
|
900
832
|
const e = t.querySelector(".product-card-segment");
|
|
901
833
|
if (e && "getAttribute" in e) {
|
|
902
|
-
const
|
|
903
|
-
if (
|
|
834
|
+
const s = (e.getAttribute("style") || "").match(/background-color:\s*([^;]+)/);
|
|
835
|
+
if (s) {
|
|
904
836
|
const n = e.getAttribute("bgcolor") || "";
|
|
905
|
-
return { bgStyle: `background-color: ${
|
|
837
|
+
return { bgStyle: `background-color: ${s[1].trim()};`, bgAttr: n };
|
|
906
838
|
}
|
|
907
839
|
}
|
|
908
840
|
const r = (i = this.currentNode) == null ? void 0 : i.querySelector(".product-card-wrapper");
|
|
909
841
|
if (r && "getStyle" in r) {
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
const
|
|
913
|
-
return { bgStyle: `background-color: ${
|
|
842
|
+
const o = r.getStyle("background-color");
|
|
843
|
+
if (o && o !== "transparent") {
|
|
844
|
+
const s = "getAttribute" in r && r.getAttribute("bgcolor") || "";
|
|
845
|
+
return { bgStyle: `background-color: ${o};`, bgAttr: s };
|
|
914
846
|
}
|
|
915
847
|
}
|
|
916
848
|
return { bgStyle: "", bgAttr: "" };
|
|
@@ -939,11 +871,11 @@ class re extends dt {
|
|
|
939
871
|
* or when all available filters have already been added (no unused attributes left).
|
|
940
872
|
*/
|
|
941
873
|
_updateAddButtonState() {
|
|
942
|
-
const t = this._readCustomAttributesFromNode(), e = t.length >=
|
|
874
|
+
const t = this._readCustomAttributesFromNode(), e = t.length >= b, r = new Set(t), i = this._getAddableFilters(), o = i.length > 0 && i.every((s) => r.has(y(s)));
|
|
943
875
|
this.api.setUIEAttribute(
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
e ||
|
|
876
|
+
X.ADD_ATTRIBUTE,
|
|
877
|
+
N.BUTTON.disabled,
|
|
878
|
+
e || o ? "true" : "false"
|
|
947
879
|
);
|
|
948
880
|
}
|
|
949
881
|
/**
|
|
@@ -971,8 +903,8 @@ class re extends dt {
|
|
|
971
903
|
*/
|
|
972
904
|
_getAddableFilters() {
|
|
973
905
|
const t = /* @__PURE__ */ new Set();
|
|
974
|
-
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" &&
|
|
975
|
-
const r =
|
|
906
|
+
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" && dt.has(e.attributeName))).filter((e) => {
|
|
907
|
+
const r = y(e);
|
|
976
908
|
return t.has(r) ? !1 : (t.add(r), !0);
|
|
977
909
|
});
|
|
978
910
|
}
|
|
@@ -982,8 +914,8 @@ class re extends dt {
|
|
|
982
914
|
* resolve to their own entry. Falls back to Title Case of the bare name.
|
|
983
915
|
*/
|
|
984
916
|
_getDisplayNameForAttribute(t) {
|
|
985
|
-
const e = Object.values(this.store.filterList).find((r) =>
|
|
986
|
-
return e ? e.displayName :
|
|
917
|
+
const e = Object.values(this.store.filterList).find((r) => y(r) === t);
|
|
918
|
+
return e ? e.displayName : _t(D(t));
|
|
987
919
|
}
|
|
988
920
|
/**
|
|
989
921
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -991,29 +923,29 @@ class re extends dt {
|
|
|
991
923
|
*/
|
|
992
924
|
_resolveAttributeContent(t, e, r) {
|
|
993
925
|
var l;
|
|
994
|
-
const
|
|
995
|
-
return
|
|
926
|
+
const o = this.store.recommendationProducts[r], s = D(t), n = $t(t) ? o == null ? void 0 : o[s] : (l = o == null ? void 0 : o.product_attributes) == null ? void 0 : l[s];
|
|
927
|
+
return yt(n) ?? e;
|
|
996
928
|
}
|
|
997
|
-
_getGridCellHtml(t, e, r, i = "",
|
|
998
|
-
const n =
|
|
929
|
+
_getGridCellHtml(t, e, r, i = "", o = "", s = "") {
|
|
930
|
+
const n = k(t), l = D(t), a = z(ht, [n], this.store.filterList), d = {
|
|
999
931
|
[l]: e,
|
|
1000
932
|
product_attributes: { [l]: e }
|
|
1001
933
|
};
|
|
1002
934
|
let c = a[n](d);
|
|
1003
|
-
return c = c.replace("<td", `<td width="${r}%"`),
|
|
1004
|
-
`padding: ${
|
|
1005
|
-
`padding: ${
|
|
1006
|
-
)), i && (c = c.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${i}"`)),
|
|
935
|
+
return c = c.replace("<td", `<td width="${r}%"`), s && (c = c.replace(
|
|
936
|
+
`padding: ${pt}`,
|
|
937
|
+
`padding: ${s}`
|
|
938
|
+
)), i && (c = c.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${i}"`)), o && (c = c.replace(/border="0"/, `border="0" bgcolor="${o}"`)), c;
|
|
1007
939
|
}
|
|
1008
940
|
_getListRowHtml(t, e, r) {
|
|
1009
|
-
const i =
|
|
941
|
+
const i = D(t), o = z(bt, [r], this.store.filterList), s = {
|
|
1010
942
|
[i]: e,
|
|
1011
943
|
product_attributes: { [i]: e }
|
|
1012
|
-
}, l =
|
|
1013
|
-
return `<tr class="
|
|
944
|
+
}, l = o[r](s).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
945
|
+
return `<tr class="recommendation-attribute-row" ${E}="${r}" ${O}="1">${l}</tr>`;
|
|
1014
946
|
}
|
|
1015
947
|
}
|
|
1016
948
|
export {
|
|
1017
|
-
|
|
1018
|
-
|
|
949
|
+
Et as COMPOSITION_CONTROL_BLOCK_ID,
|
|
950
|
+
Wt as RecommendationCardCompositionControl
|
|
1019
951
|
};
|