@useinsider/guido 2.1.0-beta.9ba2e9d → 2.1.0-beta.9ed76a4
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 +36 -0
- package/dist/@types/config/schemas.js +70 -65
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useHtmlValidator.js +107 -119
- package/dist/composables/useStripo.js +25 -23
- package/dist/composables/useVersionHistoryApi.js +1 -1
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +70 -96
- package/dist/config/i18n/en/index.js +11 -0
- package/dist/config/i18n/en/labels.json.js +7 -0
- package/dist/config/i18n/en/toasters.json.js +56 -0
- package/dist/config/i18n/en/tooltips.json.js +82 -0
- package/dist/config/i18n/index.js +7 -0
- package/dist/config/migrator/itemsBlockMigrator.js +101 -97
- package/dist/enums/defaults.js +8 -4
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +26 -23
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +27 -26
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -70
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +87 -37
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +117 -107
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +43 -31
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
- package/dist/services/recommendationApi.js +11 -9
- package/dist/services/stripoApi.js +20 -17
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
- package/dist/src/config/i18n/en/index.d.ts +1 -0
- package/dist/src/config/i18n/index.d.ts +16 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/static/styles/components/notification.css.js +19 -0
- package/dist/static/styles/components/tools.css.js +6 -2
- package/dist/static/styles/components/version-history.css.js +10 -2
- package/dist/static/styles/components/wide-panel.css.js +18 -2
- package/dist/static/styles/customEditorStyle.css.js +10 -9
- package/dist/static/styles/variables.css.js +2 -0
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/package.json +1 -1
|
@@ -1,45 +1,60 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var c = (i, o, t) => o in i ? _(i, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[o] = t;
|
|
3
|
+
var d = (i, o, t) => c(i, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { EditorStatePropertyType as u, PreviewDeviceMode as R } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as h } from "../../../common-control.js";
|
|
6
|
+
import { MAX_PRODUCT_COUNT as C, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
|
|
7
|
+
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
8
|
+
import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
|
|
9
|
+
import { ensureMobileCssRulesExist as O } from "../mobileLayout/cssRules.js";
|
|
10
|
+
import { getCurrentLayout as I, regenerateMobileProductRows as g, regenerateProductRowsWithStyles as b } from "./utils.js";
|
|
11
|
+
import { useDebounceFn as N } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
12
|
+
const P = "recommendation-product-layout-control", e = {
|
|
11
13
|
PRODUCT_COUNT: "size",
|
|
12
14
|
PRODUCT_IN_ROW: "cardsInRow",
|
|
13
|
-
PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
|
|
15
|
+
PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
|
|
16
|
+
MOBILE_CARDS_IN_ROW: "mobileCardsInRow",
|
|
17
|
+
MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel"
|
|
14
18
|
};
|
|
15
|
-
class
|
|
19
|
+
class S extends h {
|
|
16
20
|
constructor() {
|
|
17
21
|
super(...arguments);
|
|
18
22
|
// Store is used for backward compatibility with product fetching and regeneration
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
d(this, "store", l());
|
|
24
|
+
d(this, "storeUnsubscription", () => {
|
|
21
25
|
});
|
|
22
|
-
|
|
26
|
+
d(this, "_debouncedRegenerateProductRows", N(() => {
|
|
23
27
|
this._regenerateProductRows();
|
|
24
28
|
}, 500));
|
|
25
29
|
}
|
|
26
30
|
getId() {
|
|
27
|
-
return
|
|
31
|
+
return P;
|
|
28
32
|
}
|
|
29
33
|
getTemplate() {
|
|
30
34
|
return `
|
|
31
35
|
<div class="product-layout-control-container">
|
|
32
36
|
${this._GuTwoColumns([
|
|
33
37
|
this._GuLabel({ text: "Number of Products" }),
|
|
34
|
-
this._GuCounter({ name:
|
|
35
|
-
this._GuLabel({
|
|
36
|
-
|
|
38
|
+
this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: C }),
|
|
39
|
+
this._GuLabel({
|
|
40
|
+
text: "Products in One Row on Desktop",
|
|
41
|
+
name: e.PRODUCT_IN_ROW_LABEL
|
|
42
|
+
}),
|
|
43
|
+
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: p }),
|
|
44
|
+
this._GuLabel({
|
|
45
|
+
text: "Products in One Row on Mobile",
|
|
46
|
+
name: e.MOBILE_CARDS_IN_ROW_LABEL
|
|
47
|
+
}),
|
|
48
|
+
this._GuCounter({
|
|
49
|
+
name: e.MOBILE_CARDS_IN_ROW,
|
|
50
|
+
maxValue: m
|
|
51
|
+
})
|
|
37
52
|
])}
|
|
38
53
|
</div>
|
|
39
54
|
`;
|
|
40
55
|
}
|
|
41
56
|
onRender() {
|
|
42
|
-
this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
|
|
57
|
+
this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._subscribeToEditorModeChanges();
|
|
43
58
|
}
|
|
44
59
|
onTemplateNodeUpdated(t) {
|
|
45
60
|
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
|
|
@@ -48,23 +63,45 @@ class I extends c {
|
|
|
48
63
|
this.storeUnsubscription();
|
|
49
64
|
}
|
|
50
65
|
_setFormValues() {
|
|
51
|
-
const t =
|
|
66
|
+
const t = s.getConfig(this.currentNode);
|
|
52
67
|
this.api.updateValues({
|
|
53
|
-
[
|
|
54
|
-
[
|
|
68
|
+
[e.PRODUCT_COUNT]: t.size,
|
|
69
|
+
[e.PRODUCT_IN_ROW]: t.cardsInRow,
|
|
70
|
+
[e.MOBILE_CARDS_IN_ROW]: t.mobileCardsInRow
|
|
55
71
|
});
|
|
56
72
|
}
|
|
57
73
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
74
|
+
* Checks if the editor is currently in mobile preview mode
|
|
75
|
+
* using Stripo's EditorStatePropertyType API.
|
|
76
|
+
*/
|
|
77
|
+
_isMobileMode() {
|
|
78
|
+
return this.api.getEditorState()[u.previewDeviceMode] === R.MOBILE;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Updates counter visibility based on layout orientation and editor mode.
|
|
82
|
+
* - List layout: hide both counters (products always full-width)
|
|
83
|
+
* - Grid + desktop mode: show desktop counter, hide mobile counter
|
|
84
|
+
* - Grid + mobile mode: show mobile counter, hide desktop counter
|
|
61
85
|
*/
|
|
62
86
|
_updateProductsInRowVisibility() {
|
|
63
|
-
const
|
|
64
|
-
this.api.setVisibility(
|
|
87
|
+
const r = (s.getConfig(this.currentNode).layout || I(this.currentNode)) === "grid", n = this._isMobileMode();
|
|
88
|
+
this.api.setVisibility(e.PRODUCT_IN_ROW, r && !n), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, r && !n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, r && n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, r && n);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Subscribes to editor preview mode changes via Stripo API.
|
|
92
|
+
* When the user switches between desktop/mobile preview, toggles
|
|
93
|
+
* which "Products in One Row" counter is visible.
|
|
94
|
+
*/
|
|
95
|
+
_subscribeToEditorModeChanges() {
|
|
96
|
+
this.api.onEditorStatePropUpdated(
|
|
97
|
+
u.previewDeviceMode,
|
|
98
|
+
() => {
|
|
99
|
+
this._updateProductsInRowVisibility();
|
|
100
|
+
}
|
|
101
|
+
);
|
|
65
102
|
}
|
|
66
103
|
_onProductCountChange(t) {
|
|
67
|
-
this.currentNode && (
|
|
104
|
+
this.currentNode && (s.updateConfig(
|
|
68
105
|
this.api,
|
|
69
106
|
this.currentNode,
|
|
70
107
|
{ size: t },
|
|
@@ -72,24 +109,37 @@ class I extends c {
|
|
|
72
109
|
), this.store.patchCurrentBlockConfig({ size: t }), this._debouncedRegenerateProductRows());
|
|
73
110
|
}
|
|
74
111
|
_onProductsInRowChange(t) {
|
|
75
|
-
this.currentNode && (
|
|
112
|
+
this.currentNode && (s.updateConfig(
|
|
76
113
|
this.api,
|
|
77
114
|
this.currentNode,
|
|
78
115
|
{ cardsInRow: t },
|
|
79
116
|
`Changed products per row to ${t}`
|
|
80
117
|
), this.store.patchCurrentBlockConfig({ cardsInRow: t }), this._debouncedRegenerateProductRows());
|
|
81
118
|
}
|
|
119
|
+
_onMobileCardsInRowChange(t) {
|
|
120
|
+
this.currentNode && (s.updateConfig(
|
|
121
|
+
this.api,
|
|
122
|
+
this.currentNode,
|
|
123
|
+
{ mobileCardsInRow: t },
|
|
124
|
+
`Changed mobile products per row to ${t}`
|
|
125
|
+
), O(this.api), g({
|
|
126
|
+
currentNode: this.currentNode,
|
|
127
|
+
documentModifier: this.api.getDocumentModifier()
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
82
130
|
_regenerateProductRows() {
|
|
83
|
-
|
|
131
|
+
b({
|
|
84
132
|
currentNode: this.currentNode,
|
|
85
133
|
documentModifier: this.api.getDocumentModifier()
|
|
86
134
|
});
|
|
87
135
|
}
|
|
88
136
|
_listenToFormUpdates() {
|
|
89
|
-
this.api.onValueChanged(
|
|
137
|
+
this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
|
|
90
138
|
this._onProductCountChange(t.toString());
|
|
91
|
-
}), this.api.onValueChanged(
|
|
139
|
+
}), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
|
|
92
140
|
this._onProductsInRowChange(Number(t));
|
|
141
|
+
}), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
|
|
142
|
+
this._onMobileCardsInRowChange(Number(t));
|
|
93
143
|
});
|
|
94
144
|
}
|
|
95
145
|
/**
|
|
@@ -99,12 +149,12 @@ class I extends c {
|
|
|
99
149
|
_listenStateUpdates() {
|
|
100
150
|
let t = this.store.recommendationConfigs.orientation;
|
|
101
151
|
this.storeUnsubscription = this.store.$subscribe(() => {
|
|
102
|
-
const
|
|
103
|
-
|
|
152
|
+
const a = this.store.recommendationConfigs.orientation;
|
|
153
|
+
a !== t && (t = a, this._updateProductsInRowVisibility());
|
|
104
154
|
});
|
|
105
155
|
}
|
|
106
156
|
}
|
|
107
157
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
158
|
+
P as PRODUCT_LAYOUT_CONTROL_ID,
|
|
159
|
+
S as ProductLayoutControl
|
|
110
160
|
};
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { RecommendationBlockId as
|
|
3
|
-
import { CURRENCY_ATTR as y, CONTAINER_SELECTOR as
|
|
4
|
-
import {
|
|
1
|
+
import { ModificationDescription as S } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RecommendationBlockId as m } from "../../constants/blockIds.js";
|
|
3
|
+
import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as T, DESKTOP_CONTAINER_SELECTOR as w, CONTAINER_SELECTOR as _ } from "../../constants/selectors.js";
|
|
4
|
+
import { RecommendationConfigService as k } from "../../services/configService.js";
|
|
5
|
+
import { useRecommendationExtensionStore as b } from "../../store/recommendation.js";
|
|
5
6
|
import { prepareProductRows as R } from "../../templates/index.js";
|
|
6
|
-
import { formatPrice as
|
|
7
|
-
import { isTdNode as
|
|
8
|
-
import { sanitizeImageUrl as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
7
|
+
import { formatPrice as D } from "../../utils/priceFormatter.js";
|
|
8
|
+
import { isTdNode as L } from "../../utils/tagName.js";
|
|
9
|
+
import { sanitizeImageUrl as U, getDefaultProducts as H, DEFAULT_CARD_COMPOSITION as C } from "../../templates/utils.js";
|
|
10
|
+
const q = "ins-recommendation-v3-block-v2";
|
|
11
|
+
function E(o) {
|
|
11
12
|
if (!o)
|
|
12
13
|
return null;
|
|
13
14
|
if ("getAttribute" in o) {
|
|
14
15
|
const e = o.getAttribute("class");
|
|
15
|
-
if (e && e.includes(
|
|
16
|
+
if (e && e.includes(q))
|
|
16
17
|
return o;
|
|
17
18
|
}
|
|
18
|
-
return "querySelector" in o ? o.querySelector(`.${
|
|
19
|
+
return "querySelector" in o ? o.querySelector(`.${q}`) : null;
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
const e =
|
|
21
|
+
function P(o) {
|
|
22
|
+
const e = E(o);
|
|
22
23
|
if (!e || !("getAttribute" in e))
|
|
23
24
|
return "grid";
|
|
24
25
|
const t = e.getAttribute("data-layout");
|
|
25
26
|
return t === "list" || t === "horizontal" ? "list" : "grid";
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
const e =
|
|
28
|
+
function N(o) {
|
|
29
|
+
const e = E(o);
|
|
29
30
|
if (!e || !("getAttribute" in e))
|
|
30
|
-
return
|
|
31
|
+
return C;
|
|
31
32
|
const t = e.getAttribute("data-card-composition");
|
|
32
|
-
return t ? t.split(",").filter(Boolean) :
|
|
33
|
+
return t ? t.split(",").filter(Boolean) : C;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function g(o, e, t) {
|
|
35
36
|
if (!e || !("childNodes" in e))
|
|
36
37
|
return !1;
|
|
37
38
|
const n = e.childNodes().find(
|
|
@@ -39,23 +40,42 @@ function S(o, e, t) {
|
|
|
39
40
|
);
|
|
40
41
|
return n ? (o.modifyHtml(n).setText(t), !0) : !1;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
return o && o.length > 0 ? o : e.length > 0 ? e :
|
|
43
|
+
function h(o, e) {
|
|
44
|
+
return o && o.length > 0 ? o : e.length > 0 ? e : H();
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
const { currentNode: e, documentModifier: t,
|
|
46
|
+
function $(o) {
|
|
47
|
+
const { currentNode: e, documentModifier: t, products: r, layout: n } = o;
|
|
48
|
+
if (!e || !("querySelector" in e))
|
|
49
|
+
return;
|
|
50
|
+
const i = e.querySelector(T);
|
|
51
|
+
if (!i)
|
|
52
|
+
return;
|
|
53
|
+
const c = b(), u = k.getConfig(e), l = h(r, c.recommendationProducts), s = N(e), d = n ?? P(e), a = R(l, d, {
|
|
54
|
+
productsPerRow: u.mobileCardsInRow,
|
|
55
|
+
composition: s
|
|
56
|
+
});
|
|
57
|
+
t.modifyHtml(i).setInnerHtml(a).apply(new S("Updated mobile product rows"));
|
|
58
|
+
}
|
|
59
|
+
function x(o) {
|
|
60
|
+
const {
|
|
61
|
+
currentNode: e,
|
|
62
|
+
documentModifier: t,
|
|
63
|
+
afterRegenerate: r,
|
|
64
|
+
products: n,
|
|
65
|
+
layout: i
|
|
66
|
+
} = o;
|
|
47
67
|
if (!e || !("querySelector" in e))
|
|
48
68
|
return;
|
|
49
|
-
const c = e.querySelector(
|
|
69
|
+
const c = e.querySelector(w) ?? e.querySelector(_);
|
|
50
70
|
if (!c)
|
|
51
71
|
return;
|
|
52
|
-
const
|
|
53
|
-
productsPerRow:
|
|
72
|
+
const u = b(), l = h(n, u.recommendationProducts), { cardsInRow: s } = u.recommendationConfigs, d = N(e), a = i ?? P(e), p = R(l, a, {
|
|
73
|
+
productsPerRow: s,
|
|
54
74
|
composition: d
|
|
55
75
|
});
|
|
56
|
-
t.modifyHtml(c).setInnerHtml(p).apply(new
|
|
76
|
+
t.modifyHtml(c).setInnerHtml(p).apply(new S("Updated product")), $(o), r == null || r();
|
|
57
77
|
}
|
|
58
|
-
function
|
|
78
|
+
function B(o, e, t, r) {
|
|
59
79
|
const i = `0 ${Math.floor(t / 2)}px`;
|
|
60
80
|
let c = !1;
|
|
61
81
|
return r === "grid" ? Array.from(
|
|
@@ -65,29 +85,29 @@ function $(o, e, t, r) {
|
|
|
65
85
|
}) : Array.from(
|
|
66
86
|
o.querySelectorAll(".product-card-wrapper")
|
|
67
87
|
).forEach((l) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
88
|
+
const s = "parentNode" in l ? l.parentNode : null;
|
|
89
|
+
s && L(s) && (e.modifyHtml(s).setStyle("padding", i), c = !0);
|
|
70
90
|
}), c;
|
|
71
91
|
}
|
|
72
|
-
function
|
|
92
|
+
function v(o, e, t) {
|
|
73
93
|
const r = `${t}px`, n = Array.from(o.querySelectorAll(".spacer"));
|
|
74
94
|
let i = !1;
|
|
75
95
|
return n.forEach((c) => {
|
|
76
96
|
e.modifyHtml(c).setStyle("height", r), i = !0;
|
|
77
97
|
}), i;
|
|
78
98
|
}
|
|
79
|
-
function
|
|
99
|
+
function V(o) {
|
|
80
100
|
const { currentNode: e, documentModifier: t } = o;
|
|
81
101
|
if (!e)
|
|
82
102
|
return;
|
|
83
|
-
const r =
|
|
103
|
+
const r = E(e);
|
|
84
104
|
if (!r || !("getAttribute" in r))
|
|
85
105
|
return;
|
|
86
|
-
const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c =
|
|
87
|
-
let
|
|
106
|
+
const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = P(e);
|
|
107
|
+
let u = !1;
|
|
88
108
|
if (n) {
|
|
89
109
|
const l = parseInt(n);
|
|
90
|
-
Number.isNaN(l) || (
|
|
110
|
+
Number.isNaN(l) || (u = B(
|
|
91
111
|
e,
|
|
92
112
|
t,
|
|
93
113
|
l,
|
|
@@ -97,28 +117,28 @@ function H(o) {
|
|
|
97
117
|
if (i) {
|
|
98
118
|
const l = parseInt(i);
|
|
99
119
|
if (!Number.isNaN(l)) {
|
|
100
|
-
const
|
|
101
|
-
|
|
120
|
+
const s = v(e, t, l);
|
|
121
|
+
u = u || s;
|
|
102
122
|
}
|
|
103
123
|
}
|
|
104
|
-
|
|
124
|
+
u && t.apply(new S("Reapply spacing after regeneration"));
|
|
105
125
|
}
|
|
106
|
-
function
|
|
126
|
+
function ee(o) {
|
|
107
127
|
const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
|
|
108
|
-
e &&
|
|
128
|
+
e && x({
|
|
109
129
|
currentNode: e,
|
|
110
130
|
documentModifier: t,
|
|
111
131
|
products: n,
|
|
112
132
|
layout: i,
|
|
113
133
|
afterRegenerate: () => {
|
|
114
134
|
setTimeout(() => {
|
|
115
|
-
|
|
135
|
+
V({ currentNode: e, documentModifier: t });
|
|
116
136
|
}, 0), r == null || r();
|
|
117
137
|
}
|
|
118
138
|
});
|
|
119
139
|
}
|
|
120
|
-
function
|
|
121
|
-
const o =
|
|
140
|
+
function M() {
|
|
141
|
+
const o = b(), { currencySettings: e } = o.recommendationConfigs;
|
|
122
142
|
return {
|
|
123
143
|
code: e.value,
|
|
124
144
|
symbol: e.symbol,
|
|
@@ -128,40 +148,40 @@ function h() {
|
|
|
128
148
|
thousandSeparator: e.thousandSeparator
|
|
129
149
|
};
|
|
130
150
|
}
|
|
131
|
-
function
|
|
132
|
-
const t =
|
|
133
|
-
return
|
|
151
|
+
function A(o, e = "price") {
|
|
152
|
+
const t = M(), r = o[e], n = (r == null ? void 0 : r[t.code]) ?? Object.values(r ?? {})[0] ?? 0;
|
|
153
|
+
return D({
|
|
134
154
|
price: n,
|
|
135
155
|
currency: t
|
|
136
156
|
});
|
|
137
157
|
}
|
|
138
|
-
function
|
|
158
|
+
function j(o) {
|
|
139
159
|
var i, c;
|
|
140
|
-
const e =
|
|
160
|
+
const e = M(), t = ((i = o.original_price) == null ? void 0 : i[e.code]) ?? Object.values(o.original_price ?? {})[0] ?? 0, r = ((c = o.price) == null ? void 0 : c[e.code]) ?? Object.values(o.price ?? {})[0] ?? 0, n = t > 0 ? Math.round((t - r) / t * 100) : 0;
|
|
141
161
|
return n > 0 ? `-${n}%` : "0%";
|
|
142
162
|
}
|
|
143
|
-
function
|
|
163
|
+
function I(o) {
|
|
144
164
|
const { documentModifier: e, product: t, priceEl: r, oldPriceEl: n, omnibusPriceEl: i, omnibusDiscountEl: c } = o;
|
|
145
|
-
let
|
|
165
|
+
let u = !1;
|
|
146
166
|
if (r && "querySelector" in r) {
|
|
147
|
-
const l = r.querySelector("strong"),
|
|
148
|
-
|
|
167
|
+
const l = r.querySelector("strong"), s = A(t, "price");
|
|
168
|
+
g(e, l, s) && (u = !0);
|
|
149
169
|
}
|
|
150
170
|
if (n && "querySelector" in n) {
|
|
151
|
-
const l = n.querySelector("strong"),
|
|
152
|
-
|
|
171
|
+
const l = n.querySelector("strong"), s = A(t, "original_price");
|
|
172
|
+
g(e, l, s) && (u = !0);
|
|
153
173
|
}
|
|
154
174
|
if (i && "querySelector" in i) {
|
|
155
|
-
const l = i.querySelector(".omnibus-price-value"),
|
|
156
|
-
|
|
175
|
+
const l = i.querySelector(".omnibus-price-value"), s = A(t, "original_price");
|
|
176
|
+
g(e, l, s) && (u = !0);
|
|
157
177
|
}
|
|
158
178
|
if (c && "querySelector" in c) {
|
|
159
|
-
const l = c.querySelector(".omnibus-discount-value"),
|
|
160
|
-
|
|
179
|
+
const l = c.querySelector(".omnibus-discount-value"), s = j(t);
|
|
180
|
+
g(e, l, s) && (u = !0);
|
|
161
181
|
}
|
|
162
|
-
return
|
|
182
|
+
return u;
|
|
163
183
|
}
|
|
164
|
-
function
|
|
184
|
+
function W(o) {
|
|
165
185
|
const {
|
|
166
186
|
documentModifier: e,
|
|
167
187
|
product: t,
|
|
@@ -169,118 +189,119 @@ function B(o) {
|
|
|
169
189
|
nameEl: n,
|
|
170
190
|
priceEl: i,
|
|
171
191
|
oldPriceEl: c,
|
|
172
|
-
omnibusPriceEl:
|
|
192
|
+
omnibusPriceEl: u,
|
|
173
193
|
omnibusDiscountEl: l,
|
|
174
|
-
buttonEl:
|
|
194
|
+
buttonEl: s
|
|
175
195
|
} = o;
|
|
176
196
|
let d = !1;
|
|
177
197
|
if (r && "querySelector" in r) {
|
|
178
198
|
const a = r.querySelector("img");
|
|
179
|
-
a && (e.modifyHtml(a).setAttribute("src",
|
|
199
|
+
a && (e.modifyHtml(a).setAttribute("src", U(t.image_url)).setAttribute("alt", t.name), d = !0);
|
|
180
200
|
const p = r.querySelector("a");
|
|
181
201
|
p && (e.modifyHtml(p).setAttribute("href", t.url), d = !0);
|
|
182
202
|
}
|
|
183
203
|
if (n && "querySelector" in n) {
|
|
184
204
|
const a = n.querySelector("strong");
|
|
185
|
-
|
|
205
|
+
g(e, a, t.name) && (d = !0);
|
|
186
206
|
}
|
|
187
|
-
if (
|
|
207
|
+
if (I({
|
|
188
208
|
documentModifier: e,
|
|
189
209
|
product: t,
|
|
190
210
|
priceEl: i,
|
|
191
211
|
oldPriceEl: c,
|
|
192
|
-
omnibusPriceEl:
|
|
212
|
+
omnibusPriceEl: u,
|
|
193
213
|
omnibusDiscountEl: l
|
|
194
|
-
}) && (d = !0),
|
|
195
|
-
const a =
|
|
214
|
+
}) && (d = !0), s && "querySelector" in s) {
|
|
215
|
+
const a = s.querySelector("a.es-button") || s.querySelector("a");
|
|
196
216
|
a && (e.modifyHtml(a).setAttribute("href", t.url), d = !0);
|
|
197
217
|
}
|
|
198
218
|
return d;
|
|
199
219
|
}
|
|
200
|
-
function
|
|
220
|
+
function te(o) {
|
|
201
221
|
const { currentNode: e, documentModifier: t, products: r } = o;
|
|
202
222
|
if (!e || !("querySelectorAll" in e))
|
|
203
223
|
return !1;
|
|
204
224
|
const n = e.querySelectorAll(
|
|
205
|
-
`[esd-extension-block-id="${
|
|
225
|
+
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
206
226
|
), i = e.querySelectorAll(
|
|
207
|
-
`[esd-extension-block-id="${
|
|
227
|
+
`[esd-extension-block-id="${m.NAME}"]`
|
|
208
228
|
), c = e.querySelectorAll(
|
|
209
|
-
`[esd-extension-block-id="${
|
|
210
|
-
), s = e.querySelectorAll(
|
|
211
|
-
`[esd-extension-block-id="${f.OLD_PRICE}"]`
|
|
212
|
-
), l = e.querySelectorAll(
|
|
213
|
-
`[esd-extension-block-id="${f.OMNIBUS_PRICE}"]`
|
|
229
|
+
`[esd-extension-block-id="${m.PRICE}"]`
|
|
214
230
|
), u = e.querySelectorAll(
|
|
215
|
-
`[esd-extension-block-id="${
|
|
231
|
+
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
232
|
+
), l = e.querySelectorAll(
|
|
233
|
+
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
234
|
+
), s = e.querySelectorAll(
|
|
235
|
+
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
216
236
|
), d = e.querySelectorAll(
|
|
217
|
-
`[esd-extension-block-id="${
|
|
237
|
+
`[esd-extension-block-id="${m.BUTTON}"]`
|
|
218
238
|
);
|
|
219
239
|
if (n.length !== r.length)
|
|
220
240
|
return !1;
|
|
221
241
|
let a = !1;
|
|
222
|
-
return r.forEach((p,
|
|
223
|
-
const
|
|
242
|
+
return r.forEach((p, f) => {
|
|
243
|
+
const O = W({
|
|
224
244
|
documentModifier: t,
|
|
225
245
|
product: p,
|
|
226
|
-
imageEl: n[
|
|
227
|
-
nameEl: i[
|
|
228
|
-
priceEl: c[
|
|
229
|
-
oldPriceEl:
|
|
230
|
-
omnibusPriceEl: l[
|
|
231
|
-
omnibusDiscountEl:
|
|
232
|
-
buttonEl: d[
|
|
246
|
+
imageEl: n[f] ?? null,
|
|
247
|
+
nameEl: i[f] ?? null,
|
|
248
|
+
priceEl: c[f] ?? null,
|
|
249
|
+
oldPriceEl: u[f] ?? null,
|
|
250
|
+
omnibusPriceEl: l[f] ?? null,
|
|
251
|
+
omnibusDiscountEl: s[f] ?? null,
|
|
252
|
+
buttonEl: d[f] ?? null
|
|
233
253
|
});
|
|
234
|
-
a = a ||
|
|
235
|
-
}), a && t.apply(new
|
|
254
|
+
a = a || O;
|
|
255
|
+
}), a && t.apply(new S("Updated product content in-place")), !0;
|
|
236
256
|
}
|
|
237
|
-
function
|
|
257
|
+
function oe(o) {
|
|
238
258
|
const { currentNode: e, documentModifier: t } = o;
|
|
239
259
|
if (!e || !("querySelectorAll" in e))
|
|
240
260
|
return !1;
|
|
241
|
-
const n =
|
|
261
|
+
const n = b().recommendationProducts;
|
|
242
262
|
if (n.length === 0)
|
|
243
263
|
return !1;
|
|
244
264
|
const i = e.querySelectorAll(
|
|
245
|
-
`[esd-extension-block-id="${
|
|
265
|
+
`[esd-extension-block-id="${m.PRICE}"]`
|
|
246
266
|
), c = e.querySelectorAll(
|
|
247
|
-
`[esd-extension-block-id="${
|
|
248
|
-
),
|
|
249
|
-
`[esd-extension-block-id="${
|
|
267
|
+
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
268
|
+
), u = e.querySelectorAll(
|
|
269
|
+
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
250
270
|
), l = e.querySelectorAll(
|
|
251
|
-
`[esd-extension-block-id="${
|
|
271
|
+
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
252
272
|
);
|
|
253
|
-
let
|
|
273
|
+
let s = !1;
|
|
254
274
|
return n.forEach((d, a) => {
|
|
255
|
-
|
|
275
|
+
I({
|
|
256
276
|
documentModifier: t,
|
|
257
277
|
product: d,
|
|
258
278
|
priceEl: i[a] ?? null,
|
|
259
279
|
oldPriceEl: c[a] ?? null,
|
|
260
|
-
omnibusPriceEl:
|
|
280
|
+
omnibusPriceEl: u[a] ?? null,
|
|
261
281
|
omnibusDiscountEl: l[a] ?? null
|
|
262
|
-
}) && (
|
|
263
|
-
}),
|
|
282
|
+
}) && (s = !0);
|
|
283
|
+
}), s && t.apply(new S("Updated price formatting in-place")), s;
|
|
264
284
|
}
|
|
265
|
-
function
|
|
266
|
-
const { currentNode: e, documentModifier: t, currency: r } = o, n =
|
|
285
|
+
function re(o) {
|
|
286
|
+
const { currentNode: e, documentModifier: t, currency: r } = o, n = E(e);
|
|
267
287
|
if (!n)
|
|
268
288
|
return;
|
|
269
|
-
const i = r.alignment === "before" ? "0" : "1", c = (
|
|
270
|
-
t.modifyHtml(n).setAttribute(
|
|
289
|
+
const i = r.alignment === "before" ? "0" : "1", c = (u, l) => {
|
|
290
|
+
t.modifyHtml(n).setAttribute(u, l);
|
|
271
291
|
};
|
|
272
|
-
c(y.CURRENCY, r.code), c(y.SYMBOL, r.symbol), c(y.ALIGNMENT, i), c(y.THOUSAND_SEPARATOR, r.thousandSeparator), c(y.DECIMAL_SEPARATOR, r.decimalSeparator), c(y.DECIMAL_COUNT, r.decimalCount.toString()), t.apply(new
|
|
292
|
+
c(y.CURRENCY, r.code), c(y.SYMBOL, r.symbol), c(y.ALIGNMENT, i), c(y.THOUSAND_SEPARATOR, r.thousandSeparator), c(y.DECIMAL_SEPARATOR, r.decimalSeparator), c(y.DECIMAL_COUNT, r.decimalCount.toString()), t.apply(new S("Update currency attributes"));
|
|
273
293
|
}
|
|
274
294
|
export {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
295
|
+
A as formatProductPrice,
|
|
296
|
+
E as getBlockElement,
|
|
297
|
+
N as getCardComposition,
|
|
298
|
+
P as getCurrentLayout,
|
|
299
|
+
V as reapplySpacing,
|
|
300
|
+
$ as regenerateMobileProductRows,
|
|
301
|
+
x as regenerateProductRows,
|
|
302
|
+
ee as regenerateProductRowsWithStyles,
|
|
303
|
+
re as setCurrencyAttributes,
|
|
304
|
+
oe as updatePricesInPlace,
|
|
305
|
+
te as updateProductContentInPlace,
|
|
306
|
+
W as updateSingleProductContent
|
|
286
307
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModificationDescription as r } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
const i = "ins-recommendation-desktop-container", s = "ins-recommendation-mobile-container", l = `.${s} { display: none; }`, u = `@media only screen and (max-width: 480px) { .${i} { display: none !important; } .${s} { display: table !important; } }`, c = `.${s}`;
|
|
3
|
+
function a(o, e) {
|
|
4
|
+
return !!o.querySelector(e);
|
|
5
|
+
}
|
|
6
|
+
function d(o) {
|
|
7
|
+
return o.querySelectorAll(`*${i}`).length > 0;
|
|
8
|
+
}
|
|
9
|
+
function p(o) {
|
|
10
|
+
const e = o.getDocumentRootCssNode();
|
|
11
|
+
if (!e)
|
|
12
|
+
return;
|
|
13
|
+
const n = o.getDocumentModifier();
|
|
14
|
+
let t = !1;
|
|
15
|
+
a(e, c) || (n.modifyCss(e).appendRule(l), t = !0), d(e) || (n.modifyCss(e).appendRule(u), t = !0), t && n.apply(new r("Add mobile layout CSS rules"));
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
i as CSS_CLASS_DESKTOP_CONTAINER,
|
|
19
|
+
s as CSS_CLASS_MOBILE_CONTAINER,
|
|
20
|
+
p as ensureMobileCssRulesExist
|
|
21
|
+
};
|