@useinsider/guido 3.6.0-beta.0e98cf4 → 3.6.0-beta.177b0b7
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/extensions/Blocks/Recommendation/controls/cardComposition/index.js +123 -127
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +12 -11
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +46 -46
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +29 -31
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +28 -28
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +49 -56
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +20 -20
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -8
- package/package.json +1 -1
- /package/dist/src/extensions/Blocks/Recommendation/{templates/utils.test.d.ts → utils/priceFormatter.test.d.ts} +0 -0
|
@@ -1,66 +1,60 @@
|
|
|
1
|
-
import { ATTR_CUSTOM_PREFIX as
|
|
2
|
-
function y(t) {
|
|
3
|
-
return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
4
|
-
}
|
|
1
|
+
import { ATTR_CUSTOM_PREFIX as u, ATTR_PRODUCT_IMAGE as m, ATTR_PRODUCT_NAME as b, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as g, ATTR_PRODUCT_OMNIBUS_DISCOUNT as C, ATTR_PRODUCT_BUTTON as f } from "../constants/selectors.js";
|
|
5
2
|
function U(t) {
|
|
6
|
-
|
|
7
|
-
if (typeof e == "string")
|
|
8
|
-
return e;
|
|
9
|
-
if (typeof e == "number")
|
|
10
|
-
return String(e);
|
|
3
|
+
return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
11
4
|
}
|
|
12
|
-
function
|
|
5
|
+
function R(t, e) {
|
|
13
6
|
const n = Object.values(e).find((r) => r.attributeName === t);
|
|
14
7
|
return (n == null ? void 0 : n.type) === "defaultAttribute";
|
|
15
8
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
9
|
+
function y(t, e) {
|
|
10
|
+
return R(t, e) ? t : `product_attribute.${t}`;
|
|
18
11
|
}
|
|
19
12
|
const P = Symbol("customCellHtml");
|
|
20
|
-
function
|
|
13
|
+
function S(t, e, n = {}) {
|
|
21
14
|
const r = t[P];
|
|
22
15
|
if (!r)
|
|
23
16
|
return { ...t };
|
|
24
|
-
const
|
|
25
|
-
return e.filter((o) => o.startsWith(
|
|
26
|
-
const s = o.substring(
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
const
|
|
30
|
-
|
|
17
|
+
const l = { ...t };
|
|
18
|
+
return e.filter((o) => o.startsWith(u) && !l[o]).forEach((o) => {
|
|
19
|
+
const s = o.substring(u.length), a = U(s), D = y(s, n), O = R(s, n);
|
|
20
|
+
l[o] = (d) => {
|
|
21
|
+
var p;
|
|
22
|
+
const i = O ? d[s] : (p = d.product_attributes) == null ? void 0 : p[s];
|
|
23
|
+
let c = a;
|
|
24
|
+
return typeof i == "string" ? c = i : typeof i == "number" && (c = String(i)), r(D, c);
|
|
31
25
|
};
|
|
32
|
-
}),
|
|
26
|
+
}), l;
|
|
33
27
|
}
|
|
34
|
-
const
|
|
28
|
+
const L = {
|
|
35
29
|
TITLE: "You May Also Like!"
|
|
36
|
-
},
|
|
37
|
-
u,
|
|
38
|
-
p,
|
|
30
|
+
}, M = [
|
|
39
31
|
m,
|
|
40
32
|
b,
|
|
41
33
|
T,
|
|
42
34
|
_,
|
|
43
|
-
g
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
[b]: !0,
|
|
35
|
+
g,
|
|
36
|
+
C,
|
|
37
|
+
f
|
|
38
|
+
], $ = {
|
|
48
39
|
[m]: !0,
|
|
49
|
-
[
|
|
50
|
-
[_]: !
|
|
51
|
-
[
|
|
52
|
-
|
|
40
|
+
[b]: !0,
|
|
41
|
+
[_]: !0,
|
|
42
|
+
[T]: !0,
|
|
43
|
+
[g]: !1,
|
|
44
|
+
[C]: !1,
|
|
45
|
+
[f]: !0
|
|
46
|
+
}, h = `
|
|
53
47
|
<tr>
|
|
54
48
|
<td class="spacer" style="height: 10px;"></td>
|
|
55
49
|
</tr>
|
|
56
|
-
`,
|
|
57
|
-
function
|
|
58
|
-
return !t || typeof t != "string" || t.trim() === "" ?
|
|
50
|
+
`, A = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
|
|
51
|
+
function w(t) {
|
|
52
|
+
return !t || typeof t != "string" || t.trim() === "" ? A : t.startsWith("http://") ? t.replace("http://", "https://") : t;
|
|
59
53
|
}
|
|
60
|
-
function
|
|
54
|
+
function I(t) {
|
|
61
55
|
return {
|
|
62
56
|
name: "Product Name",
|
|
63
|
-
image_url:
|
|
57
|
+
image_url: A,
|
|
64
58
|
price: { USD: 18 },
|
|
65
59
|
original_price: { USD: 20 },
|
|
66
60
|
discount: { USD: 2 },
|
|
@@ -72,13 +66,13 @@ function E(t) {
|
|
|
72
66
|
category: []
|
|
73
67
|
};
|
|
74
68
|
}
|
|
75
|
-
function
|
|
69
|
+
function N(t = 6) {
|
|
76
70
|
return Array.from(
|
|
77
71
|
{ length: t },
|
|
78
|
-
(e, n) =>
|
|
72
|
+
(e, n) => I(String(n + 1))
|
|
79
73
|
);
|
|
80
74
|
}
|
|
81
|
-
function
|
|
75
|
+
function k(t = "grid", e) {
|
|
82
76
|
const n = t === "list" ? `
|
|
83
77
|
data-layout="list"` : "", r = e ? ` ${e}` : "";
|
|
84
78
|
return `
|
|
@@ -116,7 +110,7 @@ function x(t = "grid", e) {
|
|
|
116
110
|
</table>
|
|
117
111
|
</td>
|
|
118
112
|
</tr>
|
|
119
|
-
${
|
|
113
|
+
${h}
|
|
120
114
|
<tr>
|
|
121
115
|
<td>
|
|
122
116
|
<table
|
|
@@ -156,17 +150,16 @@ function x(t = "grid", e) {
|
|
|
156
150
|
}
|
|
157
151
|
export {
|
|
158
152
|
P as CUSTOM_CELL_HTML,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
U as toDisplayableAttributeValue
|
|
153
|
+
L as DEFAULTS,
|
|
154
|
+
M as DEFAULT_CARD_COMPOSITION,
|
|
155
|
+
$ as DEFAULT_CARD_VISIBILITY,
|
|
156
|
+
A as PLACEHOLDER_IMAGE,
|
|
157
|
+
S as buildElementRenderer,
|
|
158
|
+
k as createBlockTemplate,
|
|
159
|
+
N as getDefaultProducts,
|
|
160
|
+
R as isDefaultAttribute,
|
|
161
|
+
y as resolveProductAttrValue,
|
|
162
|
+
w as sanitizeImageUrl,
|
|
163
|
+
h as spacer,
|
|
164
|
+
U as toDisplayName
|
|
172
165
|
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
function d(
|
|
2
|
-
const { thousandSeparator:
|
|
1
|
+
function d(c, e) {
|
|
2
|
+
const { thousandSeparator: i, decimalSeparator: r, decimalCount: t } = e, [u, o = ""] = String(c).split("."), n = o.padEnd(t, "0"), a = u.replace(
|
|
3
3
|
/\B(?=(\d{3})+(?!\d))/g,
|
|
4
|
-
|
|
5
|
-
)
|
|
6
|
-
return
|
|
4
|
+
i
|
|
5
|
+
);
|
|
6
|
+
return t > 0 && n ? `${a}${r}${n}` : a;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const { price:
|
|
10
|
-
symbol:
|
|
11
|
-
alignment:
|
|
8
|
+
function f(c) {
|
|
9
|
+
const { price: e, currency: i } = c, {
|
|
10
|
+
symbol: r,
|
|
11
|
+
alignment: t,
|
|
12
12
|
thousandSeparator: u,
|
|
13
|
-
decimalSeparator:
|
|
14
|
-
decimalCount:
|
|
15
|
-
} =
|
|
16
|
-
if (typeof
|
|
17
|
-
const
|
|
18
|
-
return
|
|
13
|
+
decimalSeparator: o,
|
|
14
|
+
decimalCount: n
|
|
15
|
+
} = i;
|
|
16
|
+
if (typeof e != "number" || Number.isNaN(e)) {
|
|
17
|
+
const s = "0".repeat(n), m = `0${o}${s}`;
|
|
18
|
+
return t === "before" ? `${r} ${m}` : `${m} ${r}`;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const a = d(e, {
|
|
21
21
|
thousandSeparator: u,
|
|
22
|
-
decimalSeparator:
|
|
23
|
-
decimalCount:
|
|
22
|
+
decimalSeparator: o,
|
|
23
|
+
decimalCount: n
|
|
24
24
|
});
|
|
25
|
-
return
|
|
25
|
+
return t === "before" ? `${r} ${a}` : `${a} ${r}`;
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
f as formatPrice
|
|
29
29
|
};
|
|
@@ -17,11 +17,4 @@ 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;
|
|
27
20
|
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,
|
|
9
|
+
export { DEFAULTS, DEFAULT_CARD_COMPOSITION, DEFAULT_CARD_VISIBILITY, getDefaultProducts, spacer, sanitizeImageUrl, createBlockTemplate, 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,14 +5,6 @@ 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;
|
|
16
8
|
/**
|
|
17
9
|
* Checks whether an attribute is a default (top-level) product attribute
|
|
18
10
|
* vs a custom product attribute (nested under `product_attributes`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.177b0b7",
|
|
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",
|
|
File without changes
|