@useinsider/guido 3.26.0 → 3.27.0-beta.3e42e7a
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 +1 -0
- package/dist/@types/config/schemas.js +91 -89
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +5 -5
- package/dist/components/Guido.vue2.js +95 -90
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +17 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +41 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +81 -0
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +45 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +36 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +63 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
- package/dist/composables/useBlocksConfig.js +29 -20
- package/dist/composables/useDisplayConditions.js +116 -0
- package/dist/composables/useTranslations.js +2 -1
- package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/DisplayConditions/bridge.js +25 -0
- package/dist/extensions/DisplayConditions/constants.js +26 -0
- package/dist/extensions/DisplayConditions/control.js +215 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +226 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +30 -0
- package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
- package/dist/node_modules/valibot/dist/index.js +297 -261
- package/dist/package.json.js +4 -4
- package/dist/services/displayConditionApi.js +39 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +61 -0
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +18 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useDisplayConditions.d.ts +18 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/display-condition.d.ts +15 -0
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +23 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +25 -0
- package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
- package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
- package/dist/src/mock/api/display-conditions.d.ts +2 -0
- package/dist/src/services/displayConditionApi.d.ts +8 -0
- package/dist/src/stores/config.d.ts +170 -0
- package/dist/src/stores/display-condition.d.ts +86 -0
- package/dist/src/utils/displayCondition.d.ts +11 -0
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/static/styles/variables.css.js +1 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +29 -0
- package/dist/utils/displayCondition.js +29 -0
- package/dist/utils/pairProductVariables.js +29 -28
- package/dist/utils/protectTableText.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineComponent as T, ref as r, watch as I, computed as i } from "vue";
|
|
2
|
+
import O from "../../wrappers/WpDrawer.vue.js";
|
|
3
|
+
import B from "../../wrappers/WpModal.vue.js";
|
|
4
|
+
import { useDisplayConditions as L, DISPLAY_CONDITIONS_TRANS_KEY as s } from "../../../composables/useDisplayConditions.js";
|
|
5
|
+
import { useTranslations as M } from "../../../composables/useTranslations.js";
|
|
6
|
+
import { useDisplayConditionStore as h } from "../../../stores/display-condition.js";
|
|
7
|
+
import { getTooltipOptions as C } from "../../../utils/tooltipUtils.js";
|
|
8
|
+
import { InSkeleton as $, InDropdownMenu as E, InButtonV2 as b, InBasicTextInput as k } from "@useinsider/design-system-vue";
|
|
9
|
+
import w from "./DisplayConditionListState.vue.js";
|
|
10
|
+
const ee = /* @__PURE__ */ T({
|
|
11
|
+
__name: "DisplayConditionSelectDrawer",
|
|
12
|
+
setup(A) {
|
|
13
|
+
const g = [40, 76, 76, 76], l = M(), t = h(), { loadList: c, select: v, deleteSaved: d, cancel: D, describeWithAcademyLink: p } = L(), u = r(""), a = r(null), n = r(null), o = r(!1);
|
|
14
|
+
I(() => t.isSelectOpen, (e) => {
|
|
15
|
+
e && (u.value = "", a.value = null, n.value = null, c());
|
|
16
|
+
}, { immediate: !0 });
|
|
17
|
+
const f = i(() => {
|
|
18
|
+
const e = u.value.trim().toLocaleLowerCase();
|
|
19
|
+
return e ? t.list.filter((m) => `${m.name} ${m.description}`.toLocaleLowerCase().includes(e)) : t.list;
|
|
20
|
+
}), y = i(() => t.listStatus === "error" ? "error" : t.list.length ? f.value.length ? null : "no-result" : "empty"), _ = i(() => p("select-description")), S = i(() => ({
|
|
21
|
+
cancelOrBackButton: {
|
|
22
|
+
styling: "ghost",
|
|
23
|
+
type: "secondary",
|
|
24
|
+
labelText: l(`${s}.back`),
|
|
25
|
+
leftIcon: "line-arrow-left"
|
|
26
|
+
}
|
|
27
|
+
})), x = i(() => ({
|
|
28
|
+
cancelOrBackButton: {
|
|
29
|
+
type: "secondary",
|
|
30
|
+
styling: "ghost",
|
|
31
|
+
labelText: l(`${s}.cancel`),
|
|
32
|
+
disabledStatus: o.value
|
|
33
|
+
},
|
|
34
|
+
primaryButton: {
|
|
35
|
+
type: "danger",
|
|
36
|
+
labelText: l(`${s}.delete`),
|
|
37
|
+
loadingStatus: o.value
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
return { __sfc: !0, SKELETON_HEIGHTS: g, trans: l, store: t, loadList: c, select: v, deleteSaved: d, cancel: D, describeWithAcademyLink: p, search: u, expandedId: a, menuId: n, isDeleting: o, filteredList: f, listState: y, descriptionText: _, footerButtonGroupOptions: S, deleteModalButtons: x, toggleExpanded: (e) => {
|
|
41
|
+
a.value = a.value === e.id ? null : e.id;
|
|
42
|
+
}, toggleMenu: (e) => {
|
|
43
|
+
n.value = n.value === e.id ? null : e.id;
|
|
44
|
+
}, closeMenu: (e) => {
|
|
45
|
+
n.value === e.id && (n.value = null);
|
|
46
|
+
}, expandTooltip: (e) => C(
|
|
47
|
+
`guido__display-condition-expand-tooltip-${e.id}`,
|
|
48
|
+
{ staticPosition: "top right" }
|
|
49
|
+
), menuOptions: (e) => [
|
|
50
|
+
{ text: l(`${s}.delete`), value: `guido__display-condition-delete-${e.id}` }
|
|
51
|
+
], requestDelete: (e) => {
|
|
52
|
+
n.value = null, t.pendingDelete = e;
|
|
53
|
+
}, confirmDelete: async () => {
|
|
54
|
+
!t.pendingDelete || o.value || (o.value = !0, await d(t.pendingDelete), o.value = !1);
|
|
55
|
+
}, closeDeleteModal: () => {
|
|
56
|
+
o.value || (t.pendingDelete = null);
|
|
57
|
+
}, codeOf: (e) => [e.codeBefore, e.codeAfter].filter(Boolean).join(`
|
|
58
|
+
`), WpDrawer: O, WpModal: B, KEY: s, InBasicTextInput: k, InButtonV2: b, InDropdownMenu: E, InSkeleton: $, DisplayConditionListState: w };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export {
|
|
62
|
+
ee as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import e from "./DisplayConditionsHost.vue2.js";
|
|
2
|
+
import n from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
3
|
+
var r = function() {
|
|
4
|
+
var s = this, o = s._self._c, t = s._self._setupProxy;
|
|
5
|
+
return o("div", { staticClass: "guido-display-conditions-host" }, [o(t.DisplayConditionCreateDrawer), o(t.DisplayConditionSelectDrawer)], 1);
|
|
6
|
+
}, i = [], a = /* @__PURE__ */ n(
|
|
7
|
+
e,
|
|
8
|
+
r,
|
|
9
|
+
i,
|
|
10
|
+
!1,
|
|
11
|
+
null,
|
|
12
|
+
null
|
|
13
|
+
);
|
|
14
|
+
const p = a.exports;
|
|
15
|
+
export {
|
|
16
|
+
p as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineComponent as i, onMounted as s, onBeforeUnmount as m } from "vue";
|
|
2
|
+
import { useDisplayConditions as p } from "../../../composables/useDisplayConditions.js";
|
|
3
|
+
import { DisplayConditionEvent as n } from "../../../enums/display-condition.js";
|
|
4
|
+
import { useDisplayConditionStore as a } from "../../../stores/display-condition.js";
|
|
5
|
+
import d from "./DisplayConditionCreateDrawer.vue.js";
|
|
6
|
+
import f from "./DisplayConditionSelectDrawer.vue.js";
|
|
7
|
+
const E = /* @__PURE__ */ i({
|
|
8
|
+
__name: "DisplayConditionsHost",
|
|
9
|
+
setup(l) {
|
|
10
|
+
const o = a(), { handleOpen: t } = p(), e = (r) => {
|
|
11
|
+
t(r.detail);
|
|
12
|
+
};
|
|
13
|
+
return s(() => {
|
|
14
|
+
o.$reset(), document.addEventListener(n.OPEN, e);
|
|
15
|
+
}), m(() => {
|
|
16
|
+
document.removeEventListener(n.OPEN, e), o.$reset();
|
|
17
|
+
}), { __sfc: !0, store: o, handleOpen: t, onOpen: e, DisplayConditionCreateDrawer: d, DisplayConditionSelectDrawer: f };
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
export {
|
|
21
|
+
E as default
|
|
22
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useConfigStore as
|
|
3
|
-
const
|
|
1
|
+
import l from "../extensions/ModulesTabIcons/extension.js";
|
|
2
|
+
import { useConfigStore as r } from "../stores/config.js";
|
|
3
|
+
const i = {
|
|
4
4
|
"amp-accordion": "ampAccordionEnabled",
|
|
5
5
|
"amp-carousel": "ampCarouselEnabled",
|
|
6
6
|
"amp-form-controls": "ampFormControlsEnabled",
|
|
@@ -14,7 +14,7 @@ const a = {
|
|
|
14
14
|
"text-block": "textEnabled",
|
|
15
15
|
"timer-block": "timerEnabled",
|
|
16
16
|
"video-block": "videoEnabled"
|
|
17
|
-
},
|
|
17
|
+
}, c = {
|
|
18
18
|
"dynamic-content": () => import("../extensions/DynamicContent/extension.js"),
|
|
19
19
|
"checkbox-block": () => import("../extensions/Blocks/Checkbox/extension.js"),
|
|
20
20
|
"radio-button-block": () => import("../extensions/Blocks/RadioButton/extension.js"),
|
|
@@ -22,40 +22,49 @@ const a = {
|
|
|
22
22
|
"unsubscribe-block": () => import("../extensions/Blocks/Unsubscribe/extension.js"),
|
|
23
23
|
"coupon-block": () => import("../extensions/Blocks/CouponBlock/extension.js"),
|
|
24
24
|
"items-block": () => import("../extensions/Blocks/Items/extension.js")
|
|
25
|
-
},
|
|
25
|
+
}, b = (n) => {
|
|
26
26
|
if (!n || !n.length)
|
|
27
27
|
return {};
|
|
28
28
|
const t = {};
|
|
29
29
|
return n.forEach((o) => {
|
|
30
|
-
const e =
|
|
30
|
+
const e = i[o];
|
|
31
31
|
e && (t[e] = !1);
|
|
32
32
|
}), t;
|
|
33
|
-
},
|
|
34
|
-
const t =
|
|
33
|
+
}, m = async ({ externalDisplayConditions: n }) => {
|
|
34
|
+
const t = [l];
|
|
35
|
+
if (n) {
|
|
36
|
+
const o = await import("../extensions/DisplayConditions/extension.js");
|
|
37
|
+
t.push(o.default);
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
}, d = async (n, t = { externalDisplayConditions: !1 }) => {
|
|
41
|
+
const o = await m(t);
|
|
35
42
|
if (!n || !n.length)
|
|
36
|
-
return
|
|
37
|
-
const
|
|
38
|
-
n.map(async (
|
|
39
|
-
const
|
|
40
|
-
return
|
|
43
|
+
return o;
|
|
44
|
+
const e = await Promise.all(
|
|
45
|
+
n.map(async (a) => {
|
|
46
|
+
const s = c[a];
|
|
47
|
+
return s ? (await s()).default : null;
|
|
41
48
|
})
|
|
42
49
|
);
|
|
43
50
|
return [
|
|
44
|
-
...
|
|
45
|
-
...
|
|
51
|
+
...o,
|
|
52
|
+
...e.filter((a) => a !== null)
|
|
46
53
|
];
|
|
47
|
-
},
|
|
48
|
-
const n =
|
|
54
|
+
}, k = () => {
|
|
55
|
+
const n = r();
|
|
49
56
|
return {
|
|
50
57
|
getStripoBlocksConfig: async () => {
|
|
51
58
|
const o = n.blocks;
|
|
52
59
|
return {
|
|
53
|
-
baseBlocks:
|
|
54
|
-
extensions: await
|
|
60
|
+
baseBlocks: b(o == null ? void 0 : o.excludeDefaults),
|
|
61
|
+
extensions: await d(o == null ? void 0 : o.includeCustoms, {
|
|
62
|
+
externalDisplayConditions: n.externalDisplayConditions
|
|
63
|
+
})
|
|
55
64
|
};
|
|
56
65
|
}
|
|
57
66
|
};
|
|
58
67
|
};
|
|
59
68
|
export {
|
|
60
|
-
|
|
69
|
+
k as useBlocksConfig
|
|
61
70
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useToaster as M } from "./useToaster.js";
|
|
2
|
+
import { useTranslations as x } from "./useTranslations.js";
|
|
3
|
+
import { ACADEMY_LINKS as L } from "../enums/academy.js";
|
|
4
|
+
import { DisplayConditionSourceType as y, DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as I } from "../enums/display-condition.js";
|
|
5
|
+
import { ToasterTypeOptions as l } from "../enums/toaster.js";
|
|
6
|
+
import { useDisplayConditionApi as O } from "../services/displayConditionApi.js";
|
|
7
|
+
import { useConfigStore as q } from "../stores/config.js";
|
|
8
|
+
import { useDisplayConditionStore as P } from "../stores/display-condition.js";
|
|
9
|
+
import { findInvalidCodeFields as Y, nextConditionId as w } from "../utils/displayCondition.js";
|
|
10
|
+
import { escapeHtml as R } from "../utils/htmlEscape.js";
|
|
11
|
+
import { computed as b } from "vue";
|
|
12
|
+
const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
|
|
13
|
+
id: w(),
|
|
14
|
+
name: n.name.trim(),
|
|
15
|
+
description: n.description.trim(),
|
|
16
|
+
beforeScript: n.codeBefore,
|
|
17
|
+
afterScript: n.codeAfter,
|
|
18
|
+
extraData: JSON.stringify(r === void 0 ? { source: m } : { source: m, savedId: r })
|
|
19
|
+
}), v = (n) => ({
|
|
20
|
+
name: n.name,
|
|
21
|
+
description: n.description,
|
|
22
|
+
codeBefore: n.codeBefore,
|
|
23
|
+
codeAfter: n.codeAfter
|
|
24
|
+
}), ne = () => {
|
|
25
|
+
const n = P(), m = q(), r = O(), o = x(), { showToaster: p } = M(), u = b(
|
|
26
|
+
() => m.isFeatureEnabled("liquidSyntax") ? "liquid" : "pongo"
|
|
27
|
+
), f = (e) => {
|
|
28
|
+
const t = { condition: e };
|
|
29
|
+
return document.dispatchEvent(new CustomEvent(I.APPLY, { detail: t })), n.close(), t.applied === !0;
|
|
30
|
+
}, D = () => {
|
|
31
|
+
n.view !== "none" && (document.dispatchEvent(new CustomEvent(I.CANCEL)), n.close());
|
|
32
|
+
}, N = (e) => {
|
|
33
|
+
if (e.mode === "select") {
|
|
34
|
+
n.openSelect();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
n.openCreate(e.mode === "edit" ? e.current : null);
|
|
38
|
+
}, $ = async () => {
|
|
39
|
+
const e = ++n.listRequest;
|
|
40
|
+
n.listStatus = "loading";
|
|
41
|
+
try {
|
|
42
|
+
const t = await r.list(u.value);
|
|
43
|
+
e === n.listRequest && (n.list = t, n.listStatus = "loaded");
|
|
44
|
+
} catch (t) {
|
|
45
|
+
console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
|
|
46
|
+
}
|
|
47
|
+
}, h = (e) => {
|
|
48
|
+
const t = {}, d = e.name.trim();
|
|
49
|
+
d ? d.length < s.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: s.NAME_MIN }) : d.length > s.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: s.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
|
|
50
|
+
const { DESCRIPTION_MAX: C } = s;
|
|
51
|
+
e.description.trim().length > C && (t.description = o(`${i}.error-description-max`, { max: C }));
|
|
52
|
+
const g = Y(e.codeBefore, e.codeAfter, u.value);
|
|
53
|
+
return ["codeBefore", "codeAfter"].forEach((a) => {
|
|
54
|
+
e[a].trim() ? g.includes(a) ? t[a] = o(`${i}.error-code-invalid`) : e[a].length > s.CODE_MAX && (t[a] = o(`${i}.error-code-max`, { max: s.CODE_MAX })) : t[a] = o(`${i}.error-code-required`);
|
|
55
|
+
}), t;
|
|
56
|
+
}, A = (e, t) => {
|
|
57
|
+
p(e ? { type: l.Success, message: t } : { type: l.Error, message: o("products.something-went-wrong") });
|
|
58
|
+
}, T = (e) => o(
|
|
59
|
+
`${i}.${e}`,
|
|
60
|
+
{
|
|
61
|
+
academyLink: `<a href="${L.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
|
|
62
|
+
}
|
|
63
|
+
), _ = () => {
|
|
64
|
+
p({ type: l.Error, message: o(`${i}.validation-failed`) });
|
|
65
|
+
}, c = (e) => ({ name: R(e) }), E = (e, t) => {
|
|
66
|
+
e != null && e.authReported || (console.warn(t, e), p({ type: l.Error, message: t }));
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
syntax: u,
|
|
70
|
+
handleOpen: N,
|
|
71
|
+
cancel: D,
|
|
72
|
+
loadList: $,
|
|
73
|
+
validate: h,
|
|
74
|
+
notifyInvalid: _,
|
|
75
|
+
describeWithAcademyLink: T,
|
|
76
|
+
createInline: (e) => {
|
|
77
|
+
A(
|
|
78
|
+
f(S(e, y.INLINE)),
|
|
79
|
+
o(`${i}.created`, c(e.name.trim()))
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
createAndSave: async (e) => {
|
|
83
|
+
try {
|
|
84
|
+
const t = await r.create(e, u.value);
|
|
85
|
+
return n.list = [t, ...n.list.filter((d) => d.id !== t.id)], A(
|
|
86
|
+
f(S(v(t), y.SAVED, t.id)),
|
|
87
|
+
o(`${i}.created-and-saved`, c(t.name))
|
|
88
|
+
), {};
|
|
89
|
+
} catch (t) {
|
|
90
|
+
return (t == null ? void 0 : t.status) === F ? { name: o(`${i}.error-name-exists`) } : (E(t, o(`${i}.save-failed`, c(e.name.trim()))), null);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
select: (e) => {
|
|
94
|
+
A(
|
|
95
|
+
f(S(v(e), y.SAVED, e.id)),
|
|
96
|
+
o(`${i}.applied`, c(e.name))
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
deleteSaved: async (e) => {
|
|
100
|
+
try {
|
|
101
|
+
await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
|
|
102
|
+
type: l.Success,
|
|
103
|
+
message: o(`${i}.deleted`, c(e.name))
|
|
104
|
+
});
|
|
105
|
+
} catch (t) {
|
|
106
|
+
E(t, o(`${i}.delete-failed`));
|
|
107
|
+
} finally {
|
|
108
|
+
n.pendingDelete = null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
B as DISPLAY_CONDITIONS_TRANS_KEY,
|
|
115
|
+
ne as useDisplayConditions
|
|
116
|
+
};
|
|
@@ -9,7 +9,8 @@ const useTranslations = () => {
|
|
|
9
9
|
var s;
|
|
10
10
|
const r = (s = translations.value) == null ? void 0 : s[t];
|
|
11
11
|
return r ? n ? Object.entries(n).reduce(
|
|
12
|
-
|
|
12
|
+
// A function replacer keeps `$&`, `$$` and `$1` in the value literal.
|
|
13
|
+
(i, [a, l]) => i.replace(new RegExp(`{${a}}`, "g"), () => String(l)),
|
|
13
14
|
r
|
|
14
15
|
) : r : (console.warn(`Translation key not found: ${t}`), t);
|
|
15
16
|
};
|
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
import { PRODUCT_WRAPPER_SELECTOR as
|
|
2
|
-
import { DefaultConfigValues as
|
|
3
|
-
import { protectLiquid as
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { PRODUCT_WRAPPER_SELECTOR as _, hasZeroWidthDeclaration as p, isZeroWidthValue as f, withWidthPin as y, PRODUCT_TD_SELECTOR as D, withoutZeroWidth as S } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
|
|
2
|
+
import { DefaultConfigValues as M } from "../../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
3
|
+
import { protectLiquid as h, restoreLiquid as T } from "../../../utils/liquidProtection.js";
|
|
4
|
+
import { protectTableText as E, restoreTableText as m } from "../../../utils/protectTableText.js";
|
|
5
|
+
const A = "MSO_ITEMS_HIDE_START", b = "MSO_ITEMS_HIDE_END", I = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", O = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price", g = ".ins-product-td td.product-image-class img[width]", H = Number(M.productImageWidth);
|
|
6
|
+
function P(t) {
|
|
6
7
|
if (!t.includes("vertical-price") || !t.includes("ins-product-cart"))
|
|
7
8
|
return t;
|
|
8
|
-
const s = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), o = new DOMParser().parseFromString(s, "text/html");
|
|
9
|
+
const s = E(t).replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), o = new DOMParser().parseFromString(s, "text/html");
|
|
9
10
|
let n = !1;
|
|
10
|
-
if (o.querySelectorAll(
|
|
11
|
+
if (o.querySelectorAll(O).forEach((e) => {
|
|
11
12
|
var d, u;
|
|
12
|
-
const
|
|
13
|
-
if (!/display\s*:\s*none/i.test(
|
|
13
|
+
const i = e.getAttribute("style") || "";
|
|
14
|
+
if (!/display\s*:\s*none/i.test(i))
|
|
14
15
|
return;
|
|
15
16
|
const l = e.previousSibling;
|
|
16
|
-
if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !==
|
|
17
|
-
const a =
|
|
18
|
-
e.setAttribute("style", `${
|
|
17
|
+
if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== A) && ((d = e.parentNode) == null || d.insertBefore(o.createComment(A), e), (u = e.parentNode) == null || u.insertBefore(o.createComment(b), e.nextSibling)), !/mso-hide/i.test(i)) {
|
|
18
|
+
const a = i.trim().endsWith(";") ? " " : "; ";
|
|
19
|
+
e.setAttribute("style", `${i}${a}${I}`);
|
|
19
20
|
}
|
|
20
21
|
n = !0;
|
|
21
22
|
}), !n)
|
|
22
23
|
return t;
|
|
23
|
-
const c = s.match(/<!DOCTYPE[^>]*>/i)
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const c = s.match(/<!DOCTYPE[^>]*>/i), r = c ? `${c[0]}
|
|
25
|
+
` : "";
|
|
26
|
+
return m((r + o.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function R(t) {
|
|
28
29
|
if (!t.includes("ins-product-wrapper") && !t.includes("ins-product-td"))
|
|
29
30
|
return t;
|
|
30
|
-
const s = new DOMParser().parseFromString(
|
|
31
|
+
const s = new DOMParser().parseFromString(h(E(t)), "text/html");
|
|
31
32
|
let o = !1;
|
|
32
|
-
if (s.querySelectorAll(
|
|
33
|
-
const e =
|
|
34
|
-
if (!
|
|
33
|
+
if (s.querySelectorAll(_).forEach((r) => {
|
|
34
|
+
const e = r.getAttribute("style") || "";
|
|
35
|
+
if (!p(e) && !f(r.getAttribute("width")))
|
|
35
36
|
return;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
}), s.querySelectorAll(
|
|
39
|
-
const e =
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
|
|
37
|
+
const i = y(e);
|
|
38
|
+
i !== e && (r.setAttribute("style", i), o = !0), f(r.getAttribute("width")) && (r.setAttribute("width", "100%"), o = !0);
|
|
39
|
+
}), s.querySelectorAll(D).forEach((r) => {
|
|
40
|
+
const e = r.getAttribute("style") || "";
|
|
41
|
+
if (p(e)) {
|
|
42
|
+
const i = S(e);
|
|
43
|
+
i ? r.setAttribute("style", i) : r.removeAttribute("style"), o = !0;
|
|
43
44
|
}
|
|
44
|
-
f(
|
|
45
|
+
f(r.getAttribute("width")) && (r.removeAttribute("width"), o = !0);
|
|
45
46
|
}), !o)
|
|
46
47
|
return t;
|
|
47
48
|
const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
|
|
48
49
|
` : "";
|
|
49
|
-
return
|
|
50
|
+
return m(T(c + s.documentElement.outerHTML));
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function x(t) {
|
|
52
53
|
if (!t.includes("product-image-class"))
|
|
53
54
|
return t;
|
|
54
|
-
const s = new DOMParser().parseFromString(
|
|
55
|
+
const s = new DOMParser().parseFromString(h(E(t)), "text/html");
|
|
55
56
|
let o = !1;
|
|
56
|
-
if (s.querySelectorAll(
|
|
57
|
+
if (s.querySelectorAll(g).forEach((r) => {
|
|
57
58
|
var u, a;
|
|
58
|
-
const e = ((u =
|
|
59
|
-
if (!/^\d+$/.test(e) || /(^|;)\s*min-width\s*:/i.test(
|
|
59
|
+
const e = ((u = r.getAttribute("width")) == null ? void 0 : u.trim()) ?? "", i = ((a = r.getAttribute("style")) == null ? void 0 : a.trim()) ?? "";
|
|
60
|
+
if (!/^\d+$/.test(e) || /(^|;)\s*min-width\s*:/i.test(i))
|
|
60
61
|
return;
|
|
61
|
-
const l =
|
|
62
|
-
|
|
62
|
+
const l = i && !i.endsWith(";") ? ";" : "", d = Math.min(Number(e), H);
|
|
63
|
+
r.setAttribute("style", `${i}${l}min-width:${d}px;max-width:${e}px`), o = !0;
|
|
63
64
|
}), !o)
|
|
64
65
|
return t;
|
|
65
66
|
const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
|
|
66
67
|
` : "";
|
|
67
|
-
return
|
|
68
|
+
return m(T(c + s.documentElement.outerHTML));
|
|
68
69
|
}
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
b as MSO_ITEMS_HIDE_END,
|
|
72
|
+
A as MSO_ITEMS_HIDE_START,
|
|
73
|
+
x as lockHorizontalItemImageWidths,
|
|
74
|
+
R as normalizeItemsBlockWidths,
|
|
75
|
+
P as wrapHiddenPriceTdsForOutlook
|
|
75
76
|
};
|