@useinsider/guido 3.6.0-beta.4dae674 → 3.6.0-beta.590990f
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/composables/useSave.js +17 -16
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +24 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +11 -12
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +4 -6
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +17 -17
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +3 -0
- package/package.json +1 -1
- /package/dist/src/{extensions/Blocks/Recommendation/utils/priceFormatter.test.d.ts → composables/validators/useUnsubscribeBlockValidator.test.d.ts} +0 -0
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as y } from "./useConfig.js";
|
|
3
|
-
import { useSaveStart as w, useSaveComplete as
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { useStripoApi as
|
|
6
|
-
import { useTemplatePreparation as
|
|
7
|
-
import { useHtmlValidator as
|
|
3
|
+
import { useSaveStart as w, useSaveComplete as H } from "./useGuidoActions.js";
|
|
4
|
+
import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
|
|
5
|
+
import { useStripoApi as C } from "../services/stripoApi.js";
|
|
6
|
+
import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
|
|
7
|
+
import { useHtmlValidator as k } from "./useHtmlValidator.js";
|
|
8
8
|
import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
|
|
9
9
|
import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import { useUnsubscribeBlockValidator as B } from "./validators/useUnsubscribeBlockValidator.js";
|
|
11
|
+
const J = () => {
|
|
12
|
+
const o = w(), s = H(), { validateHtml: r } = k(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { validateUnsubscribeBlockUniqueness: d } = B(), { callbacks: i, isFeatureEnabled: u } = y(), { extractSyncModuleData: c } = q(), { setSyncModuleUnsubscriptionPages: m } = C(), { editorSave: p } = x();
|
|
13
|
+
return { save: async (f = !1, v = !1) => {
|
|
14
|
+
var a;
|
|
14
15
|
o();
|
|
15
|
-
const { prepareTemplateDetails:
|
|
16
|
-
if (!l(t.compiledHtml))
|
|
16
|
+
const { prepareTemplateDetails: S } = E(), t = await S();
|
|
17
|
+
if (!l(t.compiledHtml) || !d(t.compiledHtml))
|
|
17
18
|
return;
|
|
18
|
-
if (
|
|
19
|
+
if (u("liquidSyntax")) {
|
|
19
20
|
if (!await n(t.compiledHtml))
|
|
20
21
|
return;
|
|
21
22
|
} else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
|
|
22
23
|
return;
|
|
23
|
-
if ((
|
|
24
|
+
if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await p())
|
|
24
25
|
return;
|
|
25
|
-
const { unsubscribePayload:
|
|
26
|
-
return await
|
|
26
|
+
const { unsubscribePayload: V, stripoModules: b } = c(t.rawHtml);
|
|
27
|
+
return await m(V), t.modules = b, f || s({ ...t, silent: v }), t;
|
|
27
28
|
} };
|
|
28
29
|
};
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
J as useSave
|
|
31
32
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ToasterTypeOptions as p } from "../../enums/toaster.js";
|
|
2
|
+
import { PAGE_TYPES as n } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { DATA_ATTRIBUTES as b } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
+
import { useToaster as f } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
6
|
+
const E = ".unsubscribe-block-v2", C = () => {
|
|
7
|
+
const { showToaster: i } = f(), r = m();
|
|
8
|
+
return { validateUnsubscribeBlockUniqueness: (c) => {
|
|
9
|
+
const u = new DOMParser().parseFromString(c, "text/html"), a = Array.from(u.querySelectorAll(E));
|
|
10
|
+
let s = 0, t = 0;
|
|
11
|
+
a.forEach((l) => {
|
|
12
|
+
const o = Number(l.getAttribute(b.PAGE_TYPE));
|
|
13
|
+
o === n.GLOBAL_UNSUBSCRIBE ? s += 1 : o === n.SUBSCRIPTION_PREFERENCE_CENTER && (t += 1);
|
|
14
|
+
});
|
|
15
|
+
const e = [];
|
|
16
|
+
return s > 1 && e.push(r("unsubscription-preference.global-unsub-added")), t > 1 && e.push(r("unsubscription-preference.pref-center-added")), e.length ? (i({
|
|
17
|
+
type: p.Alert,
|
|
18
|
+
message: e.join(" ")
|
|
19
|
+
}), !1) : !0;
|
|
20
|
+
} };
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
C as useUnsubscribeBlockValidator
|
|
24
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var r = (o, e, t) =>
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var p = (o, e, t) => e in o ? O(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var r = (o, e, t) => p(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as N } from "../../../common-control.js";
|
|
6
6
|
import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
|
|
@@ -9,9 +9,9 @@ import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
|
|
|
9
9
|
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
|
|
11
11
|
import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
|
|
12
|
-
const U = "recommendation-layout-orientation-control",
|
|
12
|
+
const U = "recommendation-layout-orientation-control", A = "recommendationInfoBannerTest", a = {
|
|
13
13
|
LAYOUT: "layout"
|
|
14
|
-
}, y = "data-card-composition",
|
|
14
|
+
}, y = "data-card-composition", i = {
|
|
15
15
|
LAYOUT: "data-layout",
|
|
16
16
|
COLUMN_SPACING: "data-column-spacing",
|
|
17
17
|
ROW_SPACING: "data-row-spacing",
|
|
@@ -30,7 +30,7 @@ class Y extends N {
|
|
|
30
30
|
getTemplate() {
|
|
31
31
|
return `
|
|
32
32
|
<div class="layout-control-container">
|
|
33
|
-
${this._GuOnPageMessage({ name:
|
|
33
|
+
${this._GuOnPageMessage({ name: A })}
|
|
34
34
|
|
|
35
35
|
${this._GuTwoColumns([
|
|
36
36
|
this._GuLabel({ text: this.api.translate("Layout Orientation") }),
|
|
@@ -44,11 +44,10 @@ class Y extends N {
|
|
|
44
44
|
}
|
|
45
45
|
onRender() {
|
|
46
46
|
this._setInfoMessageValue(
|
|
47
|
-
|
|
47
|
+
A,
|
|
48
48
|
this.api.translate(
|
|
49
|
-
`Note that updating the Layout Orientation, Number of Products
|
|
50
|
-
Products in One Row
|
|
51
|
-
resets the style of your Recommendation block.`
|
|
49
|
+
`Note that updating the Layout Orientation, Number of Products and
|
|
50
|
+
Products in One Row settings resets the style of your Recommendation block.`
|
|
52
51
|
)
|
|
53
52
|
), this._setFormValues(), this._listenToFormUpdates();
|
|
54
53
|
}
|
|
@@ -84,8 +83,8 @@ class Y extends N {
|
|
|
84
83
|
},
|
|
85
84
|
`Changed layout to ${t}`
|
|
86
85
|
), this.store.patchCurrentBlockConfig({ orientation: t });
|
|
87
|
-
const
|
|
88
|
-
t === "list" ? (
|
|
86
|
+
const n = this.api.getDocumentModifier().modifyHtml(c).setAttribute(i.LAYOUT, t).setAttribute(i.COLUMN_SPACING, g.toString()).setAttribute(i.ROW_SPACING, l.toString()).setAttribute(i.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(i.MOBILE_ROW_SPACING, m.toString());
|
|
87
|
+
t === "list" ? (n.setClass("es-m-p0"), n.setClass("ins-recommendation-list-layout")) : (n.removeClass("es-m-p0"), n.removeClass("ins-recommendation-list-layout")), n.setAttribute(y, _.join(",")).setAttribute(L, "[]"), n.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
89
88
|
} finally {
|
|
90
89
|
this.isChangingLayout = !1;
|
|
91
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RecommendationBlockId as s } from "../../constants/blockIds.js";
|
|
2
|
-
import { ATTR_PRODUCT_ATTR as u, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_BUTTON as m, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as
|
|
2
|
+
import { ATTR_PRODUCT_ATTR as u, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_BUTTON as m, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as _, ATTR_PRODUCT_IMAGE as x } from "../../constants/selectors.js";
|
|
3
3
|
import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
|
|
4
4
|
import { formatPrice as C } from "../../utils/priceFormatter.js";
|
|
5
5
|
import { CUSTOM_CELL_HTML as R, sanitizeImageUrl as O } from "../utils.js";
|
|
@@ -23,7 +23,7 @@ function i(t, e = "price") {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
const S = {
|
|
26
|
-
[
|
|
26
|
+
[x]: (t) => `
|
|
27
27
|
<td class="${l}" style="padding: ${a}; height: 100%;" valign="top">
|
|
28
28
|
<table
|
|
29
29
|
class="product-card-segment"
|
|
@@ -51,7 +51,7 @@ const S = {
|
|
|
51
51
|
</table>
|
|
52
52
|
</td>
|
|
53
53
|
`,
|
|
54
|
-
[
|
|
54
|
+
[_]: (t) => `
|
|
55
55
|
<td class="${l}" style="padding: ${a}; height: 100%;" valign="middle">
|
|
56
56
|
<table
|
|
57
57
|
class="product-card-segment"
|
|
@@ -115,9 +115,7 @@ const S = {
|
|
|
115
115
|
class="esd-block-text product-old-price es-p15l es-p15r"
|
|
116
116
|
align="center"
|
|
117
117
|
esd-extension-block-id="${s.OLD_PRICE}">
|
|
118
|
-
<p
|
|
119
|
-
contenteditable="false"
|
|
120
|
-
style="font-size: 14px; color: #999999; text-decoration: line-through;">
|
|
118
|
+
<p contenteditable="false" style="font-size: 14px; color: #999999;">
|
|
121
119
|
<strong>${i(t, "original_price")}</strong>
|
|
122
120
|
</p>
|
|
123
121
|
</td>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
function d(
|
|
2
|
-
const { thousandSeparator:
|
|
1
|
+
function d(a, t) {
|
|
2
|
+
const { thousandSeparator: s, decimalSeparator: e, decimalCount: r } = t, u = Math.abs(a).toFixed(r), [c, o] = u.split("."), n = c.replace(
|
|
3
3
|
/\B(?=(\d{3})+(?!\d))/g,
|
|
4
|
-
|
|
5
|
-
);
|
|
6
|
-
return r > 0 &&
|
|
4
|
+
s
|
|
5
|
+
), i = a < 0 ? "-" : "";
|
|
6
|
+
return r > 0 && o ? `${i}${n}${e}${o}` : `${i}${n}`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const { price: t, currency:
|
|
8
|
+
function m(a) {
|
|
9
|
+
const { price: t, currency: s } = a, {
|
|
10
10
|
symbol: e,
|
|
11
11
|
alignment: r,
|
|
12
12
|
thousandSeparator: u,
|
|
13
|
-
decimalSeparator:
|
|
14
|
-
decimalCount:
|
|
15
|
-
} =
|
|
13
|
+
decimalSeparator: c,
|
|
14
|
+
decimalCount: o
|
|
15
|
+
} = s;
|
|
16
16
|
if (typeof t != "number" || Number.isNaN(t)) {
|
|
17
|
-
const
|
|
18
|
-
return r === "before" ? `${e} ${
|
|
17
|
+
const i = "0".repeat(o), $ = `0${c}${i}`;
|
|
18
|
+
return r === "before" ? `${e} ${$}` : `${$} ${e}`;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const n = d(t, {
|
|
21
21
|
thousandSeparator: u,
|
|
22
|
-
decimalSeparator:
|
|
23
|
-
decimalCount:
|
|
22
|
+
decimalSeparator: c,
|
|
23
|
+
decimalCount: o
|
|
24
24
|
});
|
|
25
|
-
return r === "before" ? `${e} ${
|
|
25
|
+
return r === "before" ? `${e} ${n}` : `${n} ${e}`;
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
m as formatPrice
|
|
29
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.590990f",
|
|
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",
|