@useinsider/guido 3.2.0-beta.da93bda → 3.2.0-beta.dc55d68
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/@types/config/schemas.js +150 -94
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +88 -87
- package/dist/composables/useRecommendation.js +16 -12
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/Recommendation/block.js +35 -32
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +21 -19
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +213 -0
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +56 -0
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/stores/config.d.ts +504 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/utils/htmlEscape.js +13 -0
- package/package.json +7 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (r, n, t) =>
|
|
4
|
-
import { BlockId as
|
|
5
|
-
import { getMigrationBannerHtml as
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var k = (r, n, t) => n in r ? I(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
|
|
3
|
+
var u = (r, n, t) => k(r, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { BlockId as _ } from "../../../enums/block.js";
|
|
5
|
+
import { getMigrationBannerHtml as B } from "../../../utils/migrationBannerHtml.js";
|
|
6
6
|
import { Block as b, BlockCompositionType as R, ModificationDescription as y } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
7
|
import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
|
|
8
8
|
import { ensureMobileCssRulesExist as g, setMobileLayoutOptOut as d, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
|
|
9
9
|
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
|
|
11
11
|
import { getDefaultTemplate as E } from "./templates/grid/template.js";
|
|
12
|
-
const f =
|
|
12
|
+
const f = _.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
|
|
13
13
|
let h = !1;
|
|
14
14
|
class q extends b {
|
|
15
15
|
constructor() {
|
|
@@ -38,7 +38,7 @@ class q extends b {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
getSettingsPanelTitleHtml() {
|
|
41
|
-
return
|
|
41
|
+
return B(
|
|
42
42
|
f,
|
|
43
43
|
this.api.translate("Recommendation Block"),
|
|
44
44
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
@@ -66,15 +66,18 @@ class q extends b {
|
|
|
66
66
|
* @param node - The newly created block node
|
|
67
67
|
*/
|
|
68
68
|
onCreated(t) {
|
|
69
|
-
const e = this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
i.
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const e = this._getRecommendationId(t);
|
|
70
|
+
if (e !== null && e > 0)
|
|
71
|
+
return;
|
|
72
|
+
const i = this._pendingBlockId ?? this._generateNextId();
|
|
73
|
+
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
74
|
+
const o = c.initializeConfig(this.api, t, { recommendationId: i }), s = p();
|
|
75
|
+
s.setCurrentBlock(i), g(this.api);
|
|
76
|
+
const a = this._getBlockElement(t);
|
|
77
|
+
a && (d(this.api, a, !0), C({
|
|
75
78
|
currentNode: t,
|
|
76
79
|
documentModifier: this.api.getDocumentModifier()
|
|
77
|
-
})),
|
|
80
|
+
})), s.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
|
|
78
81
|
}
|
|
79
82
|
/**
|
|
80
83
|
* Called when the document changes or template is loaded
|
|
@@ -97,10 +100,10 @@ class q extends b {
|
|
|
97
100
|
c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
98
101
|
try {
|
|
99
102
|
h || (g(this.api), h = !0);
|
|
100
|
-
const e = c.getConfig(t),
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
A(
|
|
103
|
+
const e = c.getConfig(t), i = this._getBlockElement(t);
|
|
104
|
+
if (i) {
|
|
105
|
+
const o = !e.mobileLayoutEnabled;
|
|
106
|
+
A(i) !== o && d(this.api, i, o);
|
|
104
107
|
}
|
|
105
108
|
} catch {
|
|
106
109
|
}
|
|
@@ -124,10 +127,10 @@ class q extends b {
|
|
|
124
127
|
let t = 0;
|
|
125
128
|
try {
|
|
126
129
|
const e = this.api.getDocumentRoot();
|
|
127
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
128
|
-
if ("getAttribute" in
|
|
129
|
-
const s =
|
|
130
|
-
|
|
130
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${l}`).forEach((o) => {
|
|
131
|
+
if ("getAttribute" in o) {
|
|
132
|
+
const s = o.getAttribute(m), a = s ? parseInt(s) : 0;
|
|
133
|
+
a > t && (t = a);
|
|
131
134
|
}
|
|
132
135
|
});
|
|
133
136
|
} catch {
|
|
@@ -141,11 +144,11 @@ class q extends b {
|
|
|
141
144
|
* added classes via setAttribute.
|
|
142
145
|
*/
|
|
143
146
|
_assignRecommendationId(t, e) {
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
147
|
+
const i = this._getBlockElement(t);
|
|
148
|
+
if (!i)
|
|
146
149
|
return;
|
|
147
|
-
const
|
|
148
|
-
|
|
150
|
+
const o = this.api.getDocumentModifier();
|
|
151
|
+
o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new y(`Assign recommendation ID ${e}`));
|
|
149
152
|
}
|
|
150
153
|
/**
|
|
151
154
|
* Gets the recommendation-id from a block node
|
|
@@ -154,11 +157,11 @@ class q extends b {
|
|
|
154
157
|
const e = this._getBlockElement(t);
|
|
155
158
|
if (!e || !("getAttribute" in e))
|
|
156
159
|
return null;
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
160
|
+
const i = e.getAttribute(m);
|
|
161
|
+
if (!i)
|
|
159
162
|
return null;
|
|
160
|
-
const
|
|
161
|
-
return Number.isNaN(
|
|
163
|
+
const o = parseInt(i);
|
|
164
|
+
return Number.isNaN(o) ? null : o;
|
|
162
165
|
}
|
|
163
166
|
/**
|
|
164
167
|
* Gets the block element (the element with BLOCK_CLASS)
|
|
@@ -166,10 +169,10 @@ class q extends b {
|
|
|
166
169
|
_getBlockElement(t) {
|
|
167
170
|
if ("getAttribute" in t) {
|
|
168
171
|
const e = t.getAttribute("class");
|
|
169
|
-
if (e && e.includes(
|
|
172
|
+
if (e && e.includes(l))
|
|
170
173
|
return t;
|
|
171
174
|
}
|
|
172
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
175
|
+
return "querySelector" in t ? t.querySelector(`.${l}`) ?? null : null;
|
|
173
176
|
}
|
|
174
177
|
/**
|
|
175
178
|
* Migrate configuration from legacy format
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_COLUMN_SPACING as R, DEFAULT_ROW_SPACING as U, DEFAULT_MOBILE_ROW_SPACING as i, DEFAULT_MOBILE_COLUMN_SPACING as s, DEFAULT_MOBILE_CARDS_IN_ROW as o, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
|
|
2
2
|
import { ATTR_PRODUCT_IMAGE as _, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as t, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as r, ATTR_PRODUCT_OMNIBUS_DISCOUNT as I, ATTR_PRODUCT_BUTTON as n } from "./selectors.js";
|
|
3
3
|
const O = {
|
|
4
4
|
code: "USD",
|
|
@@ -44,10 +44,10 @@ const O = {
|
|
|
44
44
|
mobileCardsInRow: o,
|
|
45
45
|
mobileLayoutEnabled: !1,
|
|
46
46
|
previousMobileCardsInRow: o,
|
|
47
|
-
columnSpacing:
|
|
48
|
-
rowSpacing:
|
|
49
|
-
mobileColumnSpacing:
|
|
50
|
-
mobileRowSpacing:
|
|
47
|
+
columnSpacing: R,
|
|
48
|
+
rowSpacing: U,
|
|
49
|
+
mobileColumnSpacing: s,
|
|
50
|
+
mobileRowSpacing: i,
|
|
51
51
|
// Composition
|
|
52
52
|
composition: a,
|
|
53
53
|
visibility: E,
|