@useinsider/guido 3.3.0 → 3.4.0-beta.0ec3bc7
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 +1 -1
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +42 -40
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +9 -11
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +70 -35
- package/dist/components/organisms/header/MiddleSlot.vue.js +7 -7
- package/dist/composables/useCortexBlueprintBridge.js +66 -0
- package/dist/composables/useEmailTemplateApplier.js +41 -0
- package/dist/composables/useGuidoStateBridge.js +48 -0
- package/dist/composables/useHtmlValidator.js +41 -36
- package/dist/composables/useRecommendation.js +2 -2
- package/dist/composables/useResponsivePreview.js +1 -1
- package/dist/config/compiler/recommendationCompilerRules.js +10 -10
- package/dist/config/migrator/radioButtonMigrator.js +30 -29
- package/dist/config/migrator/recommendation/htmlBuilder.js +65 -65
- package/dist/enums/extensions/recommendationBlock.js +101 -46
- package/dist/enums/unsubscribe.js +25 -24
- package/dist/extensions/Blocks/Checkbox/control.js +23 -23
- package/dist/extensions/Blocks/RadioButton/control.js +15 -15
- package/dist/extensions/Blocks/RadioButton/template.js +6 -6
- package/dist/extensions/Blocks/Recommendation/block.js +43 -36
- package/dist/extensions/Blocks/Recommendation/services/configService.js +33 -26
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +35 -26
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +10 -10
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +5 -5
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +26 -13
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +33 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +252 -329
- package/dist/package.json.js +1 -1
- package/dist/services/unsubscribeApi.js +6 -6
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +25 -0
- package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
- package/dist/src/composables/useGuidoStateBridge.d.ts +22 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +6 -1
- package/dist/src/enums/unsubscribe.d.ts +8 -3
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +11 -3
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +21 -0
- package/dist/src/stores/guido-email-editor.d.ts +41 -0
- package/dist/stores/guido-email-editor.js +20 -0
- package/package.json +5 -4
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { useTranslations as R } from "../composables/useTranslations.js";
|
|
2
|
-
import { ProductType as
|
|
2
|
+
import { ProductType as n } from "../@types/config/schemas.js";
|
|
3
3
|
import "../@types/config/defaults.js";
|
|
4
4
|
import { getEnvironmentPrefix as S } from "../utils/environmentUtil.js";
|
|
5
|
-
const
|
|
5
|
+
const i = {
|
|
6
6
|
UNSUBSCRIBE_LINK_TYPE: 1,
|
|
7
7
|
PREFERENCES_LINK_TYPE: 3
|
|
8
|
-
},
|
|
8
|
+
}, B = {
|
|
9
9
|
UNSUBSCRIBE_LINK_REGEX: /{{ins-unsubscribe-link}}/g,
|
|
10
10
|
DATA_OGSB_BUTTON_CSS_REGEX: "\\[data-ogsb\\]\\s*\\.es-button\\.es-button-[0-9]+\\s*\\{(?:[^\\}]*)\\}",
|
|
11
11
|
GLOBAL_UNSUBSCRIBE_LINK_REGEX: /{{ins-global-unsubscribe-link}}/g,
|
|
12
12
|
PREFERENCES_UNSUBSCRIBE_LINK_REGEX: /{{ins-preferences-unsubscribe-link}}/g
|
|
13
|
-
},
|
|
14
|
-
UNSUBSCRIBE_URL: `https://mail.${
|
|
15
|
-
PREFERENCES_URL: `https://mail.${
|
|
13
|
+
}, s = S(), C = {
|
|
14
|
+
UNSUBSCRIBE_URL: `https://mail.${s}.com/user/v1/unsub`,
|
|
15
|
+
PREFERENCES_URL: `https://mail.${s}.com/user/v1/prefs`
|
|
16
16
|
}, U = {
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
},
|
|
21
|
-
name: "
|
|
22
|
-
sendGridId:
|
|
23
|
-
},
|
|
17
|
+
[n.EMAIL]: "email",
|
|
18
|
+
[n.ARCHITECT]: "journey",
|
|
19
|
+
[n.UNSUBSCRIBE_PAGES]: "email"
|
|
20
|
+
}, o = "iid", r = "G", c = () => ({
|
|
21
|
+
name: R()("onboarding-center.email-subscribers-global-unsub-card-title"),
|
|
22
|
+
sendGridId: r
|
|
23
|
+
}), u = "/email/unsubscribe-pages", E = {
|
|
24
24
|
GLOBAL_UNSUBSCRIBE: 1,
|
|
25
25
|
GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: 2,
|
|
26
26
|
SUBSCRIPTION_PREFERENCE_CENTER: 3,
|
|
27
27
|
SUBSCRIPTION_PREFERENCE_CONFIRMATION: 4,
|
|
28
28
|
RESUBSCRIBE: 5
|
|
29
|
-
},
|
|
29
|
+
}, b = {
|
|
30
30
|
[E.GLOBAL_UNSUBSCRIBE]: "custom-unsubscribe",
|
|
31
31
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "custom-preferences"
|
|
32
32
|
}, T = {
|
|
@@ -39,7 +39,7 @@ const B = {
|
|
|
39
39
|
E.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
40
40
|
E.SUBSCRIPTION_PREFERENCE_CONFIRMATION
|
|
41
41
|
]
|
|
42
|
-
},
|
|
42
|
+
}, P = () => {
|
|
43
43
|
const e = R();
|
|
44
44
|
return {
|
|
45
45
|
[E.GLOBAL_UNSUBSCRIBE]: e("unsubscription-preference.type-global-unsubscribe"),
|
|
@@ -48,22 +48,23 @@ const B = {
|
|
|
48
48
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: e("unsubscription-preference.type-subscription-preferences-center"),
|
|
49
49
|
[E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]: e("unsubscription-preference.type-subscription-preferences-confirmation")
|
|
50
50
|
};
|
|
51
|
-
},
|
|
51
|
+
}, O = {
|
|
52
52
|
default: "{{ins-unsubscribe-link}}",
|
|
53
53
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
54
54
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
r as DEFAULT_UNSUBSCRIBE_GROUP_SEND_GRID_ID,
|
|
58
|
+
o as INSIDER_ID,
|
|
59
|
+
B as LINK_REGEXES,
|
|
60
|
+
i as LINK_TYPES,
|
|
61
|
+
O as MERGE_TAGS,
|
|
62
62
|
E as PAGE_TYPES,
|
|
63
63
|
U as PRODUCT_TYPE_URL_SEGMENTS,
|
|
64
64
|
T as TYPE_COLLECTIONS,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
u as UNSUBSCRIBE_PAGES_LINK,
|
|
66
|
+
b as UNSUBSCRIBE_SYNC_MODULE_TYPES,
|
|
67
67
|
C as URLS,
|
|
68
|
-
|
|
68
|
+
c as getDefaultUnsubscribeGroup,
|
|
69
|
+
P as getTypeTranslations
|
|
69
70
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (
|
|
4
|
-
import { useHttp as
|
|
5
|
-
import {
|
|
6
|
-
import { Control as
|
|
7
|
-
const
|
|
8
|
-
class
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var d = (i, n, e) => n in i ? E(i, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[n] = e;
|
|
3
|
+
var o = (i, n, e) => d(i, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
import { useHttp as l } from "../../../composables/useHttp.js";
|
|
5
|
+
import { getDefaultUnsubscribeGroup as L, DEFAULT_UNSUBSCRIBE_GROUP_SEND_GRID_ID as h } from "../../../enums/unsubscribe.js";
|
|
6
|
+
import { Control as p, UIElementType as r, UEAttr as t, ModificationDescription as m } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
const b = "ui-elements-checkbox", u = "select", { get: C } = l();
|
|
8
|
+
class I extends p {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
o(this, "currentNode");
|
|
@@ -13,13 +13,13 @@ class S extends h {
|
|
|
13
13
|
o(this, "unsubList", []);
|
|
14
14
|
}
|
|
15
15
|
getId() {
|
|
16
|
-
return
|
|
16
|
+
return b;
|
|
17
17
|
}
|
|
18
18
|
_setFormValues() {
|
|
19
19
|
if (this.selectedUnsubGroup = "", this.currentNode && "getAttribute" in this.currentNode) {
|
|
20
20
|
const e = this.currentNode.getAttribute("id");
|
|
21
21
|
if (e) {
|
|
22
|
-
const s = e ===
|
|
22
|
+
const s = e === h ? e : Number(e);
|
|
23
23
|
s && (this.selectedUnsubGroup = s);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -29,18 +29,18 @@ class S extends h {
|
|
|
29
29
|
}
|
|
30
30
|
_getLabel(e, s = `${Math.random()}`) {
|
|
31
31
|
return `
|
|
32
|
-
<${
|
|
32
|
+
<${r.LABEL}
|
|
33
33
|
${t.LABEL.text}="${e}"
|
|
34
34
|
${t.LABEL.name}="${s}">
|
|
35
|
-
</${
|
|
35
|
+
</${r.LABEL}>
|
|
36
36
|
`;
|
|
37
37
|
}
|
|
38
38
|
_getSelectItem(e, s) {
|
|
39
39
|
return `
|
|
40
|
-
<${
|
|
40
|
+
<${r.SELECT_ITEM}
|
|
41
41
|
${t.SELECT_ITEM.text}="${e}"
|
|
42
42
|
${t.SELECT_ITEM.value}="${s}">
|
|
43
|
-
</${
|
|
43
|
+
</${r.SELECT_ITEM}>`;
|
|
44
44
|
}
|
|
45
45
|
_getSelect() {
|
|
46
46
|
return this.unsubList.map((e) => this._getSelectItem(e.name, e.sendGridId)).join("");
|
|
@@ -49,22 +49,22 @@ class S extends h {
|
|
|
49
49
|
return `
|
|
50
50
|
<div class="checkbox-controls-container">
|
|
51
51
|
<div class="checkbox-select-container container two-columns stretch">
|
|
52
|
-
<${
|
|
52
|
+
<${r.LABEL}
|
|
53
53
|
${t.LABEL.text}="${this.api.translate("Unsubscribe Group")}"
|
|
54
54
|
${t.LABEL.name}="${Math.random()}">
|
|
55
|
-
</${
|
|
55
|
+
</${r.LABEL}>
|
|
56
56
|
|
|
57
|
-
<${
|
|
57
|
+
<${r.SELECTPICKER}
|
|
58
58
|
${t.SELECTPICKER.name}="${u}"
|
|
59
59
|
${t.SELECTPICKER.placeholder}="${this.api.translate("Select Unsubscribe Group")}">
|
|
60
60
|
${this._getSelect()}
|
|
61
|
-
</${
|
|
61
|
+
</${r.SELECTPICKER}>
|
|
62
62
|
</div>
|
|
63
63
|
</div>
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
66
66
|
_onSelectChange(e) {
|
|
67
|
-
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", e.toString()).apply(new
|
|
67
|
+
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", e.toString()).apply(new m(`Updated text to ${e}`));
|
|
68
68
|
}
|
|
69
69
|
_listenToFormUpdates() {
|
|
70
70
|
this.api.onValueChanged(u, (e) => this._onSelectChange(e));
|
|
@@ -76,18 +76,18 @@ class S extends h {
|
|
|
76
76
|
async onRender() {
|
|
77
77
|
const e = await C(
|
|
78
78
|
"/unsubscribe-groups/unsubscribe-list"
|
|
79
|
-
), s = [
|
|
79
|
+
), s = [L(), ...e.data], c = s.map((a) => ({
|
|
80
80
|
[t.SELECT_ITEM.text]: a.name,
|
|
81
81
|
[t.SELECT_ITEM.value]: a.sendGridId
|
|
82
82
|
}));
|
|
83
83
|
this.unsubList = s, this.api.setUIEAttribute(
|
|
84
84
|
u,
|
|
85
85
|
t.SELECTPICKER.items,
|
|
86
|
-
|
|
86
|
+
c
|
|
87
87
|
), this._setFormValues(), this._listenToFormUpdates();
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
b as CHECKBOX_CONTROL_BLOCK_ID,
|
|
92
|
+
I as CheckboxControl
|
|
93
93
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (r, n, t) =>
|
|
4
|
-
import { useHttp as
|
|
5
|
-
import {
|
|
6
|
-
import { Control as
|
|
7
|
-
const
|
|
8
|
-
class
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var d = (r, n, t) => n in r ? E(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
|
|
3
|
+
var o = (r, n, t) => d(r, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { useHttp as l } from "../../../composables/useHttp.js";
|
|
5
|
+
import { getDefaultUnsubscribeGroup as L, DEFAULT_UNSUBSCRIBE_GROUP_SEND_GRID_ID as p } from "../../../enums/unsubscribe.js";
|
|
6
|
+
import { Control as h, UIElementType as i, UEAttr as e, ModificationDescription as m } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
const b = "ui-elements-radio-button", u = "select", { get: $ } = l();
|
|
8
|
+
class I extends h {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
o(this, "currentNode");
|
|
@@ -13,13 +13,13 @@ class S extends p {
|
|
|
13
13
|
o(this, "unsubList", []);
|
|
14
14
|
}
|
|
15
15
|
getId() {
|
|
16
|
-
return
|
|
16
|
+
return b;
|
|
17
17
|
}
|
|
18
18
|
_setFormValues() {
|
|
19
19
|
if (this.selectedUnsubGroup = "", this.currentNode && "getAttribute" in this.currentNode) {
|
|
20
20
|
const t = this.currentNode.getAttribute("id");
|
|
21
21
|
if (t) {
|
|
22
|
-
const s = t ===
|
|
22
|
+
const s = t === p ? t : Number(t);
|
|
23
23
|
s && (this.selectedUnsubGroup = s);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -64,7 +64,7 @@ class S extends p {
|
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
66
66
|
_onSelectChange(t) {
|
|
67
|
-
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", t.toString()).apply(new
|
|
67
|
+
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", t.toString()).apply(new m(`Updated text to ${t}`));
|
|
68
68
|
}
|
|
69
69
|
_listenToFormUpdates() {
|
|
70
70
|
this.api.onValueChanged(u, (t) => this._onSelectChange(t));
|
|
@@ -76,18 +76,18 @@ class S extends p {
|
|
|
76
76
|
async onRender() {
|
|
77
77
|
const t = await $(
|
|
78
78
|
"/unsubscribe-groups/unsubscribe-list"
|
|
79
|
-
), s = [
|
|
79
|
+
), s = [L(), ...t.data], c = s.map((a) => ({
|
|
80
80
|
[e.SELECT_ITEM.text]: a.name,
|
|
81
81
|
[e.SELECT_ITEM.value]: a.sendGridId
|
|
82
82
|
}));
|
|
83
83
|
this.unsubList = s, this.api.setUIEAttribute(
|
|
84
84
|
u,
|
|
85
85
|
e.SELECTPICKER.items,
|
|
86
|
-
|
|
86
|
+
c
|
|
87
87
|
), this._setFormValues(), this._listenToFormUpdates();
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
b as CONTROL_BLOCK_ID,
|
|
92
|
+
I as RadioButtonControl
|
|
93
93
|
};
|
|
@@ -5,7 +5,7 @@ const e = {
|
|
|
5
5
|
YES: "Yes",
|
|
6
6
|
NO: "No"
|
|
7
7
|
}, d = `
|
|
8
|
-
<td align="left" class="radio-button radio-button-v2 esd-block-radio es-p10t es-p10b es-p30r es-p30l">
|
|
8
|
+
<td align="left" class="radio-button-block radio-button-v2 esd-block-radio es-p10t es-p10b es-p30r es-p30l">
|
|
9
9
|
<table cellpadding="0" cellspacing="0" role="presentation" width="100%">
|
|
10
10
|
<tbody>
|
|
11
11
|
<tr>
|
|
@@ -75,13 +75,13 @@ const e = {
|
|
|
75
75
|
</tbody>
|
|
76
76
|
</table>
|
|
77
77
|
</td>
|
|
78
|
-
`,
|
|
78
|
+
`, l = `
|
|
79
79
|
<td
|
|
80
80
|
align="left"
|
|
81
81
|
esd-extension-block-id="radio-button-block"
|
|
82
82
|
esd-handler-name="esd-extension-RadioButtonBlock"
|
|
83
83
|
class="
|
|
84
|
-
radio-button
|
|
84
|
+
radio-button-block
|
|
85
85
|
radio-button-v2
|
|
86
86
|
esd-block-ra
|
|
87
87
|
esd-radio-button-block
|
|
@@ -149,10 +149,10 @@ const e = {
|
|
|
149
149
|
</table>
|
|
150
150
|
</td>
|
|
151
151
|
`;
|
|
152
|
-
function
|
|
152
|
+
function a() {
|
|
153
153
|
return d.replace("{-{-TITLE-}-}", `<p path="1">${e.TITLE}</p>`).replace("{-{-DESCRIPTION-}-}", `<p path="1">${e.DESCRIPTION}</p>`).replace("{-{-YES-}-}", `<p path="1">${e.YES}</p>`).replace("{-{-NO-}-}", `<p path="1">${e.NO}</p>`);
|
|
154
154
|
}
|
|
155
155
|
export {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
l as default,
|
|
157
|
+
a as getDefaultTemplate
|
|
158
158
|
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BlockId as
|
|
5
|
-
import { getMigrationBannerHtml as
|
|
6
|
-
import { Block as
|
|
7
|
-
import { regenerateMobileProductRows as
|
|
8
|
-
import { ensureMobileCssRulesExist as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var _ = (r, n, t) => n in r ? k(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
|
|
3
|
+
var g = (r, n, t) => _(r, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { BlockId as B } from "../../../enums/block.js";
|
|
5
|
+
import { getMigrationBannerHtml as b } from "../../../utils/migrationBannerHtml.js";
|
|
6
|
+
import { Block as R, BlockCompositionType as y, ModificationDescription as C } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { regenerateMobileProductRows as A } from "./controls/main/utils.js";
|
|
8
|
+
import { ensureMobileCssRulesExist as d, setMobileLayoutOptOut as p, hasMobileLayoutOptOut as D } from "./controls/mobileLayout/cssRules.js";
|
|
9
|
+
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as f } from "./store/recommendation.js";
|
|
11
11
|
import { getDefaultTemplate as E } from "./templates/grid/template.js";
|
|
12
|
-
const
|
|
13
|
-
let
|
|
14
|
-
class
|
|
12
|
+
const h = B.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
|
|
13
|
+
let I = !1;
|
|
14
|
+
class v extends R {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
/**
|
|
18
18
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
19
19
|
* This avoids generating a new (different) ID in onCreated().
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
g(this, "_pendingBlockId", null);
|
|
22
22
|
}
|
|
23
23
|
getId() {
|
|
24
|
-
return
|
|
24
|
+
return h;
|
|
25
25
|
}
|
|
26
26
|
getIcon() {
|
|
27
27
|
return "recommendation-icon";
|
|
28
28
|
}
|
|
29
29
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
30
|
+
return y.CONTAINER;
|
|
31
31
|
}
|
|
32
32
|
getName() {
|
|
33
33
|
return this.api.translate("Recommendation Block");
|
|
@@ -38,8 +38,8 @@ class q extends b {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
getSettingsPanelTitleHtml() {
|
|
41
|
-
return
|
|
42
|
-
|
|
41
|
+
return b(
|
|
42
|
+
h,
|
|
43
43
|
this.api.translate("Recommendation Block"),
|
|
44
44
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
45
45
|
);
|
|
@@ -71,13 +71,20 @@ class q extends b {
|
|
|
71
71
|
return;
|
|
72
72
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
73
73
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
const { config: o, wasFreshDrop: c } = s.initializeConfig(
|
|
75
|
+
this.api,
|
|
76
|
+
t,
|
|
77
|
+
{ recommendationId: i }
|
|
78
|
+
), a = f();
|
|
79
|
+
if (a.setCurrentBlock(i), c) {
|
|
80
|
+
d(this.api);
|
|
81
|
+
const u = this._getBlockElement(t);
|
|
82
|
+
u && (p(this.api, u, !0), A({
|
|
83
|
+
currentNode: t,
|
|
84
|
+
documentModifier: this.api.getDocumentModifier()
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
a.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
|
|
81
88
|
}
|
|
82
89
|
/**
|
|
83
90
|
* Called when the document changes or template is loaded
|
|
@@ -90,20 +97,20 @@ class q extends b {
|
|
|
90
97
|
if (!(!t || !("getNodeConfig" in t))) {
|
|
91
98
|
if (!this._getRecommendationId(t)) {
|
|
92
99
|
const e = this._generateNextId();
|
|
93
|
-
this._assignRecommendationId(t, e),
|
|
100
|
+
this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
|
|
94
101
|
this.api,
|
|
95
102
|
t,
|
|
96
103
|
{ recommendationId: e },
|
|
97
104
|
"Assign recommendation ID to legacy block"
|
|
98
105
|
);
|
|
99
106
|
}
|
|
100
|
-
|
|
107
|
+
s.needsMigration(t) && this._migrateFromLegacy(t);
|
|
101
108
|
try {
|
|
102
|
-
|
|
103
|
-
const e =
|
|
109
|
+
I || (d(this.api), I = !0);
|
|
110
|
+
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
104
111
|
if (i) {
|
|
105
112
|
const o = !e.mobileLayoutEnabled;
|
|
106
|
-
|
|
113
|
+
D(i) !== o && p(this.api, i, o);
|
|
107
114
|
}
|
|
108
115
|
} catch {
|
|
109
116
|
}
|
|
@@ -117,7 +124,7 @@ class q extends b {
|
|
|
117
124
|
*/
|
|
118
125
|
onDelete(t) {
|
|
119
126
|
const e = this._getRecommendationId(t);
|
|
120
|
-
e &&
|
|
127
|
+
e && f().removeBlockState(e);
|
|
121
128
|
}
|
|
122
129
|
/**
|
|
123
130
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
@@ -129,7 +136,7 @@ class q extends b {
|
|
|
129
136
|
const e = this.api.getDocumentRoot();
|
|
130
137
|
e && "querySelectorAll" in e && e.querySelectorAll(`.${l}`).forEach((o) => {
|
|
131
138
|
if ("getAttribute" in o) {
|
|
132
|
-
const
|
|
139
|
+
const c = o.getAttribute(m), a = c ? parseInt(c) : 0;
|
|
133
140
|
a > t && (t = a);
|
|
134
141
|
}
|
|
135
142
|
});
|
|
@@ -148,7 +155,7 @@ class q extends b {
|
|
|
148
155
|
if (!i)
|
|
149
156
|
return;
|
|
150
157
|
const o = this.api.getDocumentModifier();
|
|
151
|
-
o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new
|
|
158
|
+
o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new C(`Assign recommendation ID ${e}`));
|
|
152
159
|
}
|
|
153
160
|
/**
|
|
154
161
|
* Gets the recommendation-id from a block node
|
|
@@ -178,10 +185,10 @@ class q extends b {
|
|
|
178
185
|
* Migrate configuration from legacy format
|
|
179
186
|
*/
|
|
180
187
|
_migrateFromLegacy(t) {
|
|
181
|
-
|
|
188
|
+
s.migrateFromDataAttributes(this.api, t);
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
export {
|
|
185
|
-
|
|
186
|
-
|
|
192
|
+
h as BLOCK_ID,
|
|
193
|
+
v as RecommendationBlock
|
|
187
194
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as
|
|
1
|
+
import { ModificationDescription as C } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
|
|
3
3
|
import { setCurrencyAttributes as D } from "../controls/main/utils.js";
|
|
4
4
|
import { hasMinimalConfig as A } from "../types/nodeConfig.js";
|
|
5
5
|
function S(e) {
|
|
@@ -8,7 +8,7 @@ function S(e) {
|
|
|
8
8
|
function N(e) {
|
|
9
9
|
return e === "." || e === "," || e === " " || e === "";
|
|
10
10
|
}
|
|
11
|
-
class
|
|
11
|
+
class M {
|
|
12
12
|
// ========================================================================
|
|
13
13
|
// Read Operations
|
|
14
14
|
// ========================================================================
|
|
@@ -83,7 +83,7 @@ class V {
|
|
|
83
83
|
* @returns The new complete configuration
|
|
84
84
|
*/
|
|
85
85
|
static updateConfig(i, t, o, n) {
|
|
86
|
-
const
|
|
86
|
+
const r = this.getConfig(t), u = this.deepMerge(r, o);
|
|
87
87
|
return this.saveConfig(i, t, u, n), u;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
@@ -91,21 +91,28 @@ class V {
|
|
|
91
91
|
*
|
|
92
92
|
* Called when a block is first created (dropped into template).
|
|
93
93
|
* Can optionally merge in partial config from migration.
|
|
94
|
+
*
|
|
95
|
+
* The `wasFreshDrop` flag distinguishes a brand-new drop (no prior config)
|
|
96
|
+
* from a clone (Stripo replays the source's setNodeConfig payload before
|
|
97
|
+
* onCreated fires). Callers use this to skip side-effects already inherited
|
|
98
|
+
* from the source.
|
|
94
99
|
* @example
|
|
95
100
|
* // In Block.onCreated lifecycle
|
|
96
|
-
* RecommendationConfigService.initializeConfig(this.api, node);
|
|
101
|
+
* const { config, wasFreshDrop } = RecommendationConfigService.initializeConfig(this.api, node);
|
|
97
102
|
* @param api - Stripo extension API with document modifier
|
|
98
103
|
* @param node - The immutable HTML node to initialize
|
|
99
104
|
* @param partialConfig - Optional partial config to merge with defaults
|
|
100
|
-
* @returns The initialized configuration
|
|
105
|
+
* @returns The initialized configuration and whether the node was a fresh drop
|
|
101
106
|
*/
|
|
102
107
|
static initializeConfig(i, t, o) {
|
|
108
|
+
if (this.hasConfig(t))
|
|
109
|
+
return { config: o ? this.updateConfig(i, t, o, "Initialize recommendation block") : this.getConfig(t), wasFreshDrop: !1 };
|
|
103
110
|
const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
|
|
104
111
|
return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
|
|
105
112
|
currentNode: t,
|
|
106
113
|
documentModifier: i.getDocumentModifier(),
|
|
107
114
|
currency: n.currency
|
|
108
|
-
}), n;
|
|
115
|
+
}), { config: n, wasFreshDrop: !0 };
|
|
109
116
|
}
|
|
110
117
|
/**
|
|
111
118
|
* Save complete configuration to a node
|
|
@@ -118,9 +125,9 @@ class V {
|
|
|
118
125
|
*/
|
|
119
126
|
static saveConfig(i, t, o, n) {
|
|
120
127
|
try {
|
|
121
|
-
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new
|
|
122
|
-
} catch (
|
|
123
|
-
console.warn("[RecommendationConfigService] Failed to save config:",
|
|
128
|
+
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new C(n));
|
|
129
|
+
} catch (r) {
|
|
130
|
+
console.warn("[RecommendationConfigService] Failed to save config:", r);
|
|
124
131
|
}
|
|
125
132
|
}
|
|
126
133
|
// ========================================================================
|
|
@@ -157,29 +164,29 @@ class V {
|
|
|
157
164
|
s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
|
|
158
165
|
} catch {
|
|
159
166
|
}
|
|
160
|
-
const
|
|
161
|
-
|
|
167
|
+
const r = t.getAttribute("data-layout");
|
|
168
|
+
r === "list" || r === "horizontal" ? o.layout = "list" : (r === "grid" || r === "vertical") && (o.layout = "grid");
|
|
162
169
|
const u = t.getAttribute("data-card-composition");
|
|
163
170
|
u && (o.composition = u.split(",").filter(Boolean));
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
171
|
+
const b = t.getAttribute("data-column-spacing");
|
|
172
|
+
b && (o.columnSpacing = parseInt(b) || c.columnSpacing);
|
|
173
|
+
const p = t.getAttribute("data-row-spacing");
|
|
174
|
+
if (p && (o.rowSpacing = parseInt(p) || c.rowSpacing), !o.currency) {
|
|
168
175
|
const s = t.getAttribute("currency"), y = t.getAttribute("currency-symbol"), d = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
|
|
169
176
|
if (s || y || d || f || g || m) {
|
|
170
|
-
const a =
|
|
177
|
+
const a = c.currency, h = m ? parseInt(m) : NaN;
|
|
171
178
|
o.currency = {
|
|
172
179
|
code: s ?? a.code,
|
|
173
180
|
symbol: y ?? a.symbol,
|
|
174
181
|
alignment: d === "0" ? "before" : "after",
|
|
175
|
-
decimalCount: Number.isFinite(
|
|
182
|
+
decimalCount: Number.isFinite(h) ? h : a.decimalCount,
|
|
176
183
|
decimalSeparator: S(g) ? g : a.decimalSeparator,
|
|
177
184
|
thousandSeparator: N(f) ? f : a.thousandSeparator
|
|
178
185
|
};
|
|
179
186
|
}
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
|
-
return this.initializeConfig(i, t, o);
|
|
189
|
+
return this.initializeConfig(i, t, o).config;
|
|
183
190
|
}
|
|
184
191
|
/**
|
|
185
192
|
* Check if configuration needs migration
|
|
@@ -197,12 +204,12 @@ class V {
|
|
|
197
204
|
*/
|
|
198
205
|
static cloneDefaults() {
|
|
199
206
|
return {
|
|
200
|
-
...
|
|
201
|
-
currency: { ...
|
|
202
|
-
omnibusPrice: { ...
|
|
203
|
-
omnibusDiscount: { ...
|
|
204
|
-
composition: [...
|
|
205
|
-
visibility: { ...
|
|
207
|
+
...c,
|
|
208
|
+
currency: { ...c.currency },
|
|
209
|
+
omnibusPrice: { ...c.omnibusPrice },
|
|
210
|
+
omnibusDiscount: { ...c.omnibusDiscount },
|
|
211
|
+
composition: [...c.composition],
|
|
212
|
+
visibility: { ...c.visibility },
|
|
206
213
|
filters: [],
|
|
207
214
|
productIds: [],
|
|
208
215
|
recommendationId: 0
|
|
@@ -272,5 +279,5 @@ class V {
|
|
|
272
279
|
}
|
|
273
280
|
}
|
|
274
281
|
export {
|
|
275
|
-
|
|
282
|
+
M as RecommendationConfigService
|
|
276
283
|
};
|