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