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