@useinsider/guido 3.5.1 → 3.6.0-beta.0e98cf4
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/useRecommendation.js +24 -28
- package/dist/composables/useStripo.js +12 -11
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +84 -78
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +127 -123
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +51 -47
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +46 -46
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +31 -27
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +28 -28
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +56 -49
- package/dist/package.json.js +1 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.test.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DEFAULT_PRODUCTS_PER_ROW as
|
|
2
|
-
import { getDefaultProducts as
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
1
|
+
import { DEFAULT_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
|
|
2
|
+
import { getDefaultProducts as I, DEFAULTS as b, createBlockTemplate as E, DEFAULT_CARD_COMPOSITION as L, spacer as S, buildElementRenderer as _, DEFAULT_CARD_VISIBILITY as f } from "../utils.js";
|
|
3
|
+
import { buildFillerCell as w, gridElementRenderer as A } from "./elementRenderer.js";
|
|
4
|
+
const D = `
|
|
5
5
|
<tr class="recommendation-product-row">
|
|
6
6
|
<td>
|
|
7
7
|
<table
|
|
@@ -18,7 +18,7 @@ const O = `
|
|
|
18
18
|
</table>
|
|
19
19
|
</td>
|
|
20
20
|
</tr>
|
|
21
|
-
`,
|
|
21
|
+
`, C = `
|
|
22
22
|
<tr
|
|
23
23
|
class="recommendation-attribute-row"
|
|
24
24
|
data-attribute-type="{-{-ATTR_TYPE-}-}"
|
|
@@ -27,38 +27,38 @@ const O = `
|
|
|
27
27
|
{-{-CELLS-}-}
|
|
28
28
|
</tr>
|
|
29
29
|
`;
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
return r.filter((
|
|
33
|
-
const
|
|
34
|
-
return
|
|
30
|
+
function O(t, e, n, r = L, c = {}) {
|
|
31
|
+
const a = (100 / e).toFixed(2), s = e - t.length, l = s > 0 ? w(a).repeat(s) : "", i = _(n, r, c);
|
|
32
|
+
return r.filter((o) => i[o]).map((o) => {
|
|
33
|
+
const p = f[o] ?? !0, u = p ? "" : 'style="display: none;"', T = t.map((R) => i[o](R).replace("<td", `<td width="${a}%"`)).join("");
|
|
34
|
+
return C.replace("{-{-ATTR_TYPE-}-}", o).replace("{-{-VISIBILITY-}-}", p ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", u).replace("{-{-CELLS-}-}", T + l);
|
|
35
35
|
}).join("");
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
37
|
+
function g(t, e, n, r, c = {}) {
|
|
38
|
+
const a = [];
|
|
39
39
|
for (let l = 0; l < t.length; l += e)
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
const
|
|
40
|
+
a.push(t.slice(l, l + e));
|
|
41
|
+
return a.map((l, i) => {
|
|
42
|
+
const d = O(
|
|
43
43
|
l,
|
|
44
44
|
e,
|
|
45
|
-
|
|
45
|
+
n,
|
|
46
46
|
r,
|
|
47
|
-
|
|
48
|
-
),
|
|
49
|
-
return
|
|
47
|
+
c
|
|
48
|
+
), o = D.replace("{-{-ATTRIBUTE_ROWS-}-}", d);
|
|
49
|
+
return i > 0 ? S + o : o;
|
|
50
50
|
}).join("");
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
52
|
+
function P(t, e, n, r = {}) {
|
|
53
|
+
return g(t, e, A, n, r);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
const e = t ? `ins-recommendation-v3-block-${t}` : void 0,
|
|
57
|
-
return
|
|
55
|
+
function B(t) {
|
|
56
|
+
const e = t ? `ins-recommendation-v3-block-${t}` : void 0, n = E("grid", e), r = I(), c = P(r, m);
|
|
57
|
+
return n.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
|
|
58
58
|
}
|
|
59
59
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
B as getDefaultTemplate,
|
|
61
|
+
O as prepareGridAttributeRows,
|
|
62
|
+
g as prepareGridProductRows,
|
|
63
|
+
P as prepareProductRows
|
|
64
64
|
};
|
|
@@ -1,60 +1,66 @@
|
|
|
1
|
-
import { ATTR_CUSTOM_PREFIX as
|
|
2
|
-
function
|
|
1
|
+
import { ATTR_CUSTOM_PREFIX as d, ATTR_PRODUCT_IMAGE as u, ATTR_PRODUCT_NAME as p, ATTR_PRODUCT_OLD_PRICE as m, ATTR_PRODUCT_PRICE as b, ATTR_PRODUCT_OMNIBUS_PRICE as T, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as g } from "../constants/selectors.js";
|
|
2
|
+
function y(t) {
|
|
3
3
|
return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function U(t) {
|
|
6
|
+
const e = Array.isArray(t) ? t[t.length - 1] : t;
|
|
7
|
+
if (typeof e == "string")
|
|
8
|
+
return e;
|
|
9
|
+
if (typeof e == "number")
|
|
10
|
+
return String(e);
|
|
11
|
+
}
|
|
12
|
+
function C(t, e) {
|
|
6
13
|
const n = Object.values(e).find((r) => r.attributeName === t);
|
|
7
14
|
return (n == null ? void 0 : n.type) === "defaultAttribute";
|
|
8
15
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
16
|
+
function h(t, e) {
|
|
17
|
+
return C(t, e) ? t : `product_attribute.${t}`;
|
|
11
18
|
}
|
|
12
19
|
const P = Symbol("customCellHtml");
|
|
13
|
-
function
|
|
20
|
+
function L(t, e, n = {}) {
|
|
14
21
|
const r = t[P];
|
|
15
22
|
if (!r)
|
|
16
23
|
return { ...t };
|
|
17
|
-
const
|
|
18
|
-
return e.filter((o) => o.startsWith(
|
|
19
|
-
const s = o.substring(
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
return typeof i == "string" ? c = i : typeof i == "number" && (c = String(i)), r(D, c);
|
|
24
|
+
const i = { ...t };
|
|
25
|
+
return e.filter((o) => o.startsWith(d) && !i[o]).forEach((o) => {
|
|
26
|
+
const s = o.substring(d.length), l = y(s), A = h(s, n), R = C(s, n);
|
|
27
|
+
i[o] = (c) => {
|
|
28
|
+
var a;
|
|
29
|
+
const D = R ? c[s] : (a = c.product_attributes) == null ? void 0 : a[s], O = U(D) ?? l;
|
|
30
|
+
return r(A, O);
|
|
25
31
|
};
|
|
26
|
-
}),
|
|
32
|
+
}), i;
|
|
27
33
|
}
|
|
28
|
-
const
|
|
34
|
+
const M = {
|
|
29
35
|
TITLE: "You May Also Like!"
|
|
30
|
-
},
|
|
36
|
+
}, $ = [
|
|
37
|
+
u,
|
|
38
|
+
p,
|
|
31
39
|
m,
|
|
32
40
|
b,
|
|
33
41
|
T,
|
|
34
42
|
_,
|
|
35
|
-
g
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
],
|
|
39
|
-
[m]: !0,
|
|
43
|
+
g
|
|
44
|
+
], w = {
|
|
45
|
+
[u]: !0,
|
|
46
|
+
[p]: !0,
|
|
40
47
|
[b]: !0,
|
|
41
|
-
[
|
|
42
|
-
[T]: !
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
|
|
46
|
-
}, h = `
|
|
48
|
+
[m]: !0,
|
|
49
|
+
[T]: !1,
|
|
50
|
+
[_]: !1,
|
|
51
|
+
[g]: !0
|
|
52
|
+
}, I = `
|
|
47
53
|
<tr>
|
|
48
54
|
<td class="spacer" style="height: 10px;"></td>
|
|
49
55
|
</tr>
|
|
50
|
-
`,
|
|
51
|
-
function
|
|
52
|
-
return !t || typeof t != "string" || t.trim() === "" ?
|
|
56
|
+
`, f = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
|
|
57
|
+
function N(t) {
|
|
58
|
+
return !t || typeof t != "string" || t.trim() === "" ? f : t.startsWith("http://") ? t.replace("http://", "https://") : t;
|
|
53
59
|
}
|
|
54
|
-
function
|
|
60
|
+
function E(t) {
|
|
55
61
|
return {
|
|
56
62
|
name: "Product Name",
|
|
57
|
-
image_url:
|
|
63
|
+
image_url: f,
|
|
58
64
|
price: { USD: 18 },
|
|
59
65
|
original_price: { USD: 20 },
|
|
60
66
|
discount: { USD: 2 },
|
|
@@ -66,13 +72,13 @@ function I(t) {
|
|
|
66
72
|
category: []
|
|
67
73
|
};
|
|
68
74
|
}
|
|
69
|
-
function
|
|
75
|
+
function k(t = 6) {
|
|
70
76
|
return Array.from(
|
|
71
77
|
{ length: t },
|
|
72
|
-
(e, n) =>
|
|
78
|
+
(e, n) => E(String(n + 1))
|
|
73
79
|
);
|
|
74
80
|
}
|
|
75
|
-
function
|
|
81
|
+
function x(t = "grid", e) {
|
|
76
82
|
const n = t === "list" ? `
|
|
77
83
|
data-layout="list"` : "", r = e ? ` ${e}` : "";
|
|
78
84
|
return `
|
|
@@ -110,7 +116,7 @@ function k(t = "grid", e) {
|
|
|
110
116
|
</table>
|
|
111
117
|
</td>
|
|
112
118
|
</tr>
|
|
113
|
-
${
|
|
119
|
+
${I}
|
|
114
120
|
<tr>
|
|
115
121
|
<td>
|
|
116
122
|
<table
|
|
@@ -150,16 +156,17 @@ function k(t = "grid", e) {
|
|
|
150
156
|
}
|
|
151
157
|
export {
|
|
152
158
|
P as CUSTOM_CELL_HTML,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
M as DEFAULTS,
|
|
160
|
+
$ as DEFAULT_CARD_COMPOSITION,
|
|
161
|
+
w as DEFAULT_CARD_VISIBILITY,
|
|
162
|
+
f as PLACEHOLDER_IMAGE,
|
|
163
|
+
L as buildElementRenderer,
|
|
164
|
+
x as createBlockTemplate,
|
|
165
|
+
k as getDefaultProducts,
|
|
166
|
+
C as isDefaultAttribute,
|
|
167
|
+
h as resolveProductAttrValue,
|
|
168
|
+
N as sanitizeImageUrl,
|
|
169
|
+
I as spacer,
|
|
170
|
+
y as toDisplayName,
|
|
171
|
+
U as toDisplayableAttributeValue
|
|
165
172
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,4 +17,11 @@ export declare const DEFAULT_CELL_PADDING = "0 5px";
|
|
|
17
17
|
* Used by controls to reliably select direct children for spacing adjustments
|
|
18
18
|
*/
|
|
19
19
|
export declare const ATTRIBUTE_CELL_CLASS = "attribute-cell";
|
|
20
|
+
/**
|
|
21
|
+
* Builds an empty filler cell used to pad incomplete rows (productsPerRow >
|
|
22
|
+
* number of products). Without fillers, table-layout:fixed redistributes the
|
|
23
|
+
* width among fewer cells and stretches them. Shared by the template and the
|
|
24
|
+
* card-composition control so both render identical filler markup.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildFillerCell(columnWidth: string, padding?: string): string;
|
|
20
27
|
export declare const gridElementRenderer: ElementRenderer;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
8
8
|
import { type Orientation, type PrepareProductRowsOptions } from './utils';
|
|
9
|
-
export { DEFAULTS, DEFAULT_CARD_COMPOSITION, DEFAULT_CARD_VISIBILITY, getDefaultProducts, spacer, sanitizeImageUrl, createBlockTemplate, type Orientation, type PrepareProductRowsOptions, type ElementRenderer, type ProductCardGetter, } from './utils';
|
|
9
|
+
export { DEFAULTS, DEFAULT_CARD_COMPOSITION, DEFAULT_CARD_VISIBILITY, getDefaultProducts, spacer, sanitizeImageUrl, createBlockTemplate, toDisplayableAttributeValue, type Orientation, type PrepareProductRowsOptions, type ElementRenderer, type ProductCardGetter, } from './utils';
|
|
10
10
|
/**
|
|
11
11
|
* Unified function to prepare product rows for any layout.
|
|
12
12
|
* Delegates to the appropriate layout-specific implementation.
|
|
@@ -5,6 +5,14 @@ import { ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT
|
|
|
5
5
|
* e.g., "rating_star" → "Rating Star"
|
|
6
6
|
*/
|
|
7
7
|
export declare function toDisplayName(attrName: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Reduces a raw product-attribute value to a displayable scalar string.
|
|
10
|
+
* Array-type attributes (filter types `Strings`/`Numbers`) are substituted with
|
|
11
|
+
* their last item by the email renderer at send time, so we mirror that here to
|
|
12
|
+
* keep the editor preview consistent with what is actually sent.
|
|
13
|
+
* Returns undefined when there is no displayable string/number.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toDisplayableAttributeValue(value: unknown): string | undefined;
|
|
8
16
|
/**
|
|
9
17
|
* Checks whether an attribute is a default (top-level) product attribute
|
|
10
18
|
* vs a custom product attribute (nested under `product_attributes`).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0-beta.0e98cf4",
|
|
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",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
},
|
|
93
93
|
"guido": {
|
|
94
94
|
"stripo": {
|
|
95
|
-
"version": "2.
|
|
95
|
+
"version": "2.65.0"
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|