@useinsider/guido 3.1.1 → 3.2.0-beta.080341b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -0
- package/dist/@types/config/schemas.js +166 -96
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +92 -80
- package/dist/components/organisms/AutoSaveController.vue.js +17 -0
- package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
- package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
- package/dist/components/organisms/header/RightSlot.vue.js +11 -11
- package/dist/components/organisms/header/RightSlot.vue2.js +17 -13
- 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/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
- package/dist/composables/useActionsApi.js +4 -4
- package/dist/composables/useAutoSave.js +71 -0
- package/dist/composables/useFullStoryBridge.js +14 -0
- package/dist/composables/useHtmlCompiler.js +23 -21
- package/dist/composables/useHtmlValidator.js +40 -38
- package/dist/composables/usePreviewMode.js +20 -16
- package/dist/composables/useRecommendation.js +46 -26
- package/dist/composables/useRibbonOffset.js +21 -0
- package/dist/composables/useSave.js +26 -15
- package/dist/composables/useStripo.js +48 -45
- package/dist/composables/validators/useCouponBlockValidator.js +24 -0
- package/dist/composables/validators/useLiquidValidator.js +42 -0
- package/dist/config/compiler/liquidCompilerRules.js +15 -0
- package/dist/config/compiler/recommendationCompilerRules.js +162 -43
- package/dist/config/compiler/unsubscribeCompilerRules.js +48 -45
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +110 -71
- package/dist/config/i18n/en/tooltips.json.js +2 -1
- package/dist/config/migrator/checkboxMigrator.js +5 -3
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/radioButtonMigrator.js +66 -44
- 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 +70 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +16 -12
- package/dist/enums/onboarding.js +7 -2
- package/dist/enums/recommendation.js +2 -2
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
- 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/RadioButton/template.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +60 -50
- 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/constants/selectors.js +27 -11
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
- 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 +27 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +211 -162
- 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/controls/spacing/index.js +75 -73
- package/dist/extensions/Blocks/Recommendation/services/configService.js +76 -33
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -79
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +24 -13
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
- package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +27 -15
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
- package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
- 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/services/recommendationApi.js +15 -15
- package/dist/services/stripoApi.js +9 -9
- package/dist/services/templateLibraryApi.js +49 -46
- 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 +245 -0
- package/dist/src/@types/config/types.d.ts +11 -1
- package/dist/src/@types/generic.d.ts +0 -1
- package/dist/src/@types/save-as-template.d.ts +1 -0
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -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/useAutoSave.d.ts +3 -0
- package/dist/src/composables/useConfig.d.ts +70 -0
- package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
- package/dist/src/composables/useRecommendation.d.ts +10 -1
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/composables/useRibbonOffset.d.ts +4 -0
- package/dist/src/composables/useSave.d.ts +1 -1
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
- package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
- 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/extensions/recommendationBlock.d.ts +3 -0
- package/dist/src/enums/onboarding.d.ts +6 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -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 +21 -3
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/library.d.ts +1 -1
- package/dist/src/services/templateLibraryApi.d.ts +1 -1
- package/dist/src/stores/autosave.d.ts +12 -0
- package/dist/src/stores/config.d.ts +630 -0
- package/dist/src/stores/editor.d.ts +23 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/genericUtil.d.ts +1 -1
- package/dist/src/utils/htmlCompiler.d.ts +2 -1
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/src/utils/timeUtil.d.ts +8 -0
- package/dist/static/styles/base.css.js +7 -2
- 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/autosave.js +17 -0
- package/dist/stores/editor.js +3 -1
- package/dist/stores/onboarding.js +4 -0
- package/dist/stores/preview.js +4 -3
- package/dist/utils/genericUtil.js +42 -20
- package/dist/utils/htmlCompiler.js +48 -41
- package/dist/utils/htmlEscape.js +13 -0
- package/dist/utils/pairProductVariables.js +89 -88
- package/dist/utils/templatePreparation.js +75 -24
- package/dist/utils/timeUtil.js +19 -0
- package/dist/utils/tooltipUtils.js +4 -5
- package/package.json +8 -4
- package/dist/enums/displayConditions.js +0 -80
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
- package/dist/src/enums/displayConditions.d.ts +0 -2
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { TextPaddingsBuiltInControl as d, ButtonBackgroundColorBuiltInControl as
|
|
1
|
+
import { TextPaddingsBuiltInControl as d, ButtonBackgroundColorBuiltInControl as i, TextFontFamilyBuiltInControl as u, TextStyleBuiltInControl as c, TextSizeBuiltInControl as C, TextColorBuiltInControl as g, TextAlignBuiltInControl as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { RecommendationBlockId as l } from "../../constants/blockIds.js";
|
|
3
3
|
import { RecommendationControlId as e } from "../../constants/controlIds.js";
|
|
4
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
4
|
+
import { BLOCK_ROOT_SELECTOR as A, ATTR_PRODUCT_ATTR as s } from "../../constants/selectors.js";
|
|
5
|
+
import { CustomAttributeTextTrimControl as I } from "./textTrim.js";
|
|
5
6
|
function o(t) {
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
7
|
+
const r = t.closest(A);
|
|
8
|
+
if (!r)
|
|
8
9
|
return [];
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
const T = `[esd-extension-block-id="${l.CUSTOM_ATTRIBUTE}"][${s}="${
|
|
12
|
-
return
|
|
10
|
+
const n = t.asElement().getAttribute(s);
|
|
11
|
+
if (n) {
|
|
12
|
+
const T = `[esd-extension-block-id="${l.CUSTOM_ATTRIBUTE}"][${s}="${n}"]`;
|
|
13
|
+
return r.querySelectorAll(T);
|
|
13
14
|
}
|
|
14
|
-
return
|
|
15
|
+
return r.querySelectorAll(
|
|
15
16
|
`[esd-extension-block-id="${l.CUSTOM_ATTRIBUTE}"]`
|
|
16
17
|
);
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
+
const m = class extends a {
|
|
19
20
|
getId() {
|
|
20
21
|
return e.CUSTOM_ATTR_ALIGN;
|
|
21
22
|
}
|
|
@@ -36,7 +37,7 @@ const A = class extends a {
|
|
|
36
37
|
getTargetNodes(t) {
|
|
37
38
|
return o(t);
|
|
38
39
|
}
|
|
39
|
-
},
|
|
40
|
+
}, x = class extends c {
|
|
40
41
|
getId() {
|
|
41
42
|
return e.CUSTOM_ATTR_STYLE;
|
|
42
43
|
}
|
|
@@ -50,29 +51,31 @@ const A = class extends a {
|
|
|
50
51
|
getTargetNodes(t) {
|
|
51
52
|
return o(t);
|
|
52
53
|
}
|
|
53
|
-
}, R = class extends
|
|
54
|
+
}, R = class extends i {
|
|
54
55
|
getId() {
|
|
55
56
|
return e.CUSTOM_ATTR_BACKGROUND;
|
|
56
57
|
}
|
|
57
58
|
getTargetNodes(t) {
|
|
58
59
|
return o(t);
|
|
59
60
|
}
|
|
60
|
-
},
|
|
61
|
+
}, B = class extends d {
|
|
61
62
|
getId() {
|
|
62
63
|
return e.CUSTOM_ATTR_PADDINGS;
|
|
63
64
|
}
|
|
64
65
|
getTargetNodes(t) {
|
|
65
66
|
return o(t);
|
|
66
67
|
}
|
|
67
|
-
},
|
|
68
|
-
align:
|
|
68
|
+
}, p = {
|
|
69
|
+
align: m,
|
|
69
70
|
color: _,
|
|
70
71
|
size: S,
|
|
71
|
-
style:
|
|
72
|
+
style: x,
|
|
72
73
|
fontFamily: O,
|
|
73
74
|
background: R,
|
|
74
|
-
paddings:
|
|
75
|
+
paddings: B,
|
|
76
|
+
textTrim: I
|
|
75
77
|
};
|
|
76
78
|
export {
|
|
77
|
-
|
|
79
|
+
p as CustomAttributeControls,
|
|
80
|
+
I as CustomAttributeTextTrimControl
|
|
78
81
|
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ModificationDescription as T } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as m } from "../../../common-control.js";
|
|
3
|
+
import { RecommendationBlockId as n } from "../../constants/blockIds.js";
|
|
4
|
+
import { RecommendationControlId as l } from "../../constants/controlIds.js";
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as u, ATTR_PRODUCT_ATTR as a } from "../../constants/selectors.js";
|
|
6
|
+
import { CSS_CLASS_TEXT_TRIM as o, ensureTextTrimCssRulesExist as c } from "../shared/textTrimCssRules.js";
|
|
7
|
+
const i = {
|
|
8
|
+
TEXT_TRIM_ENABLED: "customAttrTextTrimEnabled"
|
|
9
|
+
};
|
|
10
|
+
class g extends m {
|
|
11
|
+
getId() {
|
|
12
|
+
return l.CUSTOM_ATTR_TEXT_TRIM;
|
|
13
|
+
}
|
|
14
|
+
getTemplate() {
|
|
15
|
+
return `
|
|
16
|
+
<hr style="margin: 0; border: none; border-top: 1px solid #e0e0e0;" />
|
|
17
|
+
<div class="custom-attr-text-trim-control-container">
|
|
18
|
+
${this._GuTwoColumns([
|
|
19
|
+
this._GuLabel({ text: this.api.translate("Trim Long Text") }),
|
|
20
|
+
this._GuToggle(i.TEXT_TRIM_ENABLED)
|
|
21
|
+
])}
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
onRender() {
|
|
26
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
27
|
+
}
|
|
28
|
+
onTemplateNodeUpdated(t) {
|
|
29
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
30
|
+
}
|
|
31
|
+
// ========================================================================
|
|
32
|
+
// State Reading
|
|
33
|
+
// ========================================================================
|
|
34
|
+
_setFormValues() {
|
|
35
|
+
this.api.updateValues({
|
|
36
|
+
[i.TEXT_TRIM_ENABLED]: this._getCurrentTrimState()
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
_getCurrentTrimState() {
|
|
40
|
+
if (!this.currentNode || !("hasClass" in this.currentNode))
|
|
41
|
+
return !1;
|
|
42
|
+
if (this.currentNode.hasClass(o))
|
|
43
|
+
return !0;
|
|
44
|
+
const t = this._getTargetElements();
|
|
45
|
+
return t.length > 0 && "hasClass" in t[0] ? t[0].hasClass(o) : !1;
|
|
46
|
+
}
|
|
47
|
+
// ========================================================================
|
|
48
|
+
// Target Element Discovery (per-attribute scoping)
|
|
49
|
+
// ========================================================================
|
|
50
|
+
/**
|
|
51
|
+
* Finds all custom attribute elements of the same type as the current node.
|
|
52
|
+
*
|
|
53
|
+
* Similar to getCustomAttrTargetNodes in customAttribute/index.ts, but adapted
|
|
54
|
+
* for CommonControl lifecycle where currentNode is a class property (not a
|
|
55
|
+
* parameter from Stripo's getTargetNodes override).
|
|
56
|
+
*/
|
|
57
|
+
_getTargetElements() {
|
|
58
|
+
if (!this.currentNode || !("closest" in this.currentNode))
|
|
59
|
+
return [];
|
|
60
|
+
const t = this.currentNode.closest(u);
|
|
61
|
+
if (!t)
|
|
62
|
+
return [];
|
|
63
|
+
const e = "asElement" in this.currentNode ? this.currentNode.asElement().getAttribute(a) : null;
|
|
64
|
+
if (e) {
|
|
65
|
+
const s = `[esd-extension-block-id="${n.CUSTOM_ATTRIBUTE}"][${a}="${e}"]`;
|
|
66
|
+
return Array.from(t.querySelectorAll(s));
|
|
67
|
+
}
|
|
68
|
+
return Array.from(
|
|
69
|
+
t.querySelectorAll(
|
|
70
|
+
`[esd-extension-block-id="${n.CUSTOM_ATTRIBUTE}"]`
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
// ========================================================================
|
|
75
|
+
// Toggle Handler
|
|
76
|
+
// ========================================================================
|
|
77
|
+
_onTextTrimChange(t) {
|
|
78
|
+
const e = this._getTargetElements();
|
|
79
|
+
if (!e.length)
|
|
80
|
+
return;
|
|
81
|
+
t && c(this.api);
|
|
82
|
+
const r = this.api.getDocumentModifier();
|
|
83
|
+
e.forEach((s) => {
|
|
84
|
+
t ? r.modifyHtml(s).setClass(o) : r.modifyHtml(s).removeClass(o);
|
|
85
|
+
}), r.apply(
|
|
86
|
+
new T(
|
|
87
|
+
t ? "Enable custom attribute text trimming" : "Disable custom attribute text trimming"
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
_listenToFormUpdates() {
|
|
92
|
+
this.api.onValueChanged(i.TEXT_TRIM_ENABLED, (t) => {
|
|
93
|
+
this._onTextTrimChange(t);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
g as CustomAttributeTextTrimControl
|
|
99
|
+
};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
var c = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var a = (s,
|
|
4
|
-
import { UEAttr as
|
|
2
|
+
var l = (s, o, t) => o in s ? c(s, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[o] = t;
|
|
3
|
+
var a = (s, o, t) => l(s, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as d } from "../../../common-control.js";
|
|
6
6
|
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
7
7
|
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
8
|
-
|
|
8
|
+
import { mapLegacyStrategy as g } from "../../utils/legacyStrategyMap.js";
|
|
9
|
+
const u = "recommendation-algorithm-control", i = {
|
|
9
10
|
ALGORITHM: "strategy",
|
|
10
11
|
PRODUCT_IDS: "productIds"
|
|
11
12
|
};
|
|
12
|
-
class
|
|
13
|
+
class R extends d {
|
|
13
14
|
constructor() {
|
|
14
15
|
super(...arguments);
|
|
15
16
|
// Store is used ONLY for API-fetched data (algorithms list), not for config
|
|
16
17
|
a(this, "store", m());
|
|
17
18
|
}
|
|
18
19
|
getId() {
|
|
19
|
-
return
|
|
20
|
+
return u;
|
|
20
21
|
}
|
|
21
22
|
getTemplate() {
|
|
22
23
|
return `
|
|
@@ -24,13 +25,13 @@ class T extends d {
|
|
|
24
25
|
${this._GuTwoColumns([
|
|
25
26
|
this._GuLabel({ text: this.api.translate("Recommendation Algorithm") }),
|
|
26
27
|
this._GuSelect({
|
|
27
|
-
name:
|
|
28
|
+
name: i.ALGORITHM,
|
|
28
29
|
placeholder: this.api.translate("Select Recommendation Algorithm"),
|
|
29
30
|
options: this.store.getActivePredictiveAlgorithms
|
|
30
31
|
}),
|
|
31
|
-
this._GuLabel({ text: this.api.translate("Product Ids"), name: `${
|
|
32
|
+
this._GuLabel({ text: this.api.translate("Product Ids"), name: `${i.PRODUCT_IDS}_label` }),
|
|
32
33
|
this._GuTextInput({
|
|
33
|
-
name:
|
|
34
|
+
name: i.PRODUCT_IDS,
|
|
34
35
|
placeholder: this.api.translate("Enter Product Ids"),
|
|
35
36
|
className: "es-180w"
|
|
36
37
|
})
|
|
@@ -42,23 +43,23 @@ class T extends d {
|
|
|
42
43
|
this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
|
|
43
44
|
}
|
|
44
45
|
onTemplateNodeUpdated(t) {
|
|
45
|
-
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
46
|
+
super.onTemplateNodeUpdated(t), this._initializeSelectItems(), this._setFormValues();
|
|
46
47
|
}
|
|
47
48
|
_setFormValues() {
|
|
48
|
-
const t = n.getConfig(this.currentNode);
|
|
49
|
-
this._setProductIdsVisibility(
|
|
50
|
-
[
|
|
51
|
-
[
|
|
49
|
+
const t = n.getConfig(this.currentNode), e = g(t.strategy) ?? t.strategy;
|
|
50
|
+
this._setProductIdsVisibility(e), this.api.updateValues({
|
|
51
|
+
[i.ALGORITHM]: e,
|
|
52
|
+
[i.PRODUCT_IDS]: t.productIds.join(",")
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
_initializeSelectItems() {
|
|
55
|
-
var
|
|
56
|
-
const t = (
|
|
56
|
+
var e;
|
|
57
|
+
const t = (e = this.store) == null ? void 0 : e.getActivePredictiveAlgorithms;
|
|
57
58
|
if (t != null && t.length)
|
|
58
59
|
try {
|
|
59
60
|
this.api.setUIEAttribute(
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
i.ALGORITHM,
|
|
62
|
+
h.SELECTPICKER.items,
|
|
62
63
|
t
|
|
63
64
|
);
|
|
64
65
|
} catch (r) {
|
|
@@ -67,7 +68,7 @@ class T extends d {
|
|
|
67
68
|
}
|
|
68
69
|
_setProductIdsVisibility(t) {
|
|
69
70
|
const r = (t ?? n.getConfig(this.currentNode).strategy) === "manualMerchandising";
|
|
70
|
-
this.api.setVisibility(
|
|
71
|
+
this.api.setVisibility(i.PRODUCT_IDS, r), this.api.setVisibility(`${i.PRODUCT_IDS}_label`, r);
|
|
71
72
|
}
|
|
72
73
|
_onAlgorithmChange(t) {
|
|
73
74
|
!this.currentNode || n.getConfig(this.currentNode).strategy === t || (n.updateConfig(
|
|
@@ -80,23 +81,23 @@ class T extends d {
|
|
|
80
81
|
_onProductIdsChange(t) {
|
|
81
82
|
if (!this.currentNode)
|
|
82
83
|
return;
|
|
83
|
-
const
|
|
84
|
+
const e = t.split(",").map((r) => r.trim()).filter(Boolean);
|
|
84
85
|
n.updateConfig(
|
|
85
86
|
this.api,
|
|
86
87
|
this.currentNode,
|
|
87
|
-
{ productIds:
|
|
88
|
+
{ productIds: e },
|
|
88
89
|
"Updated product IDs"
|
|
89
|
-
), this.store.patchCurrentBlockConfig({ productIds:
|
|
90
|
+
), this.store.patchCurrentBlockConfig({ productIds: e });
|
|
90
91
|
}
|
|
91
92
|
_listenToFormUpdates() {
|
|
92
|
-
this.api.onValueChanged(
|
|
93
|
+
this.api.onValueChanged(i.ALGORITHM, (t) => {
|
|
93
94
|
this._onAlgorithmChange(t);
|
|
94
|
-
}), this.api.onValueChanged(
|
|
95
|
+
}), this.api.onValueChanged(i.PRODUCT_IDS, (t) => {
|
|
95
96
|
this._onProductIdsChange(t);
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
u as ALGORITHM_CONTROL_ID,
|
|
102
|
+
R as AlgorithmControl
|
|
102
103
|
};
|
|
@@ -114,7 +114,9 @@ class H extends g {
|
|
|
114
114
|
var r;
|
|
115
115
|
super.onTemplateNodeUpdated(t);
|
|
116
116
|
const e = this._getRecommendationIdFromNode(t);
|
|
117
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e)
|
|
117
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
118
|
+
this._initializeSubControls();
|
|
119
|
+
}), [
|
|
118
120
|
this.layoutOrientationControl,
|
|
119
121
|
this.productCountControl,
|
|
120
122
|
this.algorithmControl,
|