@useinsider/guido 3.21.2-beta.ccc7173 → 3.21.2-beta.d38b210
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 +41 -39
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +81 -79
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -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/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
- package/dist/composables/useBlocksConfig.js +32 -24
- package/dist/composables/useDisplayConditions.js +102 -0
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/DisplayConditions/bridge.js +17 -0
- package/dist/extensions/DisplayConditions/constants.js +17 -0
- package/dist/extensions/DisplayConditions/control.js +178 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +27 -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/services/displayConditionApi.js +39 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +59 -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/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 +16 -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 +6 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +23 -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 +166 -0
- package/dist/src/stores/display-condition.d.ts +81 -0
- package/dist/src/stores/unsubscribe.d.ts +0 -10
- package/dist/src/utils/displayCondition.d.ts +10 -0
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +28 -0
- package/dist/stores/unsubscribe.js +24 -28
- package/dist/utils/displayCondition.js +26 -0
- package/dist/utils/pairProductVariables.js +15 -14
- package/dist/utils/protectTableText.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AppliedDisplayCondition, SavedDisplayCondition } from '@@/Types/display-condition';
|
|
2
|
+
export type DisplayConditionView = 'none' | 'create' | 'select';
|
|
3
|
+
export type DisplayConditionListStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
4
|
+
interface DisplayConditionState {
|
|
5
|
+
view: DisplayConditionView;
|
|
6
|
+
editing: AppliedDisplayCondition | null;
|
|
7
|
+
list: SavedDisplayCondition[];
|
|
8
|
+
listStatus: DisplayConditionListStatus;
|
|
9
|
+
pendingDelete: SavedDisplayCondition | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const useDisplayConditionStore: import("pinia").StoreDefinition<"guidoDisplayCondition", DisplayConditionState, {
|
|
12
|
+
isCreateOpen: (state: {
|
|
13
|
+
view: DisplayConditionView;
|
|
14
|
+
editing: {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
beforeScript: string;
|
|
19
|
+
afterScript: string;
|
|
20
|
+
extraData?: string | undefined;
|
|
21
|
+
} | null;
|
|
22
|
+
list: {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
syntax: "liquid" | "pongo";
|
|
27
|
+
method: "codeOnly" | "logicBuilder";
|
|
28
|
+
codeBefore: string;
|
|
29
|
+
codeAfter: string;
|
|
30
|
+
createdAt?: string | undefined;
|
|
31
|
+
}[];
|
|
32
|
+
listStatus: DisplayConditionListStatus;
|
|
33
|
+
pendingDelete: {
|
|
34
|
+
id: number;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
syntax: "liquid" | "pongo";
|
|
38
|
+
method: "codeOnly" | "logicBuilder";
|
|
39
|
+
codeBefore: string;
|
|
40
|
+
codeAfter: string;
|
|
41
|
+
createdAt?: string | undefined;
|
|
42
|
+
} | null;
|
|
43
|
+
} & import("pinia").PiniaCustomStateProperties<DisplayConditionState>) => boolean;
|
|
44
|
+
isSelectOpen: (state: {
|
|
45
|
+
view: DisplayConditionView;
|
|
46
|
+
editing: {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
beforeScript: string;
|
|
51
|
+
afterScript: string;
|
|
52
|
+
extraData?: string | undefined;
|
|
53
|
+
} | null;
|
|
54
|
+
list: {
|
|
55
|
+
id: number;
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
syntax: "liquid" | "pongo";
|
|
59
|
+
method: "codeOnly" | "logicBuilder";
|
|
60
|
+
codeBefore: string;
|
|
61
|
+
codeAfter: string;
|
|
62
|
+
createdAt?: string | undefined;
|
|
63
|
+
}[];
|
|
64
|
+
listStatus: DisplayConditionListStatus;
|
|
65
|
+
pendingDelete: {
|
|
66
|
+
id: number;
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
syntax: "liquid" | "pongo";
|
|
70
|
+
method: "codeOnly" | "logicBuilder";
|
|
71
|
+
codeBefore: string;
|
|
72
|
+
codeAfter: string;
|
|
73
|
+
createdAt?: string | undefined;
|
|
74
|
+
} | null;
|
|
75
|
+
} & import("pinia").PiniaCustomStateProperties<DisplayConditionState>) => boolean;
|
|
76
|
+
}, {
|
|
77
|
+
openCreate(editing?: AppliedDisplayCondition | null): void;
|
|
78
|
+
openSelect(): void;
|
|
79
|
+
close(): void;
|
|
80
|
+
}>;
|
|
81
|
+
export {};
|
|
@@ -26,7 +26,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
26
26
|
createdAt: string;
|
|
27
27
|
updatedAt: string;
|
|
28
28
|
status: number;
|
|
29
|
-
isDefault?: boolean | undefined;
|
|
30
29
|
}[];
|
|
31
30
|
selectedTemplates: Record<number, number>;
|
|
32
31
|
selectedUnsubscribePages: number[];
|
|
@@ -52,7 +51,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
52
51
|
createdAt: string;
|
|
53
52
|
updatedAt: string;
|
|
54
53
|
status: number;
|
|
55
|
-
isDefault?: boolean | undefined;
|
|
56
54
|
}[];
|
|
57
55
|
selectedTemplates: Record<number, number>;
|
|
58
56
|
selectedUnsubscribePages: number[];
|
|
@@ -78,7 +76,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
78
76
|
createdAt: string;
|
|
79
77
|
updatedAt: string;
|
|
80
78
|
status: number;
|
|
81
|
-
isDefault?: boolean | undefined;
|
|
82
79
|
}[];
|
|
83
80
|
selectedTemplates: Record<number, number>;
|
|
84
81
|
selectedUnsubscribePages: number[];
|
|
@@ -102,7 +99,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
102
99
|
createdAt: string;
|
|
103
100
|
updatedAt: string;
|
|
104
101
|
status: number;
|
|
105
|
-
isDefault?: boolean | undefined;
|
|
106
102
|
}[];
|
|
107
103
|
getThumbnailByTemplateId: (state: {
|
|
108
104
|
templates: {
|
|
@@ -117,7 +113,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
117
113
|
createdAt: string;
|
|
118
114
|
updatedAt: string;
|
|
119
115
|
status: number;
|
|
120
|
-
isDefault?: boolean | undefined;
|
|
121
116
|
}[];
|
|
122
117
|
selectedTemplates: Record<number, number>;
|
|
123
118
|
selectedUnsubscribePages: number[];
|
|
@@ -143,7 +138,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
143
138
|
createdAt: string;
|
|
144
139
|
updatedAt: string;
|
|
145
140
|
status: number;
|
|
146
|
-
isDefault?: boolean | undefined;
|
|
147
141
|
}[];
|
|
148
142
|
selectedTemplates: Record<number, number>;
|
|
149
143
|
selectedUnsubscribePages: number[];
|
|
@@ -169,7 +163,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
169
163
|
createdAt: string;
|
|
170
164
|
updatedAt: string;
|
|
171
165
|
status: number;
|
|
172
|
-
isDefault?: boolean | undefined;
|
|
173
166
|
}[];
|
|
174
167
|
selectedTemplates: Record<number, number>;
|
|
175
168
|
selectedUnsubscribePages: number[];
|
|
@@ -195,7 +188,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
195
188
|
createdAt: string;
|
|
196
189
|
updatedAt: string;
|
|
197
190
|
status: number;
|
|
198
|
-
isDefault?: boolean | undefined;
|
|
199
191
|
}[];
|
|
200
192
|
selectedTemplates: Record<number, number>;
|
|
201
193
|
selectedUnsubscribePages: number[];
|
|
@@ -221,7 +213,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
221
213
|
createdAt: string;
|
|
222
214
|
updatedAt: string;
|
|
223
215
|
status: number;
|
|
224
|
-
isDefault?: boolean | undefined;
|
|
225
216
|
}[];
|
|
226
217
|
selectedTemplates: Record<number, number>;
|
|
227
218
|
selectedUnsubscribePages: number[];
|
|
@@ -247,7 +238,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
|
|
|
247
238
|
createdAt: string;
|
|
248
239
|
updatedAt: string;
|
|
249
240
|
status: number;
|
|
250
|
-
isDefault?: boolean | undefined;
|
|
251
241
|
}[];
|
|
252
242
|
selectedTemplates: Record<number, number>;
|
|
253
243
|
selectedUnsubscribePages: number[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppliedDisplayCondition, DisplayConditionSource } from '@@/Types/display-condition';
|
|
2
|
+
export declare const parseSource: (condition: AppliedDisplayCondition | null | undefined) => DisplayConditionSource | null;
|
|
3
|
+
type ConditionLike = Omit<AppliedDisplayCondition, 'description'> & {
|
|
4
|
+
description?: string | null;
|
|
5
|
+
};
|
|
6
|
+
export declare const toAppliedCondition: (condition: ConditionLike | null | undefined) => AppliedDisplayCondition | null;
|
|
7
|
+
export declare const nextConditionId: () => number;
|
|
8
|
+
export type CodeField = 'codeBefore' | 'codeAfter';
|
|
9
|
+
export declare const findInvalidCodeFields: (codeBefore: string, codeAfter: string) => CodeField[];
|
|
10
|
+
export {};
|
package/dist/stores/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MessageType as
|
|
1
|
+
import { MessageType as a } from "../@types/config/schemas.js";
|
|
2
2
|
import "../@types/config/defaults.js";
|
|
3
|
-
import { parseConfig as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
const g =
|
|
3
|
+
import { parseConfig as o } from "../@types/config/validator.js";
|
|
4
|
+
import { defineStore as l } from "pinia";
|
|
5
|
+
const g = l("guido-config", {
|
|
6
6
|
state: () => ({
|
|
7
7
|
initialized: !1,
|
|
8
8
|
config: null
|
|
@@ -132,7 +132,7 @@ const g = o("guido-config", {
|
|
|
132
132
|
* consumers stay safe in setup where a raw config read snapshots null (SD-147945).
|
|
133
133
|
*/
|
|
134
134
|
isTransactional() {
|
|
135
|
-
return this.messageType ===
|
|
135
|
+
return this.messageType === a.TRANSACTIONAL;
|
|
136
136
|
},
|
|
137
137
|
/**
|
|
138
138
|
* Soft-save policy: may the editor persist a template with validation errors?
|
|
@@ -158,6 +158,13 @@ const g = o("guido-config", {
|
|
|
158
158
|
var e, t;
|
|
159
159
|
return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
|
|
160
160
|
},
|
|
161
|
+
/**
|
|
162
|
+
* Check if the Insider display-condition UI replaces Stripo's
|
|
163
|
+
*/
|
|
164
|
+
externalDisplayConditions: (i) => {
|
|
165
|
+
var e, t, n, r;
|
|
166
|
+
return (((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.externalDisplayConditions) ?? !1) && (((r = (n = i.config) == null ? void 0 : n.features) == null ? void 0 : r.displayConditions) ?? !0);
|
|
167
|
+
},
|
|
161
168
|
/**
|
|
162
169
|
* Check if a specific feature is enabled.
|
|
163
170
|
* Returns false before init (config null) so header controls don't
|
|
@@ -174,7 +181,7 @@ const g = o("guido-config", {
|
|
|
174
181
|
* Initialize the config store with validated configuration
|
|
175
182
|
*/
|
|
176
183
|
init(i) {
|
|
177
|
-
const e =
|
|
184
|
+
const e = o(i);
|
|
178
185
|
this.config = e, this.initialized = !0;
|
|
179
186
|
},
|
|
180
187
|
/**
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineStore as i } from "pinia";
|
|
2
|
+
const n = i("guidoDisplayCondition", {
|
|
3
|
+
state: () => ({
|
|
4
|
+
view: "none",
|
|
5
|
+
editing: null,
|
|
6
|
+
list: [],
|
|
7
|
+
listStatus: "idle",
|
|
8
|
+
pendingDelete: null
|
|
9
|
+
}),
|
|
10
|
+
getters: {
|
|
11
|
+
isCreateOpen: (e) => e.view === "create",
|
|
12
|
+
isSelectOpen: (e) => e.view === "select"
|
|
13
|
+
},
|
|
14
|
+
actions: {
|
|
15
|
+
openCreate(e = null) {
|
|
16
|
+
this.editing = e, this.view = "create";
|
|
17
|
+
},
|
|
18
|
+
openSelect() {
|
|
19
|
+
this.editing = null, this.view = "select";
|
|
20
|
+
},
|
|
21
|
+
close() {
|
|
22
|
+
this.view = "none", this.pendingDelete = null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
n as useDisplayConditionStore
|
|
28
|
+
};
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { TYPE_COLLECTIONS as
|
|
1
|
+
import { TYPE_COLLECTIONS as i, PAGE_TYPES as p } from "../enums/unsubscribe.js";
|
|
2
2
|
import { useUnsubscribeApi as d } from "../services/unsubscribeApi.js";
|
|
3
3
|
import { defineStore as u } from "pinia";
|
|
4
4
|
let o = null;
|
|
5
|
-
const
|
|
5
|
+
const r = () => ({
|
|
6
6
|
templates: [],
|
|
7
7
|
selectedTemplates: {},
|
|
8
8
|
selectedUnsubscribePages: [],
|
|
9
|
-
selectedCollectionType:
|
|
10
|
-
activeType:
|
|
9
|
+
selectedCollectionType: p.GLOBAL_UNSUBSCRIBE,
|
|
10
|
+
activeType: p.GLOBAL_UNSUBSCRIBE,
|
|
11
11
|
pageSelectionUpdateStatus: !1,
|
|
12
12
|
pageSelectionDrawerStatus: !1,
|
|
13
13
|
typeSelectionDrawerStatus: !1,
|
|
14
14
|
isGlobalUnsubscribeDisabled: !1,
|
|
15
15
|
isSubscriptionPreferencesCenterDisabled: !1,
|
|
16
16
|
pendingBlockId: null
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
return [...e].sort((t, l) => +!!l.isDefault - +!!t.isDefault);
|
|
20
|
-
}
|
|
21
|
-
const f = u("guidoUnsubscribe", {
|
|
22
|
-
state: () => p(),
|
|
17
|
+
}), b = u("guidoUnsubscribe", {
|
|
18
|
+
state: () => r(),
|
|
23
19
|
getters: {
|
|
24
|
-
getSelectedCollection: (e) =>
|
|
20
|
+
getSelectedCollection: (e) => i[e.selectedCollectionType],
|
|
25
21
|
getSelectedTemplateByActiveType: (e) => e.selectedTemplates[e.activeType],
|
|
26
22
|
getTemplatesByActiveType: (e) => e.templates.filter((t) => t.type === e.activeType),
|
|
27
23
|
getThumbnailByTemplateId: (e) => (t) => {
|
|
@@ -29,31 +25,31 @@ const f = u("guidoUnsubscribe", {
|
|
|
29
25
|
return ((l = e.templates.find((s) => s.id === t)) == null ? void 0 : l.thumbnail) ?? "";
|
|
30
26
|
},
|
|
31
27
|
getSelectedUnsubscribePagesByCollection: (e) => (t) => {
|
|
32
|
-
const l =
|
|
28
|
+
const l = i[t];
|
|
33
29
|
if (!l)
|
|
34
30
|
return [];
|
|
35
31
|
const s = /* @__PURE__ */ new Map();
|
|
36
32
|
e.templates.forEach((n) => {
|
|
37
33
|
s.set(n.id, n.type);
|
|
38
34
|
});
|
|
39
|
-
const
|
|
35
|
+
const c = new Set(l);
|
|
40
36
|
return e.selectedUnsubscribePages.filter((n) => {
|
|
41
37
|
const a = s.get(n);
|
|
42
|
-
return a !== void 0 &&
|
|
38
|
+
return a !== void 0 && c.has(a);
|
|
43
39
|
});
|
|
44
40
|
},
|
|
45
41
|
isActiveTypeFirstInCollection: (e) => {
|
|
46
|
-
const t =
|
|
42
|
+
const t = i[e.selectedCollectionType] ?? [];
|
|
47
43
|
return e.activeType === t[0];
|
|
48
44
|
},
|
|
49
45
|
isActiveTypeLastInCollection: (e) => {
|
|
50
|
-
const t =
|
|
46
|
+
const t = i[e.selectedCollectionType] ?? [];
|
|
51
47
|
return e.activeType === t[t.length - 1];
|
|
52
48
|
},
|
|
53
49
|
hasTemplatesByCollectionType: (e) => {
|
|
54
50
|
const t = {};
|
|
55
|
-
return (
|
|
56
|
-
t[s] = e.templates.some((
|
|
51
|
+
return (i[e.selectedCollectionType] ?? []).forEach((s) => {
|
|
52
|
+
t[s] = e.templates.some((c) => c.type === s);
|
|
57
53
|
}), t;
|
|
58
54
|
},
|
|
59
55
|
unsubscribePagesStatus: (e) => e.selectedUnsubscribePages.length > 0
|
|
@@ -62,7 +58,7 @@ const f = u("guidoUnsubscribe", {
|
|
|
62
58
|
$reset() {
|
|
63
59
|
const { templates: e, selectedUnsubscribePages: t } = this;
|
|
64
60
|
Object.assign(this, {
|
|
65
|
-
...
|
|
61
|
+
...r(),
|
|
66
62
|
templates: e,
|
|
67
63
|
selectedUnsubscribePages: t
|
|
68
64
|
});
|
|
@@ -70,28 +66,28 @@ const f = u("guidoUnsubscribe", {
|
|
|
70
66
|
async fetchTemplates(e = !1) {
|
|
71
67
|
!e && this.templates.length || ((e || !o) && (o = (async () => {
|
|
72
68
|
const { getUnsubscribePages: t } = d();
|
|
73
|
-
this.templates =
|
|
69
|
+
this.templates = await t();
|
|
74
70
|
})().finally(() => {
|
|
75
71
|
o = null;
|
|
76
72
|
})), await o);
|
|
77
73
|
},
|
|
78
74
|
setCollection(e) {
|
|
79
75
|
this.selectedCollectionType = e;
|
|
80
|
-
const t =
|
|
76
|
+
const t = i[e];
|
|
81
77
|
if (t && t.length > 0) {
|
|
82
78
|
[this.activeType] = t;
|
|
83
79
|
const l = { ...this.selectedTemplates };
|
|
84
80
|
t.forEach((s) => {
|
|
85
81
|
if (!l[s]) {
|
|
86
|
-
const
|
|
87
|
-
|
|
82
|
+
const c = this.templates.find((n) => n.type === s);
|
|
83
|
+
c && (l[s] = c.id);
|
|
88
84
|
}
|
|
89
85
|
}), this.selectedTemplates = l;
|
|
90
86
|
}
|
|
91
87
|
},
|
|
92
88
|
setCollectionWithoutAutoSelection(e) {
|
|
93
89
|
this.selectedCollectionType = e;
|
|
94
|
-
const t =
|
|
90
|
+
const t = i[e];
|
|
95
91
|
t && t.length > 0 && ([this.activeType] = t);
|
|
96
92
|
},
|
|
97
93
|
setSelectedTemplate(e) {
|
|
@@ -111,12 +107,12 @@ const f = u("guidoUnsubscribe", {
|
|
|
111
107
|
loadSelectedTemplates(e) {
|
|
112
108
|
const t = new Map(this.templates.map((s) => [s.id, s.type])), l = { ...this.selectedTemplates };
|
|
113
109
|
e.forEach((s) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
110
|
+
const c = t.get(s);
|
|
111
|
+
c !== void 0 && (l[c] = s);
|
|
116
112
|
}), this.selectedTemplates = l;
|
|
117
113
|
},
|
|
118
114
|
getSelectedTemplatesByCollection(e) {
|
|
119
|
-
const t =
|
|
115
|
+
const t = i[e], l = [];
|
|
120
116
|
return t.forEach((s) => {
|
|
121
117
|
this.selectedTemplates[s] && l.push(this.selectedTemplates[s]);
|
|
122
118
|
}), l;
|
|
@@ -133,5 +129,5 @@ const f = u("guidoUnsubscribe", {
|
|
|
133
129
|
}
|
|
134
130
|
});
|
|
135
131
|
export {
|
|
136
|
-
|
|
132
|
+
b as useUnsubscribeStore
|
|
137
133
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DisplayConditionSourceType as d } from "../enums/display-condition.js";
|
|
2
|
+
const m = (e) => {
|
|
3
|
+
if (!e)
|
|
4
|
+
return null;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(e.extraData ?? "{}").source === d.INLINE ? "inline" : "saved";
|
|
7
|
+
} catch {
|
|
8
|
+
return "saved";
|
|
9
|
+
}
|
|
10
|
+
}, E = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
|
|
11
|
+
let o = 0;
|
|
12
|
+
const w = () => (o = Math.max(Date.now(), o + 1), o), f = /{%-?\s*(\w+)[\s\S]*?-?%}/g, p = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, u = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, l = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), h = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), S = (e) => /{%|%}|{{|}}/.test(e.replace(p, "")), C = (e, c) => {
|
|
13
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
14
|
+
return [["codeBefore", e], ["codeAfter", c]].forEach(([n, i]) => {
|
|
15
|
+
const a = i.replace(u, "");
|
|
16
|
+
S(a) && t.add(n), Array.from(a.matchAll(f), (s) => s[1]).forEach((s) => {
|
|
17
|
+
l.has(s) ? r.push(s) : s.startsWith("end") && l.has(s.slice(3)) ? r.pop() !== s.slice(3) && t.add(n) : h.has(s) && !r.length && t.add(n);
|
|
18
|
+
});
|
|
19
|
+
}), r.length && t.add("codeAfter"), [...t];
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
C as findInvalidCodeFields,
|
|
23
|
+
w as nextConditionId,
|
|
24
|
+
m as parseSource,
|
|
25
|
+
E as toAppliedCondition
|
|
26
|
+
};
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { ITEMS_CURRENCY_ATTR as
|
|
1
|
+
import { ITEMS_CURRENCY_ATTR as N, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
2
|
import { productPairs as w } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
3
|
import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
4
|
import { preserveTextStyles as P } from "./preserveTextStyles.js";
|
|
5
|
-
import {
|
|
5
|
+
import { protectTableText as v, restoreTableText as B } from "./protectTableText.js";
|
|
6
|
+
import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
|
|
6
7
|
const O = {
|
|
7
8
|
CART_ITEMS: "ins_apr",
|
|
8
9
|
BROWSED_ITEMS: "browsed_item",
|
|
9
10
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
11
|
}, q = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
-
function
|
|
12
|
+
function Q(S, y, b) {
|
|
12
13
|
let h = y;
|
|
13
14
|
for (; h > 0 && /\s/.test(S[h - 1]); )
|
|
14
15
|
h -= 1;
|
|
15
16
|
return b.some((I) => S.endsWith(I, h));
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
const y = q(S), b = new DOMParser().parseFromString(y, "text/html");
|
|
19
|
-
|
|
18
|
+
function rt(S) {
|
|
19
|
+
const y = q(v(S)), b = new DOMParser().parseFromString(y, "text/html");
|
|
20
|
+
j(b);
|
|
20
21
|
const h = w.PAIRS_FOR_EXTENSION;
|
|
21
22
|
Object.entries(h).forEach(([n, d]) => {
|
|
22
23
|
b.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
23
24
|
const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
|
|
24
25
|
r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
|
|
25
|
-
var $, F,
|
|
26
|
+
var $, F, x, D;
|
|
26
27
|
const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, f = d[g];
|
|
27
28
|
if (f)
|
|
28
29
|
switch (n) {
|
|
@@ -40,7 +41,7 @@ function Z(S) {
|
|
|
40
41
|
}
|
|
41
42
|
const i = (F = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : F.ATTR;
|
|
42
43
|
if (i && e.setAttribute("alt", `{{${i}_${o}}}`), a) {
|
|
43
|
-
const s = (
|
|
44
|
+
const s = (x = h.itemLink) == null ? void 0 : x[g];
|
|
44
45
|
if (s) {
|
|
45
46
|
const _ = s.HREF, R = s.DEFAULT_HREF || "#!", u = a.href;
|
|
46
47
|
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(R) || u === `${window.location.href}${R}` || !u || u === window.location.href) && (a.href = `{{${_}_${o}}}`);
|
|
@@ -60,18 +61,18 @@ function Z(S) {
|
|
|
60
61
|
}
|
|
61
62
|
case "price":
|
|
62
63
|
case "originalPrice": {
|
|
63
|
-
const e = f, a = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = a === "true", i = l === "true", s = t.getAttribute(
|
|
64
|
+
const e = f, a = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = a === "true", i = l === "true", s = t.getAttribute(N.POSITION) || "before";
|
|
64
65
|
let _;
|
|
65
66
|
i ? _ = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : _ = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
66
67
|
const R = e.CURRENCY;
|
|
67
68
|
let u = `{{${_}_${o}}}`;
|
|
68
|
-
const H = (t.getAttribute(
|
|
69
|
+
const H = (t.getAttribute(N.SYMBOL) || "").trim(), G = Y(H);
|
|
69
70
|
let C = "";
|
|
70
71
|
G ? C = H : R && (C = `{{${R}_${o}}}`), C && (u = s === "after" ? `${u} ${C}` : `${C} ${u}`), t.innerHTML = P(t, u);
|
|
71
72
|
break;
|
|
72
73
|
}
|
|
73
74
|
case "quantity": {
|
|
74
|
-
const e = f, a = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (
|
|
75
|
+
const e = f, a = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (D = t.textContent) == null ? void 0 : D.trim();
|
|
75
76
|
c && l.includes(c) && (t.innerHTML = P(t, `{{${a}_${o}}}`));
|
|
76
77
|
break;
|
|
77
78
|
}
|
|
@@ -139,12 +140,12 @@ function Z(S) {
|
|
|
139
140
|
const E = w.PAIRS_FOR_EXTENSION.price[d].PRICE, m = w.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, q(T)];
|
|
140
141
|
let g = "", o = 0, f = 0, $ = A.indexOf(r);
|
|
141
142
|
for (; $ !== -1; ) {
|
|
142
|
-
const F = p[f] === !0 && !
|
|
143
|
+
const F = p[f] === !0 && !Q(A, $, t);
|
|
143
144
|
g += A.slice(o, $) + (F ? `${T}${r}{% endif %}` : r), o = $ + r.length, f += 1, $ = A.indexOf(r, o);
|
|
144
145
|
}
|
|
145
146
|
A = g + A.slice(o);
|
|
146
|
-
}), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
147
|
+
}), B(A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
147
148
|
}
|
|
148
149
|
export {
|
|
149
|
-
|
|
150
|
+
rt as pairProductVariables
|
|
150
151
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const c = "guido-table-text:", l = new RegExp(`<!--${c}([A-Za-z0-9+/=]*)-->`, "g"), i = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr"]), T = /* @__PURE__ */ new Set([...o, "td", "th", "caption"]), d = (s) => btoa(unescape(encodeURIComponent(s))), f = (s) => decodeURIComponent(escape(atob(s))), p = (s) => {
|
|
2
|
+
const e = /^<(\/?)([a-zA-Z][\w-]*)/.exec(s);
|
|
3
|
+
return { name: e ? e[2].toLowerCase() : "", closing: e ? e[1] === "/" : !1 };
|
|
4
|
+
};
|
|
5
|
+
function u(s) {
|
|
6
|
+
const e = [];
|
|
7
|
+
let a = !1;
|
|
8
|
+
return s.replace(i, (t) => {
|
|
9
|
+
if (t.startsWith("<!--") || t.startsWith("{%"))
|
|
10
|
+
return t;
|
|
11
|
+
if (t.length > 1 && t.startsWith("<")) {
|
|
12
|
+
const { name: n, closing: r } = p(t);
|
|
13
|
+
return a = T.has(n), a && (r ? e.includes(n) && e.splice(e.lastIndexOf(n)) : e.push(n)), t;
|
|
14
|
+
}
|
|
15
|
+
return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${c}${d(t)}-->` : t;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const E = (s) => s.replace(l, (e, a) => f(a));
|
|
19
|
+
export {
|
|
20
|
+
u as protectTableText,
|
|
21
|
+
E as restoreTableText
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.21.2-beta.
|
|
3
|
+
"version": "3.21.2-beta.d38b210",
|
|
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",
|