@useinsider/guido 2.1.0-beta.a720424 → 2.1.0-beta.e13d291
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/config/migrator/recommendationMigrator.js +2 -2
- package/dist/extensions/Blocks/Recommendation/block.js +40 -6
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +64 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +20 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +96 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +110 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +204 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +54 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +205 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +74 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +118 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +76 -0
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
- package/dist/extensions/Blocks/Recommendation/services/configService.js +239 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -36
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +233 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +69 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +174 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +121 -0
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/controlFactories.js +125 -93
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +223 -169
- package/dist/services/recommendationApi.js +10 -9
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +45 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +57 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +42 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +214 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +17 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +39 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +54 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +154 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/dist/static/styles/customEditorStyle.css.js +25 -2
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
- package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
- package/dist/extensions/Blocks/Recommendation/control.js +0 -336
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
- package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
import { ExtensionBuilder as
|
|
2
|
-
import { RecommendationBlock as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
1
|
+
import { ExtensionBuilder as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RecommendationBlock as m } from "./block.js";
|
|
3
|
+
import { RecommendationBlockControl as n } from "./controls/main/index.js";
|
|
4
|
+
import "./store/recommendation.js";
|
|
5
|
+
import { NameControls as i } from "./controls/name/index.js";
|
|
6
|
+
import { PriceControls as e } from "./controls/price/index.js";
|
|
7
|
+
import { OldPriceControls as l } from "./controls/oldPrice/index.js";
|
|
8
|
+
import { OmnibusPriceControls as s } from "./controls/omnibusPrice/index.js";
|
|
9
|
+
import { OmnibusDiscountControls as a } from "./controls/omnibusDiscount/index.js";
|
|
10
|
+
import { ButtonControls as p } from "./controls/button/index.js";
|
|
11
|
+
import { ImageControls as c } from "./controls/image/index.js";
|
|
12
|
+
import { SpacingControl as C } from "./controls/spacing/index.js";
|
|
13
|
+
import { CardBackgroundColorControl as d } from "./controls/cardBackground/index.js";
|
|
14
|
+
import { LayoutControl as f } from "./controls/layout/index.js";
|
|
15
|
+
import { RecommendationCardCompositionControl as u } from "./controls/cardComposition/index.js";
|
|
16
|
+
import { RecommendationIconsRegistry as g } from "./iconsRegistry.js";
|
|
17
|
+
import R from "./recommendation.css.js";
|
|
18
|
+
import { SettingsPanel as y } from "./settingsPanel.js";
|
|
19
|
+
const B = [
|
|
20
|
+
i,
|
|
21
|
+
e,
|
|
22
|
+
l,
|
|
23
|
+
s,
|
|
24
|
+
a,
|
|
25
|
+
p,
|
|
26
|
+
c
|
|
27
|
+
], P = [
|
|
28
|
+
n,
|
|
29
|
+
d,
|
|
30
|
+
f,
|
|
31
|
+
C,
|
|
32
|
+
u
|
|
33
|
+
], b = [
|
|
34
|
+
...P,
|
|
35
|
+
...B.flatMap((o) => Object.values(o))
|
|
36
|
+
], F = b.reduce(
|
|
37
|
+
(o, t) => o.addControl(t),
|
|
38
|
+
new r().addBlock(m).withSettingsPanelRegistry(y)
|
|
39
|
+
).addStyles(R).withIconsRegistry(g).build();
|
|
17
40
|
export {
|
|
18
|
-
|
|
41
|
+
F as default
|
|
19
42
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IconsRegistry as
|
|
2
|
-
class
|
|
1
|
+
import { IconsRegistry as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
class o extends r {
|
|
3
3
|
registerIconsSvg(C) {
|
|
4
4
|
C["recommendation-icon"] = `
|
|
5
5
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
@@ -43,9 +43,25 @@ class n extends o {
|
|
|
43
43
|
3.40029 12.0082 3.25285 11.7656 3.15234C11.365 2.98638 11.0001 2.64849 11 2.21484V2Z"
|
|
44
44
|
fill="currentColor"/>
|
|
45
45
|
</svg>
|
|
46
|
+
`, C["grid-orientation"] = `
|
|
47
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
|
48
|
+
<rect x="1" y="1" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
49
|
+
<rect x="12" y="1" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
50
|
+
<rect x="1" y="12" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
51
|
+
<rect x="12" y="12" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
52
|
+
</svg>
|
|
53
|
+
`, C["list-orientation"] = `
|
|
54
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
|
55
|
+
<circle cx="3" cy="4" r="1" stroke="currentColor" stroke-width="1"/>
|
|
56
|
+
<rect x="7" y="3" width="11" height="2" rx="1"/>
|
|
57
|
+
<circle cx="3" cy="10" r="1" stroke="currentColor" stroke-width="1"/>
|
|
58
|
+
<rect x="7" y="9" width="11" height="2" rx="1"/>
|
|
59
|
+
<circle cx="3" cy="16" r="1" stroke="currentColor" stroke-width="1"/>
|
|
60
|
+
<rect x="7" y="15" width="11" height="2" rx="1"/>
|
|
61
|
+
</svg>
|
|
46
62
|
`;
|
|
47
63
|
}
|
|
48
64
|
}
|
|
49
65
|
export {
|
|
50
|
-
|
|
66
|
+
o as RecommendationIconsRegistry
|
|
51
67
|
};
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
const n = `/* Utils */
|
|
2
2
|
.es-180w { width: 180px; }
|
|
3
3
|
|
|
4
|
-
/* Recommendation Controls */
|
|
5
|
-
.recommendation-controls-container >
|
|
6
|
-
|
|
4
|
+
/* Recommendation Controls - Main settings panel separators */
|
|
5
|
+
.recommendation-controls-container > div {
|
|
6
|
+
border-bottom: 1px solid #e0e0e0;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.recommendation-controls-container >
|
|
9
|
+
.recommendation-controls-container > div:first-child {
|
|
10
10
|
padding-top: 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.recommendation-controls-container > div:last-child {
|
|
14
|
+
border-bottom: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
.container:has(.recommendation-controls-container) {
|
|
14
18
|
padding: 0
|
|
15
19
|
}
|
|
20
|
+
|
|
21
|
+
/* Hide drag icon for list layout (ordering disabled) */
|
|
22
|
+
ue-orderable.orderable-disabled .droppable-icon {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
16
25
|
`;
|
|
17
26
|
export {
|
|
18
27
|
n as default
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { ModificationDescription as f } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CURRENT_CONFIG_VERSION as u, DEFAULT_NODE_CONFIG as e } from "../constants/defaultConfig.js";
|
|
3
|
+
import { setCurrencyAttributes as g } from "../controls/main/utils.js";
|
|
4
|
+
import { hasMinimalConfig as a } from "../types/nodeConfig.js";
|
|
5
|
+
class C {
|
|
6
|
+
// ========================================================================
|
|
7
|
+
// Read Operations
|
|
8
|
+
// ========================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Get configuration from a node, with defaults for missing values
|
|
11
|
+
*
|
|
12
|
+
* This is the primary way to read configuration from a block.
|
|
13
|
+
* Always returns a complete config object with defaults merged in.
|
|
14
|
+
* @example
|
|
15
|
+
* const config = RecommendationConfigService.getConfig(this.currentNode);
|
|
16
|
+
* console.log(config.strategy); // 'mostPopular'
|
|
17
|
+
* @param node - The immutable HTML node to read config from
|
|
18
|
+
* @returns Complete configuration with defaults for missing values
|
|
19
|
+
*/
|
|
20
|
+
static getConfig(i) {
|
|
21
|
+
if (!i)
|
|
22
|
+
return this.cloneDefaults();
|
|
23
|
+
if (!("getNodeConfig" in i) || typeof i.getNodeConfig != "function")
|
|
24
|
+
return this.cloneDefaults();
|
|
25
|
+
try {
|
|
26
|
+
const t = i.getNodeConfig();
|
|
27
|
+
return t ? this.mergeWithDefaults(t) : this.cloneDefaults();
|
|
28
|
+
} catch {
|
|
29
|
+
return this.cloneDefaults();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if a node has valid configuration stored
|
|
34
|
+
*
|
|
35
|
+
* Used for migration detection - returns false for legacy templates
|
|
36
|
+
* that need their configuration migrated.
|
|
37
|
+
* @param node - The immutable HTML node to check
|
|
38
|
+
* @returns True if node has valid config with version number
|
|
39
|
+
*/
|
|
40
|
+
static hasConfig(i) {
|
|
41
|
+
if (!i || !("getNodeConfig" in i) || typeof i.getNodeConfig != "function")
|
|
42
|
+
return !1;
|
|
43
|
+
try {
|
|
44
|
+
const t = i.getNodeConfig();
|
|
45
|
+
return a(t);
|
|
46
|
+
} catch {
|
|
47
|
+
return !1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the configuration version from a node
|
|
52
|
+
* @param node - The immutable HTML node to check
|
|
53
|
+
* @returns Config version number, or 0 if no config exists
|
|
54
|
+
*/
|
|
55
|
+
static getConfigVersion(i) {
|
|
56
|
+
return this.hasConfig(i) && this.getConfig(i).configVersion || 0;
|
|
57
|
+
}
|
|
58
|
+
// ========================================================================
|
|
59
|
+
// Write Operations
|
|
60
|
+
// ========================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Update specific configuration values
|
|
63
|
+
*
|
|
64
|
+
* Merges the updates with existing config and persists to node.
|
|
65
|
+
* This is the primary way to update configuration from controls.
|
|
66
|
+
* @example
|
|
67
|
+
* RecommendationConfigService.updateConfig(
|
|
68
|
+
* this.api,
|
|
69
|
+
* this.currentNode,
|
|
70
|
+
* { strategy: 'complementaryItems' },
|
|
71
|
+
* 'Changed recommendation algorithm'
|
|
72
|
+
* );
|
|
73
|
+
* @param api - Stripo extension API with document modifier
|
|
74
|
+
* @param node - The immutable HTML node to update
|
|
75
|
+
* @param updates - Partial config with values to update
|
|
76
|
+
* @param description - Human-readable description for undo/redo
|
|
77
|
+
* @returns The new complete configuration
|
|
78
|
+
*/
|
|
79
|
+
static updateConfig(i, t, o, n) {
|
|
80
|
+
const s = this.getConfig(t), r = this.deepMerge(s, o);
|
|
81
|
+
return this.saveConfig(i, t, r, n), r;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Initialize configuration for a new block
|
|
85
|
+
*
|
|
86
|
+
* Called when a block is first created (dropped into template).
|
|
87
|
+
* Can optionally merge in partial config from migration.
|
|
88
|
+
* @example
|
|
89
|
+
* // In Block.onCreated lifecycle
|
|
90
|
+
* RecommendationConfigService.initializeConfig(this.api, node);
|
|
91
|
+
* @param api - Stripo extension API with document modifier
|
|
92
|
+
* @param node - The immutable HTML node to initialize
|
|
93
|
+
* @param partialConfig - Optional partial config to merge with defaults
|
|
94
|
+
* @returns The initialized configuration
|
|
95
|
+
*/
|
|
96
|
+
static initializeConfig(i, t, o) {
|
|
97
|
+
const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
|
|
98
|
+
return this.saveConfig(i, t, n, "Initialize recommendation block"), g({
|
|
99
|
+
currentNode: t,
|
|
100
|
+
documentModifier: i.getDocumentModifier(),
|
|
101
|
+
currency: n.currency
|
|
102
|
+
}), n;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Save complete configuration to a node
|
|
106
|
+
*
|
|
107
|
+
* Low-level method - prefer `updateConfig` or `initializeConfig` in most cases.
|
|
108
|
+
* @param api - Stripo extension API with document modifier
|
|
109
|
+
* @param node - The immutable HTML node to save to
|
|
110
|
+
* @param config - Complete configuration to save
|
|
111
|
+
* @param description - Human-readable description for undo/redo
|
|
112
|
+
*/
|
|
113
|
+
static saveConfig(i, t, o, n) {
|
|
114
|
+
try {
|
|
115
|
+
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new f(n));
|
|
116
|
+
} catch (s) {
|
|
117
|
+
console.warn("[RecommendationConfigService] Failed to save config:", s);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// ========================================================================
|
|
121
|
+
// Migration Helpers
|
|
122
|
+
// ========================================================================
|
|
123
|
+
/**
|
|
124
|
+
* Migrate configuration from legacy data-attributes
|
|
125
|
+
*
|
|
126
|
+
* Reads existing data-attributes and creates a proper node config.
|
|
127
|
+
* Used when loading templates created before node config was implemented.
|
|
128
|
+
* @param api - Stripo extension API with document modifier
|
|
129
|
+
* @param node - The block node to migrate
|
|
130
|
+
* @returns The migrated configuration
|
|
131
|
+
*/
|
|
132
|
+
static migrateFromDataAttributes(i, t) {
|
|
133
|
+
const o = {
|
|
134
|
+
configVersion: u
|
|
135
|
+
};
|
|
136
|
+
if ("getAttribute" in t && typeof t.getAttribute == "function") {
|
|
137
|
+
const n = t.getAttribute("data-layout");
|
|
138
|
+
n === "list" || n === "horizontal" ? o.layout = "list" : (n === "grid" || n === "vertical") && (o.layout = "grid");
|
|
139
|
+
const s = t.getAttribute("data-card-composition");
|
|
140
|
+
s && (o.composition = s.split(",").filter(Boolean));
|
|
141
|
+
const r = t.getAttribute("data-column-spacing");
|
|
142
|
+
r && (o.columnSpacing = parseInt(r) || e.columnSpacing);
|
|
143
|
+
const c = t.getAttribute("data-row-spacing");
|
|
144
|
+
c && (o.rowSpacing = parseInt(c) || e.rowSpacing);
|
|
145
|
+
}
|
|
146
|
+
return this.initializeConfig(i, t, o);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check if configuration needs migration
|
|
150
|
+
* @param node - The block node to check
|
|
151
|
+
* @returns True if migration is needed
|
|
152
|
+
*/
|
|
153
|
+
static needsMigration(i) {
|
|
154
|
+
return i ? this.hasConfig(i) ? this.getConfigVersion(i) < u : !0 : !1;
|
|
155
|
+
}
|
|
156
|
+
// ========================================================================
|
|
157
|
+
// Internal Helpers
|
|
158
|
+
// ========================================================================
|
|
159
|
+
/**
|
|
160
|
+
* Clone default config to avoid mutations
|
|
161
|
+
*/
|
|
162
|
+
static cloneDefaults() {
|
|
163
|
+
return {
|
|
164
|
+
...e,
|
|
165
|
+
currency: { ...e.currency },
|
|
166
|
+
omnibusPrice: { ...e.omnibusPrice },
|
|
167
|
+
omnibusDiscount: { ...e.omnibusDiscount },
|
|
168
|
+
composition: [...e.composition],
|
|
169
|
+
visibility: { ...e.visibility },
|
|
170
|
+
filters: [],
|
|
171
|
+
productIds: []
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Merge partial config with defaults
|
|
176
|
+
*
|
|
177
|
+
* Deep merges nested objects like currency, omnibus settings.
|
|
178
|
+
*/
|
|
179
|
+
static mergeWithDefaults(i) {
|
|
180
|
+
const t = this.cloneDefaults();
|
|
181
|
+
return {
|
|
182
|
+
...t,
|
|
183
|
+
...i,
|
|
184
|
+
currency: {
|
|
185
|
+
...t.currency,
|
|
186
|
+
...i.currency || {}
|
|
187
|
+
},
|
|
188
|
+
omnibusPrice: {
|
|
189
|
+
...t.omnibusPrice,
|
|
190
|
+
...i.omnibusPrice || {}
|
|
191
|
+
},
|
|
192
|
+
omnibusDiscount: {
|
|
193
|
+
...t.omnibusDiscount,
|
|
194
|
+
...i.omnibusDiscount || {}
|
|
195
|
+
},
|
|
196
|
+
visibility: {
|
|
197
|
+
...t.visibility,
|
|
198
|
+
...i.visibility || {}
|
|
199
|
+
},
|
|
200
|
+
composition: i.composition || t.composition,
|
|
201
|
+
filters: i.filters || [],
|
|
202
|
+
productIds: i.productIds || []
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Deep merge for nested objects
|
|
207
|
+
*
|
|
208
|
+
* Recursively merges source into target, preserving existing values
|
|
209
|
+
* that aren't explicitly overwritten.
|
|
210
|
+
*/
|
|
211
|
+
static deepMerge(i, t) {
|
|
212
|
+
return {
|
|
213
|
+
...i,
|
|
214
|
+
...t,
|
|
215
|
+
currency: {
|
|
216
|
+
...i.currency,
|
|
217
|
+
...t.currency || {}
|
|
218
|
+
},
|
|
219
|
+
omnibusPrice: {
|
|
220
|
+
...i.omnibusPrice,
|
|
221
|
+
...t.omnibusPrice || {}
|
|
222
|
+
},
|
|
223
|
+
omnibusDiscount: {
|
|
224
|
+
...i.omnibusDiscount,
|
|
225
|
+
...t.omnibusDiscount || {}
|
|
226
|
+
},
|
|
227
|
+
visibility: {
|
|
228
|
+
...i.visibility,
|
|
229
|
+
...t.visibility || {}
|
|
230
|
+
},
|
|
231
|
+
composition: t.composition ?? i.composition,
|
|
232
|
+
filters: t.filters ?? i.filters,
|
|
233
|
+
productIds: t.productIds ?? i.productIds
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export {
|
|
238
|
+
C as RecommendationConfigService
|
|
239
|
+
};
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { SettingsPanelRegistry as S, SettingsPanelTab as I, SettingsTab as T, ContainerControls as E, TextControls as C } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { BLOCK_ID as R } from "./block.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { CONTROL_BLOCK_ID as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
3
|
+
import { RecommendationBlockId as N } from "./constants/blockIds.js";
|
|
4
|
+
import { RecommendationControlId as _ } from "./constants/controlIds.js";
|
|
5
|
+
import { CONTROL_BLOCK_ID as L } from "./controls/main/index.js";
|
|
6
|
+
import "./store/recommendation.js";
|
|
7
|
+
import "./controls/name/index.js";
|
|
8
|
+
import "./controls/price/index.js";
|
|
9
|
+
import "./controls/oldPrice/index.js";
|
|
10
|
+
import "./controls/omnibusPrice/index.js";
|
|
11
|
+
import "./controls/omnibusDiscount/index.js";
|
|
12
|
+
import "./controls/button/index.js";
|
|
13
|
+
import "./controls/image/index.js";
|
|
14
|
+
import { SPACING_CONTROL_ID as U } from "./controls/spacing/index.js";
|
|
15
|
+
import { CARD_BACKGROUND_COLOR_CONTROL_ID as B } from "./controls/cardBackground/index.js";
|
|
16
|
+
import { LAYOUT_CONTROL_ID as D } from "./controls/layout/index.js";
|
|
17
|
+
import { COMPOSITION_CONTROL_BLOCK_ID as A } from "./controls/cardComposition/index.js";
|
|
18
|
+
class s extends S {
|
|
9
19
|
registerBlockControls(O) {
|
|
10
20
|
O[R] = [
|
|
11
21
|
new I(
|
|
12
22
|
T.SETTINGS,
|
|
13
23
|
[
|
|
14
|
-
|
|
24
|
+
L,
|
|
15
25
|
E.EXTERNAL_INDENTS
|
|
16
26
|
]
|
|
17
27
|
),
|
|
@@ -20,13 +30,14 @@ class m extends S {
|
|
|
20
30
|
[
|
|
21
31
|
C.TEXT_BLOCK_BACKGROUND_COLOR,
|
|
22
32
|
B,
|
|
23
|
-
D
|
|
33
|
+
D,
|
|
34
|
+
U
|
|
24
35
|
]
|
|
25
36
|
),
|
|
26
37
|
new I(
|
|
27
38
|
"Card Composition",
|
|
28
39
|
[
|
|
29
|
-
|
|
40
|
+
A
|
|
30
41
|
]
|
|
31
42
|
).withLabel("Card Composition")
|
|
32
43
|
], O[N.NAME] = [
|
|
@@ -158,5 +169,5 @@ class m extends S {
|
|
|
158
169
|
}
|
|
159
170
|
}
|
|
160
171
|
export {
|
|
161
|
-
|
|
172
|
+
s as SettingsPanel
|
|
162
173
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { RecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as l, PriceAttributes as p } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as m } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as f } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as d } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as g } from "../constants/layout.js";
|
|
6
|
+
import { generateCompleteFilterQuery as c } from "../utils/filterUtil.js";
|
|
7
|
+
const s = m(), h = () => ({
|
|
7
8
|
recommendationCampaignUrls: {},
|
|
8
9
|
recommendationProducts: [],
|
|
9
10
|
recommendationConfigs: {
|
|
10
|
-
cardsInRow:
|
|
11
|
+
cardsInRow: g,
|
|
11
12
|
currencySettings: {
|
|
12
13
|
name: "USD",
|
|
13
14
|
value: "USD",
|
|
@@ -118,14 +119,14 @@ const a = l(), d = () => ({
|
|
|
118
119
|
productIds: ["22", "12"],
|
|
119
120
|
id: 1,
|
|
120
121
|
language: "tr_TR",
|
|
121
|
-
orientation: "
|
|
122
|
+
orientation: "grid",
|
|
122
123
|
recommendedProducts: [],
|
|
123
124
|
sendProductRequestFlag: !1,
|
|
124
125
|
shuffleProducts: !1,
|
|
125
126
|
strategy: "mostPopular",
|
|
126
127
|
textTrimming: !0,
|
|
127
128
|
unresponsive: !1,
|
|
128
|
-
size: "
|
|
129
|
+
size: "6"
|
|
129
130
|
},
|
|
130
131
|
activePredictiveAlgorithms: [],
|
|
131
132
|
languages: {},
|
|
@@ -134,8 +135,8 @@ const a = l(), d = () => ({
|
|
|
134
135
|
filterSelectionDrawerStatus: !1,
|
|
135
136
|
filterList: {},
|
|
136
137
|
filterGroup: 1
|
|
137
|
-
}),
|
|
138
|
-
state: () =>
|
|
138
|
+
}), R = d("guidoRecommendationExtension", {
|
|
139
|
+
state: () => h(),
|
|
139
140
|
getters: {
|
|
140
141
|
hasFilters: (e) => !!e.recommendationConfigs.filters.length,
|
|
141
142
|
getFilterGroupCount: (e) => {
|
|
@@ -145,7 +146,7 @@ const a = l(), d = () => ({
|
|
|
145
146
|
getActivePredictiveAlgorithms: (e) => {
|
|
146
147
|
const t = [];
|
|
147
148
|
return e.activePredictiveAlgorithms.forEach((r) => {
|
|
148
|
-
t.push(...
|
|
149
|
+
t.push(...l.filter((i) => i.id === r));
|
|
149
150
|
}), t.map((r) => ({
|
|
150
151
|
text: r.name,
|
|
151
152
|
value: r.key
|
|
@@ -160,7 +161,7 @@ const a = l(), d = () => ({
|
|
|
160
161
|
value: t.text
|
|
161
162
|
})),
|
|
162
163
|
getFilterList: (e) => Object.values(e.filterList).map((t) => {
|
|
163
|
-
const r = t.type === "defaultAttribute", i =
|
|
164
|
+
const r = t.type === "defaultAttribute", i = p.includes(t.attributeName);
|
|
164
165
|
let o = r ? t.attributeName : `product_attributes.${t.attributeName}`;
|
|
165
166
|
return o = i ? `${o}.${e.recommendationConfigs.currencySettings.value}` : o, {
|
|
166
167
|
text: t.displayName,
|
|
@@ -178,13 +179,13 @@ const a = l(), d = () => ({
|
|
|
178
179
|
activePredictiveAlgorithms: e,
|
|
179
180
|
languages: t,
|
|
180
181
|
currencies: r
|
|
181
|
-
} = await
|
|
182
|
+
} = await s.fetchRecommendationCreateData();
|
|
182
183
|
this.activePredictiveAlgorithms = e, this.languages = t;
|
|
183
184
|
const [i] = r;
|
|
184
185
|
this.recommendationConfigs.currencySettings.name = i.text, this.recommendationConfigs.currencySettings.value = i.value, this.currencyList = r, this.filterStatus = !!this.recommendationConfigs.filters.length;
|
|
185
186
|
},
|
|
186
187
|
async fetchRecommendationFilters() {
|
|
187
|
-
const e = await
|
|
188
|
+
const e = await s.fetchRecommendationFilters();
|
|
188
189
|
this.filterList = e;
|
|
189
190
|
},
|
|
190
191
|
addFilterGroup(e) {
|
|
@@ -224,13 +225,15 @@ const a = l(), d = () => ({
|
|
|
224
225
|
}
|
|
225
226
|
},
|
|
226
227
|
addFilter(e) {
|
|
227
|
-
const t = [...this.recommendationConfigs.filters],
|
|
228
|
-
|
|
228
|
+
const t = [...this.recommendationConfigs.filters], i = t.filter(
|
|
229
|
+
(a) => a.filterGroup === e.filterGroup
|
|
230
|
+
).length + 1, o = t.findLastIndex((a) => a.filterGroup === e.filterGroup);
|
|
231
|
+
o !== -1 ? t.splice(o + 1, 0, {
|
|
229
232
|
...e,
|
|
230
|
-
filterNumber:
|
|
233
|
+
filterNumber: i
|
|
231
234
|
}) : t.push({
|
|
232
235
|
...e,
|
|
233
|
-
filterNumber:
|
|
236
|
+
filterNumber: i
|
|
234
237
|
}), this.$patch({
|
|
235
238
|
recommendationConfigs: {
|
|
236
239
|
filters: t
|
|
@@ -238,30 +241,32 @@ const a = l(), d = () => ({
|
|
|
238
241
|
});
|
|
239
242
|
},
|
|
240
243
|
generateFilterQuery() {
|
|
241
|
-
return
|
|
244
|
+
return c(this.recommendationConfigs.filters);
|
|
242
245
|
},
|
|
243
246
|
async fetchRecommendationProducts() {
|
|
244
|
-
var
|
|
245
|
-
const e = this.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
247
|
+
var u;
|
|
248
|
+
const e = this.recommendationConfigs.filters.filter((n) => n.isValid), t = c(e), r = ((u = l.find((n) => n.key === this.recommendationConfigs.strategy)) == null ? void 0 : u.path) || "", i = f(), o = {
|
|
249
|
+
// Note: {itemId} and {campaignId} are template placeholders replaced at runtime
|
|
250
|
+
locale: this.recommendationConfigs.language,
|
|
251
|
+
currency: this.recommendationConfigs.currencySettings.value,
|
|
252
|
+
partnerName: i.partnerName,
|
|
253
|
+
productId: this.recommendationConfigs.strategy === "manualMerchandising" ? this.recommendationConfigs.productIds.join(",") : "{itemId}",
|
|
254
|
+
size: this.recommendationConfigs.size,
|
|
255
|
+
details: !0,
|
|
256
|
+
campaignId: "{campaignId}",
|
|
257
|
+
filter: t
|
|
258
|
+
};
|
|
259
|
+
this.recommendationConfigs.shuffleProducts && (o.shuffle = !0);
|
|
260
|
+
const a = await s.fetchRecommendationProducts(
|
|
261
|
+
r,
|
|
262
|
+
o
|
|
258
263
|
);
|
|
259
264
|
this.$patch({
|
|
260
|
-
recommendationProducts:
|
|
265
|
+
recommendationProducts: a
|
|
261
266
|
});
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
269
|
});
|
|
265
270
|
export {
|
|
266
|
-
|
|
271
|
+
R as useRecommendationExtensionStore
|
|
267
272
|
};
|