@useinsider/guido 1.0.3-beta.130c176 → 1.0.3-beta.154cb70
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 +3 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +92 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +94 -90
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/enums/productEnums.js +3 -2
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +3 -2
- package/dist/extensions/Blocks/Items/extension.js +7 -6
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +2 -2
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +17 -5
- package/dist/extensions/Blocks/Items/settingsPanel.js +25 -24
- package/dist/extensions/Blocks/Items/store/items-block.js +8 -4
- package/dist/extensions/Blocks/Items/template.js +65 -59
- package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +35 -26
- package/dist/extensions/Blocks/Items/utils/updateAttributes.js +29 -27
- package/dist/extensions/Blocks/Unsubscribe/block.js +34 -30
- package/dist/services/stripoApi.js +10 -10
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +6 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +3 -4
- package/package.json +1 -1
|
@@ -1,44 +1,46 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
1
|
+
import { ModificationDescription as p } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { configAttributes as t } from "../enums/productEnums.js";
|
|
3
|
-
import { DefaultConfigValues as
|
|
4
|
-
import { useItemsBlockStore as
|
|
5
|
-
import { getConfigBlock as
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
3
|
+
import { DefaultConfigValues as i } from "../enums/settingsEnums.js";
|
|
4
|
+
import { useItemsBlockStore as s } from "../store/items-block.js";
|
|
5
|
+
import { getConfigBlock as P } from "./configBlockUtils.js";
|
|
6
|
+
function M(n, O) {
|
|
7
|
+
const e = P(n);
|
|
8
|
+
if (!e)
|
|
9
9
|
return;
|
|
10
|
-
const
|
|
10
|
+
const c = s(), {
|
|
11
11
|
itemsType: r,
|
|
12
|
-
itemIds:
|
|
12
|
+
itemIds: C,
|
|
13
13
|
orientation: T,
|
|
14
14
|
nameTrimming: _,
|
|
15
|
-
hideDiscount:
|
|
16
|
-
formattedPrice:
|
|
17
|
-
currencySymbol:
|
|
18
|
-
currencyLocation:
|
|
15
|
+
hideDiscount: E,
|
|
16
|
+
formattedPrice: R,
|
|
17
|
+
currencySymbol: N,
|
|
18
|
+
currencyLocation: m,
|
|
19
|
+
priceOrientation: I,
|
|
19
20
|
buttonLink: a,
|
|
20
21
|
imageLink: f
|
|
21
|
-
} =
|
|
22
|
+
} = c, u = {
|
|
22
23
|
"data-source": r,
|
|
23
24
|
[t.TYPE]: r,
|
|
24
|
-
[t.ITEMS_INDEX_SELECT_CONTROL_VALUE]:
|
|
25
|
+
[t.ITEMS_INDEX_SELECT_CONTROL_VALUE]: C,
|
|
25
26
|
[t.ORIENTATION]: T,
|
|
26
27
|
[t.PRODUCT_NAME_TRIMMING]: _ ? "1" : "0",
|
|
27
|
-
[t.PRODUCT_PRICE_HIDE_DISCOUNT]:
|
|
28
|
-
[t.PRODUCT_PRICE_FORMATTED]:
|
|
29
|
-
[t.PRODUCT_PRICE_CURRENCY_SYMBOL]:
|
|
30
|
-
[t.PRODUCT_PRICE_CURRENCY_LOCATION]:
|
|
28
|
+
[t.PRODUCT_PRICE_HIDE_DISCOUNT]: E ? "1" : "0",
|
|
29
|
+
[t.PRODUCT_PRICE_FORMATTED]: R ? "1" : "0",
|
|
30
|
+
[t.PRODUCT_PRICE_CURRENCY_SYMBOL]: N || "",
|
|
31
|
+
[t.PRODUCT_PRICE_CURRENCY_LOCATION]: m || "0",
|
|
32
|
+
[t.PRODUCT_ORIGINAL_PRICE_CONTROL_ORIENTATION]: I || "horizontal",
|
|
31
33
|
[t.PRODUCT_BUTTON_LINK]: a || "",
|
|
32
34
|
[t.PRODUCT_IMAGE_LINK]: f || "",
|
|
33
|
-
[t.NAME_CONTROL_ENABLED]:
|
|
34
|
-
[t.QUANTITY_CONTROL_ENABLED]:
|
|
35
|
-
[t.PRICE_CONTROL_OPENED]:
|
|
35
|
+
[t.NAME_CONTROL_ENABLED]: i.productNameControlEnabled,
|
|
36
|
+
[t.QUANTITY_CONTROL_ENABLED]: i.productQuantityControlEnabled,
|
|
37
|
+
[t.PRICE_CONTROL_OPENED]: i.productPriceControlOpened
|
|
36
38
|
};
|
|
37
|
-
let o =
|
|
38
|
-
Object.entries(u).forEach(([
|
|
39
|
-
o = o.setAttribute(
|
|
40
|
-
}), o.apply(new
|
|
39
|
+
let o = O.getDocumentModifier().modifyHtml(e);
|
|
40
|
+
Object.entries(u).forEach(([D, l]) => {
|
|
41
|
+
o = o.setAttribute(D, l);
|
|
42
|
+
}), o.apply(new p("Update config block attributes from control"));
|
|
41
43
|
}
|
|
42
44
|
export {
|
|
43
|
-
|
|
45
|
+
M as updateConfigBlockAttributes
|
|
44
46
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (n, i, e) =>
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
5
|
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as
|
|
7
|
-
import { getDefaultTemplate as
|
|
6
|
+
import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as L } from "./template.js";
|
|
8
8
|
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
|
-
import { parsePageList as
|
|
10
|
-
const
|
|
9
|
+
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
+
const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
|
|
11
11
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
12
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class R extends h {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
u(this, "selectEventListener", null);
|
|
@@ -19,13 +19,13 @@ class D extends d {
|
|
|
19
19
|
u(this, "currentNode");
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return g;
|
|
23
23
|
}
|
|
24
24
|
getIcon() {
|
|
25
25
|
return "unsubscribe-icon";
|
|
26
26
|
}
|
|
27
27
|
getBlockCompositionType() {
|
|
28
|
-
return
|
|
28
|
+
return S.BLOCK;
|
|
29
29
|
}
|
|
30
30
|
getName() {
|
|
31
31
|
return this.api.translate("Unsubscribe Block");
|
|
@@ -34,13 +34,10 @@ class D extends d {
|
|
|
34
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
35
35
|
}
|
|
36
36
|
getTemplate() {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
onCreated(e) {
|
|
40
|
-
"getOuterHTML" in e && !e.getOuterHTML() || "getAttribute" in e && e.getAttribute("data-migration") || (this.currentNode = e, this._resetStoreState(), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
37
|
+
return L();
|
|
41
38
|
}
|
|
42
39
|
onSelect(e) {
|
|
43
|
-
this.currentNode = e, this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener();
|
|
40
|
+
this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
44
41
|
}
|
|
45
42
|
onDelete(e) {
|
|
46
43
|
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
|
|
@@ -66,7 +63,13 @@ class D extends d {
|
|
|
66
63
|
this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
|
|
67
64
|
}
|
|
68
65
|
_handleCancel() {
|
|
69
|
-
|
|
66
|
+
try {
|
|
67
|
+
if (!this.currentNode)
|
|
68
|
+
return;
|
|
69
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
_removeEventListeners() {
|
|
72
75
|
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
@@ -74,26 +77,27 @@ class D extends d {
|
|
|
74
77
|
_updateBlock(e, s) {
|
|
75
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
76
79
|
return;
|
|
77
|
-
const t = this.currentNode.querySelector(
|
|
80
|
+
const t = this.currentNode.querySelector(v);
|
|
78
81
|
if (!t)
|
|
79
82
|
return;
|
|
80
83
|
const r = this._getMergeTag(e);
|
|
81
84
|
this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
|
|
82
85
|
}
|
|
83
86
|
_getMergeTag(e) {
|
|
84
|
-
return
|
|
87
|
+
return T[e] ?? B;
|
|
85
88
|
}
|
|
86
89
|
_openDrawer() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
91
|
+
try {
|
|
92
|
+
const e = c();
|
|
93
|
+
e.typeSelectionDrawerStatus = !0;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
_checkExistingBlocks() {
|
|
95
99
|
const e = c();
|
|
96
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(
|
|
100
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
|
|
97
101
|
if ("getAttribute" in t) {
|
|
98
102
|
const r = t.getAttribute(o.PAGE_TYPE);
|
|
99
103
|
if (r) {
|
|
@@ -109,8 +113,8 @@ class D extends d {
|
|
|
109
113
|
const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
|
|
110
114
|
if (!s || !t)
|
|
111
115
|
return;
|
|
112
|
-
const r = c(), l = Number(s),
|
|
113
|
-
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(
|
|
116
|
+
const r = c(), l = Number(s), m = p(t);
|
|
117
|
+
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
|
|
114
118
|
}
|
|
115
119
|
_resetStoreState() {
|
|
116
120
|
c().$reset();
|
|
@@ -121,11 +125,11 @@ class D extends d {
|
|
|
121
125
|
const s = e.getAttribute(o.PAGE_LIST);
|
|
122
126
|
if (!s)
|
|
123
127
|
return;
|
|
124
|
-
const t = c(), r =
|
|
128
|
+
const t = c(), r = p(s);
|
|
125
129
|
t.removeUnsubscribePages(r);
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
g as UNSUBSCRIBE_BLOCK_ID,
|
|
134
|
+
R as UnsubscribeBlock
|
|
131
135
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useHttp as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
const
|
|
4
|
-
const { get: r } =
|
|
1
|
+
import { useHttp as a } from "../composables/useHttp.js";
|
|
2
|
+
import { useToaster as s } from "../composables/useToaster.js";
|
|
3
|
+
const m = () => {
|
|
4
|
+
const { get: r } = a(), { handleError: o } = s();
|
|
5
5
|
return {
|
|
6
6
|
getToken: async () => {
|
|
7
7
|
try {
|
|
8
8
|
const t = Number(localStorage.getItem("ins-guido-test-instance")), { data: e } = await r(`/stripo/get-user-token?test=${t}`);
|
|
9
9
|
return e.body.token;
|
|
10
10
|
} catch (t) {
|
|
11
|
-
return
|
|
11
|
+
return o(t, "Failed to fetch token"), "";
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
getCustomFonts: async () => {
|
|
@@ -19,7 +19,7 @@ const h = () => {
|
|
|
19
19
|
active: !0
|
|
20
20
|
}));
|
|
21
21
|
} catch (t) {
|
|
22
|
-
return
|
|
22
|
+
return o(t, "Failed to fetch custom fonts"), [];
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
getDefaultTemplate: async () => {
|
|
@@ -29,21 +29,21 @@ const h = () => {
|
|
|
29
29
|
forceRecreate: !0
|
|
30
30
|
};
|
|
31
31
|
try {
|
|
32
|
-
const
|
|
32
|
+
const { data: e } = await r("/stripo/default-template/0");
|
|
33
33
|
try {
|
|
34
34
|
return {
|
|
35
|
-
...JSON.parse(
|
|
35
|
+
...JSON.parse(e),
|
|
36
36
|
forceRecreate: !0
|
|
37
37
|
};
|
|
38
38
|
} catch {
|
|
39
39
|
return t;
|
|
40
40
|
}
|
|
41
41
|
} catch (e) {
|
|
42
|
-
return
|
|
42
|
+
return o(e, "Failed to fetch default template"), t;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
export {
|
|
48
|
-
|
|
48
|
+
m as useStripoApi
|
|
49
49
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
|
+
import { CommonControl } from '../../../common-control';
|
|
3
|
+
import { ItemsBlockControlId } from '../../enums/controlEnums';
|
|
4
|
+
export declare const CONTROL_BLOCK_ID = ItemsBlockControlId.PRICE_ORIENTATION;
|
|
5
|
+
export declare class PriceOrientationControl extends CommonControl {
|
|
6
|
+
private store;
|
|
7
|
+
getId(): string;
|
|
8
|
+
getTemplate(): string;
|
|
9
|
+
onRender(): void;
|
|
10
|
+
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
11
|
+
_onPriceOrientationChange(value: string): void;
|
|
12
|
+
private _updateHorizontalLayout;
|
|
13
|
+
private _updateVerticalLayout;
|
|
14
|
+
_getPriceOrientation(): string;
|
|
15
|
+
}
|
|
@@ -44,6 +44,7 @@ export declare enum ItemsBlockControlId {
|
|
|
44
44
|
PRICE_FORMATTED_PRICE = "items-block-price-formatted-price-control",
|
|
45
45
|
PRICE_CURRENCY_SYMBOL = "items-block-price-currency-symbol-control",
|
|
46
46
|
PRICE_CURRENCY_LOCATION = "items-block-price-currency-location-control",
|
|
47
|
+
PRICE_ORIENTATION = "items-block-price-orientation-control",
|
|
47
48
|
NAME_ALIGN = "items-block-name-align-control",
|
|
48
49
|
NAME_COLOR = "items-block-name-color-control",
|
|
49
50
|
NAME_SIZE = "items-block-name-size-control",
|
|
@@ -8,6 +8,7 @@ export declare const configAttributes: {
|
|
|
8
8
|
PRODUCT_PRICE_FORMATTED: string;
|
|
9
9
|
PRODUCT_PRICE_CURRENCY_SYMBOL: string;
|
|
10
10
|
PRODUCT_PRICE_CURRENCY_LOCATION: string;
|
|
11
|
+
PRODUCT_ORIGINAL_PRICE_CONTROL_ORIENTATION: string;
|
|
11
12
|
PRODUCT_BUTTON_LINK: string;
|
|
12
13
|
PRODUCT_IMAGE_LINK: string;
|
|
13
14
|
PRODUCT_NAME_CONTROL_VALUE: string;
|
|
@@ -10,6 +10,7 @@ interface ItemsBlockState {
|
|
|
10
10
|
currencySymbol: string;
|
|
11
11
|
currencyLocation: string;
|
|
12
12
|
formattedPrice: boolean;
|
|
13
|
+
priceOrientation: 'vertical' | 'horizontal';
|
|
13
14
|
templateData: {
|
|
14
15
|
imageSrc: string;
|
|
15
16
|
name: string;
|
|
@@ -30,6 +31,7 @@ export declare const useItemsBlockStore: import("pinia").StoreDefinition<"guidoI
|
|
|
30
31
|
setCurrencySymbol(currencySymbol: string): void;
|
|
31
32
|
setCurrencyLocation(currencyLocation: string): void;
|
|
32
33
|
setFormattedPrice(formattedPrice: boolean): void;
|
|
34
|
+
setPriceOrientation(priceOrientation: "vertical" | "horizontal"): void;
|
|
33
35
|
setTemplateData(templateData: ItemsBlockState["templateData"]): void;
|
|
34
36
|
updateFromAttributes(attributes: {
|
|
35
37
|
itemsType?: string;
|
|
@@ -42,3 +42,9 @@ export declare function syncButtonLinkFromAttributes(currentNode: ImmutableHtmlN
|
|
|
42
42
|
* @param currentNode - The current node from the control (usually this.currentNode)
|
|
43
43
|
*/
|
|
44
44
|
export declare function syncImageLinkFromAttributes(currentNode: ImmutableHtmlNode | undefined): void;
|
|
45
|
+
/**
|
|
46
|
+
* Reads price orientation value from esd-config-block attribute and updates the store.
|
|
47
|
+
* This makes the price orientation value mutable by syncing it from the DOM.
|
|
48
|
+
* @param currentNode - The current node from the control (usually this.currentNode)
|
|
49
|
+
*/
|
|
50
|
+
export declare function syncPriceOrientationFromAttributes(currentNode: ImmutableHtmlNode | undefined): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
3
|
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
4
|
export declare class UnsubscribeBlock extends Block {
|
|
@@ -12,9 +12,8 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
12
12
|
getName(): string;
|
|
13
13
|
getDescription(): string;
|
|
14
14
|
getTemplate(): string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onDelete(node: ImmutableHtmlNode): undefined;
|
|
15
|
+
onSelect(node: ImmutableHtmlElementNode): void;
|
|
16
|
+
onDelete(node: ImmutableHtmlElementNode): void;
|
|
18
17
|
onDestroy(): void;
|
|
19
18
|
private _setupSelectEventListener;
|
|
20
19
|
private _removeSelectEventListener;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "1.0.3-beta.
|
|
3
|
+
"version": "1.0.3-beta.154cb70",
|
|
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",
|