@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,31 +1,37 @@
|
|
|
1
1
|
import { BlockId as f } from "../../enums/block.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as b } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as y } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as T } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as v } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { extractCurrencyFromBlock as C, extractTitleText as M, hasVisibleTitle as R, extractCardBgColor as S, isPartnerManagedBlock as h } from "./recommendation/extractors.js";
|
|
5
7
|
import { buildBlockHtml as w } from "./recommendation/htmlBuilder.js";
|
|
6
|
-
import { parseRecommendationId as x, parseLegacyConfig as
|
|
7
|
-
import { mapSettings as
|
|
8
|
-
const
|
|
9
|
-
function B(
|
|
10
|
-
var
|
|
8
|
+
import { parseRecommendationId as x, parseLegacyConfig as E } from "./recommendation/parseLegacyConfig.js";
|
|
9
|
+
import { mapSettings as A } from "./recommendation/settingsMapper.js";
|
|
10
|
+
const H = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
|
|
11
|
+
function B(n, t, a) {
|
|
12
|
+
var l;
|
|
11
13
|
const o = x(t);
|
|
12
14
|
if (o === null)
|
|
13
15
|
return console.warn(
|
|
14
16
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
15
17
|
), !1;
|
|
16
|
-
const r =
|
|
18
|
+
const r = E(t);
|
|
17
19
|
if (!r)
|
|
18
20
|
return console.warn(
|
|
19
21
|
`[RecommendationMigrator] Aborting block id=${o} — \`esd-dev-product-config\` missing or unable to be parsed`
|
|
20
22
|
), !1;
|
|
21
|
-
const
|
|
22
|
-
currencySettings:
|
|
23
|
-
}, c =
|
|
23
|
+
const i = a[String(o)] ?? {
|
|
24
|
+
currencySettings: C(t)
|
|
25
|
+
}, c = A(i, r, o), e = v((l = r.composition) == null ? void 0 : l.variables), d = M(t);
|
|
26
|
+
e.titleVariable || (e.visibility[y] = R(t));
|
|
27
|
+
const p = S(t), g = {
|
|
24
28
|
...c,
|
|
29
|
+
strategyId: "",
|
|
25
30
|
composition: e.composition,
|
|
26
31
|
visibility: e.visibility,
|
|
32
|
+
previousTitleHtml: b.previousTitleHtml,
|
|
27
33
|
textTrimming: e.anyTextTrimming
|
|
28
|
-
}, m =
|
|
34
|
+
}, m = h(t), u = `
|
|
29
35
|
<table>
|
|
30
36
|
<tbody>
|
|
31
37
|
<tr>
|
|
@@ -33,10 +39,10 @@ function B(i, t, a) {
|
|
|
33
39
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
34
40
|
<tbody>
|
|
35
41
|
<tr>${w({
|
|
36
|
-
nodeConfig:
|
|
42
|
+
nodeConfig: g,
|
|
37
43
|
composition: e,
|
|
38
|
-
cardBg:
|
|
39
|
-
titleText:
|
|
44
|
+
cardBg: p,
|
|
45
|
+
titleText: d,
|
|
40
46
|
legacyId: t.getAttribute("id") ?? void 0,
|
|
41
47
|
legacyBgColor: t.getAttribute("bgcolor") ?? void 0,
|
|
42
48
|
preserveInnerHtml: m ? t.innerHTML : void 0,
|
|
@@ -48,15 +54,15 @@ function B(i, t, a) {
|
|
|
48
54
|
</tr>
|
|
49
55
|
</tbody>
|
|
50
56
|
</table>
|
|
51
|
-
`, s =
|
|
57
|
+
`, s = n.parseFromString(u, "text/html").querySelector("td.esd-structure");
|
|
52
58
|
return !s || !t.parentNode ? (console.warn(
|
|
53
59
|
`[RecommendationMigrator] Aborting block id=${o} — failed to construct new HTML element`
|
|
54
60
|
), !1) : (t.parentNode.replaceChild(s, t), !0);
|
|
55
61
|
}
|
|
56
|
-
function
|
|
57
|
-
const a = new DOMParser(), o = a.parseFromString(
|
|
62
|
+
function G(n, t = {}) {
|
|
63
|
+
const a = new DOMParser(), o = a.parseFromString(n, "text/html"), r = Array.from(o.querySelectorAll(H));
|
|
58
64
|
try {
|
|
59
|
-
|
|
65
|
+
T().$patch((e) => {
|
|
60
66
|
e.migrations = {
|
|
61
67
|
...e.migrations,
|
|
62
68
|
[f.Recommendation]: r.length
|
|
@@ -65,16 +71,16 @@ function q(i, t = {}) {
|
|
|
65
71
|
} catch {
|
|
66
72
|
}
|
|
67
73
|
if (r.length === 0)
|
|
68
|
-
return
|
|
69
|
-
let
|
|
74
|
+
return n;
|
|
75
|
+
let i = 0;
|
|
70
76
|
return r.forEach((c) => {
|
|
71
77
|
try {
|
|
72
|
-
B(a, c, t) && (
|
|
78
|
+
B(a, c, t) && (i += 1);
|
|
73
79
|
} catch (e) {
|
|
74
80
|
console.error("[RecommendationMigrator] Unexpected error migrating block:", e);
|
|
75
81
|
}
|
|
76
|
-
}),
|
|
82
|
+
}), i > 0 && console.info(`[RecommendationMigrator] Migrated ${i} legacy Recommendation block(s)`), o.documentElement.outerHTML;
|
|
77
83
|
}
|
|
78
84
|
export {
|
|
79
|
-
|
|
85
|
+
G as migrateRecommendation
|
|
80
86
|
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var f = (s, t, e) => t in s ? R(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var a = (s, t, e) => f(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { RecommendationBlockId as d } from "../../extensions/Blocks/Recommendation/constants/blockIds.js";
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as u, CSS_CLASS_SKIP_COMPILE as m, ATTR_DATA_ATTRIBUTE_TYPE as S, ATTR_RECOMMENDATION_TITLE as l, CONTAINER_SELECTOR as E, CSS_CLASS_TITLE_CELL as c, CSS_CLASS_SPACER as C, CSS_CLASS_ATTRIBUTE_ROW as A, ATTR_DATA_VISIBILITY as L } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
|
+
const p = u.slice(1), g = `${u}:not(.${m})`, O = `[${S}="${l}"]`, h = "td.esd-block-text", _ = "table.container > tbody", T = "esd-ext-config";
|
|
7
|
+
class y {
|
|
8
|
+
constructor() {
|
|
9
|
+
a(this, "parser");
|
|
10
|
+
this.parser = new DOMParser();
|
|
11
|
+
}
|
|
12
|
+
migrate(t) {
|
|
13
|
+
try {
|
|
14
|
+
if (!t.includes(p))
|
|
15
|
+
return t;
|
|
16
|
+
const e = this.parser.parseFromString(t, "text/html");
|
|
17
|
+
return Array.from(e.querySelectorAll(g)).reduce(
|
|
18
|
+
(n, o) => this._migrateBlock(o) || n,
|
|
19
|
+
!1
|
|
20
|
+
) ? e.documentElement.outerHTML : t;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return console.error("RecommendationTitleMigrator failed:", e), t;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Migrates one block. Returns `true` when the block was changed. */
|
|
26
|
+
_migrateBlock(t) {
|
|
27
|
+
if (t.querySelector(O) || this._hasRecordedTitleState(t))
|
|
28
|
+
return !1;
|
|
29
|
+
const e = this._findTitleCell(t), i = e !== null && (e.textContent ?? "").trim().length > 0;
|
|
30
|
+
return i ? this._tagExistingTitle(t, e) : this._removeTitleRemnants(t, e), this._writeVisibility(t, i), !0;
|
|
31
|
+
}
|
|
32
|
+
/** The only `esd-block-text` cell outside the product containers is the title. */
|
|
33
|
+
_findTitleCell(t) {
|
|
34
|
+
return Array.from(t.querySelectorAll(h)).find((e) => !e.closest(E) && this._isTitlePosition(t, e)) ?? null;
|
|
35
|
+
}
|
|
36
|
+
_isTitlePosition(t, e) {
|
|
37
|
+
var r;
|
|
38
|
+
const i = this._wrapperRowOf(t, e);
|
|
39
|
+
return e.classList.contains(c) || i !== null && i === ((r = i.parentElement) == null ? void 0 : r.firstElementChild);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Stamps the attribute-row tagging onto the title's wrapper row and the spacer
|
|
43
|
+
* below it, so one toggle governs the pair and the compiler drops both when off.
|
|
44
|
+
*/
|
|
45
|
+
_tagExistingTitle(t, e) {
|
|
46
|
+
e.classList.add(c), e.setAttribute("esd-extension-block-id", d.TITLE);
|
|
47
|
+
const i = this._wrapperRowOf(t, e);
|
|
48
|
+
if (!i)
|
|
49
|
+
return;
|
|
50
|
+
this._tagRow(i);
|
|
51
|
+
const r = i.nextElementSibling;
|
|
52
|
+
r && this._isSpacerRow(r) && this._tagRow(r);
|
|
53
|
+
}
|
|
54
|
+
/** The `<tr>` inside `table.container > tbody` that wraps the title's own table. */
|
|
55
|
+
_wrapperRowOf(t, e) {
|
|
56
|
+
if (!e)
|
|
57
|
+
return null;
|
|
58
|
+
const i = t.querySelector(_);
|
|
59
|
+
return Array.from((i == null ? void 0 : i.children) ?? []).find((r) => r.contains(e)) ?? null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Direct children only — a product-container row holds spacer cells further down,
|
|
63
|
+
* and `querySelector` would happily reach them. (`:scope >` is unsupported in happy-dom.)
|
|
64
|
+
*/
|
|
65
|
+
_isSpacerRow(t) {
|
|
66
|
+
return Array.from(t.children).some((e) => e.classList.contains(C));
|
|
67
|
+
}
|
|
68
|
+
_tagRow(t) {
|
|
69
|
+
t.classList.add(A), t.setAttribute(S, l), t.setAttribute(L, "1");
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A deleted title leaves nothing to tag — the toggle re-injects the markup only
|
|
73
|
+
* when the user switches it back on. Its leftovers (an emptied wrapper row, the
|
|
74
|
+
* spacer that trailed it) would otherwise render as blank padding on top.
|
|
75
|
+
*/
|
|
76
|
+
_removeTitleRemnants(t, e) {
|
|
77
|
+
var o;
|
|
78
|
+
const i = this._wrapperRowOf(t, e), r = i == null ? void 0 : i.nextElementSibling;
|
|
79
|
+
if (r && this._isSpacerRow(r) && r.remove(), i) {
|
|
80
|
+
i.remove();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const n = (o = t.querySelector(_)) == null ? void 0 : o.firstElementChild;
|
|
84
|
+
n && this._isSpacerRow(n) && n.remove();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Mirrors the resolved state into the persisted config blob, so a saved module
|
|
88
|
+
* whose `data-*` attributes Stripo strips on re-drop still restores the toggle.
|
|
89
|
+
*/
|
|
90
|
+
_writeVisibility(t, e) {
|
|
91
|
+
const i = this._readConfig(t);
|
|
92
|
+
if (!i)
|
|
93
|
+
return;
|
|
94
|
+
const r = typeof i.visibility == "object" && i.visibility !== null ? i.visibility : {};
|
|
95
|
+
i.visibility = { ...r, [l]: e }, t.setAttribute(T, JSON.stringify(i));
|
|
96
|
+
}
|
|
97
|
+
_hasRecordedTitleState(t) {
|
|
98
|
+
var i;
|
|
99
|
+
const e = (i = this._readConfig(t)) == null ? void 0 : i.visibility;
|
|
100
|
+
return typeof e == "object" && e !== null && l in e;
|
|
101
|
+
}
|
|
102
|
+
_readConfig(t) {
|
|
103
|
+
const e = t.getAttribute(T);
|
|
104
|
+
if (!e)
|
|
105
|
+
return null;
|
|
106
|
+
try {
|
|
107
|
+
const i = JSON.parse(e);
|
|
108
|
+
return typeof i == "object" && i !== null ? i : null;
|
|
109
|
+
} catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function v(s) {
|
|
115
|
+
return new y().migrate(s);
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
v as migrateRecommendationTitle
|
|
119
|
+
};
|
package/dist/enums/academy.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const e = "https://academy.insiderone.com", o = {
|
|
2
2
|
EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
|
|
3
3
|
GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
|
|
4
|
-
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails
|
|
4
|
+
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
|
|
5
|
+
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
|
|
5
6
|
};
|
|
6
7
|
export {
|
|
7
8
|
o as ACADEMY_LINKS
|
package/dist/enums/date.js
CHANGED
|
@@ -2,7 +2,9 @@ import { useTranslations as r } from "../../composables/useTranslations.js";
|
|
|
2
2
|
const l = {
|
|
3
3
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
|
-
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes"
|
|
5
|
+
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
6
|
+
RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
|
|
7
|
+
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
6
8
|
}, c = {
|
|
7
9
|
CLIENT_ID: "clientId"
|
|
8
10
|
}, d = () => {
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var D = (l, a, t) => a in l ? k(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
|
|
3
|
+
var y = (l, a, t) => D(l, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { BlockId as N } from "../../../enums/block.js";
|
|
5
|
+
import { useOnboardingStore as T } from "../../../stores/onboarding.js";
|
|
6
|
+
import { getMigrationBannerHtml as S } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as A, BlockCompositionType as M, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { currencyAttrTargets as H, ITEMS_CURRENCY_ATTR as m } from "./constants/currency.js";
|
|
9
|
+
import { ItemsBlockId as R } from "./enums/controlEnums.js";
|
|
10
|
+
import { SETTINGS_ENUMS as C, DefaultConfigValues as g } from "./enums/settingsEnums.js";
|
|
11
|
+
import { getDefaultTemplate as O } from "./template.js";
|
|
12
|
+
import { getItemsBlockContainer as b, getItemsBlockConfig as h, deriveItemNumber as B, generateBlockInstanceId as E, getDefaultItemsBlockConfig as w } from "./utils/nodeConfigUtils.js";
|
|
13
|
+
const _ = N.Items, P = "Reconcile Items currency DOM attributes";
|
|
14
|
+
class K extends A {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
18
|
+
y(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
19
|
+
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
20
|
+
y(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
|
|
21
|
+
}
|
|
10
22
|
getId() {
|
|
11
|
-
return
|
|
23
|
+
return _;
|
|
12
24
|
}
|
|
13
25
|
getIcon() {
|
|
14
26
|
return "items-icon";
|
|
15
27
|
}
|
|
16
28
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
29
|
+
return M.CONTAINER;
|
|
18
30
|
}
|
|
19
31
|
getName() {
|
|
20
32
|
return this.api.translate("Items");
|
|
@@ -23,20 +35,20 @@ class E extends C {
|
|
|
23
35
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
36
|
}
|
|
25
37
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
27
|
-
|
|
38
|
+
return S(
|
|
39
|
+
_,
|
|
28
40
|
this.api.translate("Items"),
|
|
29
41
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
30
42
|
);
|
|
31
43
|
}
|
|
32
44
|
getTemplate() {
|
|
33
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
45
|
+
return O({
|
|
46
|
+
orientation: C.ORIENTATION.VERTICAL,
|
|
47
|
+
itemsType: C.ITEMS_TYPE.CART_ITEMS,
|
|
36
48
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
49
|
+
currencySymbol: g.productPriceCurrencySymbolControlValue,
|
|
50
|
+
currencyLocation: g.productPriceCurrencyLocationControlValue,
|
|
51
|
+
formattedPrice: g.productPriceFormattedControlValue === "1"
|
|
40
52
|
});
|
|
41
53
|
}
|
|
42
54
|
allowInnerBlocksDND() {
|
|
@@ -45,24 +57,27 @@ class E extends C {
|
|
|
45
57
|
canBeSavedAsModule() {
|
|
46
58
|
return !0;
|
|
47
59
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
60
|
+
onCreated(t) {
|
|
61
|
+
const o = this.api.getDocumentModifier(), c = this.api.getDocumentRootCssNode();
|
|
62
|
+
c.querySelector('[product-attr="imageSrc"] img') || o.modifyCss(c).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
63
|
+
const i = b(t);
|
|
64
|
+
if (!i)
|
|
53
65
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
|
|
66
|
+
const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, e = h(t);
|
|
67
|
+
if (e != null && e.initialized) {
|
|
68
|
+
if (!s) {
|
|
69
|
+
const d = this.api.getDocumentModifier();
|
|
70
|
+
d.modifyHtml(i).setNodeConfig(e), this._stampProductTdDomAttributes(i, e, d), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(i, e, d), d.apply(new u("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(e.blockInstanceId);
|
|
71
|
+
return;
|
|
61
72
|
}
|
|
62
|
-
else {
|
|
63
|
-
const
|
|
64
|
-
|
|
73
|
+
} else {
|
|
74
|
+
const d = w(), p = this.api.getDocumentModifier();
|
|
75
|
+
p.modifyHtml(i).setNodeConfig(d), this._stampProductTdDomAttributes(i, d, p, !0), p.apply(new u("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
|
|
76
|
+
return;
|
|
65
77
|
}
|
|
78
|
+
const n = this._resolveInstanceId(e.blockInstanceId), f = this.api.getDocumentModifier();
|
|
79
|
+
let I = !1;
|
|
80
|
+
n !== e.blockInstanceId && (f.modifyHtml(i).setNodeConfig({ ...e, blockInstanceId: n }), I = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(i, e, f) && (I = !0), I && f.apply(new u("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
66
81
|
}
|
|
67
82
|
/**
|
|
68
83
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -70,18 +85,24 @@ class E extends C {
|
|
|
70
85
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
86
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
87
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
88
|
+
onDocumentChanged(t) {
|
|
89
|
+
const o = b(t);
|
|
90
|
+
if (!o)
|
|
76
91
|
return;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
92
|
+
const c = o.getNodeConfig();
|
|
93
|
+
if (c && Object.keys(c).length > 0) {
|
|
94
|
+
const e = h(t);
|
|
95
|
+
if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
|
|
96
|
+
const n = this.api.getDocumentModifier();
|
|
97
|
+
this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new u(P)), this._markCurrencyHealed(e.blockInstanceId);
|
|
98
|
+
}
|
|
79
99
|
return;
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
}
|
|
101
|
+
const r = h(t);
|
|
102
|
+
if (!(r != null && r.initialized))
|
|
82
103
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
104
|
+
const s = this.api.getDocumentModifier();
|
|
105
|
+
s.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, s), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, s), s.apply(new u("Recover Items block config from saved module")), this._markCurrencyHealed(r.blockInstanceId);
|
|
85
106
|
}
|
|
86
107
|
/**
|
|
87
108
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -91,14 +112,62 @@ class E extends C {
|
|
|
91
112
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
113
|
* relies on this td-level fallback in pairProductVariables.
|
|
93
114
|
*/
|
|
94
|
-
_stampProductTdDomAttributes(
|
|
95
|
-
const
|
|
96
|
-
|
|
115
|
+
_stampProductTdDomAttributes(t, o, c, i = !1) {
|
|
116
|
+
const r = B(o.itemsSelectValue, o.type), s = (e, n) => {
|
|
117
|
+
i && t.getAttribute(e) || c.modifyHtml(t).setAttribute(e, n);
|
|
97
118
|
};
|
|
98
|
-
|
|
119
|
+
s("data-type", o.type), s("data-number", r), s("data-nodup", String(o.priceHideDiscount));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Whether a currency self-heal pass should run for this block (SD-147588). The only gate here is
|
|
123
|
+
* once-per-session: heal each instance at most once, so the auto-fix can't fight undo (undo
|
|
124
|
+
* re-drifts the attr, which would otherwise re-trigger the heal forever). The position-vs-symbol
|
|
125
|
+
* authority split lives in `_reconcileCurrencyDomAttributes` — position is always authoritative,
|
|
126
|
+
* the symbol write alone is skipped for the 'USD' sentinel — so we must NOT gate the whole pass
|
|
127
|
+
* on symbol customization here, or a default-symbol block with a toggled location never heals.
|
|
128
|
+
*/
|
|
129
|
+
_shouldReconcileCurrency(t) {
|
|
130
|
+
return !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
|
|
131
|
+
}
|
|
132
|
+
/** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
|
|
133
|
+
_markCurrencyHealed(t) {
|
|
134
|
+
t && this._currencyHealed.add(t);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Resolves the id for a just-created block to one that is unique per live instance.
|
|
138
|
+
* A saved module serializes its blockInstanceId, so every re-drop of the same module
|
|
139
|
+
* arrives with an id already owned by a live instance — reusing it collides both the
|
|
140
|
+
* currency heal guard and settings-panel switch detection. Mint a fresh id on absence
|
|
141
|
+
* or collision, otherwise keep the existing one. Registers the result as claimed.
|
|
142
|
+
*/
|
|
143
|
+
_resolveInstanceId(t) {
|
|
144
|
+
let o = t;
|
|
145
|
+
if (!o || this._seenInstanceIds.has(o))
|
|
146
|
+
do
|
|
147
|
+
o = E();
|
|
148
|
+
while (this._seenInstanceIds.has(o));
|
|
149
|
+
return this._seenInstanceIds.add(o), o;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
|
|
153
|
+
* attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
|
|
154
|
+
* Config is the source of truth — never derive from visible text.
|
|
155
|
+
*
|
|
156
|
+
* Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
|
|
157
|
+
* is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
|
|
158
|
+
*
|
|
159
|
+
* Returns true only when an attr actually changed, so the caller can skip an empty apply that
|
|
160
|
+
* would otherwise re-trigger onDocumentChanged and loop.
|
|
161
|
+
*/
|
|
162
|
+
_reconcileCurrencyDomAttributes(t, o, c) {
|
|
163
|
+
const { position: i, symbol: r } = H(o), s = t.querySelectorAll(`.${R.PRICE} p`);
|
|
164
|
+
let e = !1;
|
|
165
|
+
return s.forEach((n) => {
|
|
166
|
+
i !== void 0 && n.getAttribute(m.POSITION) !== i && (c.modifyHtml(n).setAttribute(m.POSITION, i), e = !0), r !== void 0 && n.getAttribute(m.SYMBOL) !== r && (c.modifyHtml(n).setAttribute(m.SYMBOL, r), e = !0);
|
|
167
|
+
}), e;
|
|
99
168
|
}
|
|
100
169
|
}
|
|
101
170
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
171
|
+
_ as BLOCK_ID,
|
|
172
|
+
K as ItemsBlock
|
|
104
173
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
|
|
2
|
+
const s = {
|
|
3
|
+
POSITION: "data-curency",
|
|
4
|
+
SYMBOL: "data-currency_symbol"
|
|
5
|
+
};
|
|
6
|
+
function e(r) {
|
|
7
|
+
return r === "1" ? "after" : "before";
|
|
8
|
+
}
|
|
9
|
+
function i(r) {
|
|
10
|
+
const o = (r ?? "").trim();
|
|
11
|
+
return o !== "" && o !== c.productPriceCurrencySymbolControlValue;
|
|
12
|
+
}
|
|
13
|
+
function a(r) {
|
|
14
|
+
const o = r.priceCurrencyLocation, n = typeof o == "string" && o.trim() !== "", t = (r.priceCurrencySymbol ?? "").trim();
|
|
15
|
+
return {
|
|
16
|
+
position: n ? e(o) : void 0,
|
|
17
|
+
symbol: i(t) ? t : void 0
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
s as ITEMS_CURRENCY_ATTR,
|
|
22
|
+
a as currencyAttrTargets,
|
|
23
|
+
e as currencyPositionFromLocation,
|
|
24
|
+
i as isCustomCurrencySymbol
|
|
25
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { currencyLocationMaps as
|
|
2
|
-
import { UEAttr as
|
|
3
|
-
import { CommonControl as
|
|
1
|
+
import { currencyLocationMaps as p } from "../../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { CommonControl as L } from "../../../common-control.js";
|
|
4
|
+
import { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
|
|
4
5
|
import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
const
|
|
6
|
+
import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
|
|
7
|
+
const b = m.PRICE_CURRENCY_LOCATION, c = {
|
|
7
8
|
CURRENCY_LOCATION: "currencyLocation"
|
|
8
9
|
};
|
|
9
|
-
class
|
|
10
|
+
class Y extends L {
|
|
10
11
|
getId() {
|
|
11
|
-
return
|
|
12
|
+
return b;
|
|
12
13
|
}
|
|
13
14
|
getTemplate() {
|
|
14
15
|
return `
|
|
@@ -18,32 +19,32 @@ class A extends N {
|
|
|
18
19
|
`;
|
|
19
20
|
}
|
|
20
21
|
onRender() {
|
|
21
|
-
const e =
|
|
22
|
-
this.api.setUIEAttribute(c.CURRENCY_LOCATION,
|
|
22
|
+
const e = l(this.currentNode);
|
|
23
|
+
this.api.setUIEAttribute(c.CURRENCY_LOCATION, N.SELECTPICKER.items, p), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
|
|
23
24
|
this._onCurrencyLocationChange(t);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
onTemplateNodeUpdated(e) {
|
|
27
28
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
29
|
+
const t = l(this.currentNode);
|
|
29
30
|
this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
_onCurrencyLocationChange(e) {
|
|
33
|
-
if (console.debug("Currency location changed to: ", e),
|
|
34
|
+
if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
|
|
34
35
|
return;
|
|
35
36
|
const t = this._getPriceBlocks();
|
|
36
37
|
if (!t || t.length === 0)
|
|
37
38
|
return;
|
|
38
|
-
const r =
|
|
39
|
-
t.forEach((
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
39
|
+
const r = l(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = E(n), s = this.api.getDocumentModifier();
|
|
40
|
+
t.forEach((h) => {
|
|
41
|
+
const a = this._getParagraph(h);
|
|
42
|
+
if (!a)
|
|
42
43
|
return;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
`Updated currency location to ${
|
|
44
|
+
const d = a.getInnerHTML().trim() || "", C = a.getInnerText().trim() || "", u = (o == null ? void 0 : o.trim()) || "", _ = this._removeCurrencySymbol(C, u), g = this._detectSymbolInText(C) || u, R = this._buildPriceContent(_, g, n), y = d.replace(C, f(R));
|
|
45
|
+
s.modifyHtml(a).setInnerHtml(y).setAttribute(T.POSITION, i);
|
|
46
|
+
}), s.apply(new I(
|
|
47
|
+
`Updated currency location to ${i}`
|
|
47
48
|
));
|
|
48
49
|
}
|
|
49
50
|
_getPriceBlocks() {
|
|
@@ -65,8 +66,8 @@ class A extends N {
|
|
|
65
66
|
} else {
|
|
66
67
|
const o = r.match(/([^0-9.,\s]+)/);
|
|
67
68
|
if (o && o[1]) {
|
|
68
|
-
const i = o[1].trim(),
|
|
69
|
-
n = r.replace(
|
|
69
|
+
const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
|
|
70
|
+
n = r.replace(s, "").trim();
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
return n;
|
|
@@ -85,13 +86,13 @@ class A extends N {
|
|
|
85
86
|
this._GuSelect({
|
|
86
87
|
name: c.CURRENCY_LOCATION,
|
|
87
88
|
placeholder: "",
|
|
88
|
-
options:
|
|
89
|
+
options: p
|
|
89
90
|
})
|
|
90
91
|
])}
|
|
91
92
|
`;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
b as CONTROL_BLOCK_ID,
|
|
97
|
+
Y as PriceCurrencyLocationControl
|
|
97
98
|
};
|