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