@useinsider/guido 3.30.0-beta.e841504 → 3.30.0-beta.f3f01ef
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/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +1 -1
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +44 -45
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/package.json.js +1 -1
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import r from "./AssignStrategyDrawer.vue2.js";
|
|
|
3
3
|
import o from "../../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
4
|
var a = function() {
|
|
5
5
|
var e = this, s = e._self._c, t = e._self._setupProxy;
|
|
6
|
-
return t.
|
|
6
|
+
return t.store.assignStrategyDrawerStatus ? s(t.OrgStrategyDetailModal, { staticClass: "assign-strategy-drawer", attrs: { "description-status": "", show: "", "description-text": t.drawerDescription, "footer-button-group-options": t.footerButtonGroupOptions, strategy: t.selectedStrategy ?? {}, "title-text": t.trans("gpt-app-builder.assign-recommendation-strategy") }, on: { close: t.closeDrawer, primaryClick: t.assignStrategy }, scopedSlots: e._u([{ key: "contentTop", fn: function() {
|
|
7
7
|
return [s("div", { staticClass: "assign-strategy-drawer-content px-5 py-5" }, [t.strategiesLoading ? s(t.InSkeleton, { staticClass: "assign-strategy-select-skeleton", attrs: { sizing: t.SELECT_SKELETON_SIZING } }) : s(t.OrgStrategyDropdown, { staticClass: "assign-strategy-select w-23-s", attrs: { id: "assign-strategy-select", "create-button-visible": "", "info-box-position": "bottom right", "placeholder-text": t.trans("smart-recommender.select-recommendation-strategy"), "selected-strategy-id": t.selectedStrategyId, state: t.showSelectionError ? "error" : "default", "state-message": t.showSelectionError ? t.trans("ds-steps.select-strategy-tooltip") : "", strategies: t.strategyOptions }, on: { create: function(c) {
|
|
8
8
|
return t.store.openStrategyCreation();
|
|
9
9
|
}, infoBoxButtonClick: t.onInfoBoxButtonClick, select: t.onSelect } })], 1)];
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as b, defineAsyncComponent as T, ref as w, computed as o, watch as N } from "vue";
|
|
2
2
|
import "@useinsider/design-system-organisms/style";
|
|
3
|
-
import { useToaster as
|
|
4
|
-
import { useTranslations as
|
|
5
|
-
import { DOTTED_DATE_LOCALE as
|
|
6
|
-
import { URLS as
|
|
7
|
-
import { ToasterTypeOptions as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { commitStrategyChange as
|
|
10
|
-
import
|
|
11
|
-
import { formatShortDate as
|
|
3
|
+
import { useToaster as R } from "../../../../composables/useToaster.js";
|
|
4
|
+
import { useTranslations as P } from "../../../../composables/useTranslations.js";
|
|
5
|
+
import { DOTTED_DATE_LOCALE as U } from "../../../../enums/date.js";
|
|
6
|
+
import { URLS as G } from "../../../../enums/extensions/recommendationBlock.js";
|
|
7
|
+
import { ToasterTypeOptions as u } from "../../../../enums/toaster.js";
|
|
8
|
+
import { useRecommendationExtensionStore as M } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { commitStrategyChange as E } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
|
|
10
|
+
import $ from "./StrategyInfoBoxContent.vue.js";
|
|
11
|
+
import { formatShortDate as z } from "../../../../utils/dateUtil.js";
|
|
12
12
|
import { asText as D } from "../../../../utils/genericUtil.js";
|
|
13
|
-
import { escapeHtml as
|
|
14
|
-
import { InSkeleton as
|
|
15
|
-
const
|
|
13
|
+
import { escapeHtml as H } from "../../../../utils/htmlEscape.js";
|
|
14
|
+
import { InSkeleton as O } from "@useinsider/design-system-vue";
|
|
15
|
+
const it = /* @__PURE__ */ b({
|
|
16
16
|
__name: "AssignStrategyDrawer",
|
|
17
|
-
setup(
|
|
18
|
-
const g = () => import("@useinsider/design-system-organisms"),
|
|
19
|
-
render: (s) => s(
|
|
20
|
-
}),
|
|
17
|
+
setup(F) {
|
|
18
|
+
const g = () => import("@useinsider/design-system-organisms"), p = (t, r) => ({
|
|
19
|
+
render: (s) => s(O, { props: { sizing: { width: t, height: r } } })
|
|
20
|
+
}), I = T({
|
|
21
21
|
loader: async () => (await g()).OrgStrategyDetailModal,
|
|
22
|
-
loadingComponent:
|
|
22
|
+
loadingComponent: p(480, 240),
|
|
23
23
|
delay: 0
|
|
24
|
-
}),
|
|
24
|
+
}), h = T({
|
|
25
25
|
loader: async () => (await g()).OrgStrategyDropdown
|
|
26
|
-
}), i = "guido-edit-strategy-",
|
|
27
|
-
|
|
26
|
+
}), i = "guido-edit-strategy-", x = { width: 480, height: 42 }, a = P(), e = M(), { showToaster: c } = R(), n = w(null), d = "legacy", l = w(!1), A = o(() => e.strategiesLoading || e.legacyConversionLoading), C = o(() => e.assignStrategyDrawerStatus ? a("email-editor.assign-strategy-description", { url: G.RECOMMENDATION_STRATEGIES_PANEL_PATH }) : "");
|
|
27
|
+
N(() => e.assignStrategyDrawerStatus, (t) => {
|
|
28
28
|
if (!t)
|
|
29
29
|
return;
|
|
30
|
-
S.value = !0;
|
|
31
30
|
const { strategyId: r } = e.recommendationConfigs;
|
|
32
31
|
n.value = r || (e.isLegacyStrategyBlock ? d : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
|
|
33
32
|
c({
|
|
34
|
-
type:
|
|
33
|
+
type: u.Error,
|
|
35
34
|
message: a("discovery-strategy.error-description")
|
|
36
35
|
});
|
|
37
36
|
});
|
|
38
37
|
});
|
|
39
|
-
const
|
|
38
|
+
const f = (t) => {
|
|
40
39
|
const r = D(t.updated_at || t.created_at);
|
|
41
40
|
if (!r)
|
|
42
41
|
return "";
|
|
43
|
-
const s =
|
|
42
|
+
const s = z(r, U);
|
|
44
43
|
return a("recommendation-strategy.last-updated-on", { value: s });
|
|
45
|
-
},
|
|
44
|
+
}, S = o(() => ({
|
|
46
45
|
text: a("ds-steps.legacy-strategy"),
|
|
47
46
|
value: d,
|
|
48
47
|
hidden: !0
|
|
@@ -55,10 +54,10 @@ const ct = /* @__PURE__ */ N({
|
|
|
55
54
|
variant: "information",
|
|
56
55
|
size: "small",
|
|
57
56
|
class: "assign-strategy-info-box",
|
|
58
|
-
titleText:
|
|
57
|
+
titleText: H(D(t.name)),
|
|
59
58
|
descriptionStatus: !0,
|
|
60
|
-
descriptionText:
|
|
61
|
-
slot:
|
|
59
|
+
descriptionText: f(t),
|
|
60
|
+
slot: $,
|
|
62
61
|
slotProps: { strategy: t },
|
|
63
62
|
// The info box drops the option's value/text, so the id is the only channel
|
|
64
63
|
// that can carry the strategy back to the click handler.
|
|
@@ -71,17 +70,17 @@ const ct = /* @__PURE__ */ N({
|
|
|
71
70
|
icon: "line-open-website"
|
|
72
71
|
}]
|
|
73
72
|
}
|
|
74
|
-
}))),
|
|
75
|
-
var
|
|
76
|
-
const r = (
|
|
73
|
+
}))), L = o(() => e.isLegacyStrategyBlock ? [S.value, ...m.value] : m.value), B = (t) => {
|
|
74
|
+
var _;
|
|
75
|
+
const r = (_ = t == null ? void 0 : t.id) != null && _.startsWith(i) ? t.id.slice(i.length) : "";
|
|
77
76
|
if (!r)
|
|
78
77
|
return;
|
|
79
|
-
const s = e.currentRecommendationId,
|
|
80
|
-
e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null),
|
|
81
|
-
},
|
|
78
|
+
const s = e.currentRecommendationId, y = e.recommendationConfigs.strategyId === r;
|
|
79
|
+
e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), y && (e.removeStrategy(), s !== null && E(s, "Removed recommendation strategy")));
|
|
80
|
+
}, v = o(() => {
|
|
82
81
|
const t = e.strategies.find((r) => String(r.strategy_id) === String(n.value ?? ""));
|
|
83
82
|
return t ? { ...t, fallback_config: null } : null;
|
|
84
|
-
}),
|
|
83
|
+
}), k = o(() => ({
|
|
85
84
|
primaryButton: {
|
|
86
85
|
styling: "solid",
|
|
87
86
|
type: "primary",
|
|
@@ -93,10 +92,10 @@ const ct = /* @__PURE__ */ N({
|
|
|
93
92
|
labelText: a("products.cancel")
|
|
94
93
|
}
|
|
95
94
|
}));
|
|
96
|
-
return { __sfc: !0, loadOrganisms: g, skeleton:
|
|
95
|
+
return { __sfc: !0, loadOrganisms: g, skeleton: p, OrgStrategyDetailModal: I, OrgStrategyDropdown: h, EDIT_BUTTON_ID_PREFIX: i, SELECT_SKELETON_SIZING: x, trans: a, store: e, showToaster: c, selectedStrategyId: n, LEGACY_OPTION_VALUE: d, showSelectionError: l, strategiesLoading: A, drawerDescription: C, lastUpdatedText: f, legacyStrategyOption: S, remoteStrategyOptions: m, strategyOptions: L, onInfoBoxButtonClick: B, selectedStrategy: v, footerButtonGroupOptions: k, closeDrawer: () => {
|
|
97
96
|
e.closeAssignStrategyDrawer();
|
|
98
97
|
}, assignStrategy: async () => {
|
|
99
|
-
const t =
|
|
98
|
+
const t = v.value;
|
|
100
99
|
if (!t) {
|
|
101
100
|
l.value = !0;
|
|
102
101
|
return;
|
|
@@ -104,26 +103,26 @@ const ct = /* @__PURE__ */ N({
|
|
|
104
103
|
let r = "";
|
|
105
104
|
try {
|
|
106
105
|
r = await e.resolveStrategyUrlTemplate(t, e.recommendationConfigs.currencySettings.value);
|
|
107
|
-
} catch (
|
|
108
|
-
console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed",
|
|
106
|
+
} catch (y) {
|
|
107
|
+
console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed", y);
|
|
109
108
|
}
|
|
110
109
|
if (!r) {
|
|
111
110
|
c({
|
|
112
|
-
type:
|
|
111
|
+
type: u.Error,
|
|
113
112
|
message: a("email-editor.strategy-assign-failed", { strategyName: t.name })
|
|
114
113
|
});
|
|
115
114
|
return;
|
|
116
115
|
}
|
|
117
116
|
const s = e.currentRecommendationId;
|
|
118
117
|
e.assignStrategy(t), c({
|
|
119
|
-
type:
|
|
118
|
+
type: u.Success,
|
|
120
119
|
message: a("email-editor.strategy-assigned-success", { strategyName: t.name })
|
|
121
|
-
}), e.closeAssignStrategyDrawer(), s !== null && await
|
|
120
|
+
}), e.closeAssignStrategyDrawer(), s !== null && await E(s, "Assigned recommendation strategy");
|
|
122
121
|
}, onSelect: (t) => {
|
|
123
122
|
n.value = t.value, l.value = !1;
|
|
124
|
-
}, InSkeleton:
|
|
123
|
+
}, InSkeleton: O };
|
|
125
124
|
}
|
|
126
125
|
});
|
|
127
126
|
export {
|
|
128
|
-
|
|
127
|
+
it as default
|
|
129
128
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
|
-
var N = (
|
|
3
|
-
var w = (
|
|
2
|
+
var N = (r, t, e) => t in r ? V(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var w = (r, t, e) => N(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { BLOCK_ID as H } from "../../extensions/Blocks/Items/block.js";
|
|
5
5
|
import { hasZeroWidthDeclaration as U, withoutZeroWidth as W } from "../../extensions/Blocks/Items/constants/cardWidth.js";
|
|
6
|
-
import { ItemInCartOptions as
|
|
6
|
+
import { ItemInCartOptions as h, DefaultConfigValues as S, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
7
|
import { getDefaultTemplate as $ } from "../../extensions/Blocks/Items/template.js";
|
|
8
8
|
import { useTemplateStore as F } from "../../stores/template.js";
|
|
9
9
|
import { protectLiquid as P, restoreLiquid as D } from "../../utils/liquidProtection.js";
|
|
@@ -17,107 +17,107 @@ const Y = /\{%-?\s*(\w+)(?:(?!\{%)[\s\S])*?%\}/g, z = [
|
|
|
17
17
|
"td.esd-browsed-items-block",
|
|
18
18
|
"td.esd-purchased-items-block"
|
|
19
19
|
].join(", ");
|
|
20
|
-
function
|
|
21
|
-
const t = Number(
|
|
20
|
+
function I(r) {
|
|
21
|
+
const t = Number(r.getAttribute("width"));
|
|
22
22
|
return Number.isFinite(t) && t > 0 ? t : 0;
|
|
23
23
|
}
|
|
24
|
-
function k(
|
|
25
|
-
return Array.from(
|
|
24
|
+
function k(r) {
|
|
25
|
+
return Array.from(r.children).filter((t) => t.tagName === "TBODY").flatMap((t) => Array.from(t.children)).flatMap((t) => Array.from(t.children).filter((e) => e.tagName === "TD"));
|
|
26
26
|
}
|
|
27
|
-
function J(
|
|
28
|
-
var e,
|
|
29
|
-
let t = (e =
|
|
27
|
+
function J(r) {
|
|
28
|
+
var e, l;
|
|
29
|
+
let t = (e = r.parentElement) == null ? void 0 : e.closest("table");
|
|
30
30
|
for (; t; ) {
|
|
31
|
-
const a =
|
|
31
|
+
const a = I(t);
|
|
32
32
|
if (a)
|
|
33
33
|
return a;
|
|
34
|
-
t = (
|
|
34
|
+
t = (l = t.parentElement) == null ? void 0 : l.closest("table");
|
|
35
35
|
}
|
|
36
36
|
return 0;
|
|
37
37
|
}
|
|
38
|
-
function q(
|
|
39
|
-
var
|
|
40
|
-
const t = (
|
|
41
|
-
if (!t || !e || !t.matches(R) || !
|
|
38
|
+
function q(r) {
|
|
39
|
+
var u, o;
|
|
40
|
+
const t = (o = (u = r.parentElement) == null ? void 0 : u.parentElement) == null ? void 0 : o.parentElement, e = t == null ? void 0 : t.parentElement;
|
|
41
|
+
if (!t || !e || !t.matches(R) || !I(r))
|
|
42
42
|
return !1;
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
43
|
+
const l = k(t), a = l.some((n) => !n.matches(j) && I(n));
|
|
44
|
+
if (!l.includes(r) || a)
|
|
45
45
|
return !1;
|
|
46
|
-
const
|
|
47
|
-
return
|
|
46
|
+
const i = Array.from(e.children).filter((n) => n.matches(R)).reduce((n, d) => n + Math.max(0, ...k(d).map(I)), 0), c = J(e);
|
|
47
|
+
return c > 0 && i <= c;
|
|
48
48
|
}
|
|
49
49
|
function Z() {
|
|
50
50
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
52
|
+
function B(r) {
|
|
53
|
+
return r ? {
|
|
54
54
|
CartItems: p.ITEMS_TYPE.CART_ITEMS,
|
|
55
55
|
BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
56
56
|
PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
57
57
|
CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
|
|
58
58
|
BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
59
59
|
PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
|
|
60
|
-
}[
|
|
60
|
+
}[r] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
61
61
|
}
|
|
62
|
-
function K(
|
|
63
|
-
return
|
|
62
|
+
function K(r) {
|
|
63
|
+
return r.classList.contains("esd-browsed-items-block") ? p.ITEMS_TYPE.BROWSED_ITEMS : r.classList.contains("esd-purchased-items-block") ? p.ITEMS_TYPE.PURCHASED_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
var
|
|
67
|
-
const t = (
|
|
68
|
-
let
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
|
|
65
|
+
function v(r) {
|
|
66
|
+
var u;
|
|
67
|
+
const t = (o, n) => o == null ? n : o === "1" || o === "true", e = (o, n) => o || n, l = r["data-type"] || r["data-source"], a = B(l), i = h[a];
|
|
68
|
+
let c = r["data-cart_items_select_control_value"] || ((u = i == null ? void 0 : i[0]) == null ? void 0 : u.value) || S.cartItemsSelectControlValue;
|
|
69
|
+
if (c && !c.includes("{{") && /^\d+$/.test(c)) {
|
|
70
|
+
const o = parseInt(c) - 1, n = h[a];
|
|
71
|
+
n && n[o] && (c = n[o].value);
|
|
72
72
|
}
|
|
73
73
|
return {
|
|
74
74
|
initialized: !0,
|
|
75
|
-
blockInstanceId: e(
|
|
75
|
+
blockInstanceId: e(r["data-block-instance-id"], Z()),
|
|
76
76
|
source: a,
|
|
77
77
|
type: a,
|
|
78
|
-
itemsSelectValue:
|
|
79
|
-
orientation:
|
|
80
|
-
nameTrimming: t(
|
|
81
|
-
priceHideDiscount: t(
|
|
82
|
-
priceFormatted: t(
|
|
83
|
-
priceSinglePrice: t(
|
|
78
|
+
itemsSelectValue: c,
|
|
79
|
+
orientation: r["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
|
|
80
|
+
nameTrimming: t(r["data-product_name_control_trim"], !0),
|
|
81
|
+
priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
|
|
82
|
+
priceFormatted: t(r["data-product_price_control_formated"], !0),
|
|
83
|
+
priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
|
|
84
84
|
priceCurrencySymbol: e(
|
|
85
|
-
|
|
85
|
+
r["data-product_price_control_currency_symbol"],
|
|
86
86
|
S.productPriceCurrencySymbolControlValue
|
|
87
87
|
),
|
|
88
88
|
priceCurrencyLocation: e(
|
|
89
|
-
|
|
89
|
+
r["data-product_price_currency_location"],
|
|
90
90
|
S.productPriceCurrencyLocationControlValue
|
|
91
91
|
),
|
|
92
|
-
priceOrientation:
|
|
93
|
-
quantityControlEnabled: t(
|
|
94
|
-
buttonLink: e(
|
|
95
|
-
imageLink: e(
|
|
96
|
-
buttonLabel: e(
|
|
97
|
-
buttonFullWidth: t(
|
|
98
|
-
imageVisible: t(
|
|
99
|
-
nameVisible: t(
|
|
100
|
-
quantityVisible: t(
|
|
101
|
-
priceVisible: t(
|
|
102
|
-
originalPriceVisible: t(
|
|
103
|
-
buttonVisible: t(
|
|
92
|
+
priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
|
|
93
|
+
quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
|
|
94
|
+
buttonLink: e(r["data-product_button_link"], S.productButtonLinkControlValue),
|
|
95
|
+
imageLink: e(r["data-product_image_link"], S.productImageLinkControlValue),
|
|
96
|
+
buttonLabel: e(r["data-product_button_control_label"], "Buy"),
|
|
97
|
+
buttonFullWidth: t(r["data-product_button_control_atw"], !0),
|
|
98
|
+
imageVisible: t(r["data-product_image_control_enabled"], !0),
|
|
99
|
+
nameVisible: t(r["data-product_name_control_enabled"], !0),
|
|
100
|
+
quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
|
|
101
|
+
priceVisible: t(r["data-product_price_control_enabled"], !0),
|
|
102
|
+
originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
|
|
103
|
+
buttonVisible: t(r["data-product_button_control_enabled"], !0)
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
function Q(
|
|
106
|
+
function Q(r, t) {
|
|
107
107
|
const e = {
|
|
108
108
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
109
109
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
110
110
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
111
111
|
};
|
|
112
|
-
return e[
|
|
112
|
+
return e[r] || e.CART_ITEMS;
|
|
113
113
|
}
|
|
114
|
-
function X(
|
|
114
|
+
function X(r, t) {
|
|
115
115
|
const e = {
|
|
116
116
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
117
117
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
118
118
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
119
119
|
};
|
|
120
|
-
return e[
|
|
120
|
+
return e[r] || e.CART_ITEMS;
|
|
121
121
|
}
|
|
122
122
|
class tt {
|
|
123
123
|
constructor() {
|
|
@@ -128,41 +128,41 @@ class tt {
|
|
|
128
128
|
try {
|
|
129
129
|
if (!this.containsItemsBlock(t))
|
|
130
130
|
return this.backfillV2ProductTdAttributes(t);
|
|
131
|
-
const e = this.removeJinjaConditionals(t),
|
|
131
|
+
const e = this.removeJinjaConditionals(t), l = this.parser.parseFromString(P(e), "text/html"), a = l.querySelectorAll(
|
|
132
132
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
133
133
|
);
|
|
134
|
-
if (F().$patch((
|
|
135
|
-
|
|
134
|
+
if (F().$patch((u) => {
|
|
135
|
+
u.migrations = { ...u.migrations, [H]: a.length };
|
|
136
136
|
}), a.length === 0)
|
|
137
|
-
return console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(
|
|
138
|
-
const
|
|
139
|
-
return a.forEach((
|
|
140
|
-
const
|
|
141
|
-
orientation:
|
|
142
|
-
itemsType:
|
|
143
|
-
itemId:
|
|
144
|
-
currencySymbol:
|
|
145
|
-
currencyLocation:
|
|
146
|
-
formattedPrice:
|
|
147
|
-
configBlockAttributes:
|
|
137
|
+
return console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(t);
|
|
138
|
+
const c = new Set(Array.from(a).filter(q));
|
|
139
|
+
return a.forEach((u) => {
|
|
140
|
+
const o = this.extractConfiguration(u), n = $({
|
|
141
|
+
orientation: o.orientation,
|
|
142
|
+
itemsType: o.itemsType,
|
|
143
|
+
itemId: o.itemId,
|
|
144
|
+
currencySymbol: o.currencySymbol,
|
|
145
|
+
currencyLocation: o.currencyLocation,
|
|
146
|
+
formattedPrice: o.formattedPrice,
|
|
147
|
+
configBlockAttributes: o.configBlockAttributes,
|
|
148
148
|
migrate: !0,
|
|
149
|
-
nameStyles:
|
|
150
|
-
buttonStyles:
|
|
151
|
-
priceStyles:
|
|
152
|
-
originalPriceStyles:
|
|
153
|
-
quantityStyles:
|
|
154
|
-
nodeConfig:
|
|
149
|
+
nameStyles: o.nameStyles,
|
|
150
|
+
buttonStyles: o.buttonStyles,
|
|
151
|
+
priceStyles: o.priceStyles,
|
|
152
|
+
originalPriceStyles: o.originalPriceStyles,
|
|
153
|
+
quantityStyles: o.quantityStyles,
|
|
154
|
+
nodeConfig: v(o.configBlockAttributes)
|
|
155
155
|
}), s = this.parser.parseFromString(
|
|
156
|
-
`<table><tbody><tr>${
|
|
156
|
+
`<table><tbody><tr>${n}</tr></tbody></table>`,
|
|
157
157
|
"text/html"
|
|
158
158
|
).querySelector("td");
|
|
159
|
-
if (s &&
|
|
160
|
-
const _ =
|
|
159
|
+
if (s && u.parentNode) {
|
|
160
|
+
const _ = v(o.configBlockAttributes);
|
|
161
161
|
s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
|
|
162
162
|
const m = s.querySelector("esd-config-block");
|
|
163
|
-
m && m.remove(),
|
|
163
|
+
m && m.remove(), c.has(u) && (s.setAttribute("width", String(I(u))), s.classList.add("esd-container-frame")), u.parentNode.replaceChild(s, u);
|
|
164
164
|
}
|
|
165
|
-
}), this.backfillV2ProductTdAttributes(D(
|
|
165
|
+
}), this.backfillV2ProductTdAttributes(D(l.documentElement.outerHTML));
|
|
166
166
|
} catch (e) {
|
|
167
167
|
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
168
168
|
}
|
|
@@ -175,24 +175,24 @@ class tt {
|
|
|
175
175
|
*/
|
|
176
176
|
extractConfiguration(t) {
|
|
177
177
|
var M;
|
|
178
|
-
const e =
|
|
178
|
+
const e = B(
|
|
179
179
|
this.readSelfOrDescendantAttribute(t, "data-type") || K(t)
|
|
180
|
-
),
|
|
181
|
-
this.applyDomFallbacks(t,
|
|
182
|
-
const
|
|
180
|
+
), l = this.readSelfOrDescendantAttribute(t, "data-number") || "1", a = parseInt(l) - 1, i = h[e], c = ((M = i == null ? void 0 : i[a]) == null ? void 0 : M.value) || i[0].value, u = this.extractConfigBlockAttributes(t, e, l);
|
|
181
|
+
this.applyDomFallbacks(t, u);
|
|
182
|
+
const o = t.querySelector('[product-attr="price"]'), n = u["data-product_price_control_currency_symbol"], d = u["data-product_price_currency_location"] || "0", s = u["data-product_price_control_formated"], _ = s !== "false" && s !== "0", A = u["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", g = t.querySelector('a[product-attr="name"]'), y = (g == null ? void 0 : g.getAttribute("style")) || void 0, b = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), E = (b == null ? void 0 : b.getAttribute("style")) || void 0, L = (o == null ? void 0 : o.getAttribute("style")) || void 0, f = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = f != null && f.getAttribute("style") ? f : (f == null ? void 0 : f.closest("p")) ?? f, O = (T == null ? void 0 : T.getAttribute("style")) || void 0, C = t.querySelector('[product-attr="quantity"]'), x = (C == null ? void 0 : C.getAttribute("style")) || void 0;
|
|
183
183
|
return {
|
|
184
184
|
orientation: A,
|
|
185
185
|
itemsType: e,
|
|
186
|
-
itemId:
|
|
187
|
-
currencySymbol:
|
|
186
|
+
itemId: c,
|
|
187
|
+
currencySymbol: n,
|
|
188
188
|
currencyLocation: d,
|
|
189
189
|
formattedPrice: _,
|
|
190
|
-
configBlockAttributes:
|
|
190
|
+
configBlockAttributes: u,
|
|
191
191
|
nameStyles: y,
|
|
192
|
-
buttonStyles:
|
|
193
|
-
priceStyles:
|
|
194
|
-
originalPriceStyles:
|
|
195
|
-
quantityStyles:
|
|
192
|
+
buttonStyles: E,
|
|
193
|
+
priceStyles: L,
|
|
194
|
+
originalPriceStyles: O,
|
|
195
|
+
quantityStyles: x
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -204,7 +204,7 @@ class tt {
|
|
|
204
204
|
*/
|
|
205
205
|
applyDomFallbacks(t, e) {
|
|
206
206
|
var A, g;
|
|
207
|
-
const
|
|
207
|
+
const l = t.querySelector("esd-config-block"), a = (...y) => !l || y.every((b) => !(l.getAttribute(b) ?? "").trim());
|
|
208
208
|
Object.entries({
|
|
209
209
|
image: '[product-attr="imageSrc"]',
|
|
210
210
|
name: '[product-attr="name"]',
|
|
@@ -213,14 +213,14 @@ class tt {
|
|
|
213
213
|
quantity: '[product-attr="quantity"]',
|
|
214
214
|
button: '[product-attr="button"]'
|
|
215
215
|
}).forEach(([y, b]) => {
|
|
216
|
-
const
|
|
217
|
-
a(
|
|
216
|
+
const E = `data-product_${y}_control_enabled`;
|
|
217
|
+
a(E) && (e[E] = t.querySelector(b) ? "true" : "false");
|
|
218
218
|
}), a("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
a("data-product_button_control_atw") && /display:\s*inline/.test(
|
|
223
|
-
const
|
|
219
|
+
const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), u = (A = c == null ? void 0 : c.textContent) == null ? void 0 : A.replace(/\s+/g, " ").trim();
|
|
220
|
+
u && a("data-product_button_control_label") && (e["data-product_button_control_label"] = u);
|
|
221
|
+
const o = (c == null ? void 0 : c.getAttribute("style")) || "";
|
|
222
|
+
a("data-product_button_control_atw") && /display:\s*inline/.test(o) && !/(?:^|;)\s*width\s*:\s*100%/.test(o) && (e["data-product_button_control_atw"] = "false");
|
|
223
|
+
const n = t.querySelector('[product-attr="imageSrc"]'), d = n ? this.readImageSize(n) : null, s = (d == null ? void 0 : d.height) ?? (d == null ? void 0 : d.width), _ = (d == null ? void 0 : d.width) ?? (d == null ? void 0 : d.height);
|
|
224
224
|
s && a("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), _ && a("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = _), this.applyPriceDomFallbacks(t, e, a);
|
|
225
225
|
const m = ((g = t.querySelector('[product-attr="name"]')) == null ? void 0 : g.getAttribute("style")) || "";
|
|
226
226
|
a("data-product_name_control_trim") && /white-space:\s*normal/.test(m) && (e["data-product_name_control_trim"] = "0");
|
|
@@ -232,22 +232,22 @@ class tt {
|
|
|
232
232
|
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
233
233
|
* the default back over the real value.
|
|
234
234
|
*/
|
|
235
|
-
applyPriceDomFallbacks(t, e,
|
|
236
|
-
var
|
|
235
|
+
applyPriceDomFallbacks(t, e, l) {
|
|
236
|
+
var n;
|
|
237
237
|
const a = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
238
238
|
if (!a)
|
|
239
239
|
return;
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
const d =
|
|
240
|
+
const i = (n = a.getAttribute("data-currency_symbol")) == null ? void 0 : n.trim();
|
|
241
|
+
i && l("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = i);
|
|
242
|
+
const c = a.getAttribute("data-curency");
|
|
243
|
+
if (c && l("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
244
|
+
const d = c === "after" ? "1" : "0";
|
|
245
245
|
e["data-product_price_currency_location"] = d, e["data-product_price_control_curency"] = d;
|
|
246
246
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
247
|
+
const u = a.getAttribute("data-formated");
|
|
248
|
+
u && l("data-product_price_control_formated") && (e["data-product_price_control_formated"] = u);
|
|
249
|
+
const o = a.getAttribute("data-single_price");
|
|
250
|
+
o && l("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = o);
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
@@ -255,8 +255,8 @@ class tt {
|
|
|
255
255
|
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
256
256
|
*/
|
|
257
257
|
readSelfOrDescendantAttribute(t, e) {
|
|
258
|
-
var
|
|
259
|
-
return t.getAttribute(e) || ((
|
|
258
|
+
var l;
|
|
259
|
+
return t.getAttribute(e) || ((l = t.querySelector(`[${e}]`)) == null ? void 0 : l.getAttribute(e)) || null;
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
262
|
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
@@ -276,15 +276,15 @@ class tt {
|
|
|
276
276
|
* to nothing, so only a positive integer counts as an answer.
|
|
277
277
|
*/
|
|
278
278
|
readImageDimension(t, e) {
|
|
279
|
-
var
|
|
280
|
-
const
|
|
279
|
+
var n;
|
|
280
|
+
const l = (d) => {
|
|
281
281
|
const s = (d ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), _ = s ? Math.floor(parseFloat(s[1])) : 0;
|
|
282
282
|
return _ > 0 ? String(_) : null;
|
|
283
|
-
}, a =
|
|
283
|
+
}, a = l((n = t.getAttribute(e)) == null ? void 0 : n.trim());
|
|
284
284
|
if (a)
|
|
285
285
|
return a;
|
|
286
|
-
const
|
|
287
|
-
return
|
|
286
|
+
const i = t.getAttribute("style") || "", c = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), u = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = i.match(c) || i.match(u);
|
|
287
|
+
return l(o == null ? void 0 : o[1]);
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* Extracts all data-* attributes from the esd-config-block element
|
|
@@ -293,27 +293,30 @@ class tt {
|
|
|
293
293
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
294
294
|
* @param itemNumber - The item number (1-based index)
|
|
295
295
|
*/
|
|
296
|
-
extractConfigBlockAttributes(t, e,
|
|
297
|
-
|
|
296
|
+
extractConfigBlockAttributes(t, e, l) {
|
|
297
|
+
var o;
|
|
298
|
+
const a = t.querySelector("esd-config-block"), i = {};
|
|
298
299
|
if (a) {
|
|
299
|
-
if (Array.from(a.attributes).forEach((
|
|
300
|
-
|
|
301
|
-
}),
|
|
302
|
-
const
|
|
303
|
-
if (/^\d+$/.test(
|
|
304
|
-
const
|
|
305
|
-
|
|
300
|
+
if (Array.from(a.attributes).forEach((n) => {
|
|
301
|
+
n.name.startsWith("data-") && (i[n.name] = n.value);
|
|
302
|
+
}), i["data-cart_items_select_control_value"]) {
|
|
303
|
+
const n = i["data-cart_items_select_control_value"];
|
|
304
|
+
if (/^\d+$/.test(n)) {
|
|
305
|
+
const d = parseInt(n) - 1, s = h[e];
|
|
306
|
+
s && s[d] && (i["data-cart_items_select_control_value"] = s[d].value);
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
let
|
|
311
|
-
|
|
309
|
+
if (i["data-product_price_control_curency"]) {
|
|
310
|
+
const n = i["data-product_price_control_curency"];
|
|
311
|
+
let d = n;
|
|
312
|
+
n === "before" ? d = "0" : n === "after" && (d = "1"), i["data-product_price_control_curency"] = d, i["data-product_price_currency_location"] = d;
|
|
312
313
|
}
|
|
313
|
-
(!
|
|
314
|
+
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
314
315
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
316
|
+
const c = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
317
|
+
c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = Q(e, l), c["data-product_button_link"] = X(e, l);
|
|
318
|
+
const u = (o = h[e]) == null ? void 0 : o[parseInt(l) - 1];
|
|
319
|
+
return !c["data-cart_items_select_control_value"] && u && (c["data-cart_items_select_control_value"] = u.value), c;
|
|
317
320
|
}
|
|
318
321
|
/**
|
|
319
322
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -389,30 +392,30 @@ class tt {
|
|
|
389
392
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
390
393
|
return t;
|
|
391
394
|
const e = this.parser.parseFromString(P(t), "text/html");
|
|
392
|
-
let
|
|
393
|
-
const a = Array.from(e.querySelectorAll(".ins-product-td")),
|
|
394
|
-
return a.forEach((
|
|
395
|
-
const
|
|
396
|
-
!
|
|
397
|
-
!
|
|
395
|
+
let l = !1;
|
|
396
|
+
const a = Array.from(e.querySelectorAll(".ins-product-td")), i = new Set(a.filter(q));
|
|
397
|
+
return a.forEach((c) => {
|
|
398
|
+
const u = i.has(c);
|
|
399
|
+
!u && c.hasAttribute("width") && (c.removeAttribute("width"), l = !0), !u && c.classList.contains("esd-container-frame") && (c.classList.remove("esd-container-frame"), l = !0), c.querySelectorAll("table.ins-product-wrapper").forEach((_) => {
|
|
400
|
+
!u && _.hasAttribute("width") && _.getAttribute("width") !== "100%" && (_.setAttribute("width", "100%"), l = !0);
|
|
398
401
|
const m = _.getAttribute("style");
|
|
399
|
-
m && U(m) && (_.setAttribute("style", W(m)), _.setAttribute("width", "100%"),
|
|
402
|
+
m && U(m) && (_.setAttribute("style", W(m)), _.setAttribute("width", "100%"), l = !0);
|
|
400
403
|
});
|
|
401
|
-
const
|
|
402
|
-
let
|
|
404
|
+
const o = c.getAttribute("esd-ext-config");
|
|
405
|
+
let n = null;
|
|
403
406
|
try {
|
|
404
|
-
|
|
407
|
+
n = o ? JSON.parse(o) : null;
|
|
405
408
|
} catch {
|
|
406
409
|
}
|
|
407
|
-
if (!
|
|
410
|
+
if (!n || (!c.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (c.setAttribute("data-nodup", String(n.priceHideDiscount)), l = !0), c.getAttribute("data-type")))
|
|
408
411
|
return;
|
|
409
|
-
const d =
|
|
412
|
+
const d = n.type || n.source;
|
|
410
413
|
if (!d)
|
|
411
414
|
return;
|
|
412
|
-
|
|
413
|
-
const s = typeof
|
|
414
|
-
s &&
|
|
415
|
-
}),
|
|
415
|
+
c.setAttribute("data-type", d), l = !0;
|
|
416
|
+
const s = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
417
|
+
s && c.getAttribute("data-number") !== s[1] && c.setAttribute("data-number", s[1]);
|
|
418
|
+
}), l ? D(e.documentElement.outerHTML) : t;
|
|
416
419
|
}
|
|
417
420
|
/**
|
|
418
421
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -427,23 +430,23 @@ class tt {
|
|
|
427
430
|
* Liquid inside esd-custom-display-condition(s) attribute values is skipped.
|
|
428
431
|
*/
|
|
429
432
|
removeJinjaConditionals(t) {
|
|
430
|
-
const e = [...t.matchAll(G)].map((
|
|
431
|
-
let a = t.replace(Y, (
|
|
432
|
-
if (e.some(({ start:
|
|
433
|
-
return
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
return
|
|
433
|
+
const e = [...t.matchAll(G)].map((i) => ({ start: i.index, end: i.index + i[0].length })), l = [];
|
|
434
|
+
let a = t.replace(Y, (i, c, u) => {
|
|
435
|
+
if (e.some(({ start: o, end: n }) => u >= o && u < n))
|
|
436
|
+
return i;
|
|
437
|
+
if (c === "if") {
|
|
438
|
+
const o = z.some((n) => n.test(i));
|
|
439
|
+
return l.push(o), o ? "" : i;
|
|
437
440
|
}
|
|
438
|
-
return
|
|
441
|
+
return c === "endif" && l.pop() ? "" : i;
|
|
439
442
|
});
|
|
440
443
|
return a = a.replace(/\n\s*\n\s*\n/g, `
|
|
441
444
|
|
|
442
445
|
`), a;
|
|
443
446
|
}
|
|
444
447
|
}
|
|
445
|
-
function lt(
|
|
446
|
-
return new tt().migrate(
|
|
448
|
+
function lt(r) {
|
|
449
|
+
return new tt().migrate(r);
|
|
447
450
|
}
|
|
448
451
|
export {
|
|
449
452
|
lt as migrateItemsBlock
|
package/dist/package.json.js
CHANGED
|
@@ -1,129 +1,128 @@
|
|
|
1
|
-
import { isNewPriceFormatRoot as
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const q = {
|
|
1
|
+
import { isNewPriceFormatRoot as W, ITEMS_PRICE_FORMAT_ATTR as w, currencyPositionFromLocation as V, ITEMS_CURRENCY_ATTR as x, isCustomCurrencySymbol as G } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as N } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
|
+
import { preserveTextStyles as H } from "./preserveTextStyles.js";
|
|
4
|
+
import { protectTableText as Y, restoreTableText as B } from "./protectTableText.js";
|
|
5
|
+
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
6
|
+
const D = {
|
|
8
7
|
CART_ITEMS: "ins_apr",
|
|
9
8
|
BROWSED_ITEMS: "browsed_item",
|
|
10
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
for (;
|
|
15
|
-
|
|
16
|
-
return
|
|
10
|
+
}, U = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(r, _, u) {
|
|
12
|
+
let l = _;
|
|
13
|
+
for (; l > 0 && /\s/.test(r[l - 1]); )
|
|
14
|
+
l -= 1;
|
|
15
|
+
return u.some((p) => r.endsWith(p, l));
|
|
17
16
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
var
|
|
21
|
-
const
|
|
22
|
-
for (let
|
|
23
|
-
(
|
|
17
|
+
const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
18
|
+
function Q(r, _) {
|
|
19
|
+
var l;
|
|
20
|
+
const u = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
|
|
21
|
+
for (let p = u.nextNode(); p; p = u.nextNode())
|
|
22
|
+
(l = p.nodeValue) != null && l.includes("[if mso]") && (p.nodeValue = p.nodeValue.replace(j, (I, E) => `${E}href="${_}"`));
|
|
24
23
|
}
|
|
25
|
-
function
|
|
24
|
+
function z(r) {
|
|
26
25
|
return {
|
|
27
26
|
isFormatted: r.getAttribute("data-formated") === "true",
|
|
28
27
|
isSinglePrice: r.getAttribute("data-single_price") === "true",
|
|
29
|
-
currencyPosition: r.getAttribute(
|
|
30
|
-
configuredSymbol: (r.getAttribute(
|
|
28
|
+
currencyPosition: r.getAttribute(x.POSITION) || "before",
|
|
29
|
+
configuredSymbol: (r.getAttribute(x.SYMBOL) || "").trim()
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
|
-
function
|
|
32
|
+
function J(r) {
|
|
34
33
|
return {
|
|
35
34
|
isFormatted: !1,
|
|
36
|
-
isSinglePrice: r.getAttribute(
|
|
37
|
-
currencyPosition:
|
|
38
|
-
r.getAttribute(
|
|
35
|
+
isSinglePrice: r.getAttribute(w.SINGLE_PRICE) === "true",
|
|
36
|
+
currencyPosition: V(
|
|
37
|
+
r.getAttribute(w.ALIGNMENT) ?? void 0
|
|
39
38
|
),
|
|
40
|
-
configuredSymbol: (r.getAttribute(
|
|
39
|
+
configuredSymbol: (r.getAttribute(w.SYMBOL) || "").trim()
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
|
-
function
|
|
44
|
-
const { isFormatted:
|
|
42
|
+
function K(r, _, u) {
|
|
43
|
+
const { isFormatted: l, isSinglePrice: p, currencyPosition: I, configuredSymbol: E } = u;
|
|
45
44
|
let y;
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
return
|
|
45
|
+
p ? y = l ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = l ? r.PRICE_FORMATTED : r.PRICE;
|
|
46
|
+
const b = r.CURRENCY;
|
|
47
|
+
let S = `{{${y}_${_}}}`, o = "";
|
|
48
|
+
return G(E) ? o = E : b && (o = `{{${b}_${_}}}`), o && (S = I === "after" ? `${S} ${o}` : `${o} ${S}`), S;
|
|
50
49
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
Object.entries(
|
|
56
|
-
|
|
57
|
-
const
|
|
50
|
+
function nt(r) {
|
|
51
|
+
const _ = U(Y(r)), u = new DOMParser().parseFromString(_, "text/html");
|
|
52
|
+
X(u);
|
|
53
|
+
const l = N.PAIRS_FOR_EXTENSION;
|
|
54
|
+
Object.entries(l).forEach(([o, R]) => {
|
|
55
|
+
u.querySelectorAll(".ins-product-td").forEach((n) => {
|
|
56
|
+
const m = n.getAttribute("data-number") || "1", C = n.getAttribute("data-type") || "CART_ITEMS";
|
|
58
57
|
n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
59
|
-
var
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
58
|
+
var h, L, k, O;
|
|
59
|
+
const P = t.getAttribute("data-type") || C, c = t.getAttribute("data-number") || m, d = R[P];
|
|
60
|
+
if (d)
|
|
62
61
|
switch (o) {
|
|
63
62
|
case "imageSrc": {
|
|
64
63
|
let e = null, i = null;
|
|
65
64
|
if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
|
|
66
65
|
break;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
return
|
|
66
|
+
const A = d.DEFAULT, a = d.ATTR;
|
|
67
|
+
if (A && e.src) {
|
|
68
|
+
const f = e.src;
|
|
69
|
+
A.some((F) => {
|
|
70
|
+
const T = F.split("/").pop() || "", q = f.split("/").pop() || "";
|
|
71
|
+
return f.includes(F) || f.includes(T) || q === T;
|
|
73
72
|
}) && (e.src = `{{${a}_${c}}}`);
|
|
74
73
|
}
|
|
75
|
-
const s = (
|
|
74
|
+
const s = (L = (h = l.name) == null ? void 0 : h[P]) == null ? void 0 : L.ATTR;
|
|
76
75
|
if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
(
|
|
76
|
+
const f = (k = l.itemLink) == null ? void 0 : k[P];
|
|
77
|
+
if (f) {
|
|
78
|
+
const M = f.HREF, F = f.DEFAULT_HREF || "#!", T = i.href;
|
|
79
|
+
(T === "#" || T === "" || T.endsWith("#!") || T.endsWith(F) || T === `${window.location.href}${F}` || !T || T === window.location.href) && (i.href = `{{${M}_${c}}}`);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
break;
|
|
84
83
|
}
|
|
85
84
|
case "name": {
|
|
86
|
-
const e =
|
|
87
|
-
t.textContent && (t.innerHTML =
|
|
85
|
+
const e = d, i = e.ATTR, A = e.DEFAULT_HREF || "#!", a = e.HREF;
|
|
86
|
+
t.textContent && (t.innerHTML = H(t, `{{${i}_${c}}}`));
|
|
88
87
|
const s = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
89
88
|
if (s && a) {
|
|
90
|
-
const
|
|
91
|
-
(
|
|
89
|
+
const f = s.href, M = `${window.location.href}${A}`;
|
|
90
|
+
(f === M || f.endsWith(A)) && (s.href = `{{${a}_${c}}}`);
|
|
92
91
|
}
|
|
93
92
|
break;
|
|
94
93
|
}
|
|
95
94
|
case "price":
|
|
96
95
|
case "originalPrice": {
|
|
97
|
-
const e =
|
|
98
|
-
t.innerHTML =
|
|
96
|
+
const e = d, i = W(n) ? J(n) : z(t);
|
|
97
|
+
t.innerHTML = H(t, K(e, c, i));
|
|
99
98
|
break;
|
|
100
99
|
}
|
|
101
100
|
case "quantity": {
|
|
102
|
-
const e =
|
|
103
|
-
a &&
|
|
101
|
+
const e = d, i = e.ATTR, A = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (O = t.textContent) == null ? void 0 : O.trim();
|
|
102
|
+
a && A.includes(a) && (t.innerHTML = H(t, `{{${i}_${c}}}`));
|
|
104
103
|
break;
|
|
105
104
|
}
|
|
106
105
|
case "button": {
|
|
107
|
-
const e =
|
|
106
|
+
const e = d, i = e.HREF, A = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
|
|
108
107
|
if (a) {
|
|
109
|
-
const s = a.href || "",
|
|
110
|
-
(s === "" || s === "#" || s ===
|
|
108
|
+
const s = a.href || "", f = `${window.location.href}${A}`;
|
|
109
|
+
(s === "" || s === "#" || s === f || s.endsWith(A) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
Q(t, `{{${i}_${c}}}`);
|
|
113
112
|
break;
|
|
114
113
|
}
|
|
115
114
|
case "itemLink": {
|
|
116
|
-
const e =
|
|
115
|
+
const e = d, i = e.HREF, A = e.DEFAULT_HREF || "#!", a = t;
|
|
117
116
|
if (a.href) {
|
|
118
|
-
const s = a.href,
|
|
119
|
-
(s ===
|
|
117
|
+
const s = a.href, f = `${window.location.href}${A}`;
|
|
118
|
+
(s === f || s.endsWith(A)) && (a.href = `{{${i}_${c}}}`);
|
|
120
119
|
}
|
|
121
120
|
break;
|
|
122
121
|
}
|
|
123
122
|
default: {
|
|
124
|
-
if ("ATTR" in
|
|
125
|
-
const e =
|
|
126
|
-
t.textContent && (t.innerHTML =
|
|
123
|
+
if ("ATTR" in d) {
|
|
124
|
+
const e = d.ATTR;
|
|
125
|
+
t.textContent && (t.innerHTML = H(t, `{{${e}_${c}}}`));
|
|
127
126
|
}
|
|
128
127
|
break;
|
|
129
128
|
}
|
|
@@ -131,49 +130,40 @@ function at(r) {
|
|
|
131
130
|
});
|
|
132
131
|
});
|
|
133
132
|
});
|
|
134
|
-
const
|
|
135
|
-
` : ""
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
number: _
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
let E = L + p.documentElement.outerHTML;
|
|
146
|
-
y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
|
|
147
|
-
const n = q[T], S = n ? `${n}_total_product_kind` : "";
|
|
148
|
-
if (S) {
|
|
149
|
-
const b = parseInt(_) - 1, c = `${`{% if ${S} > ${b} %}`}${o}{% endif %}`;
|
|
150
|
-
E = E.replace(o, v(c));
|
|
151
|
-
}
|
|
133
|
+
const p = _.match(/<!DOCTYPE[^>]*>/i), I = p ? `${p[0]}
|
|
134
|
+
` : "";
|
|
135
|
+
u.querySelectorAll(".ins-product-td").forEach((o) => {
|
|
136
|
+
const R = o.getAttribute("data-type") || "CART_ITEMS", $ = D[R];
|
|
137
|
+
if (!$)
|
|
138
|
+
return;
|
|
139
|
+
const n = parseInt(o.getAttribute("data-number") || "1") - 1;
|
|
140
|
+
o.before(u.createComment(`{% if ${$}_total_product_kind > ${n} %}`)), o.after(u.createComment("{% endif %}"));
|
|
152
141
|
});
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
let E = I + u.documentElement.outerHTML;
|
|
143
|
+
const y = u.querySelectorAll('[product-attr="originalPrice"][data-type]'), b = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
|
|
144
|
+
return y.forEach((o) => {
|
|
155
145
|
var t;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
146
|
+
const R = o.getAttribute("data-number"), $ = o.getAttribute("data-type");
|
|
147
|
+
if (!R || !D[$])
|
|
158
148
|
return;
|
|
159
149
|
const n = o.closest(".product-original-price-class");
|
|
160
|
-
if (!n ||
|
|
150
|
+
if (!n || S.has(n))
|
|
161
151
|
return;
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
}),
|
|
166
|
-
if (n.includes("{% if") ||
|
|
152
|
+
S.add(n);
|
|
153
|
+
const m = n.outerHTML, C = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), g = b.get(m) ?? { number: R, type: $, wrap: [] };
|
|
154
|
+
g.wrap.push(C !== "false"), b.set(m, g);
|
|
155
|
+
}), b.forEach(({ number: o, type: R, wrap: $ }, n) => {
|
|
156
|
+
if (n.includes("{% if") || !$.some(Boolean))
|
|
167
157
|
return;
|
|
168
|
-
const
|
|
169
|
-
let
|
|
170
|
-
for (;
|
|
171
|
-
const
|
|
172
|
-
|
|
158
|
+
const m = N.PAIRS_FOR_EXTENSION.price[R].PRICE, C = N.PAIRS_FOR_EXTENSION.originalPrice[R].PRICE, g = `{% if ${m}_${o} != ${C}_${o} %}`, t = [g, U(g)];
|
|
159
|
+
let P = "", c = 0, d = 0, h = E.indexOf(n);
|
|
160
|
+
for (; h !== -1; ) {
|
|
161
|
+
const L = $[d] === !0 && !v(E, h, t);
|
|
162
|
+
P += E.slice(c, h) + (L ? `${g}${n}{% endif %}` : n), c = h + n.length, d += 1, h = E.indexOf(n, c);
|
|
173
163
|
}
|
|
174
|
-
E =
|
|
175
|
-
}),
|
|
164
|
+
E = P + E.slice(c);
|
|
165
|
+
}), B(E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
176
166
|
}
|
|
177
167
|
export {
|
|
178
|
-
|
|
168
|
+
nt as pairProductVariables
|
|
179
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.0-beta.
|
|
3
|
+
"version": "3.30.0-beta.f3f01ef",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|