@useinsider/guido 3.19.0-beta.acb00a2 → 3.19.0-beta.b539426
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/@types/config/schemas.js +104 -91
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +85 -86
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useActionsApi.js +44 -43
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useCortexBlueprintBridge.js +54 -122
- package/dist/composables/useEmailTemplateApplier.js +52 -108
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/extensions/Blocks/Recommendation/block.js +15 -14
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +105 -96
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -2
- package/dist/src/composables/useEmailTemplateApplier.d.ts +5 -18
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/guido-email-editor.d.ts +10 -20
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/guido-email-editor.js +1 -3
- package/dist/stores/onboarding.js +4 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/stripoEditorApi.js +11 -0
- package/package.json +2 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
var at = Object.defineProperty;
|
|
2
|
-
var ct = (
|
|
3
|
-
var
|
|
2
|
+
var ct = (g, f, t) => f in g ? at(g, f, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[f] = t;
|
|
3
|
+
var v = (g, f, t) => ct(g, typeof f != "symbol" ? f + "" : f, t);
|
|
4
4
|
import { ACADEMY_LINKS as dt } from "../../../../../enums/academy.js";
|
|
5
|
-
import { UIElementType as
|
|
5
|
+
import { UIElementType as b, UEAttr as O, ModificationDescription as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
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
|
|
7
|
+
import { ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_NAME as mt, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OLD_PRICE as I, ATTR_PRODUCT_OMNIBUS_PRICE as ht, ATTR_PRODUCT_OMNIBUS_DISCOUNT as pt, ATTR_PRODUCT_BUTTON as x, ATTR_RECOMMENDATION_TITLE as $, ATTR_DATA_CARD_COMPOSITION as K, ATTR_DATA_CUSTOM_ATTRIBUTES as W, ATTR_CUSTOM_PREFIX as N, SELECTOR_ATTRIBUTE_ROW as E, SELECTOR_TITLE_CELL as z, ATTR_DATA_VISIBILITY as D, ATTR_DATA_ATTRIBUTE_TYPE as R, CSS_CLASS_ATTRIBUTE_ROW as G, CSS_CLASS_SPACER as _t, BUILT_IN_DEFAULT_ATTRIBUTES as gt } from "../../constants/selectors.js";
|
|
8
8
|
import { DEFAULT_COMPOSITION as Y, DEFAULT_VISIBILITY as X } from "../../constants/defaultConfig.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as p } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as ft } from "../../store/recommendation.js";
|
|
11
11
|
import { ATTRIBUTE_CELL_CLASS as bt, gridElementRenderer as yt, DEFAULT_CELL_PADDING as Tt, buildFillerCell as Ct } from "../../templates/grid/elementRenderer.js";
|
|
12
12
|
import { listElementRenderer as St } from "../../templates/list/elementRenderer.js";
|
|
13
13
|
import { buildTitleRows as At, DEFAULT_TITLE_PARAGRAPH as It, DEFAULT_TITLE_TEXT as $t } from "../../templates/titleRows.js";
|
|
14
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
|
|
15
|
+
import { normalizeCompositionKeys as Rt, normalizeCustomAttrValues as Lt, compositionKeyToProductAttr as M, resolveRowVisibilityKeys as Ot, filterToProductAttrValue as C, findAttributeRow as Dt, rewriteLegacyRowKeyHtml as Q, bareAttributeName as H, isDefaultProductAttr as Ht, productAttrToCompositionKey as k } from "../../utils/compositionKeys.js";
|
|
16
16
|
import { getTableDisplayValue as Pt } from "../../utils/tagName.js";
|
|
17
|
-
import { isPartnerManagedBlock as wt, regenerateProductRowsWithStyles as Bt, getMainContainerTbody as
|
|
17
|
+
import { isPartnerManagedBlock as wt, regenerateProductRowsWithStyles as Bt, getMainContainerTbody as Mt, getCurrentLayout as kt } from "../main/utils.js";
|
|
18
18
|
const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wrapper > tbody", Z = ".product-info-cell > table > tbody", tt = {
|
|
19
19
|
ADD_ATTRIBUTE: "addAttribute"
|
|
20
|
-
},
|
|
20
|
+
}, y = 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
21
|
{ key: q, label: "Product Image" },
|
|
22
22
|
{ key: mt, label: "Product Name" },
|
|
23
|
-
{ key:
|
|
24
|
-
{ key:
|
|
23
|
+
{ key: _, label: "Product Price" },
|
|
24
|
+
{ key: I, label: "Product Original Price" },
|
|
25
25
|
{ key: ht, label: "Omnibus Price" },
|
|
26
26
|
{ key: pt, label: "Omnibus Discount" },
|
|
27
27
|
{ key: x, label: "Product Button" }
|
|
28
|
-
],
|
|
28
|
+
], L = { key: $, label: "Title" }, xt = new Set(m.map((g) => g.key)), A = "customAttr_", w = "deleteAttr_";
|
|
29
29
|
class se extends ut {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
v(this, "store", ft());
|
|
33
|
+
v(this, "unsubscribeStore", null);
|
|
34
|
+
v(this, "eventController", null);
|
|
35
35
|
/**
|
|
36
36
|
* Guard flag: when true, onTemplateNodeUpdated skips _initializeComposition.
|
|
37
37
|
* Used during _onReorder to prevent multiple intermediate rebuilds.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
v(this, "reorderInProgress", !1);
|
|
40
40
|
}
|
|
41
41
|
getId() {
|
|
42
42
|
return Ut;
|
|
@@ -50,7 +50,7 @@ class se extends ut {
|
|
|
50
50
|
${this._GuToggle(`visibility_${d.key}`)}
|
|
51
51
|
</div>
|
|
52
52
|
`).join(""), e = Array.from(
|
|
53
|
-
{ length:
|
|
53
|
+
{ length: y },
|
|
54
54
|
(d, c) => `
|
|
55
55
|
<div data-custom-select-key="${A}${c}" style="display: none;">
|
|
56
56
|
${this._GuSelect({
|
|
@@ -62,34 +62,34 @@ class se extends ut {
|
|
|
62
62
|
})}
|
|
63
63
|
</div>
|
|
64
64
|
`
|
|
65
|
-
).join(""), r = m.length +
|
|
65
|
+
).join(""), r = m.length + y, i = Array.from(
|
|
66
66
|
{ length: r },
|
|
67
67
|
(d, c) => `
|
|
68
68
|
<div data-reorder-icon-key="${P}${c}" style="display: none;">
|
|
69
|
-
<${
|
|
69
|
+
<${b.BUTTON}
|
|
70
70
|
class="guido-drag-handle-btn flat-inline flat-white"
|
|
71
71
|
${O.BUTTON.name}="${P}${c}"
|
|
72
72
|
>
|
|
73
|
-
<${
|
|
73
|
+
<${b.ICON}
|
|
74
74
|
src="reorder"
|
|
75
75
|
class="icon-button"
|
|
76
|
-
></${
|
|
77
|
-
</${
|
|
76
|
+
></${b.ICON}>
|
|
77
|
+
</${b.BUTTON}>
|
|
78
78
|
</div>
|
|
79
79
|
`
|
|
80
80
|
).join(""), s = Array.from(
|
|
81
|
-
{ length:
|
|
81
|
+
{ length: y },
|
|
82
82
|
(d, c) => `
|
|
83
83
|
<div data-custom-delete-key="${w}${c}" style="display: none;">
|
|
84
|
-
<${
|
|
84
|
+
<${b.BUTTON}
|
|
85
85
|
class="custom-attr-delete flat-inline flat-white"
|
|
86
86
|
${O.BUTTON.name}="${w}${c}"
|
|
87
87
|
>
|
|
88
|
-
<${
|
|
88
|
+
<${b.ICON}
|
|
89
89
|
src="delete"
|
|
90
90
|
class="icon-button"
|
|
91
|
-
></${
|
|
92
|
-
</${
|
|
91
|
+
></${b.ICON}>
|
|
92
|
+
</${b.BUTTON}>
|
|
93
93
|
</div>
|
|
94
94
|
`
|
|
95
95
|
).join(""), o = dt.EMAIL_RECOMMENDATION_BLOCK, n = this.api.translate(
|
|
@@ -123,10 +123,10 @@ class se extends ut {
|
|
|
123
123
|
</div>
|
|
124
124
|
|
|
125
125
|
<div class="orderable-list">
|
|
126
|
-
<div class="orderable-item title-item" data-key="${
|
|
127
|
-
<span class="item-label">${this.api.translate(
|
|
126
|
+
<div class="orderable-item title-item" data-key="${L.key}">
|
|
127
|
+
<span class="item-label">${this.api.translate(L.label)}</span>
|
|
128
128
|
<div class="item-action">
|
|
129
|
-
${this._GuToggle(`visibility_${
|
|
129
|
+
${this._GuToggle(`visibility_${L.key}`)}
|
|
130
130
|
</div>
|
|
131
131
|
</div>
|
|
132
132
|
</div>
|
|
@@ -172,12 +172,12 @@ class se extends ut {
|
|
|
172
172
|
this.api.updateValues(s), i && this._initializeCustomSelects(e), this._updateAddButtonState();
|
|
173
173
|
}
|
|
174
174
|
_registerValueChangeListeners() {
|
|
175
|
-
[
|
|
175
|
+
[L, ...m].forEach((t) => {
|
|
176
176
|
this.api.onValueChanged(`visibility_${t.key}`, (e) => {
|
|
177
177
|
this._applyVisibilityToBlock(t.key, e);
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
|
-
for (let t = 0; t <
|
|
180
|
+
for (let t = 0; t < y; t++) {
|
|
181
181
|
const e = `${A}${t}`, r = t;
|
|
182
182
|
this.api.onValueChanged(e, (i) => {
|
|
183
183
|
this._onCustomAttributeChanged(r, i);
|
|
@@ -193,7 +193,7 @@ class se extends ut {
|
|
|
193
193
|
const t = this.currentNode.getAttribute(K);
|
|
194
194
|
if (t)
|
|
195
195
|
return this._normalizeComposition(t.split(",").filter(Boolean));
|
|
196
|
-
const { composition: e } =
|
|
196
|
+
const { composition: e } = p.getConfig(this.currentNode);
|
|
197
197
|
return e != null && e.length ? this._normalizeComposition([...e]) : [...Y];
|
|
198
198
|
}
|
|
199
199
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
@@ -214,19 +214,19 @@ class se extends ut {
|
|
|
214
214
|
} catch {
|
|
215
215
|
return [];
|
|
216
216
|
}
|
|
217
|
-
return this._readCompositionFromNode().filter((e) => e.startsWith(
|
|
217
|
+
return this._readCompositionFromNode().filter((e) => e.startsWith(N)).map(M);
|
|
218
218
|
}
|
|
219
219
|
_readVisibilityFromRows() {
|
|
220
220
|
if (!this.currentNode)
|
|
221
221
|
return this._getDefaultVisibilities();
|
|
222
|
-
const t = Array.from(this.currentNode.querySelectorAll(
|
|
222
|
+
const t = Array.from(this.currentNode.querySelectorAll(E)), e = this._extractVisibilityFromRows(t);
|
|
223
223
|
if (Object.keys(e).length > 0)
|
|
224
224
|
return this._withTitlePresence(this._mergeWithDefaults(e));
|
|
225
|
-
const r =
|
|
225
|
+
const r = p.getConfig(this.currentNode).visibility;
|
|
226
226
|
return this._withTitlePresence(this._mergeWithDefaults({ ...r }));
|
|
227
227
|
}
|
|
228
228
|
_withTitlePresence(t) {
|
|
229
|
-
return t[
|
|
229
|
+
return t[$] = this._hasTitle(), t;
|
|
230
230
|
}
|
|
231
231
|
_hasTitle() {
|
|
232
232
|
var t;
|
|
@@ -240,8 +240,10 @@ class se extends ut {
|
|
|
240
240
|
return t.forEach((r) => {
|
|
241
241
|
if (!("getAttribute" in r))
|
|
242
242
|
return;
|
|
243
|
-
const i =
|
|
244
|
-
i
|
|
243
|
+
const i = r.getAttribute(D);
|
|
244
|
+
i !== null && Ot(r).forEach((s) => {
|
|
245
|
+
e[s] = this._parseVisibilityValue(i);
|
|
246
|
+
});
|
|
245
247
|
}), e;
|
|
246
248
|
}
|
|
247
249
|
_parseVisibilityValue(t) {
|
|
@@ -253,7 +255,7 @@ class se extends ut {
|
|
|
253
255
|
}), t;
|
|
254
256
|
}
|
|
255
257
|
_buildVisibilityValues(t) {
|
|
256
|
-
return [
|
|
258
|
+
return [L, ...m].reduce((e, r) => (e[`visibility_${r.key}`] = t[r.key] ?? !0, e), {});
|
|
257
259
|
}
|
|
258
260
|
// ========================================================================
|
|
259
261
|
// UI Rendering (Orderable List)
|
|
@@ -270,22 +272,22 @@ class se extends ut {
|
|
|
270
272
|
const i = r.querySelector("[data-composition-list]");
|
|
271
273
|
if (!i)
|
|
272
274
|
return !1;
|
|
273
|
-
const s = !
|
|
275
|
+
const s = !p.getConfig(this.currentNode).priceMovedToNextLine;
|
|
274
276
|
if (!(i.dataset.inlinePrices !== String(s)) && this._tryReorderInPlace(i, t))
|
|
275
277
|
return !1;
|
|
276
278
|
i.dataset.inlinePrices = String(s);
|
|
277
279
|
const n = new Set(e), l = vt(t);
|
|
278
280
|
let a = 0, d = 0;
|
|
279
281
|
const c = t.map((u) => {
|
|
280
|
-
if (s && (u ===
|
|
282
|
+
if (s && (u === _ || u === I))
|
|
281
283
|
return u === l.anchor ? this._createPriceGroupItemHtml(d++, l.originalFirst) : "";
|
|
282
284
|
if (xt.has(u)) {
|
|
283
|
-
const
|
|
284
|
-
return this._createBuiltInItemHtml(
|
|
285
|
+
const h = m.find((S) => S.key === u);
|
|
286
|
+
return this._createBuiltInItemHtml(h, d++);
|
|
285
287
|
}
|
|
286
|
-
if (u.startsWith(
|
|
287
|
-
const
|
|
288
|
-
if (n.has(
|
|
288
|
+
if (u.startsWith(N)) {
|
|
289
|
+
const h = M(u);
|
|
290
|
+
if (n.has(h))
|
|
289
291
|
return this._createCustomItemHtml(u, a++, d++);
|
|
290
292
|
}
|
|
291
293
|
return "";
|
|
@@ -306,7 +308,7 @@ class se extends ut {
|
|
|
306
308
|
if (i.length !== e.length)
|
|
307
309
|
return !1;
|
|
308
310
|
const s = [...i].sort().join(","), o = [...e].sort().join(",");
|
|
309
|
-
if (s !== o || e.some((a) => a.startsWith(
|
|
311
|
+
if (s !== o || e.some((a) => a.startsWith(N)))
|
|
310
312
|
return !1;
|
|
311
313
|
const n = /* @__PURE__ */ new Map();
|
|
312
314
|
r.forEach((a) => {
|
|
@@ -344,18 +346,18 @@ class se extends ut {
|
|
|
344
346
|
*/
|
|
345
347
|
_createPriceGroupItemHtml(t, e) {
|
|
346
348
|
var n, l;
|
|
347
|
-
const r = ((n = m.find((a) => a.key ===
|
|
349
|
+
const r = ((n = m.find((a) => a.key === _)) == null ? void 0 : n.label) ?? "Product Price", i = ((l = m.find((a) => a.key === I)) == null ? void 0 : l.label) ?? "Product Original Price", s = (a, d) => `
|
|
348
350
|
<div class="price-suborderable-item" draggable="true" data-subkey="${a}">
|
|
349
351
|
<span class="sub-drag-handle">${qt}</span>
|
|
350
352
|
<span class="item-label">${this.api.translate(d)}</span>
|
|
351
|
-
</div>`, o = e ? s(
|
|
353
|
+
</div>`, o = e ? s(I, i) + s(_, r) : s(_, r) + s(I, i);
|
|
352
354
|
return `
|
|
353
355
|
<div class="orderable-item price-group-item" draggable="true"
|
|
354
|
-
data-key="${
|
|
356
|
+
data-key="${_}" data-group="prices">
|
|
355
357
|
<div class="price-group-header">
|
|
356
358
|
<span class="guido-drag-handle" data-reorder-icon-slot="${t}"></span>
|
|
357
359
|
<span class="item-label">${this.api.translate("Product Prices")}</span>
|
|
358
|
-
<div class="item-action" data-action-for="${
|
|
360
|
+
<div class="item-action" data-action-for="${_}"></div>
|
|
359
361
|
</div>
|
|
360
362
|
<div class="price-suborderable-list">${o}</div>
|
|
361
363
|
</div>
|
|
@@ -395,13 +397,13 @@ class se extends ut {
|
|
|
395
397
|
const i = /* @__PURE__ */ new Map();
|
|
396
398
|
r.forEach((o) => i.set(o.attributeName, (i.get(o.attributeName) ?? 0) + 1));
|
|
397
399
|
const s = new Set(e);
|
|
398
|
-
return s.delete(t), r.filter((o) => !s.has(
|
|
400
|
+
return s.delete(t), r.filter((o) => !s.has(C(o))).map((o) => ({
|
|
399
401
|
text: this._toOptionLabel(
|
|
400
402
|
o.displayName,
|
|
401
403
|
o.type === "defaultAttribute",
|
|
402
404
|
(i.get(o.attributeName) ?? 0) > 1
|
|
403
405
|
),
|
|
404
|
-
value:
|
|
406
|
+
value: C(o)
|
|
405
407
|
}));
|
|
406
408
|
}
|
|
407
409
|
/**
|
|
@@ -463,7 +465,7 @@ class se extends ut {
|
|
|
463
465
|
* Same rescue pattern as _rescueTogglesToStore — prevents innerHTML from destroying them.
|
|
464
466
|
*/
|
|
465
467
|
_rescueSelectsToStore(t) {
|
|
466
|
-
for (let e = 0; e <
|
|
468
|
+
for (let e = 0; e < y; e++) {
|
|
467
469
|
const r = `${A}${e}`, i = t.querySelector(`[data-custom-select-key="${r}"]`), s = t.querySelector(`[data-custom-select-slot="${e}"]`);
|
|
468
470
|
if (s) {
|
|
469
471
|
const o = s.querySelector("ue-select");
|
|
@@ -489,7 +491,7 @@ class se extends ut {
|
|
|
489
491
|
* Same rescue pattern as _rescueSelectsToStore — prevents innerHTML from destroying them.
|
|
490
492
|
*/
|
|
491
493
|
_rescueDeleteButtonsToStore(t) {
|
|
492
|
-
for (let e = 0; e <
|
|
494
|
+
for (let e = 0; e < y; e++) {
|
|
493
495
|
const r = `${w}${e}`, i = t.querySelector(`[data-custom-delete-key="${r}"]`), s = t.querySelector(`[data-custom-delete-slot="${e}"]`);
|
|
494
496
|
if (s) {
|
|
495
497
|
const o = s.querySelector("ue-button");
|
|
@@ -515,7 +517,7 @@ class se extends ut {
|
|
|
515
517
|
* Same rescue pattern as _rescueDeleteButtonsToStore — prevents innerHTML from destroying them.
|
|
516
518
|
*/
|
|
517
519
|
_rescueReorderIconsToStore(t) {
|
|
518
|
-
const e = m.length +
|
|
520
|
+
const e = m.length + y;
|
|
519
521
|
for (let r = 0; r < e; r++) {
|
|
520
522
|
const i = `${P}${r}`, s = t.querySelector(`[data-reorder-icon-key="${i}"]`), o = t.querySelector(`[data-reorder-icon-slot="${r}"]`);
|
|
521
523
|
if (o) {
|
|
@@ -534,8 +536,8 @@ class se extends ut {
|
|
|
534
536
|
return;
|
|
535
537
|
const r = e.querySelector("[data-composition-list]"), i = e.querySelector("#guido__btn-add-attribute");
|
|
536
538
|
r && (this._setupDragAndDrop(r, t), this._setupDeleteHandler(r, t)), i && i.addEventListener("click", () => {
|
|
537
|
-
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(
|
|
538
|
-
o && this._onAddAttribute(
|
|
539
|
+
const s = new Set(this._readCustomAttributesFromNode()), o = this._getAddableFilters().find((n) => !s.has(C(n)));
|
|
540
|
+
o && this._onAddAttribute(C(o), o.displayName);
|
|
539
541
|
}, { signal: t });
|
|
540
542
|
}
|
|
541
543
|
/**
|
|
@@ -616,7 +618,7 @@ class se extends ut {
|
|
|
616
618
|
// Actions (Add, Delete, Reorder)
|
|
617
619
|
// ========================================================================
|
|
618
620
|
_onAddAttribute(t, e) {
|
|
619
|
-
const r =
|
|
621
|
+
const r = k(t), i = this._readCompositionFromNode();
|
|
620
622
|
i.push(r);
|
|
621
623
|
const s = [...this._readCustomAttributesFromNode(), t];
|
|
622
624
|
this._updateBothAttributes(i, s), this._injectCustomAttributeHtml(t, e, r, i), this._renderOrderableItems(i, s), this._initializeCustomSelects(s), this._updateAddButtonState();
|
|
@@ -640,17 +642,17 @@ class se extends ut {
|
|
|
640
642
|
const r = this._readCustomAttributesFromNode(), i = r[t];
|
|
641
643
|
if (i === void 0 || i === e)
|
|
642
644
|
return;
|
|
643
|
-
const s =
|
|
645
|
+
const s = k(e), o = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(o, t);
|
|
644
646
|
n !== -1 && (o[n] = s), r[t] = e;
|
|
645
647
|
const l = this._getDisplayNameForAttribute(e);
|
|
646
648
|
this._updateBothAttributes(o, r), this._injectCustomAttributeHtml(e, l, s, o), this._renderOrderableItems(o, r), this._initializeCustomSelects(r);
|
|
647
649
|
}
|
|
648
650
|
_onReorder(t) {
|
|
649
|
-
const e = t.filter((r) => r.startsWith(
|
|
651
|
+
const e = t.filter((r) => r.startsWith(N)).map(M);
|
|
650
652
|
this.reorderInProgress = !0;
|
|
651
653
|
try {
|
|
652
654
|
this._updateBothAttributes(t, e);
|
|
653
|
-
const r = !
|
|
655
|
+
const r = !p.getConfig(this.currentNode).priceMovedToNextLine;
|
|
654
656
|
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && Bt({
|
|
655
657
|
currentNode: this.currentNode,
|
|
656
658
|
documentModifier: this.api.getDocumentModifier()
|
|
@@ -673,7 +675,7 @@ class se extends ut {
|
|
|
673
675
|
if (r && "getOuterHTML" in r)
|
|
674
676
|
return Q(r.getOuterHTML(), e);
|
|
675
677
|
const i = t.querySelector(
|
|
676
|
-
`${
|
|
678
|
+
`${E}[${R}="${e}"]`
|
|
677
679
|
);
|
|
678
680
|
return i && "getOuterHTML" in i ? Q(i.getOuterHTML(), e) : "";
|
|
679
681
|
}
|
|
@@ -686,11 +688,11 @@ class se extends ut {
|
|
|
686
688
|
const s = this.currentNode.querySelectorAll(U);
|
|
687
689
|
if (!(s != null && s.length))
|
|
688
690
|
return;
|
|
689
|
-
const o =
|
|
691
|
+
const o = p.getConfig(this.currentNode), l = `0 ${Math.floor(o.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), d = this.store.recommendationProducts.length;
|
|
690
692
|
let c = 0;
|
|
691
693
|
s.forEach((u) => {
|
|
692
694
|
var V;
|
|
693
|
-
const
|
|
695
|
+
const h = u.querySelector(E), S = ((V = h == null ? void 0 : h.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
696
|
if (j === r) {
|
|
695
697
|
const st = Array.from(
|
|
696
698
|
{ length: B },
|
|
@@ -710,12 +712,12 @@ class se extends ut {
|
|
|
710
712
|
);
|
|
711
713
|
}
|
|
712
714
|
).join(""), ot = Ct(F, l).repeat(S - B);
|
|
713
|
-
return `<tr class="${G}" ${
|
|
715
|
+
return `<tr class="${G}" ${R}="${r}" ${D}="1">${st}${ot}</tr>`;
|
|
714
716
|
}
|
|
715
717
|
return this._getExistingRowHtml(u, j);
|
|
716
718
|
}).join("");
|
|
717
719
|
c += B, d > 0 && c >= d && (c = 0), a.modifyHtml(u).setInnerHtml(it);
|
|
718
|
-
}), a.apply(new
|
|
720
|
+
}), a.apply(new T(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
719
721
|
}
|
|
720
722
|
_injectListAttributeRow(t, e, r, i) {
|
|
721
723
|
const s = this.currentNode.querySelectorAll(Z);
|
|
@@ -731,7 +733,7 @@ class se extends ut {
|
|
|
731
733
|
return this._getExistingRowHtml(l, c);
|
|
732
734
|
}).join("");
|
|
733
735
|
n.modifyHtml(l).setInnerHtml(d);
|
|
734
|
-
}), n.apply(new
|
|
736
|
+
}), n.apply(new T(`${this.api.translate("Add custom attribute")}: ${e}`));
|
|
735
737
|
}
|
|
736
738
|
/**
|
|
737
739
|
* Removes a custom attribute by rebuilding product card content without it.
|
|
@@ -754,7 +756,7 @@ class se extends ut {
|
|
|
754
756
|
r.modifyHtml(o).setInnerHtml(n);
|
|
755
757
|
});
|
|
756
758
|
}
|
|
757
|
-
r.apply(new
|
|
759
|
+
r.apply(new T(this.api.translate("Remove custom attribute")));
|
|
758
760
|
}
|
|
759
761
|
// ========================================================================
|
|
760
762
|
// DOM Mutation (Block Root Attributes, Reorder)
|
|
@@ -770,10 +772,10 @@ class se extends ut {
|
|
|
770
772
|
if (!this.currentNode)
|
|
771
773
|
return;
|
|
772
774
|
const r = {
|
|
773
|
-
...
|
|
775
|
+
...p.getConfig(this.currentNode),
|
|
774
776
|
composition: t
|
|
775
777
|
};
|
|
776
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(K, t.join(",")).setAttribute(W, JSON.stringify(e)).setNodeConfig(r).apply(new
|
|
778
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(K, t.join(",")).setAttribute(W, JSON.stringify(e)).setNodeConfig(r).apply(new T(this.api.translate("Update card composition")));
|
|
777
779
|
}
|
|
778
780
|
/**
|
|
779
781
|
* Reorders attribute rows within each product card based on composition order.
|
|
@@ -789,7 +791,7 @@ class se extends ut {
|
|
|
789
791
|
e.forEach((i) => {
|
|
790
792
|
const s = this._buildCompositionHtml(i, t);
|
|
791
793
|
r.modifyHtml(i).setInnerHtml(s);
|
|
792
|
-
}), r.apply(new
|
|
794
|
+
}), r.apply(new T(this.api.translate("Reorder product attributes")));
|
|
793
795
|
}
|
|
794
796
|
/**
|
|
795
797
|
* Builds HTML string with attributes ordered according to composition.
|
|
@@ -804,37 +806,44 @@ class se extends ut {
|
|
|
804
806
|
_applyVisibilityToBlock(t, e) {
|
|
805
807
|
if (!this.currentNode)
|
|
806
808
|
return;
|
|
807
|
-
if (t ===
|
|
809
|
+
if (t === $) {
|
|
808
810
|
this._applyTitleVisibilityToBlock(e);
|
|
809
811
|
return;
|
|
810
812
|
}
|
|
811
|
-
const r = this.currentNode.querySelectorAll(`${
|
|
812
|
-
if (!
|
|
813
|
+
const r = this._resolveVisibilityKeys(t), { currentNode: i } = this, s = r.flatMap((c) => Array.from(i.querySelectorAll(`${E}[${R}="${c}"]`) ?? []));
|
|
814
|
+
if (!s.length)
|
|
813
815
|
return;
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
|
|
816
|
+
const o = e ? "1" : "0", n = e ? this.api.translate("visible") : this.api.translate("hidden"), l = `${this.api.translate("Set visibility")}: ${t} → ${n}`, a = this.api.getDocumentModifier();
|
|
817
|
+
s.forEach((c) => {
|
|
818
|
+
const u = Pt(c), h = e ? u : "none";
|
|
819
|
+
a.modifyHtml(c).setStyle("display", h).setAttribute(D, o);
|
|
818
820
|
});
|
|
819
|
-
const
|
|
820
|
-
...
|
|
821
|
-
visibility: {
|
|
821
|
+
const d = {
|
|
822
|
+
...p.getConfig(this.currentNode),
|
|
823
|
+
visibility: {
|
|
824
|
+
...this._readVisibilityFromRows(),
|
|
825
|
+
...Object.fromEntries(r.map((c) => [c, e]))
|
|
826
|
+
}
|
|
822
827
|
};
|
|
823
|
-
|
|
828
|
+
a.modifyHtml(this.currentNode).setNodeConfig(d), a.apply(new T(l));
|
|
829
|
+
}
|
|
830
|
+
/** Inline "Product Prices" group row is tagged with whichever price comes first, so it drives both keys. */
|
|
831
|
+
_resolveVisibilityKeys(t) {
|
|
832
|
+
return !p.getConfig(this.currentNode).priceMovedToNextLine && t === _ ? [_, I] : [t];
|
|
824
833
|
}
|
|
825
834
|
_applyTitleVisibilityToBlock(t) {
|
|
826
|
-
const e =
|
|
835
|
+
const e = p.getConfig(this.currentNode), r = t ? this._resolveTitleInjection(e) : null, i = t ? [] : this._findTitleRows(), s = t ? this._hasTitle() || !r : i.length === 0;
|
|
827
836
|
if (!this.currentNode || s)
|
|
828
837
|
return;
|
|
829
838
|
const o = this.api.getDocumentModifier();
|
|
830
839
|
r ? o.modifyHtml(r.containerBody).setInnerHtml(r.html) : i.forEach((l) => o.modifyHtml(l).delete()), o.modifyHtml(this.currentNode).setNodeConfig({
|
|
831
840
|
...e,
|
|
832
841
|
previousTitleHtml: t ? e.previousTitleHtml : this._readTitleHtml(i),
|
|
833
|
-
visibility: { ...this._readVisibilityFromRows(), [
|
|
842
|
+
visibility: { ...this._readVisibilityFromRows(), [$]: t }
|
|
834
843
|
});
|
|
835
844
|
const n = t ? this.api.translate("visible") : this.api.translate("hidden");
|
|
836
|
-
o.apply(new
|
|
837
|
-
`${this.api.translate("Set visibility")}: ${
|
|
845
|
+
o.apply(new T(
|
|
846
|
+
`${this.api.translate("Set visibility")}: ${$} → ${n}`
|
|
838
847
|
));
|
|
839
848
|
}
|
|
840
849
|
_resolveTitleInjection(t) {
|
|
@@ -850,7 +859,7 @@ class se extends ut {
|
|
|
850
859
|
_findTitleRows() {
|
|
851
860
|
var e;
|
|
852
861
|
const t = Array.from(((e = this.currentNode) == null ? void 0 : e.querySelectorAll(
|
|
853
|
-
`${
|
|
862
|
+
`${E}[${R}="${$}"]`
|
|
854
863
|
)) ?? []);
|
|
855
864
|
return t.length > 0 ? t : this._findTitleRowsByClass();
|
|
856
865
|
}
|
|
@@ -865,7 +874,7 @@ class se extends ut {
|
|
|
865
874
|
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(_t));
|
|
866
875
|
}
|
|
867
876
|
_findTitleContainerBody() {
|
|
868
|
-
return (this.currentNode ?
|
|
877
|
+
return (this.currentNode ? Mt(this.currentNode) : null) ?? void 0;
|
|
869
878
|
}
|
|
870
879
|
_readInnerHtml(t) {
|
|
871
880
|
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : null;
|
|
@@ -884,7 +893,7 @@ class se extends ut {
|
|
|
884
893
|
_findNthCustomKeyIndex(t, e) {
|
|
885
894
|
let r = 0;
|
|
886
895
|
for (let i = 0; i < t.length; i++)
|
|
887
|
-
if (t[i].startsWith(
|
|
896
|
+
if (t[i].startsWith(N)) {
|
|
888
897
|
if (r === e)
|
|
889
898
|
return i;
|
|
890
899
|
r++;
|
|
@@ -892,7 +901,7 @@ class se extends ut {
|
|
|
892
901
|
return -1;
|
|
893
902
|
}
|
|
894
903
|
_getCurrentLayout() {
|
|
895
|
-
return this.store.recommendationConfigs.orientation ||
|
|
904
|
+
return this.store.recommendationConfigs.orientation || kt(this.currentNode);
|
|
896
905
|
}
|
|
897
906
|
/**
|
|
898
907
|
* Extracts background color properties from existing card elements.
|
|
@@ -944,7 +953,7 @@ class se extends ut {
|
|
|
944
953
|
* or when all available filters have already been added (no unused attributes left).
|
|
945
954
|
*/
|
|
946
955
|
_updateAddButtonState() {
|
|
947
|
-
const t = this._readCustomAttributesFromNode(), e = t.length >=
|
|
956
|
+
const t = this._readCustomAttributesFromNode(), e = t.length >= y, r = new Set(t), i = this._getAddableFilters(), s = i.length > 0 && i.every((o) => r.has(C(o)));
|
|
948
957
|
this.api.setUIEAttribute(
|
|
949
958
|
tt.ADD_ATTRIBUTE,
|
|
950
959
|
O.BUTTON.disabled,
|
|
@@ -977,7 +986,7 @@ class se extends ut {
|
|
|
977
986
|
_getAddableFilters() {
|
|
978
987
|
const t = /* @__PURE__ */ new Set();
|
|
979
988
|
return Object.values(this.store.filterList).filter((e) => !(e.type === "defaultAttribute" && gt.has(e.attributeName))).filter((e) => {
|
|
980
|
-
const r =
|
|
989
|
+
const r = C(e);
|
|
981
990
|
return t.has(r) ? !1 : (t.add(r), !0);
|
|
982
991
|
});
|
|
983
992
|
}
|
|
@@ -987,7 +996,7 @@ class se extends ut {
|
|
|
987
996
|
* resolve to their own entry. Falls back to Title Case of the bare name.
|
|
988
997
|
*/
|
|
989
998
|
_getDisplayNameForAttribute(t) {
|
|
990
|
-
const e = Object.values(this.store.filterList).find((r) =>
|
|
999
|
+
const e = Object.values(this.store.filterList).find((r) => C(r) === t);
|
|
991
1000
|
return e ? e.displayName : Nt(H(t));
|
|
992
1001
|
}
|
|
993
1002
|
/**
|
|
@@ -1000,7 +1009,7 @@ class se extends ut {
|
|
|
1000
1009
|
return Et(n) ?? e;
|
|
1001
1010
|
}
|
|
1002
1011
|
_getGridCellHtml(t, e, r, i = "", s = "", o = "") {
|
|
1003
|
-
const n =
|
|
1012
|
+
const n = k(t), l = H(t), a = J(yt, [n], this.store.filterList), d = {
|
|
1004
1013
|
[l]: e,
|
|
1005
1014
|
product_attributes: { [l]: e }
|
|
1006
1015
|
};
|
|
@@ -1015,7 +1024,7 @@ class se extends ut {
|
|
|
1015
1024
|
[i]: e,
|
|
1016
1025
|
product_attributes: { [i]: e }
|
|
1017
1026
|
}, l = s[r](o).replace(/<tr>/, "").replace(/<\/tr>/, "");
|
|
1018
|
-
return `<tr class="${G}" ${
|
|
1027
|
+
return `<tr class="${G}" ${R}="${r}" ${D}="1">${l}</tr>`;
|
|
1019
1028
|
}
|
|
1020
1029
|
}
|
|
1021
1030
|
export {
|