@useinsider/guido 3.7.2-beta.13c9a35 → 3.7.2-beta.1e8f93e
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 +66 -70
- package/dist/composables/usePreviewMode.js +14 -15
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +82 -90
- package/dist/config/migrator/recommendation/htmlBuilder.js +58 -59
- package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
- package/dist/extensions/Blocks/Items/block.js +48 -29
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
- package/dist/extensions/Blocks/Recommendation/block.js +41 -60
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +288 -369
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +84 -96
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +80 -82
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +5 -7
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +72 -101
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -31
- package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -9
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +59 -74
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -88
- package/dist/src/@types/config/schemas.d.ts +0 -16
- package/dist/src/composables/useConfig.d.ts +0 -4
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -13
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -33
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
- package/dist/src/stores/config.d.ts +0 -36
- package/package.json +1 -1
- package/dist/composables/useRecommendationPreview.js +0 -100
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
- package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
|
@@ -1,33 +1,10 @@
|
|
|
1
|
-
import type { CurrencyConfig } from '../types/nodeConfig';
|
|
2
1
|
import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
|
|
3
2
|
import { ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON } from '../constants';
|
|
4
|
-
type PriceKey = 'price' | 'original_price' | 'discount';
|
|
5
|
-
/**
|
|
6
|
-
* Current currency configuration from the store, in CurrencyConfig shape.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getCurrentCurrencyConfig(): CurrencyConfig;
|
|
9
|
-
/**
|
|
10
|
-
* Formats a product price using current currency settings. Falls back to the
|
|
11
|
-
* first available currency, then 0, when the active currency has no value.
|
|
12
|
-
*/
|
|
13
|
-
export declare function formatProductPrice(product: RecommendationProduct, priceKey?: PriceKey): string;
|
|
14
3
|
/**
|
|
15
4
|
* Converts a snake_case attribute name to Title Case display name.
|
|
16
5
|
* e.g., "rating_star" → "Rating Star"
|
|
17
6
|
*/
|
|
18
7
|
export declare function toDisplayName(attrName: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Resolves the inline (side-by-side) price layout from the composition order so
|
|
21
|
-
* it matches the stacked order. `anchor` is whichever of price / original price
|
|
22
|
-
* comes first in the composition (the merged cell renders there); `skip` is the
|
|
23
|
-
* other (dropped, since it's merged in); `originalFirst` puts the original price
|
|
24
|
-
* on the left when it precedes the sale price (the default composition order).
|
|
25
|
-
*/
|
|
26
|
-
export declare function resolveInlinePriceOrder(composition: string[]): {
|
|
27
|
-
originalFirst: boolean;
|
|
28
|
-
anchor: string;
|
|
29
|
-
skip: string;
|
|
30
|
-
};
|
|
31
8
|
/**
|
|
32
9
|
* Reduces a raw product-attribute value to a displayable scalar string.
|
|
33
10
|
* Array-type attributes (filter types `Strings`/`Numbers`) are substituted with
|
|
@@ -80,15 +57,7 @@ export type Orientation = 'list' | 'grid';
|
|
|
80
57
|
/**
|
|
81
58
|
* Options for prepareProductRows unified function
|
|
82
59
|
*/
|
|
83
|
-
|
|
84
|
-
* Block-level price placement flags threaded into the row builders.
|
|
85
|
-
* - `priceInline`: render sale + original price on one line (skip the standalone
|
|
86
|
-
* original-price row).
|
|
87
|
-
*/
|
|
88
|
-
export interface PricePlacementFlags {
|
|
89
|
-
priceInline?: boolean;
|
|
90
|
-
}
|
|
91
|
-
export interface PrepareProductRowsOptions extends PricePlacementFlags {
|
|
60
|
+
export interface PrepareProductRowsOptions {
|
|
92
61
|
/** Number of products per row (only for grid layout, defaults to 3) */
|
|
93
62
|
productsPerRow?: number;
|
|
94
63
|
/** Number of products per row on mobile (only for grid layout, defaults to 1) */
|
|
@@ -155,4 +124,3 @@ export declare function getDefaultProducts(count?: number): RecommendationProduc
|
|
|
155
124
|
* @returns HTML template string with {-{-TITLE-}-}, {-{-PRODUCT_ROWS-}-}, and {-{-MOBILE_PRODUCT_ROWS-}-} (grid only) placeholders
|
|
156
125
|
*/
|
|
157
126
|
export declare function createBlockTemplate(layout?: Orientation, instanceClass?: string): string;
|
|
158
|
-
export {};
|
|
@@ -152,21 +152,6 @@ export interface RecommendationNodeConfig {
|
|
|
152
152
|
* Whether to trim long product names with ellipsis
|
|
153
153
|
*/
|
|
154
154
|
textTrimming: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Whether the price and original price render on separate stacked lines.
|
|
157
|
-
* - true (default): each on its own attribute row (current Guido look)
|
|
158
|
-
* - false: both rendered inline on the same line, and Card Composition
|
|
159
|
-
* collapses them into a single "Product Prices" entry
|
|
160
|
-
* Ported from the legacy product block's `isPriceMovedToNextLine`.
|
|
161
|
-
*/
|
|
162
|
-
priceMovedToNextLine: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Whether to hide the redundant original price when it equals the sale
|
|
165
|
-
* price (no real discount). Enforced in the real email via a liquid
|
|
166
|
-
* condition and mirrored in the editor on mock data.
|
|
167
|
-
* Ported from the legacy product block's `isPriceDeletedForZeroSale`.
|
|
168
|
-
*/
|
|
169
|
-
priceHideIfSameAsDiscounted: boolean;
|
|
170
155
|
/**
|
|
171
156
|
* Configuration version for future migrations
|
|
172
157
|
* Increment when making breaking changes to schema
|
|
@@ -65,8 +65,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
65
65
|
blockType?: string | undefined;
|
|
66
66
|
size?: string | number | undefined;
|
|
67
67
|
verticalResponsiveness?: boolean | undefined;
|
|
68
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
69
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
70
68
|
} & {
|
|
71
69
|
[key: string]: unknown;
|
|
72
70
|
};
|
|
@@ -199,8 +197,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
199
197
|
blockType?: string | undefined;
|
|
200
198
|
size?: string | number | undefined;
|
|
201
199
|
verticalResponsiveness?: boolean | undefined;
|
|
202
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
203
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
204
200
|
} & {
|
|
205
201
|
[key: string]: unknown;
|
|
206
202
|
};
|
|
@@ -333,8 +329,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
333
329
|
blockType?: string | undefined;
|
|
334
330
|
size?: string | number | undefined;
|
|
335
331
|
verticalResponsiveness?: boolean | undefined;
|
|
336
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
337
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
338
332
|
} & {
|
|
339
333
|
[key: string]: unknown;
|
|
340
334
|
};
|
|
@@ -467,8 +461,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
467
461
|
blockType?: string | undefined;
|
|
468
462
|
size?: string | number | undefined;
|
|
469
463
|
verticalResponsiveness?: boolean | undefined;
|
|
470
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
471
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
472
464
|
} & {
|
|
473
465
|
[key: string]: unknown;
|
|
474
466
|
};
|
|
@@ -601,8 +593,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
601
593
|
blockType?: string | undefined;
|
|
602
594
|
size?: string | number | undefined;
|
|
603
595
|
verticalResponsiveness?: boolean | undefined;
|
|
604
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
605
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
606
596
|
} & {
|
|
607
597
|
[key: string]: unknown;
|
|
608
598
|
};
|
|
@@ -735,8 +725,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
735
725
|
blockType?: string | undefined;
|
|
736
726
|
size?: string | number | undefined;
|
|
737
727
|
verticalResponsiveness?: boolean | undefined;
|
|
738
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
739
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
740
728
|
} & {
|
|
741
729
|
[key: string]: unknown;
|
|
742
730
|
};
|
|
@@ -869,8 +857,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
869
857
|
blockType?: string | undefined;
|
|
870
858
|
size?: string | number | undefined;
|
|
871
859
|
verticalResponsiveness?: boolean | undefined;
|
|
872
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
873
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
874
860
|
} & {
|
|
875
861
|
[key: string]: unknown;
|
|
876
862
|
};
|
|
@@ -1003,8 +989,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1003
989
|
blockType?: string | undefined;
|
|
1004
990
|
size?: string | number | undefined;
|
|
1005
991
|
verticalResponsiveness?: boolean | undefined;
|
|
1006
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1007
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1008
992
|
} & {
|
|
1009
993
|
[key: string]: unknown;
|
|
1010
994
|
};
|
|
@@ -1137,8 +1121,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1137
1121
|
blockType?: string | undefined;
|
|
1138
1122
|
size?: string | number | undefined;
|
|
1139
1123
|
verticalResponsiveness?: boolean | undefined;
|
|
1140
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1141
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1142
1124
|
} & {
|
|
1143
1125
|
[key: string]: unknown;
|
|
1144
1126
|
};
|
|
@@ -1271,8 +1253,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1271
1253
|
blockType?: string | undefined;
|
|
1272
1254
|
size?: string | number | undefined;
|
|
1273
1255
|
verticalResponsiveness?: boolean | undefined;
|
|
1274
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1275
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1276
1256
|
} & {
|
|
1277
1257
|
[key: string]: unknown;
|
|
1278
1258
|
};
|
|
@@ -1405,8 +1385,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1405
1385
|
blockType?: string | undefined;
|
|
1406
1386
|
size?: string | number | undefined;
|
|
1407
1387
|
verticalResponsiveness?: boolean | undefined;
|
|
1408
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1409
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1410
1388
|
} & {
|
|
1411
1389
|
[key: string]: unknown;
|
|
1412
1390
|
};
|
|
@@ -1539,8 +1517,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1539
1517
|
blockType?: string | undefined;
|
|
1540
1518
|
size?: string | number | undefined;
|
|
1541
1519
|
verticalResponsiveness?: boolean | undefined;
|
|
1542
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1543
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1544
1520
|
} & {
|
|
1545
1521
|
[key: string]: unknown;
|
|
1546
1522
|
};
|
|
@@ -1673,8 +1649,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1673
1649
|
blockType?: string | undefined;
|
|
1674
1650
|
size?: string | number | undefined;
|
|
1675
1651
|
verticalResponsiveness?: boolean | undefined;
|
|
1676
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1677
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1678
1652
|
} & {
|
|
1679
1653
|
[key: string]: unknown;
|
|
1680
1654
|
};
|
|
@@ -1807,8 +1781,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1807
1781
|
blockType?: string | undefined;
|
|
1808
1782
|
size?: string | number | undefined;
|
|
1809
1783
|
verticalResponsiveness?: boolean | undefined;
|
|
1810
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1811
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1812
1784
|
} & {
|
|
1813
1785
|
[key: string]: unknown;
|
|
1814
1786
|
};
|
|
@@ -1941,8 +1913,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1941
1913
|
blockType?: string | undefined;
|
|
1942
1914
|
size?: string | number | undefined;
|
|
1943
1915
|
verticalResponsiveness?: boolean | undefined;
|
|
1944
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
1945
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
1946
1916
|
} & {
|
|
1947
1917
|
[key: string]: unknown;
|
|
1948
1918
|
};
|
|
@@ -2075,8 +2045,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2075
2045
|
blockType?: string | undefined;
|
|
2076
2046
|
size?: string | number | undefined;
|
|
2077
2047
|
verticalResponsiveness?: boolean | undefined;
|
|
2078
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
2079
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
2080
2048
|
} & {
|
|
2081
2049
|
[key: string]: unknown;
|
|
2082
2050
|
};
|
|
@@ -2209,8 +2177,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2209
2177
|
blockType?: string | undefined;
|
|
2210
2178
|
size?: string | number | undefined;
|
|
2211
2179
|
verticalResponsiveness?: boolean | undefined;
|
|
2212
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
2213
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
2214
2180
|
} & {
|
|
2215
2181
|
[key: string]: unknown;
|
|
2216
2182
|
};
|
|
@@ -2343,8 +2309,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2343
2309
|
blockType?: string | undefined;
|
|
2344
2310
|
size?: string | number | undefined;
|
|
2345
2311
|
verticalResponsiveness?: boolean | undefined;
|
|
2346
|
-
isPriceMovedToNextLine?: boolean | undefined;
|
|
2347
|
-
isPriceDeletedForZeroSale?: boolean | undefined;
|
|
2348
2312
|
} & {
|
|
2349
2313
|
[key: string]: unknown;
|
|
2350
2314
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.7.2-beta.
|
|
3
|
+
"version": "3.7.2-beta.1e8f93e",
|
|
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,100 +0,0 @@
|
|
|
1
|
-
import { BLOCK_ROOT_SELECTOR as S, CURRENCY_ATTR as d, CONTAINER_SELECTOR as f } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
-
import { useRecommendationExtensionStore as O } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
3
|
-
import { formatPrice as g } from "../extensions/Blocks/Recommendation/utils/priceFormatter.js";
|
|
4
|
-
const p = `${S}[recommendation-id]`, R = ".product-old-price", C = /\{\{(?:reco_)?(\d+_\d+_[a-zA-Z0-9_.]+)\}\}/g, h = new RegExp(
|
|
5
|
-
"\\{%\\s*if\\s+([\\s\\S]+?)\\s*%\\}([\\s\\S]*?)(?:\\{%\\s*else\\s*%\\}([\\s\\S]*?))?\\{%\\s*endif\\s*%\\}",
|
|
6
|
-
"g"
|
|
7
|
-
);
|
|
8
|
-
function T(e) {
|
|
9
|
-
const t = e.getAttribute(d.CURRENCY) || "USD", i = e.getAttribute(d.DECIMAL_SEPARATOR) || ".", s = e.getAttribute(d.THOUSAND_SEPARATOR) || ",";
|
|
10
|
-
return {
|
|
11
|
-
code: t,
|
|
12
|
-
symbol: e.getAttribute(d.SYMBOL) || t,
|
|
13
|
-
alignment: e.getAttribute(d.ALIGNMENT) === "0" ? "before" : "after",
|
|
14
|
-
decimalCount: parseInt(e.getAttribute(d.DECIMAL_COUNT) || "2") || 2,
|
|
15
|
-
decimalSeparator: i,
|
|
16
|
-
thousandSeparator: s
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function _(e, t) {
|
|
20
|
-
return (e == null ? void 0 : e[t]) ?? Object.values(e ?? {})[0] ?? 0;
|
|
21
|
-
}
|
|
22
|
-
function b(e, t) {
|
|
23
|
-
const i = _(e.original_price, t), s = _(e.price, t), n = i > 0 ? Math.round((i - s) / i * 100) : 0;
|
|
24
|
-
return n > 0 ? `${n}%` : "0%";
|
|
25
|
-
}
|
|
26
|
-
function N(e, t, i, s, n, a) {
|
|
27
|
-
s.forEach((o, c) => {
|
|
28
|
-
const r = (m) => `${i}_${c}_${m}`, u = g({ price: _(o.price, n.code), currency: n }), l = g({ price: _(o.original_price, n.code), currency: n }), A = b(o, n.code);
|
|
29
|
-
e.set(r("name"), o.name ?? ""), e.set(r("image_url"), o.image_url ?? ""), e.set(r("url"), o.url ?? ""), e.set(r("item_id"), o.item_id ?? ""), e.set(r("currency"), ""), e.set(r("price"), u), e.set(r("original_price"), l), e.set(r("discount"), A), e.set(r("omnibus_price"), l), e.set(r("omnibus_discount"), A), a && u === l && t.add(`${i}_${c}`), Object.entries(o.product_attributes ?? {}).forEach(([m, E]) => {
|
|
30
|
-
e.set(r(`product_attribute.${m}`), String(E)), e.set(r(m), String(E));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function L(e, t) {
|
|
35
|
-
const i = e.match(/^(.+?)\s*(!=|==)\s*"([^"]*)"$/);
|
|
36
|
-
if (!i)
|
|
37
|
-
return !0;
|
|
38
|
-
const [, s, n, a] = i, o = t.get(s.trim()) ?? "";
|
|
39
|
-
return n === "!=" ? o !== a : o === a;
|
|
40
|
-
}
|
|
41
|
-
function P(e, t) {
|
|
42
|
-
return e.replace(
|
|
43
|
-
h,
|
|
44
|
-
(i, s, n, a) => s.split(/\s+and\s+/).every((c) => L(c.trim(), t)) ? n : a ?? ""
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
function $(e) {
|
|
48
|
-
let t = e;
|
|
49
|
-
for (; t.children.length === 1; )
|
|
50
|
-
[t] = t.children;
|
|
51
|
-
return t;
|
|
52
|
-
}
|
|
53
|
-
function D(e, t) {
|
|
54
|
-
var o;
|
|
55
|
-
if (!t.size)
|
|
56
|
-
return e;
|
|
57
|
-
const i = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), s = new DOMParser().parseFromString(i, "text/html");
|
|
58
|
-
s.querySelectorAll(p).forEach((c) => {
|
|
59
|
-
const r = Number(c.getAttribute("recommendation-id"));
|
|
60
|
-
if (!Number.isFinite(r))
|
|
61
|
-
return;
|
|
62
|
-
const u = c.querySelectorAll(f);
|
|
63
|
-
(u.length ? Array.from(u) : [c]).forEach((A) => {
|
|
64
|
-
A.querySelectorAll(R).forEach((m, E) => {
|
|
65
|
-
t.has(`${r}_${E}`) && ($(m).textContent = "");
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
const n = (o = e.match(/<!DOCTYPE[^>]*>/i)) == null ? void 0 : o[0];
|
|
70
|
-
return ((n ? `${n}
|
|
71
|
-
` : "") + s.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
72
|
-
}
|
|
73
|
-
function I(e) {
|
|
74
|
-
if (!e || !e.includes("recommendation-block-v2"))
|
|
75
|
-
return e;
|
|
76
|
-
const t = O(), i = new DOMParser().parseFromString(e, "text/html"), s = Array.from(i.querySelectorAll(p)), n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
77
|
-
if (s.forEach((c) => {
|
|
78
|
-
var l;
|
|
79
|
-
const r = Number(c.getAttribute("recommendation-id"));
|
|
80
|
-
if (!Number.isFinite(r))
|
|
81
|
-
return;
|
|
82
|
-
const u = ((l = t.blockStates[r]) == null ? void 0 : l.recommendationProducts) ?? [];
|
|
83
|
-
u.length && N(
|
|
84
|
-
n,
|
|
85
|
-
a,
|
|
86
|
-
r,
|
|
87
|
-
u,
|
|
88
|
-
T(c),
|
|
89
|
-
c.getAttribute("hide-price") === "true"
|
|
90
|
-
);
|
|
91
|
-
}), !n.size)
|
|
92
|
-
return e;
|
|
93
|
-
let o = D(e, a);
|
|
94
|
-
return o = o.replace(C, (c, r) => n.has(r) ? n.get(r) : c), o = P(o, n), o;
|
|
95
|
-
}
|
|
96
|
-
const x = () => ({ substituteRecommendationPreview: I });
|
|
97
|
-
export {
|
|
98
|
-
I as substituteRecommendationPreview,
|
|
99
|
-
x as useRecommendationPreview
|
|
100
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
var m = Object.defineProperty;
|
|
2
|
-
var p = (i, o, e) => o in i ? m(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
3
|
-
var d = (i, o, e) => p(i, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
-
import { UEAttr as u, ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as f } from "../../../common-control.js";
|
|
6
|
-
import { ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OLD_PRICE as I } from "../../constants/selectors.js";
|
|
7
|
-
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
8
|
-
import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
|
|
9
|
-
import { getBlockElement as l, regenerateProductRowsWithStyles as g } from "./utils.js";
|
|
10
|
-
const E = "recommendation-price-placement-control", N = "hide-price", r = {
|
|
11
|
-
ORIENTATION: "priceOrientation",
|
|
12
|
-
HIDE_IF_SAME: "priceHideIfSameAsDiscounted"
|
|
13
|
-
}, A = [
|
|
14
|
-
{ icon: "vertical-orientation", value: "vertical" },
|
|
15
|
-
{ icon: "horizontal-orientation", value: "horizontal" }
|
|
16
|
-
], C = (i) => i ? "vertical" : "horizontal";
|
|
17
|
-
class P extends f {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
d(this, "store", T());
|
|
21
|
-
}
|
|
22
|
-
getId() {
|
|
23
|
-
return E;
|
|
24
|
-
}
|
|
25
|
-
getTemplate() {
|
|
26
|
-
return `
|
|
27
|
-
<div class="price-placement-control-container" style="border-bottom: 1px solid #e0e0e0;">
|
|
28
|
-
${this._GuTwoColumns([
|
|
29
|
-
this._GuLabel({ text: this.api.translate("Product Price Orientation") }),
|
|
30
|
-
this._GuRadioButton({
|
|
31
|
-
name: r.ORIENTATION,
|
|
32
|
-
buttons: A
|
|
33
|
-
})
|
|
34
|
-
])}
|
|
35
|
-
${this._GuTwoColumns([
|
|
36
|
-
this._GuLabel({ text: this.api.translate("Hide if same as discounted") }),
|
|
37
|
-
this._GuToggle(r.HIDE_IF_SAME)
|
|
38
|
-
])}
|
|
39
|
-
</div>
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
onRender() {
|
|
43
|
-
const e = n.getConfig(this.currentNode);
|
|
44
|
-
this._initializeHideToggle(e), this._setFormValues(e), this._updateOrientationDisabled(), this._listenToFormUpdates();
|
|
45
|
-
}
|
|
46
|
-
onTemplateNodeUpdated(e) {
|
|
47
|
-
super.onTemplateNodeUpdated(e), this._setFormValues(n.getConfig(this.currentNode)), this._updateOrientationDisabled();
|
|
48
|
-
}
|
|
49
|
-
_setFormValues(e) {
|
|
50
|
-
this.api.updateValues({
|
|
51
|
-
[r.ORIENTATION]: C(e.priceMovedToNextLine),
|
|
52
|
-
[r.HIDE_IF_SAME]: e.priceHideIfSameAsDiscounted
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
_initializeHideToggle(e) {
|
|
56
|
-
this.api.setUIEAttribute(
|
|
57
|
-
r.HIDE_IF_SAME,
|
|
58
|
-
u.SELECTPICKER.items,
|
|
59
|
-
e.priceHideIfSameAsDiscounted
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Disables the orientation radio when a price element is hidden via Card
|
|
64
|
-
* Composition — orientation is meaningless without both prices visible.
|
|
65
|
-
* Visibility lives on the attribute rows' `data-visibility` (set by the Card
|
|
66
|
-
* Composition control). Inline mode has no standalone original-price row, so
|
|
67
|
-
* the merged "Product Prices" entry (the price row) governs.
|
|
68
|
-
*/
|
|
69
|
-
_updateOrientationDisabled() {
|
|
70
|
-
const e = l(this.currentNode);
|
|
71
|
-
if (!e || !("querySelectorAll" in e))
|
|
72
|
-
return;
|
|
73
|
-
const s = Array.from(
|
|
74
|
-
e.querySelectorAll(".recommendation-attribute-row[data-attribute-type]")
|
|
75
|
-
).some((a) => {
|
|
76
|
-
const c = a.getAttribute("data-attribute-type");
|
|
77
|
-
return (c === _ || c === I) && a.getAttribute("data-visibility") === "0";
|
|
78
|
-
});
|
|
79
|
-
this.api.setUIEAttribute(
|
|
80
|
-
r.ORIENTATION,
|
|
81
|
-
u.RADIO_BUTTONS.disabled,
|
|
82
|
-
s ? "true" : "false"
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
_onOrientationChange(e) {
|
|
86
|
-
if (!this.currentNode)
|
|
87
|
-
return;
|
|
88
|
-
const t = e === "vertical";
|
|
89
|
-
n.getConfig(this.currentNode).priceMovedToNextLine !== t && (n.updateConfig(
|
|
90
|
-
this.api,
|
|
91
|
-
this.currentNode,
|
|
92
|
-
{ priceMovedToNextLine: t },
|
|
93
|
-
`${t ? "Stacked" : "Inlined"} recommendation prices`
|
|
94
|
-
), this.store.patchCurrentBlockConfig({ priceMovedToNextLine: t }), this._regenerate());
|
|
95
|
-
}
|
|
96
|
-
_onHideIfSameChange(e) {
|
|
97
|
-
!this.currentNode || n.getConfig(this.currentNode).priceHideIfSameAsDiscounted === e || (n.updateConfig(
|
|
98
|
-
this.api,
|
|
99
|
-
this.currentNode,
|
|
100
|
-
{ priceHideIfSameAsDiscounted: e },
|
|
101
|
-
`${e ? "Enabled" : "Disabled"} hide-if-same price`
|
|
102
|
-
), this.store.patchCurrentBlockConfig({ priceHideIfSameAsDiscounted: e }), this._stampHideIfSameAttr(e));
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Mirrors the hide-if-same flag onto the durable `hide-price` block attribute
|
|
106
|
-
* read by email-service at send time.
|
|
107
|
-
*/
|
|
108
|
-
_stampHideIfSameAttr(e) {
|
|
109
|
-
const t = l(this.currentNode);
|
|
110
|
-
t && this.api.getDocumentModifier().modifyHtml(t).setAttribute(N, String(e)).apply(new h("Update hide-if-same price flag"));
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Rebuilds the product rows so the renderer re-reads the inline/stacked
|
|
114
|
-
* layout flag from the store. Used by the orientation change only.
|
|
115
|
-
*/
|
|
116
|
-
_regenerate() {
|
|
117
|
-
this.currentNode && g({
|
|
118
|
-
currentNode: this.currentNode,
|
|
119
|
-
documentModifier: this.api.getDocumentModifier()
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
_listenToFormUpdates() {
|
|
123
|
-
this.api.onValueChanged(r.ORIENTATION, (e) => {
|
|
124
|
-
(e === "vertical" || e === "horizontal") && this._onOrientationChange(e);
|
|
125
|
-
}), this.api.onValueChanged(r.HIDE_IF_SAME, (e) => {
|
|
126
|
-
this._onHideIfSameChange(!!e);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export {
|
|
131
|
-
E as PRICE_PLACEMENT_CONTROL_ID,
|
|
132
|
-
P as PricePlacementControl
|
|
133
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Substitutes recommendation product variables in compiled preview HTML with the
|
|
3
|
-
* blocks' fetched sample products, then simulates the email-service hide rule by
|
|
4
|
-
* emptying the original-price cell (DOM kept) for slots with no real discount.
|
|
5
|
-
* Returns the input unchanged when there are no reco blocks or no products.
|
|
6
|
-
*/
|
|
7
|
-
export declare function substituteRecommendationPreview(html: string): string;
|
|
8
|
-
export declare const useRecommendationPreview: () => {
|
|
9
|
-
substituteRecommendationPreview: typeof substituteRecommendationPreview;
|
|
10
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Price Placement Control
|
|
3
|
-
*
|
|
4
|
-
* Two block-level price settings ported from the legacy product block, shown
|
|
5
|
-
* above the Currency control in the main Settings tab:
|
|
6
|
-
*
|
|
7
|
-
* - "Product Price Orientation" (`priceMovedToNextLine`): a vertical/horizontal
|
|
8
|
-
* icon radio (mirrors the Items block control). `vertical` (default) keeps the
|
|
9
|
-
* price and original price on separate stacked rows (current Guido look);
|
|
10
|
-
* `horizontal` renders them inline on the same line and Card Composition
|
|
11
|
-
* collapses them into a single "Product Prices" entry.
|
|
12
|
-
* - "Hide if same as discounted" (`priceHideIfSameAsDiscounted`): a toggle.
|
|
13
|
-
* When ON, email-service blanks the redundant original price at send time when
|
|
14
|
-
* it equals the sale price (see the `hide-price` block attribute below).
|
|
15
|
-
*
|
|
16
|
-
* Orientation re-renders the rows (it changes the saved template layout).
|
|
17
|
-
* Hide-if-same NEVER touches the template — it only persists config + stamps the
|
|
18
|
-
* `hide-price` attribute; the visual hide is simulated in the preview and applied
|
|
19
|
-
* for real server-side by email-service.
|
|
20
|
-
*/
|
|
21
|
-
import type { RecommendationNodeConfig } from '../../types/nodeConfig';
|
|
22
|
-
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
23
|
-
import { CommonControl } from '../../../common-control';
|
|
24
|
-
export declare const PRICE_PLACEMENT_CONTROL_ID = "recommendation-price-placement-control";
|
|
25
|
-
type Orientation = 'vertical' | 'horizontal';
|
|
26
|
-
/**
|
|
27
|
-
* Control for the block-level price orientation radio + hide-if-same toggle.
|
|
28
|
-
*/
|
|
29
|
-
export declare class PricePlacementControl extends CommonControl {
|
|
30
|
-
private store;
|
|
31
|
-
getId(): string;
|
|
32
|
-
getTemplate(): string;
|
|
33
|
-
onRender(): void;
|
|
34
|
-
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
35
|
-
_setFormValues(config: RecommendationNodeConfig): void;
|
|
36
|
-
_initializeHideToggle(config: RecommendationNodeConfig): void;
|
|
37
|
-
/**
|
|
38
|
-
* Disables the orientation radio when a price element is hidden via Card
|
|
39
|
-
* Composition — orientation is meaningless without both prices visible.
|
|
40
|
-
* Visibility lives on the attribute rows' `data-visibility` (set by the Card
|
|
41
|
-
* Composition control). Inline mode has no standalone original-price row, so
|
|
42
|
-
* the merged "Product Prices" entry (the price row) governs.
|
|
43
|
-
*/
|
|
44
|
-
_updateOrientationDisabled(): void;
|
|
45
|
-
_onOrientationChange(orientation: Orientation): void;
|
|
46
|
-
_onHideIfSameChange(value: boolean): void;
|
|
47
|
-
/**
|
|
48
|
-
* Mirrors the hide-if-same flag onto the durable `hide-price` block attribute
|
|
49
|
-
* read by email-service at send time.
|
|
50
|
-
*/
|
|
51
|
-
_stampHideIfSameAttr(value: boolean): void;
|
|
52
|
-
/**
|
|
53
|
-
* Rebuilds the product rows so the renderer re-reads the inline/stacked
|
|
54
|
-
* layout flag from the store. Used by the orientation change only.
|
|
55
|
-
*/
|
|
56
|
-
_regenerate(): void;
|
|
57
|
-
_listenToFormUpdates(): void;
|
|
58
|
-
}
|
|
59
|
-
export {};
|