@useinsider/guido 2.0.0-beta.9b144a9 → 2.0.0-beta.b46bbf6
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 +6 -4
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/composables/useStripo.js +54 -55
- package/dist/config/migrator/index.js +9 -8
- package/dist/config/migrator/itemsBlockMigrator.js +283 -0
- package/dist/extensions/Blocks/Items/block.js +39 -40
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +46 -49
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +28 -26
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +132 -127
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -48
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -58
- package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
- package/dist/extensions/Blocks/Items/template.js +296 -123
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +172 -0
- package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +11 -20
- package/dist/extensions/Blocks/Recommendation/control.js +1 -1
- package/dist/extensions/Blocks/common-control.js +64 -53
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +366 -287
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
- package/dist/src/extensions/Blocks/Items/template.d.ts +20 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +71 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +13 -8
- package/dist/src/stores/config.d.ts +17 -0
- package/dist/static/styles/components/narrow-panel.css.js +0 -10
- package/package.json +3 -3
- package/dist/package.json.js +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { object as o, number as p, optional as e, string as t, pipe as m, picklist as n, boolean as c, array as a, minLength as u, literal as r, custom as
|
|
1
|
+
import { object as o, number as p, optional as e, string as t, pipe as m, picklist as n, boolean as c, array as a, minLength as u, literal as r, custom as b, variant as S } from "../../node_modules/valibot/dist/index.js";
|
|
2
2
|
const i = {
|
|
3
3
|
/** Promotional/marketing emails */
|
|
4
4
|
PROMOTIONAL: 1,
|
|
@@ -103,7 +103,9 @@ const i = {
|
|
|
103
103
|
/** Enable display conditions */
|
|
104
104
|
displayConditions: e(c(), !0),
|
|
105
105
|
/** Enable unsubscribe block */
|
|
106
|
-
unsubscribe: e(c(), !0)
|
|
106
|
+
unsubscribe: e(c(), !0),
|
|
107
|
+
/** Disable modules panel in the editor */
|
|
108
|
+
modulesDisabled: e(c(), !1)
|
|
107
109
|
}), f = n([
|
|
108
110
|
"amp-accordion",
|
|
109
111
|
"amp-carousel",
|
|
@@ -171,8 +173,8 @@ const i = {
|
|
|
171
173
|
...l.entries,
|
|
172
174
|
type: r("custom"),
|
|
173
175
|
/** Custom processor function */
|
|
174
|
-
processor:
|
|
175
|
-
(
|
|
176
|
+
processor: b(
|
|
177
|
+
(d) => typeof d == "function",
|
|
176
178
|
"processor must be a function"
|
|
177
179
|
)
|
|
178
180
|
}), B = S("type", [
|
|
@@ -7,14 +7,14 @@ var s = function() {
|
|
|
7
7
|
return [t(e.EmailHeaderInfo)];
|
|
8
8
|
}, proxy: !0 }, { key: "headerRightSlot", fn: function() {
|
|
9
9
|
return [t(e.EmailSizeIndicator)];
|
|
10
|
-
}, proxy: !0 }]) }, [e.isContainerReady ? t("iframe", { staticClass: "email-iframe w-1 bor-w-0", style: { height: e.iframeHeight }, attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts", srcdoc: e.previewStore.previewHtml } }) : r._e()])], 1);
|
|
10
|
+
}, proxy: !0 }]) }, [e.isContainerReady ? t("iframe", { staticClass: "email-iframe w-1 bor-w-0", style: { height: e.iframeHeight }, attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts allow-popups-to-escape-sandbox", srcdoc: e.previewStore.previewHtml } }) : r._e()])], 1);
|
|
11
11
|
}, i = [], n = /* @__PURE__ */ a(
|
|
12
12
|
o,
|
|
13
13
|
s,
|
|
14
14
|
i,
|
|
15
15
|
!1,
|
|
16
16
|
null,
|
|
17
|
-
"
|
|
17
|
+
"b37f3f6d"
|
|
18
18
|
);
|
|
19
19
|
const d = n.exports;
|
|
20
20
|
export {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import n from "./ContentView.vue2.js";
|
|
2
2
|
import e from "../../../../_virtual/_plugin-vue2_normalizer.js";
|
|
3
|
-
var
|
|
3
|
+
var o = function() {
|
|
4
4
|
var a = this, s = a._self._c, t = a._self._setupProxy;
|
|
5
5
|
return s("div", { staticClass: "w-1 h-1 b-c-4 d-f f-d-c" }, [s("div", { staticClass: "d-f j-c-s-b a-i-c p-2 h-6-s" }, [s("div", { staticClass: "d-f a-i-c cur-p", on: { click: function(l) {
|
|
6
6
|
return a.$emit("back-to-inbox");
|
|
7
|
-
} } }, [s(t.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [a._v(a._s(t.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(t.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(t.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("iframe", { ref: "iframeRef", staticClass: "f-g-1 w-1 d-b b-c-4 bor-s-n", attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts", srcdoc: t.previewStore.previewHtml }, on: { load: t.onLoad } })]);
|
|
8
|
-
},
|
|
7
|
+
} } }, [s(t.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [a._v(a._s(t.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(t.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(t.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("iframe", { ref: "iframeRef", staticClass: "f-g-1 w-1 d-b b-c-4 bor-s-n", attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts allow-popups-to-escape-sandbox", srcdoc: t.previewStore.previewHtml }, on: { load: t.onLoad } })]);
|
|
8
|
+
}, c = [], i = /* @__PURE__ */ e(
|
|
9
9
|
n,
|
|
10
|
+
o,
|
|
10
11
|
c,
|
|
11
|
-
i,
|
|
12
12
|
!1,
|
|
13
13
|
null,
|
|
14
14
|
null
|
|
15
15
|
);
|
|
16
|
-
const d =
|
|
16
|
+
const d = i.exports;
|
|
17
17
|
export {
|
|
18
18
|
d as default
|
|
19
19
|
};
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
1
|
+
import { useActionsApi as _ } from "./useActionsApi.js";
|
|
2
2
|
import { useBlocksConfig as k } from "./useBlocksConfig.js";
|
|
3
|
-
import { useConfig as
|
|
3
|
+
import { useConfig as B } from "./useConfig.js";
|
|
4
4
|
import { useCustomInterfaceAppearance as V } from "./useCustomInterfaceAppearance.js";
|
|
5
|
-
import { useStripoEventHandler as
|
|
6
|
-
import { useToaster as
|
|
7
|
-
import { displayConditions as
|
|
8
|
-
import { useStripoApi as
|
|
9
|
-
import
|
|
10
|
-
import { useEditorStore as
|
|
11
|
-
import { dynamicContentToMergeTags as
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const e = I(), { html: n, css: u, forceRecreate: a } = i, { baseBlocks: t, extensions: d } = await C(), p = ((m = g.value) == null ? void 0 : m.displayConditions) ?? !0;
|
|
5
|
+
import { useStripoEventHandler as A } from "./useStripoEventHandler.js";
|
|
6
|
+
import { useToaster as v } from "./useToaster.js";
|
|
7
|
+
import { displayConditions as F } from "../enums/displayConditions.js";
|
|
8
|
+
import { useStripoApi as D } from "../services/stripoApi.js";
|
|
9
|
+
import I from "../static/styles/customEditorStyle.css.js";
|
|
10
|
+
import { useEditorStore as M } from "../stores/editor.js";
|
|
11
|
+
import { dynamicContentToMergeTags as U } from "../utils/genericUtil.js";
|
|
12
|
+
const $ = (a) => {
|
|
13
|
+
const { features: d } = B(), { handleError: c } = v(), { getToken: g, getCustomFonts: f } = D(), { handleEvent: y } = A(), { getStripoBlocksConfig: C } = k(), S = async (i, n = []) => {
|
|
14
|
+
var p, m;
|
|
15
|
+
const o = M(), { html: s, css: t, forceRecreate: h } = i, { baseBlocks: l, extensions: w } = await C(), u = ((p = d.value) == null ? void 0 : p.displayConditions) ?? !0, b = ((m = d.value) == null ? void 0 : m.modulesDisabled) ?? !1;
|
|
17
16
|
window.UIEditor.initEditor(
|
|
18
17
|
document.querySelector("#guido-editor"),
|
|
19
18
|
{
|
|
20
|
-
metadata:
|
|
21
|
-
html:
|
|
22
|
-
css:
|
|
23
|
-
forceRecreate:
|
|
19
|
+
metadata: a,
|
|
20
|
+
html: s,
|
|
21
|
+
css: t,
|
|
22
|
+
forceRecreate: h,
|
|
24
23
|
locale: "en",
|
|
25
24
|
undoButtonSelector: "#guido__undo-button",
|
|
26
25
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -30,87 +29,87 @@ const N = (c) => {
|
|
|
30
29
|
customAppearanceMergetags: !0,
|
|
31
30
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
32
31
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
33
|
-
customViewStyles:
|
|
34
|
-
conditionsEnabled:
|
|
35
|
-
customConditionsEnabled:
|
|
36
|
-
conditionCategories:
|
|
32
|
+
customViewStyles: I,
|
|
33
|
+
conditionsEnabled: u,
|
|
34
|
+
customConditionsEnabled: u,
|
|
35
|
+
conditionCategories: F,
|
|
37
36
|
enableXSSSecurity: !0,
|
|
37
|
+
modulesDisabled: b,
|
|
38
38
|
messageSettingsEnabled: !0,
|
|
39
39
|
displayGmailAnnotations: !0,
|
|
40
40
|
displayHiddenPreheader: !1,
|
|
41
41
|
displayTitle: !1,
|
|
42
42
|
displayUTM: !1,
|
|
43
43
|
selectElementAfterDrop: !0,
|
|
44
|
-
...
|
|
44
|
+
...l ? { baseBlocks: l } : {},
|
|
45
45
|
editorFonts: {
|
|
46
46
|
showDefaultStandardFonts: !0,
|
|
47
47
|
showDefaultNotStandardFonts: !0,
|
|
48
|
-
customFonts:
|
|
48
|
+
customFonts: n
|
|
49
49
|
},
|
|
50
50
|
mergeTags: [
|
|
51
51
|
{
|
|
52
|
-
entries:
|
|
52
|
+
entries: U(a.preselectedDynamicContentList)
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
|
-
async onTokenRefreshRequest(
|
|
55
|
+
async onTokenRefreshRequest(e) {
|
|
56
56
|
try {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
} catch (
|
|
60
|
-
|
|
57
|
+
const r = await g();
|
|
58
|
+
e(r);
|
|
59
|
+
} catch (r) {
|
|
60
|
+
c(r, "Failed to refresh token");
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
onTemplateLoaded() {
|
|
64
64
|
try {
|
|
65
|
-
const { importCss:
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const { importCss: e } = V(), { activateCustomViewStyles: r, updateTimerInClonedTemplate: T } = _();
|
|
66
|
+
e(), r(), T(), a.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
|
|
67
|
+
o.hasChanges = !1;
|
|
68
68
|
}, 1e3);
|
|
69
|
-
} catch (
|
|
70
|
-
|
|
69
|
+
} catch (e) {
|
|
70
|
+
c(e, "Failed to load custom interface appearance");
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
onCodeEditorVisibilityChanged(
|
|
74
|
-
|
|
73
|
+
onCodeEditorVisibilityChanged(e) {
|
|
74
|
+
o.isCodeEditorOpen = e;
|
|
75
75
|
},
|
|
76
|
-
onEditorVisualModeChanged(
|
|
77
|
-
|
|
76
|
+
onEditorVisualModeChanged(e) {
|
|
77
|
+
o.editorVisualMode = e.toLowerCase();
|
|
78
78
|
},
|
|
79
|
-
onVersionHistoryVisibilityChanged(
|
|
80
|
-
|
|
79
|
+
onVersionHistoryVisibilityChanged(e) {
|
|
80
|
+
o.isVersionHistoryOpen = e;
|
|
81
81
|
},
|
|
82
82
|
onDataChanged() {
|
|
83
|
-
|
|
83
|
+
o.hasChanges = !0;
|
|
84
84
|
},
|
|
85
|
-
onEvent:
|
|
85
|
+
onEvent: y,
|
|
86
86
|
ignoreClickOutsideSelectors: [
|
|
87
87
|
"#guido-dynamic-content-modal",
|
|
88
88
|
".in-on-board-wrapper",
|
|
89
89
|
".in-drawer__container"
|
|
90
90
|
],
|
|
91
|
-
extensions:
|
|
91
|
+
extensions: w
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
|
-
},
|
|
95
|
-
var d;
|
|
94
|
+
}, E = (i) => new Promise((n, o) => {
|
|
96
95
|
if (document.getElementById("UiEditorScript")) {
|
|
97
|
-
i(),
|
|
96
|
+
i(), n();
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
100
|
-
const
|
|
101
|
-
t.id = "UiEditorScript", t.type = "module", t.src =
|
|
102
|
-
i(),
|
|
99
|
+
const s = "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js", t = document.createElement("script");
|
|
100
|
+
t.id = "UiEditorScript", t.type = "module", t.src = s, t.onload = () => {
|
|
101
|
+
i(), n();
|
|
103
102
|
}, t.onerror = () => {
|
|
104
|
-
|
|
103
|
+
o(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
|
|
105
104
|
}, document.body.appendChild(t);
|
|
106
105
|
});
|
|
107
106
|
return { initPlugin: async (i) => {
|
|
108
|
-
await
|
|
109
|
-
const
|
|
110
|
-
await
|
|
107
|
+
await E(async () => {
|
|
108
|
+
const n = await f();
|
|
109
|
+
await S(i, n);
|
|
111
110
|
});
|
|
112
111
|
} };
|
|
113
112
|
};
|
|
114
113
|
export {
|
|
115
|
-
|
|
114
|
+
$ as useStripo
|
|
116
115
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
1
|
+
import { migrateCheckbox as t } from "./checkboxMigrator.js";
|
|
2
2
|
import { migrateCouponBlock as o } from "./couponBlockMigrator.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { migrateItemsBlock as i } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateRadioButton as e } from "./radioButtonMigrator.js";
|
|
5
|
+
import { migrateRecommendation as a } from "./recommendationMigrator.js";
|
|
6
|
+
import { migrateUnsubscribe as g } from "./unsubscribeMigrator.js";
|
|
7
|
+
const u = async (r) => {
|
|
8
|
+
let m = r;
|
|
9
|
+
return m = t(m), m = e(m), m = await g(m), m = o(m), m = a(m), m = i(m), m;
|
|
9
10
|
};
|
|
10
11
|
export {
|
|
11
|
-
|
|
12
|
+
u as migrate
|
|
12
13
|
};
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var q = (o, t, r) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
|
|
3
|
+
var A = (o, t, r) => q(o, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { productPairs as L } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
5
|
+
import { ItemInCartOptions as I, DefaultConfigValues as m, SETTINGS_ENUMS as l } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
|
|
7
|
+
const V = {
|
|
8
|
+
ins_apr_img: {
|
|
9
|
+
pairsKey: "imageSrc",
|
|
10
|
+
defaultKey: "DEFAULT",
|
|
11
|
+
isArray: !0
|
|
12
|
+
},
|
|
13
|
+
ins_apr_name: {
|
|
14
|
+
pairsKey: "name",
|
|
15
|
+
defaultKey: "DEFAULT",
|
|
16
|
+
isArray: !0
|
|
17
|
+
},
|
|
18
|
+
ins_apr_url: {
|
|
19
|
+
pairsKey: "button",
|
|
20
|
+
defaultKey: "DEFAULT_HREF",
|
|
21
|
+
isArray: !1
|
|
22
|
+
},
|
|
23
|
+
ins_apr_formattedprice: {
|
|
24
|
+
pairsKey: "price",
|
|
25
|
+
defaultKey: "DEFAULT_PRICE_FORMATTED",
|
|
26
|
+
isArray: !1
|
|
27
|
+
},
|
|
28
|
+
ins_apr_productcurrency: {
|
|
29
|
+
pairsKey: "price",
|
|
30
|
+
defaultKey: "DEFAULT_CURRENCY",
|
|
31
|
+
isArray: !1
|
|
32
|
+
},
|
|
33
|
+
ins_apr_quantity: {
|
|
34
|
+
pairsKey: "quantity",
|
|
35
|
+
defaultKey: "DEFAULT",
|
|
36
|
+
isArray: !1
|
|
37
|
+
},
|
|
38
|
+
ins_apr_price: {
|
|
39
|
+
pairsKey: "price",
|
|
40
|
+
defaultKey: "DEFAULT_PRICE",
|
|
41
|
+
isArray: !1
|
|
42
|
+
},
|
|
43
|
+
ins_apr_originalprice: {
|
|
44
|
+
pairsKey: "originalPrice",
|
|
45
|
+
defaultKey: "DEFAULT_PRICE",
|
|
46
|
+
isArray: !1
|
|
47
|
+
},
|
|
48
|
+
ins_apr_originalformattedprice: {
|
|
49
|
+
pairsKey: "originalPrice",
|
|
50
|
+
defaultKey: "DEFAULT_PRICE_FORMATTED",
|
|
51
|
+
isArray: !1
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function U() {
|
|
55
|
+
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
56
|
+
}
|
|
57
|
+
function F(o) {
|
|
58
|
+
return o ? {
|
|
59
|
+
CartItems: l.ITEMS_TYPE.CART_ITEMS,
|
|
60
|
+
BrowsedItems: l.ITEMS_TYPE.BROWSED_ITEMS,
|
|
61
|
+
PurchasedItems: l.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
62
|
+
CART_ITEMS: l.ITEMS_TYPE.CART_ITEMS,
|
|
63
|
+
BROWSED_ITEMS: l.ITEMS_TYPE.BROWSED_ITEMS,
|
|
64
|
+
PURCHASED_ITEMS: l.ITEMS_TYPE.PURCHASED_ITEMS
|
|
65
|
+
}[o] || l.ITEMS_TYPE.CART_ITEMS : l.ITEMS_TYPE.CART_ITEMS;
|
|
66
|
+
}
|
|
67
|
+
function D(o) {
|
|
68
|
+
const t = (e, a) => e == null ? a : e === "1" || e === "true", r = (e, a) => e || a, c = o["data-type"] || o["data-source"], n = F(c);
|
|
69
|
+
let i = o["data-cart_items_select_control_value"] || m.cartItemsSelectControlValue;
|
|
70
|
+
if (i && !i.includes("{{") && /^\d+$/.test(i)) {
|
|
71
|
+
const e = parseInt(i) - 1, a = I[n];
|
|
72
|
+
a && a[e] && (i = a[e].value);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
initialized: !0,
|
|
76
|
+
blockInstanceId: r(o["data-block-instance-id"], U()),
|
|
77
|
+
source: n,
|
|
78
|
+
type: n,
|
|
79
|
+
itemsSelectValue: i,
|
|
80
|
+
orientation: o["data-card_orientation_control_value"] || l.ORIENTATION.VERTICAL,
|
|
81
|
+
nameTrimming: t(o["data-product_name_trimming"], !0),
|
|
82
|
+
nameControlEnabled: t(o["data-product_name_control_enabled"], !0),
|
|
83
|
+
priceHideDiscount: t(o["data-product_price_hide_discount"], !1),
|
|
84
|
+
priceFormatted: t(o["data-product_price_formatted"], !0),
|
|
85
|
+
priceCurrencySymbol: r(
|
|
86
|
+
o["data-product_price_currency_symbol"],
|
|
87
|
+
m.productPriceCurrencySymbolControlValue
|
|
88
|
+
),
|
|
89
|
+
priceCurrencyLocation: r(
|
|
90
|
+
o["data-product_price_currency_location"],
|
|
91
|
+
m.productPriceCurrencyLocationControlValue
|
|
92
|
+
),
|
|
93
|
+
priceControlOpened: t(o["data-product_price_control_opened"], !0),
|
|
94
|
+
priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
|
|
95
|
+
quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
|
|
96
|
+
buttonLink: r(o["data-product_button_link"], m.productButtonLinkControlValue),
|
|
97
|
+
imageLink: r(o["data-product_image_link"], m.productImageLinkControlValue),
|
|
98
|
+
buttonLabel: r(o["data-product_button_control_label"], "Buy"),
|
|
99
|
+
imageVisible: t(o["data-product_image_visible"], !0),
|
|
100
|
+
nameVisible: t(o["data-product_name_visible"], !0),
|
|
101
|
+
quantityVisible: t(o["data-product_quantity_visible"], !0),
|
|
102
|
+
priceVisible: t(o["data-product_price_visible"], !0),
|
|
103
|
+
originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
|
|
104
|
+
buttonVisible: t(o["data-product_button_visible"], !0)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
class w {
|
|
108
|
+
constructor() {
|
|
109
|
+
A(this, "parser");
|
|
110
|
+
A(this, "DATA_TYPE", "CART_ITEMS");
|
|
111
|
+
this.parser = new DOMParser();
|
|
112
|
+
}
|
|
113
|
+
migrate(t) {
|
|
114
|
+
try {
|
|
115
|
+
let r = this.removeJinjaConditionals(t);
|
|
116
|
+
r = this.replaceTemplateVariables(r);
|
|
117
|
+
const c = this.parser.parseFromString(r, "text/html"), n = c.querySelectorAll("td.esd-cart-items-block");
|
|
118
|
+
return n.length === 0 ? (console.warn('ItemsBlockMigrator: No blocks found with selector "td.esd-cart-items-block"'), r) : (n.forEach((i) => {
|
|
119
|
+
const e = this.extractConfiguration(i), a = K({
|
|
120
|
+
orientation: e.orientation,
|
|
121
|
+
itemsType: e.itemsType,
|
|
122
|
+
itemId: e.itemId,
|
|
123
|
+
currencySymbol: e.currencySymbol,
|
|
124
|
+
currencyLocation: e.currencyLocation,
|
|
125
|
+
formattedPrice: e.formattedPrice,
|
|
126
|
+
configBlockAttributes: e.configBlockAttributes,
|
|
127
|
+
migrate: !0,
|
|
128
|
+
nameStyles: e.nameStyles,
|
|
129
|
+
buttonStyles: e.buttonStyles,
|
|
130
|
+
priceStyles: e.priceStyles,
|
|
131
|
+
originalPriceStyles: e.originalPriceStyles,
|
|
132
|
+
quantityStyles: e.quantityStyles,
|
|
133
|
+
nodeConfig: D(e.configBlockAttributes)
|
|
134
|
+
}), u = this.parser.parseFromString(
|
|
135
|
+
`<table><tbody><tr>${a}</tr></tbody></table>`,
|
|
136
|
+
"text/html"
|
|
137
|
+
).querySelector("td");
|
|
138
|
+
if (u && i.parentNode) {
|
|
139
|
+
const s = D(e.configBlockAttributes);
|
|
140
|
+
u.setAttribute("esd-ext-config", JSON.stringify(s));
|
|
141
|
+
const p = u.querySelector("esd-config-block");
|
|
142
|
+
p && p.remove(), i.parentNode.replaceChild(u, i);
|
|
143
|
+
}
|
|
144
|
+
}), c.documentElement.outerHTML);
|
|
145
|
+
} catch (r) {
|
|
146
|
+
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Extracts configuration from legacy HTML block
|
|
151
|
+
* Parses data attributes and structure to determine:
|
|
152
|
+
* - orientation, itemsType, itemNumber, currency settings, esd-config-block attributes
|
|
153
|
+
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
154
|
+
*/
|
|
155
|
+
extractConfiguration(t) {
|
|
156
|
+
var E, C, P;
|
|
157
|
+
const r = ((E = t.querySelector("[data-type]")) == null ? void 0 : E.getAttribute("data-type")) || "CART_ITEMS", c = ((C = t.querySelector("[data-number]")) == null ? void 0 : C.getAttribute("data-number")) || "1", n = parseInt(c) - 1, i = I[r], e = ((P = i == null ? void 0 : i[n]) == null ? void 0 : P.value) || i[0].value, a = t.querySelector('[product-attr="price"]'), _ = (a == null ? void 0 : a.getAttribute("data-currency_symbol")) || void 0, s = ((a == null ? void 0 : a.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (a == null ? void 0 : a.getAttribute("data-formated")) !== "false", y = this.extractConfigBlockAttributes(t, r), f = y["data-product_original_price_control_orientation"] === "vertical" ? "vertical" : "horizontal", d = t.querySelector('a[product-attr="name"]'), v = (d == null ? void 0 : d.getAttribute("style")) || void 0, b = t.querySelector('a[product-attr="button"]'), M = (b == null ? void 0 : b.getAttribute("style")) || void 0, h = (a == null ? void 0 : a.getAttribute("style")) || void 0, S = t.querySelector('[product-attr="originalPrice"]'), R = (S == null ? void 0 : S.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), k = (T == null ? void 0 : T.getAttribute("style")) || void 0;
|
|
158
|
+
return {
|
|
159
|
+
orientation: f,
|
|
160
|
+
itemsType: r,
|
|
161
|
+
itemId: e,
|
|
162
|
+
currencySymbol: _,
|
|
163
|
+
currencyLocation: s,
|
|
164
|
+
formattedPrice: p,
|
|
165
|
+
configBlockAttributes: y,
|
|
166
|
+
nameStyles: v,
|
|
167
|
+
buttonStyles: M,
|
|
168
|
+
priceStyles: h,
|
|
169
|
+
originalPriceStyles: R,
|
|
170
|
+
quantityStyles: k
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Extracts all data-* attributes from the esd-config-block element
|
|
175
|
+
* Returns a key-value mapping of all configuration attributes
|
|
176
|
+
* @param block - The block element containing the esd-config-block
|
|
177
|
+
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
178
|
+
*/
|
|
179
|
+
extractConfigBlockAttributes(t, r) {
|
|
180
|
+
const c = t.querySelector("esd-config-block"), n = {};
|
|
181
|
+
if (!c)
|
|
182
|
+
return this.getDefaultConfigBlockAttributes();
|
|
183
|
+
if (Array.from(c.attributes).forEach((e) => {
|
|
184
|
+
e.name.startsWith("data-") && (n[e.name] = e.value);
|
|
185
|
+
}), n["data-cart_items_select_control_value"]) {
|
|
186
|
+
const e = n["data-cart_items_select_control_value"];
|
|
187
|
+
if (/^\d+$/.test(e)) {
|
|
188
|
+
const a = parseInt(e) - 1, _ = I[r];
|
|
189
|
+
_ && _[a] && (n["data-cart_items_select_control_value"] = _[a].value);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (n["data-product_price_control_curency"]) {
|
|
193
|
+
const e = n["data-product_price_control_curency"];
|
|
194
|
+
e === "before" ? n["data-product_price_control_curency"] = "0" : e === "after" && (n["data-product_price_control_curency"] = "1");
|
|
195
|
+
}
|
|
196
|
+
(!n["data-product_price_currency_symbol"] || n["data-product_price_currency_symbol"].trim() === "") && (n["data-product_price_currency_symbol"] = "USD");
|
|
197
|
+
const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
198
|
+
return i["data-type"] = r, i["data-source"] = r, i;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Returns default esd-config-block attributes based on the old template structure
|
|
202
|
+
* These serve as fallbacks when attributes are missing
|
|
203
|
+
*/
|
|
204
|
+
getDefaultConfigBlockAttributes() {
|
|
205
|
+
return {
|
|
206
|
+
"data-type": "CART_ITEMS",
|
|
207
|
+
"data-product_image_control_opened": "false",
|
|
208
|
+
"data-product_image_control_image-width": "250",
|
|
209
|
+
"data-product_image_control_image-height": "250",
|
|
210
|
+
"data-product_image_control_align_button": "true",
|
|
211
|
+
"data-product_image_control_padding_mobile": "true",
|
|
212
|
+
"data-product_name_control_opened": "false",
|
|
213
|
+
"data-product_quantity_control_opened": "true",
|
|
214
|
+
// DONE
|
|
215
|
+
"data-product_quantity_control_enabled": "false",
|
|
216
|
+
"data-product_name_control_font_font_size": "20",
|
|
217
|
+
"data-product_price_control_opened": "false",
|
|
218
|
+
"data-product_price_control_font_font_size": "20",
|
|
219
|
+
"data-product_price_control_color": "#060606",
|
|
220
|
+
"data-product_price_control_curency": "0",
|
|
221
|
+
"data-product_price_currency_symbol": "USD",
|
|
222
|
+
"data-product_original_price_control_opened": "false",
|
|
223
|
+
"data-product_original_price_control_font_font_size": "19",
|
|
224
|
+
"data-product_original_price_control_align_align_desktop": "center",
|
|
225
|
+
"data-product_original_price_control_orientation": "vertical",
|
|
226
|
+
"data-product_button_control_opened": "true",
|
|
227
|
+
"data-product_button_control_label": "Comprar",
|
|
228
|
+
// DONE
|
|
229
|
+
"data-product_button_control_font_font_size": "17",
|
|
230
|
+
"data-product_button_control_color": "#ffffff",
|
|
231
|
+
"data-product_button_control_background": "#010101",
|
|
232
|
+
"data-product_button_control_atw": "false",
|
|
233
|
+
"data-product_original_price_control_enabled": "false"
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Removes Jinja2 conditional statements from HTML
|
|
238
|
+
* - Removes {% if ins_apr_total_product_kind > N %}
|
|
239
|
+
* - Removes {% if ins_apr_price_N != ins_apr_originalprice_N %}
|
|
240
|
+
* - Removes {% endif %}
|
|
241
|
+
*/
|
|
242
|
+
removeJinjaConditionals(t) {
|
|
243
|
+
let r = t.replace(/\{%\s*if\s+ins_apr_total_product_kind\s*(>|>)\s*\d+\s*%\}/g, "");
|
|
244
|
+
return r = r.replace(/\{%\s*if\s+ins_apr_price_\d+\s*(!=|!=)\s*ins_apr_originalprice_\d+\s*%\}/g, ""), r = r.replace(/\{%\s*endif\s*%\}/g, ""), r = r.replace(/\n\s*\n\s*\n/g, `
|
|
245
|
+
|
|
246
|
+
`), r;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Replaces template variables with default values from productPairs
|
|
250
|
+
*
|
|
251
|
+
* Examples:
|
|
252
|
+
* - {{ins_apr_img_1}} → https://s3.../ins_apr_img_1.jpeg (array-based, uses index 0)
|
|
253
|
+
* - {{ins_apr_name_2}} → 'Set of Sprite Yoga Straps' (array-based, uses index 1)
|
|
254
|
+
* - {{ins_apr_formattedprice_1}} → '1,100.00' (single value, ignores index)
|
|
255
|
+
* - {{ins_apr_url_3}} → '#!' (single value, ignores index)
|
|
256
|
+
*/
|
|
257
|
+
replaceTemplateVariables(t) {
|
|
258
|
+
const { PAIRS_FOR_EXTENSION: r } = L;
|
|
259
|
+
return t.replace(/{{([^}]+)}}/g, (c, n) => {
|
|
260
|
+
const i = n.match(/^(ins_apr_[a-z]+)_(\d+)$/);
|
|
261
|
+
if (!i)
|
|
262
|
+
return c;
|
|
263
|
+
const [, e, a] = i, _ = V[e];
|
|
264
|
+
if (!_)
|
|
265
|
+
return console.warn(`Unknown variable mapping for: ${e}`), c;
|
|
266
|
+
const { pairsKey: u, defaultKey: s, isArray: p } = _, y = r[u][this.DATA_TYPE];
|
|
267
|
+
if (!y)
|
|
268
|
+
return console.warn(`No data found for: ${u}.${this.DATA_TYPE}`), c;
|
|
269
|
+
if (p) {
|
|
270
|
+
const f = parseInt(a) - 1, d = y[s];
|
|
271
|
+
return Array.isArray(d) && d[f] ? d[f] : (console.warn(`Array value not found: ${u}.${this.DATA_TYPE}.${s}[${f}]`), c);
|
|
272
|
+
}
|
|
273
|
+
const g = y[s];
|
|
274
|
+
return g !== void 0 ? String(g) : (console.warn(`Default value not found: ${u}.${this.DATA_TYPE}.${s}`), c);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function $(o) {
|
|
279
|
+
return new w().migrate(o);
|
|
280
|
+
}
|
|
281
|
+
export {
|
|
282
|
+
$ as migrateItemsBlock
|
|
283
|
+
};
|