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