@useinsider/guido 3.15.0-beta.afdb685 → 3.15.0-beta.bc7091e
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/useAllowlist.js +48 -30
- package/dist/composables/useHtmlCompiler.js +19 -16
- package/dist/composables/useHtmlValidator.js +50 -50
- package/dist/composables/useStripo.js +29 -30
- package/dist/config/compiler/htmlCompilerRules.js +34 -7
- package/dist/config/compiler/recommendationCompilerRules.js +30 -30
- package/dist/config/i18n/en/labels.json.js +7 -3
- package/dist/config/migrator/itemsBlockMigrator.js +1 -1
- package/dist/config/migrator/recommendation/compositionMapper.js +26 -23
- package/dist/config/migrator/recommendation/htmlBuilder.js +156 -155
- package/dist/enums/recommendation.js +17 -17
- package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +18 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +363 -322
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +271 -231
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +16 -16
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +16 -16
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +120 -120
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +55 -54
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +89 -0
- package/dist/extensions/Blocks/common-control.js +42 -35
- package/dist/src/composables/useHtmlValidator.d.ts +3 -2
- package/dist/src/config/migrator/recommendation/types.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +27 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +47 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useRecommendation as N } from "../../composables/useRecommendation.js";
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as C, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as A, HTML as g } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as O } from "./utils/recommendationCompilerUtils.js";
|
|
4
|
-
const
|
|
4
|
+
const P = "https://s3-eu-west-1.amazonaws.com/", D = (t) => t.replace("https://", P), U = [
|
|
5
5
|
{
|
|
6
6
|
id: "replace-images-with-variable-names",
|
|
7
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
8
8
|
type: "custom",
|
|
9
9
|
processor: (t) => {
|
|
10
10
|
let e = t;
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
e = e.replaceAll(
|
|
11
|
+
return Object.entries(C).forEach(([, i]) => {
|
|
12
|
+
Object.entries(i).forEach(([o, r]) => {
|
|
13
|
+
e = e.replaceAll(D(r), `{{${o}}}`).replaceAll(r, `{{${o}}}`);
|
|
14
14
|
});
|
|
15
15
|
}), e;
|
|
16
16
|
},
|
|
@@ -42,13 +42,13 @@ const H = [
|
|
|
42
42
|
description: "Adding recommendation unresponsive css",
|
|
43
43
|
type: "custom",
|
|
44
44
|
processor: (t) => {
|
|
45
|
-
const { calculateCardWidth: e, getRecommendationCampaignData:
|
|
45
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: i } = N();
|
|
46
46
|
let o = t;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
47
|
+
const r = o.match(d.ID);
|
|
48
|
+
if (r) {
|
|
49
49
|
const s = [];
|
|
50
|
-
if (
|
|
51
|
-
const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u =
|
|
50
|
+
if (r.forEach((c) => {
|
|
51
|
+
const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u = i(E);
|
|
52
52
|
u.textTrimming && u.orientation === $ && s.push(e(u));
|
|
53
53
|
}), s.length) {
|
|
54
54
|
const c = `width:${Math.min(...s)}px!important;`;
|
|
@@ -72,25 +72,25 @@ const H = [
|
|
|
72
72
|
type: "custom",
|
|
73
73
|
processor: (t) => {
|
|
74
74
|
let e = t;
|
|
75
|
-
const
|
|
76
|
-
return
|
|
77
|
-
const s =
|
|
75
|
+
const i = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: o } = N();
|
|
76
|
+
return i !== null && i.forEach((r) => {
|
|
77
|
+
const s = r.match(d.CUSTOM_FIELD);
|
|
78
78
|
if (!s)
|
|
79
79
|
return;
|
|
80
|
-
const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u =
|
|
80
|
+
const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = r.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
81
81
|
if (!m || !E || !u)
|
|
82
82
|
return;
|
|
83
|
-
const [
|
|
83
|
+
const [b] = m, [I] = E, [T] = u, _ = I.substring(1, I.length - 2), S = T.match(d.COMPOSITION) !== null;
|
|
84
84
|
let a = c;
|
|
85
85
|
if (S) {
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const f = b.substring(2, b.length - 3), l = o(f);
|
|
87
|
+
_ === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), _ === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
|
|
88
88
|
}
|
|
89
|
-
const R =
|
|
90
|
-
let
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
e = e.replace(
|
|
89
|
+
const R = b.substring(2);
|
|
90
|
+
let y = "";
|
|
91
|
+
_ in A.IF && (y = A.IF[_].replaceAll(`{${p.DISCOUNT}}`, `${R}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${R}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${R}${p.OMNIBUS_PRICE}`));
|
|
92
|
+
const h = `${T}${a}${g.PARAGRAPH_END_TAG}`, M = `${y}${S ? h : r}${A.ELSE}${T}${g.PARAGRAPH_END_TAG}${A.END_IF}`;
|
|
93
|
+
e = e.replace(r, M);
|
|
94
94
|
}), e;
|
|
95
95
|
},
|
|
96
96
|
priority: 53
|
|
@@ -114,7 +114,7 @@ const H = [
|
|
|
114
114
|
const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|data-same-price|product-attr|composition)="[^"]*"/g;
|
|
115
115
|
return t.replace(
|
|
116
116
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
117
|
-
(
|
|
117
|
+
(i, o) => `<!--REC_START-->${o.replace(e, "")}<!--REC_END-->`
|
|
118
118
|
);
|
|
119
119
|
},
|
|
120
120
|
priority: 55
|
|
@@ -146,9 +146,9 @@ const H = [
|
|
|
146
146
|
""
|
|
147
147
|
), e = e.replace(
|
|
148
148
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
149
|
-
(
|
|
150
|
-
const
|
|
151
|
-
return
|
|
149
|
+
(i, o) => {
|
|
150
|
+
const r = o.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
151
|
+
return r.every((m) => s.test(m)) ? "" : i;
|
|
152
152
|
}
|
|
153
153
|
)), e;
|
|
154
154
|
},
|
|
@@ -167,7 +167,7 @@ const H = [
|
|
|
167
167
|
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
168
168
|
(e) => e.replace(
|
|
169
169
|
/([;"]color:)([^;"]+)/g,
|
|
170
|
-
(
|
|
170
|
+
(i, o, r) => r.includes("!important") ? i : `${o}${r} !important`
|
|
171
171
|
)
|
|
172
172
|
),
|
|
173
173
|
priority: 58
|
|
@@ -184,8 +184,8 @@ const H = [
|
|
|
184
184
|
description: "Collapse whitespace inside recommendation blocks and strip boundary markers",
|
|
185
185
|
type: "custom",
|
|
186
186
|
processor: (t) => {
|
|
187
|
-
const e = (
|
|
188
|
-
return t.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (
|
|
187
|
+
const e = (i) => i.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (o) => o.replace(/\s+/g, " "));
|
|
188
|
+
return t.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (i, o) => e(o)).replaceAll("<!--REC_START-->", "").replaceAll("<!--REC_END-->", "");
|
|
189
189
|
},
|
|
190
190
|
priority: 99
|
|
191
191
|
},
|
|
@@ -208,5 +208,5 @@ const H = [
|
|
|
208
208
|
}
|
|
209
209
|
];
|
|
210
210
|
export {
|
|
211
|
-
|
|
211
|
+
U as recommendationCompilerRules
|
|
212
212
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e = "Items", o = {
|
|
1
|
+
const e = "Items", o = "Default", t = "Custom", s = {
|
|
2
2
|
"Global Styles & Layout": "Global Styles and Layout",
|
|
3
3
|
"Structures & Modules": "Structures and Modules",
|
|
4
4
|
"Recommendation Block": "Recommendation",
|
|
@@ -7,9 +7,13 @@ const e = "Items", o = {
|
|
|
7
7
|
"This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.": "This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.",
|
|
8
8
|
"Pixel Tracking Opt-in": "Pixel Tracking Opt-in",
|
|
9
9
|
"OPT-IN SELECTION": "OPT-IN SELECTION",
|
|
10
|
-
"UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS"
|
|
10
|
+
"UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS",
|
|
11
|
+
Default: o,
|
|
12
|
+
Custom: t
|
|
11
13
|
};
|
|
12
14
|
export {
|
|
15
|
+
t as Custom,
|
|
16
|
+
o as Default,
|
|
13
17
|
e as Items,
|
|
14
|
-
|
|
18
|
+
s as default
|
|
15
19
|
};
|
|
@@ -381,7 +381,7 @@ class H {
|
|
|
381
381
|
* Supports all block types by detecting prefix and using appropriate type:
|
|
382
382
|
*
|
|
383
383
|
* Examples:
|
|
384
|
-
* - {{ins_apr_img_1}} → https://
|
|
384
|
+
* - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
|
|
385
385
|
* - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
|
|
386
386
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
387
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_COMPOSITION as
|
|
1
|
+
import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
2
|
import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
3
|
import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
|
|
4
4
|
const C = "__title__", a = "product_attribute.";
|
|
@@ -23,19 +23,22 @@ function N(r) {
|
|
|
23
23
|
return { key: k, kind: "button" };
|
|
24
24
|
default:
|
|
25
25
|
if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const o = r.value ?? "", s = o.startsWith(a) ? o.slice(a.length) : o;
|
|
27
|
+
if (!s)
|
|
28
|
+
return null;
|
|
29
|
+
const e = o || `${a}${s}`;
|
|
30
|
+
return {
|
|
31
|
+
key: `${l}${e}`,
|
|
29
32
|
kind: "custom",
|
|
30
|
-
customAttrName:
|
|
31
|
-
customAttrValue:
|
|
32
|
-
}
|
|
33
|
+
customAttrName: s,
|
|
34
|
+
customAttrValue: e
|
|
35
|
+
};
|
|
33
36
|
}
|
|
34
37
|
return null;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
|
-
function
|
|
38
|
-
const t =
|
|
40
|
+
function _(r) {
|
|
41
|
+
const t = p.indexOf(r);
|
|
39
42
|
return t === -1 ? Number.POSITIVE_INFINITY : t;
|
|
40
43
|
}
|
|
41
44
|
function S(r) {
|
|
@@ -48,8 +51,8 @@ function S(r) {
|
|
|
48
51
|
anyTextTrimming: !1
|
|
49
52
|
};
|
|
50
53
|
if (!r || r.length === 0)
|
|
51
|
-
return t.composition = [...
|
|
52
|
-
const
|
|
54
|
+
return t.composition = [...p], t;
|
|
55
|
+
const o = [];
|
|
53
56
|
r.forEach((e, i) => {
|
|
54
57
|
const n = N(e);
|
|
55
58
|
if (n) {
|
|
@@ -57,7 +60,7 @@ function S(r) {
|
|
|
57
60
|
t.titleVariable = e;
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
o.push({
|
|
61
64
|
key: n.key,
|
|
62
65
|
kind: n.kind,
|
|
63
66
|
hidden: e.hidden === !0,
|
|
@@ -68,30 +71,30 @@ function S(r) {
|
|
|
68
71
|
originalIndex: i
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
|
-
}),
|
|
74
|
+
}), o.sort((e, i) => {
|
|
72
75
|
if (e.positionIdx !== i.positionIdx)
|
|
73
76
|
return e.positionIdx - i.positionIdx;
|
|
74
|
-
const n =
|
|
77
|
+
const n = _(e.key), u = _(i.key);
|
|
75
78
|
return n !== u ? n - u : e.originalIndex - i.originalIndex;
|
|
76
79
|
});
|
|
77
|
-
const
|
|
78
|
-
return
|
|
79
|
-
const { key: i, kind: n, hidden: u, legacy:
|
|
80
|
-
switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" &&
|
|
80
|
+
const s = {};
|
|
81
|
+
return o.forEach((e) => {
|
|
82
|
+
const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
|
|
83
|
+
switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && d && m && (t.customAttributes.includes(m) || t.customAttributes.push(m), t.customAttrValues[i] = m), n) {
|
|
81
84
|
case "image":
|
|
82
|
-
|
|
85
|
+
s[i] = b(c.theme);
|
|
83
86
|
break;
|
|
84
87
|
case "button":
|
|
85
|
-
|
|
88
|
+
s[i] = O(c.theme);
|
|
86
89
|
break;
|
|
87
90
|
case "text":
|
|
88
91
|
case "custom": {
|
|
89
|
-
const
|
|
90
|
-
|
|
92
|
+
const T = E(c.theme);
|
|
93
|
+
s[i] = T, T.textTrimming && (t.anyTextTrimming = !0);
|
|
91
94
|
break;
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
|
-
}), t.perElementStyles =
|
|
97
|
+
}), t.perElementStyles = s, t;
|
|
95
98
|
}
|
|
96
99
|
export {
|
|
97
100
|
S as mapComposition
|