@useinsider/guido 3.21.1-beta.f5fb7ac → 3.21.2-beta.cfc5be2

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.
Files changed (75) hide show
  1. package/README.md +1 -9
  2. package/dist/@types/config/schemas.js +19 -19
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +8 -8
  5. package/dist/components/Guido.vue2.js +74 -76
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  14. package/dist/composables/useBlocksConfig.js +32 -24
  15. package/dist/composables/useDisplayConditions.js +102 -0
  16. package/dist/composables/useModuleRepair.js +23 -32
  17. package/dist/config/compiler/utils/recommendationCompilerUtils.js +55 -53
  18. package/dist/config/migrator/index.js +9 -10
  19. package/dist/enums/academy.js +2 -2
  20. package/dist/enums/display-condition.js +12 -0
  21. package/dist/extensions/Blocks/Recommendation/block.js +52 -37
  22. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +76 -16
  23. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +16 -15
  24. package/dist/extensions/DisplayConditions/bridge.js +17 -0
  25. package/dist/extensions/DisplayConditions/constants.js +17 -0
  26. package/dist/extensions/DisplayConditions/control.js +178 -0
  27. package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
  28. package/dist/extensions/DisplayConditions/extension.js +28 -0
  29. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  30. package/dist/extensions/DisplayConditions/library.js +27 -0
  31. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  32. package/dist/guido.css +1 -1
  33. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  34. package/dist/node_modules/valibot/dist/index.js +297 -261
  35. package/dist/services/displayConditionApi.js +39 -0
  36. package/dist/src/@types/config/schemas.d.ts +4 -4
  37. package/dist/src/@types/display-condition.d.ts +59 -0
  38. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  39. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  40. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  41. package/dist/src/composables/useConfig.d.ts +2 -2
  42. package/dist/src/composables/useDisplayConditions.d.ts +16 -0
  43. package/dist/src/composables/useModuleRepair.d.ts +11 -2
  44. package/dist/src/enums/academy.d.ts +1 -1
  45. package/dist/src/enums/display-condition.d.ts +15 -0
  46. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +2 -0
  47. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +31 -17
  48. package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
  49. package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
  50. package/dist/src/extensions/DisplayConditions/control.d.ts +23 -0
  51. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  52. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  53. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  54. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  55. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  56. package/dist/src/services/displayConditionApi.d.ts +8 -0
  57. package/dist/src/stores/config.d.ts +166 -20
  58. package/dist/src/stores/display-condition.d.ts +81 -0
  59. package/dist/src/stores/editor.d.ts +0 -25
  60. package/dist/src/utils/displayCondition.d.ts +10 -0
  61. package/dist/src/utils/protectTableText.d.ts +2 -0
  62. package/dist/stores/config.js +13 -6
  63. package/dist/stores/display-condition.js +28 -0
  64. package/dist/stores/editor.js +14 -15
  65. package/dist/utils/displayCondition.js +26 -0
  66. package/dist/utils/pairProductVariables.js +15 -14
  67. package/dist/utils/protectTableText.js +22 -0
  68. package/package.json +1 -1
  69. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +0 -17
  70. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +0 -30
  71. package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +0 -16
  72. package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +0 -1
  73. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +0 -10
  74. package/dist/utils/legacyUnsubscribeConversion.js +0 -49
  75. /package/dist/src/components/organisms/{unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts → display-conditions/DisplayConditionCreateDrawer.vue.d.ts} +0 -0
@@ -8,7 +8,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
8
8
  hasChanges: boolean;
9
9
  changeSeq: number;
10
10
  isStripoInitialized: boolean;
11
- isLegacyUnsubscribeModalRequested: boolean;
12
11
  templateId: string;
13
12
  syncModulesEnabled: boolean;
14
13
  trackIdSessionFloor: number;
@@ -23,7 +22,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
23
22
  hasChanges: boolean;
24
23
  changeSeq: number;
25
24
  isStripoInitialized: boolean;
26
- isLegacyUnsubscribeModalRequested: boolean;
27
25
  templateId: string;
28
26
  syncModulesEnabled: boolean;
29
27
  trackIdSessionFloor: number;
@@ -37,7 +35,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
37
35
  hasChanges: boolean;
38
36
  changeSeq: number;
39
37
  isStripoInitialized: boolean;
40
- isLegacyUnsubscribeModalRequested: boolean;
41
38
  templateId: string;
42
39
  syncModulesEnabled: boolean;
43
40
  trackIdSessionFloor: number;
@@ -52,7 +49,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
52
49
  hasChanges: boolean;
53
50
  changeSeq: number;
54
51
  isStripoInitialized: boolean;
55
- isLegacyUnsubscribeModalRequested: boolean;
56
52
  templateId: string;
57
53
  syncModulesEnabled: boolean;
58
54
  trackIdSessionFloor: number;
@@ -66,7 +62,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
66
62
  hasChanges: boolean;
67
63
  changeSeq: number;
68
64
  isStripoInitialized: boolean;
69
- isLegacyUnsubscribeModalRequested: boolean;
70
65
  templateId: string;
71
66
  syncModulesEnabled: boolean;
72
67
  trackIdSessionFloor: number;
@@ -81,7 +76,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
81
76
  hasChanges: boolean;
82
77
  changeSeq: number;
83
78
  isStripoInitialized: boolean;
84
- isLegacyUnsubscribeModalRequested: boolean;
85
79
  templateId: string;
86
80
  syncModulesEnabled: boolean;
87
81
  trackIdSessionFloor: number;
@@ -95,7 +89,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
95
89
  hasChanges: boolean;
96
90
  changeSeq: number;
97
91
  isStripoInitialized: boolean;
98
- isLegacyUnsubscribeModalRequested: boolean;
99
92
  templateId: string;
100
93
  syncModulesEnabled: boolean;
101
94
  trackIdSessionFloor: number;
@@ -110,7 +103,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
110
103
  hasChanges: boolean;
111
104
  changeSeq: number;
112
105
  isStripoInitialized: boolean;
113
- isLegacyUnsubscribeModalRequested: boolean;
114
106
  templateId: string;
115
107
  syncModulesEnabled: boolean;
116
108
  trackIdSessionFloor: number;
@@ -124,7 +116,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
124
116
  hasChanges: boolean;
125
117
  changeSeq: number;
126
118
  isStripoInitialized: boolean;
127
- isLegacyUnsubscribeModalRequested: boolean;
128
119
  templateId: string;
129
120
  syncModulesEnabled: boolean;
130
121
  trackIdSessionFloor: number;
@@ -139,7 +130,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
139
130
  hasChanges: boolean;
140
131
  changeSeq: number;
141
132
  isStripoInitialized: boolean;
142
- isLegacyUnsubscribeModalRequested: boolean;
143
133
  templateId: string;
144
134
  syncModulesEnabled: boolean;
145
135
  trackIdSessionFloor: number;
@@ -153,7 +143,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
153
143
  hasChanges: boolean;
154
144
  changeSeq: number;
155
145
  isStripoInitialized: boolean;
156
- isLegacyUnsubscribeModalRequested: boolean;
157
146
  templateId: string;
158
147
  syncModulesEnabled: boolean;
159
148
  trackIdSessionFloor: number;
@@ -168,7 +157,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
168
157
  hasChanges: boolean;
169
158
  changeSeq: number;
170
159
  isStripoInitialized: boolean;
171
- isLegacyUnsubscribeModalRequested: boolean;
172
160
  templateId: string;
173
161
  syncModulesEnabled: boolean;
174
162
  trackIdSessionFloor: number;
@@ -182,7 +170,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
182
170
  hasChanges: boolean;
183
171
  changeSeq: number;
184
172
  isStripoInitialized: boolean;
185
- isLegacyUnsubscribeModalRequested: boolean;
186
173
  templateId: string;
187
174
  syncModulesEnabled: boolean;
188
175
  trackIdSessionFloor: number;
@@ -197,7 +184,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
197
184
  hasChanges: boolean;
198
185
  changeSeq: number;
199
186
  isStripoInitialized: boolean;
200
- isLegacyUnsubscribeModalRequested: boolean;
201
187
  templateId: string;
202
188
  syncModulesEnabled: boolean;
203
189
  trackIdSessionFloor: number;
@@ -211,7 +197,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
211
197
  hasChanges: boolean;
212
198
  changeSeq: number;
213
199
  isStripoInitialized: boolean;
214
- isLegacyUnsubscribeModalRequested: boolean;
215
200
  templateId: string;
216
201
  syncModulesEnabled: boolean;
217
202
  trackIdSessionFloor: number;
@@ -226,7 +211,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
226
211
  hasChanges: boolean;
227
212
  changeSeq: number;
228
213
  isStripoInitialized: boolean;
229
- isLegacyUnsubscribeModalRequested: boolean;
230
214
  templateId: string;
231
215
  syncModulesEnabled: boolean;
232
216
  trackIdSessionFloor: number;
@@ -240,7 +224,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
240
224
  hasChanges: boolean;
241
225
  changeSeq: number;
242
226
  isStripoInitialized: boolean;
243
- isLegacyUnsubscribeModalRequested: boolean;
244
227
  templateId: string;
245
228
  syncModulesEnabled: boolean;
246
229
  trackIdSessionFloor: number;
@@ -255,7 +238,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
255
238
  hasChanges: boolean;
256
239
  changeSeq: number;
257
240
  isStripoInitialized: boolean;
258
- isLegacyUnsubscribeModalRequested: boolean;
259
241
  templateId: string;
260
242
  syncModulesEnabled: boolean;
261
243
  trackIdSessionFloor: number;
@@ -269,7 +251,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
269
251
  hasChanges: boolean;
270
252
  changeSeq: number;
271
253
  isStripoInitialized: boolean;
272
- isLegacyUnsubscribeModalRequested: boolean;
273
254
  templateId: string;
274
255
  syncModulesEnabled: boolean;
275
256
  trackIdSessionFloor: number;
@@ -284,7 +265,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
284
265
  hasChanges: boolean;
285
266
  changeSeq: number;
286
267
  isStripoInitialized: boolean;
287
- isLegacyUnsubscribeModalRequested: boolean;
288
268
  templateId: string;
289
269
  syncModulesEnabled: boolean;
290
270
  trackIdSessionFloor: number;
@@ -298,7 +278,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
298
278
  hasChanges: boolean;
299
279
  changeSeq: number;
300
280
  isStripoInitialized: boolean;
301
- isLegacyUnsubscribeModalRequested: boolean;
302
281
  templateId: string;
303
282
  syncModulesEnabled: boolean;
304
283
  trackIdSessionFloor: number;
@@ -313,7 +292,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
313
292
  hasChanges: boolean;
314
293
  changeSeq: number;
315
294
  isStripoInitialized: boolean;
316
- isLegacyUnsubscribeModalRequested: boolean;
317
295
  templateId: string;
318
296
  syncModulesEnabled: boolean;
319
297
  trackIdSessionFloor: number;
@@ -327,7 +305,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
327
305
  hasChanges: boolean;
328
306
  changeSeq: number;
329
307
  isStripoInitialized: boolean;
330
- isLegacyUnsubscribeModalRequested: boolean;
331
308
  templateId: string;
332
309
  syncModulesEnabled: boolean;
333
310
  trackIdSessionFloor: number;
@@ -342,7 +319,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
342
319
  hasChanges: boolean;
343
320
  changeSeq: number;
344
321
  isStripoInitialized: boolean;
345
- isLegacyUnsubscribeModalRequested: boolean;
346
322
  templateId: string;
347
323
  syncModulesEnabled: boolean;
348
324
  trackIdSessionFloor: number;
@@ -356,7 +332,6 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
356
332
  hasChanges: boolean;
357
333
  changeSeq: number;
358
334
  isStripoInitialized: boolean;
359
- isLegacyUnsubscribeModalRequested: boolean;
360
335
  templateId: string;
361
336
  syncModulesEnabled: boolean;
362
337
  trackIdSessionFloor: 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 {};
@@ -0,0 +1,2 @@
1
+ export declare function protectTableText(html: string): string;
2
+ export declare const restoreTableText: (html: string) => string;
@@ -1,8 +1,8 @@
1
- import { MessageType as r } from "../@types/config/schemas.js";
1
+ import { MessageType as a } from "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
- import { parseConfig as a } from "../@types/config/validator.js";
4
- import { defineStore as o } from "pinia";
5
- const g = o("guido-config", {
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 === r.TRANSACTIONAL;
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 = a(i);
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,5 +1,5 @@
1
- import { defineStore as i } from "pinia";
2
- const o = i("guidoEditor", {
1
+ import { defineStore as e } from "pinia";
2
+ const o = e("guidoEditor", {
3
3
  state: () => ({
4
4
  loadingStatus: !0,
5
5
  isCodeEditorOpen: !1,
@@ -13,7 +13,6 @@ const o = i("guidoEditor", {
13
13
  // that need every change (the outbound state bridge) watch this instead.
14
14
  changeSeq: 0,
15
15
  isStripoInitialized: !1,
16
- isLegacyUnsubscribeModalRequested: !1,
17
16
  templateId: "",
18
17
  syncModulesEnabled: !1,
19
18
  // In-session id high-water mark; floors tracking-id minting so ids
@@ -22,20 +21,20 @@ const o = i("guidoEditor", {
22
21
  }),
23
22
  getters: {
24
23
  // Middle Slot
25
- isEditorToolbarVisible: (e) => !e.isVersionHistoryOpen && !e.isPreviewModeOpen,
26
- isUndoButtonDisabled: (e) => e.loadingStatus || e.isPreviewModeOpen,
27
- isRedoButtonDisabled: (e) => e.loadingStatus || e.isPreviewModeOpen,
28
- isCodeEditorButtonDisabled: (e) => e.loadingStatus || e.isPreviewModeOpen,
29
- isPreviewButtonDisabled: (e) => e.loadingStatus,
30
- isViewOptionsDisabled: (e) => e.loadingStatus || e.isPreviewModeOpen,
24
+ isEditorToolbarVisible: (i) => !i.isVersionHistoryOpen && !i.isPreviewModeOpen,
25
+ isUndoButtonDisabled: (i) => i.loadingStatus || i.isPreviewModeOpen,
26
+ isRedoButtonDisabled: (i) => i.loadingStatus || i.isPreviewModeOpen,
27
+ isCodeEditorButtonDisabled: (i) => i.loadingStatus || i.isPreviewModeOpen,
28
+ isPreviewButtonDisabled: (i) => i.loadingStatus,
29
+ isViewOptionsDisabled: (i) => i.loadingStatus || i.isPreviewModeOpen,
31
30
  // Right Slot
32
- isVersionHistoryButtonDisabled: (e) => e.loadingStatus || e.isPreviewModeOpen,
33
- isExportButtonDisabled: (e) => e.loadingStatus || e.isVersionHistoryOpen,
34
- isSaveAsButtonDisabled: (e) => e.loadingStatus || e.isVersionHistoryOpen,
35
- isTestButtonDisabled: (e) => e.loadingStatus || e.isVersionHistoryOpen,
36
- isSaveButtonDisabled: (e) => e.loadingStatus || e.isVersionHistoryOpen || e.isPreviewModeOpen,
31
+ isVersionHistoryButtonDisabled: (i) => i.loadingStatus || i.isPreviewModeOpen,
32
+ isExportButtonDisabled: (i) => i.loadingStatus || i.isVersionHistoryOpen,
33
+ isSaveAsButtonDisabled: (i) => i.loadingStatus || i.isVersionHistoryOpen,
34
+ isTestButtonDisabled: (i) => i.loadingStatus || i.isVersionHistoryOpen,
35
+ isSaveButtonDisabled: (i) => i.loadingStatus || i.isVersionHistoryOpen || i.isPreviewModeOpen,
37
36
  // Autosave
38
- isInSaveableState: (e) => !e.loadingStatus && !e.isVersionHistoryOpen && !e.isPreviewModeOpen && !e.isCodeEditorOpen
37
+ isInSaveableState: (i) => !i.loadingStatus && !i.isVersionHistoryOpen && !i.isPreviewModeOpen && !i.isCodeEditorOpen
39
38
  }
40
39
  });
41
40
  export {
@@ -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 x, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
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 { unwrapProductNameLinks as v } from "./unwrapProductNameLink.js";
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 B(S, y, b) {
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 Z(S) {
18
- const y = q(S), b = new DOMParser().parseFromString(y, "text/html");
19
- v(b);
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, D, N;
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 = (D = h.itemLink) == null ? void 0 : D[g];
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(x.POSITION) || "before";
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(x.SYMBOL) || "").trim(), G = Y(H);
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 = (N = t.textContent) == null ? void 0 : N.trim();
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 && !B(A, $, t);
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("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
147
+ }), B(A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
147
148
  }
148
149
  export {
149
- Z as pairProductVariables
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.1-beta.f5fb7ac",
3
+ "version": "3.21.2-beta.cfc5be2",
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",
@@ -1,17 +0,0 @@
1
- import s from "./LegacyUnsubscribeConvertedModal.vue2.js";
2
- import n from "../../../_virtual/_plugin-vue2_normalizer.js";
3
- var r = function() {
4
- var o = this, t = o._self._c, e = o._self._setupProxy;
5
- return e.isVisible ? t(e.WpModal, { attrs: { id: "guido__legacy-unsubscribe-converted-modal", state: "warning", "close-on-outside-click": !1, "footer-button-options": e.footerButtonOptions, title: e.trans("email-editor.legacy-unsubscribe-converted-modal-title") }, on: { close: e.close, "primary-action": e.close, "secondary-action": e.openAcademy } }, [t("p", [o._v(o._s(e.trans("email-editor.legacy-unsubscribe-converted-modal-message")))])]) : o._e();
6
- }, a = [], c = /* @__PURE__ */ n(
7
- s,
8
- r,
9
- a,
10
- !1,
11
- null,
12
- null
13
- );
14
- const d = c.exports;
15
- export {
16
- d as default
17
- };
@@ -1,30 +0,0 @@
1
- import { defineComponent as n, computed as t } from "vue";
2
- import i from "../../wrappers/WpModal.vue.js";
3
- import { useTranslations as a } from "../../../composables/useTranslations.js";
4
- import { ACADEMY_LINKS as c } from "../../../enums/academy.js";
5
- import { useEditorStore as p } from "../../../stores/editor.js";
6
- const L = /* @__PURE__ */ n({
7
- __name: "LegacyUnsubscribeConvertedModal",
8
- setup(d) {
9
- const o = a(), e = p(), r = t(
10
- () => e.isLegacyUnsubscribeModalRequested && e.isStripoInitialized
11
- ), s = t(() => ({
12
- secondaryButton: {
13
- type: "subtle-primary",
14
- labelText: o("email-editor.legacy-unsubscribe-converted-modal-visit-academy")
15
- },
16
- primaryButton: {
17
- type: "primary",
18
- labelText: o("action-builder.ok")
19
- }
20
- }));
21
- return { __sfc: !0, trans: o, editorStore: e, isVisible: r, footerButtonOptions: s, close: () => {
22
- e.isLegacyUnsubscribeModalRequested = !1;
23
- }, openAcademy: () => {
24
- window.open(c.LEGACY_UNSUBSCRIBE_MODULE, "_blank", "noopener,noreferrer");
25
- }, WpModal: i };
26
- }
27
- });
28
- export {
29
- L as default
30
- };
@@ -1,16 +0,0 @@
1
- import { useConfigStore as o } from "../../stores/config.js";
2
- import { useEditorStore as s } from "../../stores/editor.js";
3
- import { hasLegacyUnsubscribeClass as c, convertLegacyUnsubscribeInDocumentHtml as i } from "../../utils/legacyUnsubscribeConversion.js";
4
- const b = (e) => {
5
- try {
6
- if (!c(e) || !o().isFeatureEnabled("legacyUnsubscribeConversion"))
7
- return e;
8
- const { html: r, converted: t } = i(e);
9
- return t && (s().isLegacyUnsubscribeModalRequested = !0), r;
10
- } catch (r) {
11
- return console.error("LegacyUnsubscribeTextMigrator failed:", r), e;
12
- }
13
- };
14
- export {
15
- b as migrateLegacyUnsubscribeText
16
- };
@@ -1 +0,0 @@
1
- export declare const migrateLegacyUnsubscribeText: (html: string) => string;
@@ -1,10 +0,0 @@
1
- export declare const LEGACY_UNSUBSCRIBE_SELECTOR = "td.unsubscribe-block";
2
- export declare const LEGACY_UNSUBSCRIBE_LINK_SELECTORS: readonly ["a.unsubscribe-link", "a[href*=\"unsubscribe\"]"];
3
- export interface LegacyUnsubscribeConversionResult {
4
- html: string;
5
- converted: boolean;
6
- }
7
- export declare const hasLegacyUnsubscribeClass: (html: string) => boolean;
8
- export declare const convertLinklessLegacyUnsubscribeBlocks: (root: ParentNode) => number;
9
- export declare const convertLegacyUnsubscribeInModuleHtml: (html: string) => LegacyUnsubscribeConversionResult;
10
- export declare const convertLegacyUnsubscribeInDocumentHtml: (html: string) => LegacyUnsubscribeConversionResult;
@@ -1,49 +0,0 @@
1
- import { protectLiquid as a, restoreLiquid as u } from "./liquidProtection.js";
2
- const b = "td.unsubscribe-block", l = ["a.unsubscribe-link", 'a[href*="unsubscribe"]'], d = "esd-block-text", m = [
3
- "unsubscribe-block",
4
- "esd-extension",
5
- "esd-extension-block",
6
- "esd-unsubscribe-block",
7
- "esd-block-unsubscribe"
8
- ], L = "esd-extension-block-id", S = "data-unsubscribe-", E = "address,article,aside,blockquote,center,details,dialog,dir,div,dd,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,listing,main,menu,nav,ol,p,plaintext,pre,search,section,summary,table,ul,xmp", f = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?![\\w-])`, "i"), p = (e) => typeof e == "string" && f.test(e), y = (e) => l.some((t) => e.querySelector(t) !== null), g = (e) => {
9
- e.classList.remove(...m), e.classList.add(d), e.removeAttribute(L), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(S)).forEach(({ name: t }) => e.removeAttribute(t)), e.querySelector(E) || (e.innerHTML = `<p path="1">${e.innerHTML}</p>`);
10
- }, h = (e) => {
11
- const t = Array.from(e.querySelectorAll(b)).filter((r) => !y(r));
12
- return t.forEach(g), t.length;
13
- }, v = (e) => {
14
- const t = e.trimStart(), r = new DOMParser();
15
- return /^<t[dh][\s>]/i.test(t) ? r.parseFromString(`<table><tbody><tr>${e}</tr></tbody></table>`, "text/html").querySelector("tr") : /^<tr[\s>]/i.test(t) ? r.parseFromString(`<table><tbody>${e}</tbody></table>`, "text/html").querySelector("tbody") : /^<table[\s>]/i.test(t) ? r.parseFromString(e, "text/html").body : (console.debug("[LegacyUnsubscribeConversion] Skipped module with a non-table root"), null);
16
- }, c = (e) => {
17
- const t = e.search(/<html[\s>]/i), r = [...e.matchAll(/<\/html\s*>/gi)].at(-1), s = (r == null ? void 0 : r.index) === void 0 ? -1 : r.index + r[0].length;
18
- return t < 0 || s <= t ? { head: "", root: e, tail: "" } : { head: e.slice(0, t), root: e.slice(t, s), tail: e.slice(s) };
19
- }, i = (e, t, r, s) => {
20
- if (!p(e))
21
- return { html: e, converted: !1 };
22
- try {
23
- const o = a(e), n = t(o);
24
- return !n || h(n) === 0 ? { html: e, converted: !1 } : { html: u(r(n, o)), converted: !0 };
25
- } catch (o) {
26
- return console.error(`Failed to convert legacy unsubscribe blocks in ${s}:`, o), { html: e, converted: !1 };
27
- }
28
- }, C = (e) => i(
29
- e,
30
- v,
31
- (t) => t.innerHTML,
32
- "module"
33
- ), _ = (e) => i(
34
- e,
35
- (t) => new DOMParser().parseFromString(c(t).root, "text/html"),
36
- (t, r) => {
37
- const { head: s, tail: o } = c(r);
38
- return `${s}${t.documentElement.outerHTML}${o}`;
39
- },
40
- "document"
41
- );
42
- export {
43
- l as LEGACY_UNSUBSCRIBE_LINK_SELECTORS,
44
- b as LEGACY_UNSUBSCRIBE_SELECTOR,
45
- _ as convertLegacyUnsubscribeInDocumentHtml,
46
- C as convertLegacyUnsubscribeInModuleHtml,
47
- h as convertLinklessLegacyUnsubscribeBlocks,
48
- p as hasLegacyUnsubscribeClass
49
- };