@useinsider/guido 3.2.0-beta.d5a560f → 3.2.0-beta.dc55d68
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 +150 -94
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +88 -87
- package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
- package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
- package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
- package/dist/composables/useActionsApi.js +4 -4
- package/dist/composables/useFullStoryBridge.js +1 -1
- package/dist/composables/useRecommendation.js +16 -12
- package/dist/composables/useRibbonOffset.js +21 -0
- package/dist/composables/useSave.js +1 -1
- package/dist/config/compiler/recommendationCompilerRules.js +72 -67
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +33 -30
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/enums/onboarding.js +7 -2
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
- package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
- package/dist/extensions/Blocks/Recommendation/block.js +35 -32
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +48 -42
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +213 -0
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +56 -0
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/composables/useRibbonOffset.d.ts +4 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/onboarding.d.ts +6 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/stores/config.d.ts +504 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/static/styles/components/button.css.js +16 -9
- package/dist/static/styles/components/loader.css.js +4 -0
- package/dist/static/styles/components/narrow-panel.css.js +52 -0
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/htmlEscape.js +13 -0
- package/package.json +7 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { RecommendationBlockId as
|
|
4
|
-
import { RecommendationControlId as
|
|
5
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
6
|
-
|
|
1
|
+
import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as u } from "../../../common-control.js";
|
|
3
|
+
import { RecommendationBlockId as a } from "../../constants/blockIds.js";
|
|
4
|
+
import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as m } from "../../constants/selectors.js";
|
|
6
|
+
import { CSS_CLASS_TEXT_TRIM as r, ensureTextTrimCssRulesExist as T } from "../shared/textTrimCssRules.js";
|
|
7
|
+
const s = {
|
|
7
8
|
TEXT_TRIM_ENABLED: "textTrimEnabled"
|
|
8
|
-
}
|
|
9
|
-
class N extends
|
|
9
|
+
};
|
|
10
|
+
class N extends u {
|
|
10
11
|
getId() {
|
|
11
|
-
return
|
|
12
|
+
return d.NAME_TEXT_TRIM;
|
|
12
13
|
}
|
|
13
14
|
getTemplate() {
|
|
14
15
|
return `
|
|
@@ -16,7 +17,7 @@ class N extends d {
|
|
|
16
17
|
<div class="name-text-trim-control-container">
|
|
17
18
|
${this._GuTwoColumns([
|
|
18
19
|
this._GuLabel({ text: this.api.translate("Trim Long Text") }),
|
|
19
|
-
this._GuToggle(
|
|
20
|
+
this._GuToggle(s.TEXT_TRIM_ENABLED)
|
|
20
21
|
])}
|
|
21
22
|
</div>
|
|
22
23
|
`;
|
|
@@ -30,76 +31,45 @@ class N extends d {
|
|
|
30
31
|
_setFormValues() {
|
|
31
32
|
const e = this._getCurrentTrimState();
|
|
32
33
|
this.api.updateValues({
|
|
33
|
-
[
|
|
34
|
+
[s.TEXT_TRIM_ENABLED]: e
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
_getCurrentTrimState() {
|
|
37
38
|
if (!this.currentNode || !("hasClass" in this.currentNode))
|
|
38
39
|
return !1;
|
|
39
|
-
if (this.currentNode.hasClass(
|
|
40
|
+
if (this.currentNode.hasClass(r))
|
|
40
41
|
return !0;
|
|
41
|
-
const e = this.currentNode.closest(
|
|
42
|
+
const e = this.currentNode.closest(m);
|
|
42
43
|
if (!e)
|
|
43
44
|
return !1;
|
|
44
45
|
const t = e.querySelector(
|
|
45
|
-
`[esd-extension-block-id="${
|
|
46
|
+
`[esd-extension-block-id="${a.NAME}"]`
|
|
46
47
|
);
|
|
47
|
-
return t && "hasClass" in t ? t.hasClass(
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Finds an existing CSS rule in the document stylesheet by exact query
|
|
51
|
-
* @param query - The CSS query to search for (uses Stripo's CSS query syntax)
|
|
52
|
-
* @returns The CSS rule node if found, undefined otherwise
|
|
53
|
-
*/
|
|
54
|
-
_findCssRule(e) {
|
|
55
|
-
const t = this.api.getDocumentRootCssNode();
|
|
56
|
-
if (t)
|
|
57
|
-
return t.querySelector(e);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Finds the .text-trim-enabled p rule by searching all text-trim rules and comparing selectors
|
|
61
|
-
* This is needed because Stripo's CSS query syntax interprets spaces as path separators
|
|
62
|
-
* @returns true if the rule exists
|
|
63
|
-
*/
|
|
64
|
-
_hasParagraphRule() {
|
|
65
|
-
const e = this.api.getDocumentRootCssNode();
|
|
66
|
-
return e ? e.querySelectorAll(`*${o}`).some((s) => "getSelector" in s && typeof s.getSelector == "function" ? s.getSelector() === T : !1) : !1;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Ensures the text-trim CSS rules exist in the document stylesheet
|
|
70
|
-
* Only adds rules if they don't already exist (prevents duplicates across multiple blocks)
|
|
71
|
-
*/
|
|
72
|
-
_ensureCssRulesExist() {
|
|
73
|
-
const e = this.api.getDocumentRootCssNode();
|
|
74
|
-
if (!e)
|
|
75
|
-
return;
|
|
76
|
-
const t = this.api.getDocumentModifier();
|
|
77
|
-
let s = !1;
|
|
78
|
-
this._findCssRule(c) || (t.modifyCss(e).appendRule(p), s = !0), this._hasParagraphRule() || (t.modifyCss(e).appendRule(_), s = !0), s && t.apply(new a("Add text trim CSS rules"));
|
|
48
|
+
return t && "hasClass" in t ? t.hasClass(r) : !1;
|
|
79
49
|
}
|
|
80
50
|
_onTextTrimChange(e) {
|
|
81
51
|
if (!this.currentNode || !("closest" in this.currentNode))
|
|
82
52
|
return;
|
|
83
|
-
const t = this.currentNode.closest(
|
|
53
|
+
const t = this.currentNode.closest(m);
|
|
84
54
|
if (!t || !("querySelectorAll" in t))
|
|
85
55
|
return;
|
|
86
|
-
const
|
|
87
|
-
t.querySelectorAll(`[esd-extension-block-id="${
|
|
56
|
+
const i = Array.from(
|
|
57
|
+
t.querySelectorAll(`[esd-extension-block-id="${a.NAME}"]`)
|
|
88
58
|
);
|
|
89
|
-
if (!
|
|
59
|
+
if (!i.length)
|
|
90
60
|
return;
|
|
91
|
-
e && this.
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
e ?
|
|
95
|
-
}),
|
|
96
|
-
new
|
|
61
|
+
e && T(this.api);
|
|
62
|
+
const o = this.api.getDocumentModifier();
|
|
63
|
+
i.forEach((n) => {
|
|
64
|
+
e ? o.modifyHtml(n).setClass(r) : o.modifyHtml(n).removeClass(r);
|
|
65
|
+
}), o.apply(
|
|
66
|
+
new l(
|
|
97
67
|
e ? "Enable product name text trimming" : "Disable product name text trimming"
|
|
98
68
|
)
|
|
99
69
|
);
|
|
100
70
|
}
|
|
101
71
|
_listenToFormUpdates() {
|
|
102
|
-
this.api.onValueChanged(
|
|
72
|
+
this.api.onValueChanged(s.TEXT_TRIM_ENABLED, (e) => {
|
|
103
73
|
this._onTextTrimChange(e);
|
|
104
74
|
});
|
|
105
75
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModificationDescription as r } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
const t = "text-trim-enabled", l = `.${t}`, c = `.${t} p`, S = `.${t} { max-width: 0; }`, T = `.${t} p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; display: block; }`;
|
|
3
|
+
function f(n) {
|
|
4
|
+
const e = n.getDocumentRootCssNode();
|
|
5
|
+
if (!e)
|
|
6
|
+
return;
|
|
7
|
+
const o = n.getDocumentModifier();
|
|
8
|
+
let i = !1;
|
|
9
|
+
e.querySelector(l) || (o.modifyCss(e).appendRule(S), i = !0), e.querySelectorAll(`*${t}`).some((s) => "getSelector" in s && typeof s.getSelector == "function" && s.getSelector() === c) || (o.modifyCss(e).appendRule(T), i = !0), i && o.apply(new r("Add text trim CSS rules"));
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as CSS_CLASS_TEXT_TRIM,
|
|
13
|
+
f as ensureTextTrimCssRulesExist
|
|
14
|
+
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CURRENT_CONFIG_VERSION as
|
|
3
|
-
import { setCurrencyAttributes as
|
|
4
|
-
import { hasMinimalConfig as
|
|
5
|
-
|
|
1
|
+
import { ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as r } from "../constants/defaultConfig.js";
|
|
3
|
+
import { setCurrencyAttributes as D } from "../controls/main/utils.js";
|
|
4
|
+
import { hasMinimalConfig as A } from "../types/nodeConfig.js";
|
|
5
|
+
function S(e) {
|
|
6
|
+
return e === "." || e === "," || e === " ";
|
|
7
|
+
}
|
|
8
|
+
function N(e) {
|
|
9
|
+
return e === "." || e === "," || e === " " || e === "";
|
|
10
|
+
}
|
|
11
|
+
class V {
|
|
6
12
|
// ========================================================================
|
|
7
13
|
// Read Operations
|
|
8
14
|
// ========================================================================
|
|
@@ -42,7 +48,7 @@ class C {
|
|
|
42
48
|
return !1;
|
|
43
49
|
try {
|
|
44
50
|
const t = i.getNodeConfig();
|
|
45
|
-
return
|
|
51
|
+
return A(t);
|
|
46
52
|
} catch {
|
|
47
53
|
return !1;
|
|
48
54
|
}
|
|
@@ -77,8 +83,8 @@ class C {
|
|
|
77
83
|
* @returns The new complete configuration
|
|
78
84
|
*/
|
|
79
85
|
static updateConfig(i, t, o, n) {
|
|
80
|
-
const
|
|
81
|
-
return this.saveConfig(i, t,
|
|
86
|
+
const c = this.getConfig(t), u = this.deepMerge(c, o);
|
|
87
|
+
return this.saveConfig(i, t, u, n), u;
|
|
82
88
|
}
|
|
83
89
|
/**
|
|
84
90
|
* Initialize configuration for a new block
|
|
@@ -95,7 +101,7 @@ class C {
|
|
|
95
101
|
*/
|
|
96
102
|
static initializeConfig(i, t, o) {
|
|
97
103
|
const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
|
|
98
|
-
return this.saveConfig(i, t, n, "Initialize recommendation block"),
|
|
104
|
+
return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
|
|
99
105
|
currentNode: t,
|
|
100
106
|
documentModifier: i.getDocumentModifier(),
|
|
101
107
|
currency: n.currency
|
|
@@ -112,9 +118,9 @@ class C {
|
|
|
112
118
|
*/
|
|
113
119
|
static saveConfig(i, t, o, n) {
|
|
114
120
|
try {
|
|
115
|
-
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new
|
|
116
|
-
} catch (
|
|
117
|
-
console.warn("[RecommendationConfigService] Failed to save config:",
|
|
121
|
+
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(n));
|
|
122
|
+
} catch (c) {
|
|
123
|
+
console.warn("[RecommendationConfigService] Failed to save config:", c);
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
// ========================================================================
|
|
@@ -125,23 +131,53 @@ class C {
|
|
|
125
131
|
*
|
|
126
132
|
* Reads existing data-attributes and creates a proper node config.
|
|
127
133
|
* Used when loading templates created before node config was implemented.
|
|
134
|
+
*
|
|
135
|
+
* Sources, in priority order (later overrides earlier):
|
|
136
|
+
* 1. `esd-ext-config` JSON blob — emitted by the recommendation migrator and
|
|
137
|
+
* by hand-authored new templates. Carries the full RecommendationNodeConfig
|
|
138
|
+
* (strategy, language, currency, filters, productIds, etc.) which the
|
|
139
|
+
* discrete data-* attrs below cannot capture.
|
|
140
|
+
* 2. Discrete `data-*` attributes — runtime source of truth for
|
|
141
|
+
* layout/composition/spacing; controls keep these in sync as the user
|
|
142
|
+
* edits, so we let them override the JSON blob if they disagree.
|
|
143
|
+
* 3. `currency-*` attributes — durable currency source on the block element.
|
|
128
144
|
* @param api - Stripo extension API with document modifier
|
|
129
145
|
* @param node - The block node to migrate
|
|
130
146
|
* @returns The migrated configuration
|
|
131
147
|
*/
|
|
132
148
|
static migrateFromDataAttributes(i, t) {
|
|
133
149
|
const o = {
|
|
134
|
-
configVersion:
|
|
150
|
+
configVersion: l
|
|
135
151
|
};
|
|
136
152
|
if ("getAttribute" in t && typeof t.getAttribute == "function") {
|
|
137
|
-
const n = t.getAttribute("
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
c
|
|
153
|
+
const n = t.getAttribute("esd-ext-config");
|
|
154
|
+
if (n)
|
|
155
|
+
try {
|
|
156
|
+
const s = JSON.parse(n);
|
|
157
|
+
s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
const c = t.getAttribute("data-layout");
|
|
161
|
+
c === "list" || c === "horizontal" ? o.layout = "list" : (c === "grid" || c === "vertical") && (o.layout = "grid");
|
|
162
|
+
const u = t.getAttribute("data-card-composition");
|
|
163
|
+
u && (o.composition = u.split(",").filter(Boolean));
|
|
164
|
+
const p = t.getAttribute("data-column-spacing");
|
|
165
|
+
p && (o.columnSpacing = parseInt(p) || r.columnSpacing);
|
|
166
|
+
const b = t.getAttribute("data-row-spacing");
|
|
167
|
+
if (b && (o.rowSpacing = parseInt(b) || r.rowSpacing), !o.currency) {
|
|
168
|
+
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
|
+
if (s || y || d || f || g || m) {
|
|
170
|
+
const a = r.currency, C = m ? parseInt(m) : NaN;
|
|
171
|
+
o.currency = {
|
|
172
|
+
code: s ?? a.code,
|
|
173
|
+
symbol: y ?? a.symbol,
|
|
174
|
+
alignment: d === "0" ? "before" : "after",
|
|
175
|
+
decimalCount: Number.isFinite(C) ? C : a.decimalCount,
|
|
176
|
+
decimalSeparator: S(g) ? g : a.decimalSeparator,
|
|
177
|
+
thousandSeparator: N(f) ? f : a.thousandSeparator
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
145
181
|
}
|
|
146
182
|
return this.initializeConfig(i, t, o);
|
|
147
183
|
}
|
|
@@ -151,7 +187,7 @@ class C {
|
|
|
151
187
|
* @returns True if migration is needed
|
|
152
188
|
*/
|
|
153
189
|
static needsMigration(i) {
|
|
154
|
-
return i ? this.hasConfig(i) ? this.getConfigVersion(i) <
|
|
190
|
+
return i ? this.hasConfig(i) ? this.getConfigVersion(i) < l : !0 : !1;
|
|
155
191
|
}
|
|
156
192
|
// ========================================================================
|
|
157
193
|
// Internal Helpers
|
|
@@ -161,12 +197,12 @@ class C {
|
|
|
161
197
|
*/
|
|
162
198
|
static cloneDefaults() {
|
|
163
199
|
return {
|
|
164
|
-
...
|
|
165
|
-
currency: { ...
|
|
166
|
-
omnibusPrice: { ...
|
|
167
|
-
omnibusDiscount: { ...
|
|
168
|
-
composition: [...
|
|
169
|
-
visibility: { ...
|
|
200
|
+
...r,
|
|
201
|
+
currency: { ...r.currency },
|
|
202
|
+
omnibusPrice: { ...r.omnibusPrice },
|
|
203
|
+
omnibusDiscount: { ...r.omnibusDiscount },
|
|
204
|
+
composition: [...r.composition],
|
|
205
|
+
visibility: { ...r.visibility },
|
|
170
206
|
filters: [],
|
|
171
207
|
productIds: [],
|
|
172
208
|
recommendationId: 0
|
|
@@ -236,5 +272,5 @@ class C {
|
|
|
236
272
|
}
|
|
237
273
|
}
|
|
238
274
|
export {
|
|
239
|
-
|
|
275
|
+
V as RecommendationConfigService
|
|
240
276
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SettingsPanelRegistry as E, SettingsPanelTab as _, SettingsTab as O, ContainerControls as C, TextControls as R } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { BLOCK_ID as U } from "./block.js";
|
|
3
|
-
import { RecommendationBlockId as
|
|
3
|
+
import { RecommendationBlockId as S } from "./constants/blockIds.js";
|
|
4
4
|
import { RecommendationControlId as T } from "./constants/controlIds.js";
|
|
5
5
|
import { CONTROL_BLOCK_ID as A } from "./controls/main/index.js";
|
|
6
6
|
import "./store/recommendation.js";
|
|
@@ -14,7 +14,7 @@ import "./controls/image/index.js";
|
|
|
14
14
|
import { SPACING_CONTROL_ID as L } from "./controls/spacing/index.js";
|
|
15
15
|
import { CARD_BACKGROUND_COLOR_CONTROL_ID as D } from "./controls/cardBackground/index.js";
|
|
16
16
|
import { COMPOSITION_CONTROL_BLOCK_ID as B } from "./controls/cardComposition/index.js";
|
|
17
|
-
import { SYNC_INFO_MESSAGE_CONTROL_ID as
|
|
17
|
+
import { SYNC_INFO_MESSAGE_CONTROL_ID as N } from "./controls/syncInfoMessage.js";
|
|
18
18
|
class Z extends E {
|
|
19
19
|
registerBlockControls(I) {
|
|
20
20
|
I[U] = [
|
|
@@ -39,11 +39,11 @@ class Z extends E {
|
|
|
39
39
|
B
|
|
40
40
|
]
|
|
41
41
|
).withLabel(this.api.translate("Card Composition"))
|
|
42
|
-
], I[
|
|
42
|
+
], I[S.NAME] = [
|
|
43
43
|
new _(
|
|
44
44
|
O.SETTINGS,
|
|
45
45
|
[
|
|
46
|
-
|
|
46
|
+
N,
|
|
47
47
|
T.NAME_STYLE,
|
|
48
48
|
T.NAME_ALIGN,
|
|
49
49
|
T.NAME_TEXT_TRIM,
|
|
@@ -59,11 +59,11 @@ class Z extends E {
|
|
|
59
59
|
T.NAME_COLOR
|
|
60
60
|
]
|
|
61
61
|
)
|
|
62
|
-
], I[
|
|
62
|
+
], I[S.PRICE] = [
|
|
63
63
|
new _(
|
|
64
64
|
O.SETTINGS,
|
|
65
65
|
[
|
|
66
|
-
|
|
66
|
+
N,
|
|
67
67
|
T.PRICE_STYLE,
|
|
68
68
|
T.PRICE_ALIGN,
|
|
69
69
|
T.PRICE_PADDINGS
|
|
@@ -78,11 +78,11 @@ class Z extends E {
|
|
|
78
78
|
T.PRICE_COLOR
|
|
79
79
|
]
|
|
80
80
|
)
|
|
81
|
-
], I[
|
|
81
|
+
], I[S.OLD_PRICE] = [
|
|
82
82
|
new _(
|
|
83
83
|
O.SETTINGS,
|
|
84
84
|
[
|
|
85
|
-
|
|
85
|
+
N,
|
|
86
86
|
T.OLD_PRICE_STYLE,
|
|
87
87
|
T.OLD_PRICE_ALIGN,
|
|
88
88
|
T.OLD_PRICE_PADDINGS
|
|
@@ -97,11 +97,11 @@ class Z extends E {
|
|
|
97
97
|
T.OLD_PRICE_COLOR
|
|
98
98
|
]
|
|
99
99
|
)
|
|
100
|
-
], I[
|
|
100
|
+
], I[S.OMNIBUS_PRICE] = [
|
|
101
101
|
new _(
|
|
102
102
|
O.SETTINGS,
|
|
103
103
|
[
|
|
104
|
-
|
|
104
|
+
N,
|
|
105
105
|
T.OMNIBUS_PRICE_TEXT_BEFORE,
|
|
106
106
|
T.OMNIBUS_PRICE_TEXT_AFTER,
|
|
107
107
|
T.OMNIBUS_PRICE_STYLE,
|
|
@@ -118,11 +118,11 @@ class Z extends E {
|
|
|
118
118
|
T.OMNIBUS_PRICE_COLOR
|
|
119
119
|
]
|
|
120
120
|
)
|
|
121
|
-
], I[
|
|
121
|
+
], I[S.OMNIBUS_DISCOUNT] = [
|
|
122
122
|
new _(
|
|
123
123
|
O.SETTINGS,
|
|
124
124
|
[
|
|
125
|
-
|
|
125
|
+
N,
|
|
126
126
|
T.OMNIBUS_DISCOUNT_TEXT_BEFORE,
|
|
127
127
|
T.OMNIBUS_DISCOUNT_TEXT_AFTER,
|
|
128
128
|
T.OMNIBUS_DISCOUNT_STYLE,
|
|
@@ -139,11 +139,11 @@ class Z extends E {
|
|
|
139
139
|
T.OMNIBUS_DISCOUNT_COLOR
|
|
140
140
|
]
|
|
141
141
|
)
|
|
142
|
-
], I[
|
|
142
|
+
], I[S.BUTTON] = [
|
|
143
143
|
new _(
|
|
144
144
|
O.SETTINGS,
|
|
145
145
|
[
|
|
146
|
-
|
|
146
|
+
N,
|
|
147
147
|
T.BUTTON_TEXT,
|
|
148
148
|
T.BUTTON_ALIGN,
|
|
149
149
|
T.BUTTON_PADDINGS,
|
|
@@ -162,12 +162,13 @@ class Z extends E {
|
|
|
162
162
|
T.BUTTON_BORDER
|
|
163
163
|
]
|
|
164
164
|
)
|
|
165
|
-
], I[
|
|
165
|
+
], I[S.CUSTOM_ATTRIBUTE] = [
|
|
166
166
|
new _(
|
|
167
167
|
O.SETTINGS,
|
|
168
168
|
[
|
|
169
169
|
T.CUSTOM_ATTR_STYLE,
|
|
170
170
|
T.CUSTOM_ATTR_ALIGN,
|
|
171
|
+
T.CUSTOM_ATTR_TEXT_TRIM,
|
|
171
172
|
T.CUSTOM_ATTR_PADDINGS
|
|
172
173
|
]
|
|
173
174
|
),
|
|
@@ -180,11 +181,11 @@ class Z extends E {
|
|
|
180
181
|
T.CUSTOM_ATTR_COLOR
|
|
181
182
|
]
|
|
182
183
|
)
|
|
183
|
-
], I[
|
|
184
|
+
], I[S.IMAGE] = [
|
|
184
185
|
new _(
|
|
185
186
|
O.SETTINGS,
|
|
186
187
|
[
|
|
187
|
-
|
|
188
|
+
N,
|
|
188
189
|
T.IMAGE_SIZE,
|
|
189
190
|
T.IMAGE_MARGINS
|
|
190
191
|
]
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { RecommendationFeedSourceMaps as g, getOperatorOptions as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
1
|
+
import { RecommendationFeedSourceMaps as g, getOperatorOptions as k, PriceAttributes as R } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as C } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as y } from "../../../../stores/config.js";
|
|
4
4
|
import { defineStore as G } from "pinia";
|
|
5
5
|
import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
6
6
|
import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
|
|
7
7
|
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
8
8
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
|
-
import { isFilterValid as
|
|
10
|
-
const h =
|
|
11
|
-
let
|
|
9
|
+
import { isFilterValid as P } from "../validation/filterSchema.js";
|
|
10
|
+
const h = C();
|
|
11
|
+
let m = null, u = null, d = null;
|
|
12
12
|
function I() {
|
|
13
13
|
return {
|
|
14
14
|
cardsInRow: F,
|
|
@@ -37,7 +37,7 @@ function I() {
|
|
|
37
37
|
customAttributes: []
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function D() {
|
|
41
41
|
return {
|
|
42
42
|
recommendationConfigs: I(),
|
|
43
43
|
recommendationProducts: [],
|
|
@@ -57,7 +57,7 @@ const v = () => ({
|
|
|
57
57
|
blockStates: {},
|
|
58
58
|
currentRecommendationId: null,
|
|
59
59
|
configVersion: 0
|
|
60
|
-
}),
|
|
60
|
+
}), z = G("guidoRecommendationExtension", {
|
|
61
61
|
state: () => v(),
|
|
62
62
|
getters: {
|
|
63
63
|
// ====================================================================
|
|
@@ -131,11 +131,10 @@ const v = () => ({
|
|
|
131
131
|
})),
|
|
132
132
|
getFilterList() {
|
|
133
133
|
return Object.values(this.filterList).map((t) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
|
|
134
|
+
let r;
|
|
135
|
+
return t.type === "productAttribute" ? r = `product_attributes.${t.attributeName}` : R.includes(t.attributeName) ? r = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : r = t.attributeName, {
|
|
137
136
|
text: t.displayName,
|
|
138
|
-
value:
|
|
137
|
+
value: r,
|
|
139
138
|
type: t.attributeType
|
|
140
139
|
};
|
|
141
140
|
});
|
|
@@ -155,7 +154,7 @@ const v = () => ({
|
|
|
155
154
|
setCurrentBlock(t) {
|
|
156
155
|
this.blockStates[t] || (this.blockStates = {
|
|
157
156
|
...this.blockStates,
|
|
158
|
-
[t]:
|
|
157
|
+
[t]: D()
|
|
159
158
|
}), this.currentRecommendationId = t;
|
|
160
159
|
},
|
|
161
160
|
/**
|
|
@@ -163,10 +162,15 @@ const v = () => ({
|
|
|
163
162
|
* Resets currentRecommendationId if it was the deleted block.
|
|
164
163
|
*/
|
|
165
164
|
removeBlockState(t) {
|
|
166
|
-
const r =
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
this.
|
|
165
|
+
const r = t.toString();
|
|
166
|
+
if (this.recommendationCampaignUrls[r]) {
|
|
167
|
+
const n = { ...this.recommendationCampaignUrls };
|
|
168
|
+
delete n[r], this.recommendationCampaignUrls = n;
|
|
169
|
+
}
|
|
170
|
+
const e = { ...this.blockStates };
|
|
171
|
+
if (delete e[t], this.blockStates = e, this.currentRecommendationId === t) {
|
|
172
|
+
const n = Object.keys(this.blockStates).map(Number);
|
|
173
|
+
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
170
174
|
}
|
|
171
175
|
},
|
|
172
176
|
/**
|
|
@@ -199,7 +203,7 @@ const v = () => ({
|
|
|
199
203
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
200
204
|
*/
|
|
201
205
|
createDefaultFilter(t, r) {
|
|
202
|
-
const [e] = this.getFilterList, [n] =
|
|
206
|
+
const [e] = this.getFilterList, [n] = k(e == null ? void 0 : e.type);
|
|
203
207
|
return {
|
|
204
208
|
type: "standardFilter",
|
|
205
209
|
attribute: (e == null ? void 0 : e.value) ?? "",
|
|
@@ -251,11 +255,11 @@ const v = () => ({
|
|
|
251
255
|
// ====================================================================
|
|
252
256
|
async fetchRecommendationCreateData() {
|
|
253
257
|
if (!this.activePredictiveAlgorithms.length) {
|
|
254
|
-
if (
|
|
255
|
-
await
|
|
258
|
+
if (m) {
|
|
259
|
+
await m;
|
|
256
260
|
return;
|
|
257
261
|
}
|
|
258
|
-
|
|
262
|
+
m = (async () => {
|
|
259
263
|
const {
|
|
260
264
|
activePredictiveAlgorithms: t,
|
|
261
265
|
languages: r,
|
|
@@ -268,26 +272,26 @@ const v = () => ({
|
|
|
268
272
|
this.currencyList = e;
|
|
269
273
|
})();
|
|
270
274
|
try {
|
|
271
|
-
await
|
|
275
|
+
await m;
|
|
272
276
|
} finally {
|
|
273
|
-
|
|
277
|
+
m = null;
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
280
|
},
|
|
277
281
|
async fetchRecommendationFilters() {
|
|
278
282
|
if (!Object.keys(this.filterList).length) {
|
|
279
|
-
if (
|
|
280
|
-
await
|
|
283
|
+
if (u) {
|
|
284
|
+
await u;
|
|
281
285
|
return;
|
|
282
286
|
}
|
|
283
|
-
|
|
287
|
+
u = (async () => {
|
|
284
288
|
const t = await h.fetchRecommendationFilters();
|
|
285
289
|
this.filterList = t;
|
|
286
290
|
})();
|
|
287
291
|
try {
|
|
288
|
-
await
|
|
292
|
+
await u;
|
|
289
293
|
} finally {
|
|
290
|
-
|
|
294
|
+
u = null;
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
297
|
},
|
|
@@ -302,10 +306,10 @@ const v = () => ({
|
|
|
302
306
|
deleteFilterGroup(t) {
|
|
303
307
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
304
308
|
return;
|
|
305
|
-
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o),
|
|
309
|
+
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), l = new Map(n.map((i, o) => [i, o + 1]));
|
|
306
310
|
r.recommendationConfigs.filters = e.map((i) => ({
|
|
307
311
|
...i,
|
|
308
|
-
filterGroup:
|
|
312
|
+
filterGroup: l.get(i.filterGroup) ?? i.filterGroup
|
|
309
313
|
}));
|
|
310
314
|
},
|
|
311
315
|
updateFilter(t) {
|
|
@@ -316,7 +320,7 @@ const v = () => ({
|
|
|
316
320
|
const n = [...r.recommendationConfigs.filters];
|
|
317
321
|
n[e] = {
|
|
318
322
|
...t,
|
|
319
|
-
isValid:
|
|
323
|
+
isValid: P(t)
|
|
320
324
|
}, r.recommendationConfigs.filters = n;
|
|
321
325
|
}
|
|
322
326
|
},
|
|
@@ -330,7 +334,7 @@ const v = () => ({
|
|
|
330
334
|
let i = 1;
|
|
331
335
|
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
332
336
|
} else {
|
|
333
|
-
const i = [...new Set(n.map((s) => s.filterGroup))].sort((s,
|
|
337
|
+
const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, c) => s - c), o = new Map(i.map((s, c) => [s, c + 1]));
|
|
334
338
|
n = n.map((s) => ({
|
|
335
339
|
...s,
|
|
336
340
|
filterGroup: o.get(s.filterGroup) ?? s.filterGroup
|
|
@@ -342,15 +346,15 @@ const v = () => ({
|
|
|
342
346
|
addFilter(t) {
|
|
343
347
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
344
348
|
return;
|
|
345
|
-
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters],
|
|
349
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], l = e.filter(
|
|
346
350
|
(o) => o.filterGroup === t.filterGroup
|
|
347
351
|
).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
348
352
|
i !== -1 ? e.splice(i + 1, 0, {
|
|
349
353
|
...t,
|
|
350
|
-
filterNumber:
|
|
354
|
+
filterNumber: l
|
|
351
355
|
}) : e.push({
|
|
352
356
|
...t,
|
|
353
|
-
filterNumber:
|
|
357
|
+
filterNumber: l
|
|
354
358
|
}), r.recommendationConfigs.filters = e;
|
|
355
359
|
},
|
|
356
360
|
generateFilterQuery() {
|
|
@@ -375,7 +379,7 @@ const v = () => ({
|
|
|
375
379
|
},
|
|
376
380
|
async _doFetchProducts() {
|
|
377
381
|
var p;
|
|
378
|
-
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid),
|
|
382
|
+
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), l = b(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = y(), s = parseInt(e.size) || 6, c = {
|
|
379
383
|
locale: e.language,
|
|
380
384
|
currency: e.currencySettings.value,
|
|
381
385
|
partnerName: o.partnerName,
|
|
@@ -383,21 +387,23 @@ const v = () => ({
|
|
|
383
387
|
details: !0,
|
|
384
388
|
campaignId: o.variationId
|
|
385
389
|
};
|
|
386
|
-
e.strategy === "manualMerchandising" ?
|
|
387
|
-
const l = parseInt(e.size) || 6;
|
|
390
|
+
e.strategy === "manualMerchandising" ? c.productId = e.productIds.slice(0, s).join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), e.strategy === "userBased" && (c.userId = "{user_id}"), l && (c.filter = l), e.shuffleProducts && (c.shuffle = !0);
|
|
388
391
|
let f;
|
|
389
392
|
try {
|
|
390
|
-
f = await h.fetchRecommendationProducts(i,
|
|
393
|
+
f = await h.fetchRecommendationProducts(i, c);
|
|
391
394
|
} catch {
|
|
392
395
|
f = [];
|
|
393
396
|
}
|
|
394
397
|
if (this.blockStates[t]) {
|
|
395
|
-
const a = f.length > 0 ? f : S(
|
|
396
|
-
|
|
398
|
+
const a = f.length > 0 ? f : S(s);
|
|
399
|
+
a.length < s ? this.blockStates[t].recommendationProducts = [
|
|
400
|
+
...a,
|
|
401
|
+
...S(s - a.length)
|
|
402
|
+
] : a.length > s ? this.blockStates[t].recommendationProducts = a.slice(0, s) : this.blockStates[t].recommendationProducts = a;
|
|
397
403
|
}
|
|
398
404
|
}
|
|
399
405
|
}
|
|
400
406
|
});
|
|
401
407
|
export {
|
|
402
|
-
|
|
408
|
+
z as useRecommendationExtensionStore
|
|
403
409
|
};
|