@useinsider/guido 3.21.2-beta.4c14c74 → 3.21.2-beta.5a809f7
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/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +74 -26
- package/dist/config/migrator/recommendation/htmlBuilder.js +279 -202
- package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
- package/dist/config/migrator/recommendationMigrator.js +65 -59
- package/dist/extensions/Blocks/Items/controls/button/link.js +17 -14
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +17 -14
- package/dist/extensions/Blocks/Items/controls/image/link.js +17 -14
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +10 -9
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +13 -12
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +30 -29
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +16 -15
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +26 -25
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +28 -27
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +80 -75
- package/dist/extensions/Blocks/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +27 -26
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +216 -236
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +3 -2
- package/dist/extensions/Blocks/common-control.js +55 -62
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +26 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +4 -11
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -19
- package/dist/src/extensions/Blocks/common-control.d.ts +0 -2
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PRE_RRS_CONFIG_VERSION as
|
|
2
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
3
|
-
import { mapLegacyStrategy as
|
|
4
|
-
function
|
|
1
|
+
import { PRE_RRS_CONFIG_VERSION as p, DEFAULT_CURRENCY as i } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { DEFAULT_CARDS_IN_ROW as d, DEFAULT_MOBILE_ROW_SPACING as S, DEFAULT_MOBILE_COLUMN_SPACING as c, DEFAULT_ROW_SPACING as f, DEFAULT_COLUMN_SPACING as l, DEFAULT_MOBILE_CARDS_IN_ROW as s } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
3
|
+
import { mapLegacyStrategy as _ } from "../../../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
|
|
4
|
+
function I(t) {
|
|
5
5
|
return t === "0" || t === 0 ? "before" : "after";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function A(t) {
|
|
8
8
|
if (typeof t == "number" && Number.isFinite(t))
|
|
9
9
|
return t;
|
|
10
10
|
if (typeof t == "string") {
|
|
@@ -14,51 +14,52 @@ function _(t) {
|
|
|
14
14
|
}
|
|
15
15
|
return i.decimalCount;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function L(t) {
|
|
18
18
|
return t === "." || t === "," || t === " " || t === "" ? t : ",";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function N(t) {
|
|
21
21
|
return t === "." || t === "," || t === " " ? t : ".";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function R(t) {
|
|
24
24
|
if (!t || typeof t != "object")
|
|
25
25
|
return { ...i };
|
|
26
|
-
const o = t, n = o.value ?? o.name ?? i.code,
|
|
26
|
+
const o = t, n = o.value ?? o.name ?? i.code, e = o.symbol ?? n;
|
|
27
27
|
return {
|
|
28
28
|
code: n,
|
|
29
|
-
symbol:
|
|
30
|
-
alignment:
|
|
31
|
-
decimalCount:
|
|
32
|
-
decimalSeparator:
|
|
33
|
-
thousandSeparator:
|
|
29
|
+
symbol: e,
|
|
30
|
+
alignment: I(o.alignment),
|
|
31
|
+
decimalCount: A(o.decimalCount),
|
|
32
|
+
decimalSeparator: N(o.decimalSeparator),
|
|
33
|
+
thousandSeparator: L(o.thousandSeparator)
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function b(t) {
|
|
37
37
|
return t === "horizontal" || t === "list" ? "list" : "grid";
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function D(t) {
|
|
40
|
+
return _(t) || "mostPopular";
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
42
|
+
function U(t, o, n) {
|
|
43
|
+
var a, u;
|
|
44
|
+
const e = o.rowCount ?? t.cardsInRow ?? d, m = o.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
|
|
44
45
|
return {
|
|
45
46
|
recommendationId: n,
|
|
46
|
-
strategy:
|
|
47
|
-
productIds: (t.productIds ?? []).map((
|
|
48
|
-
size: String(
|
|
47
|
+
strategy: D(t.strategy),
|
|
48
|
+
productIds: (t.productIds ?? []).map((r) => String(r)),
|
|
49
|
+
size: String(m),
|
|
49
50
|
shuffleProducts: !!t.shuffleProducts,
|
|
50
51
|
language: t.language ?? "en_US",
|
|
51
|
-
currency:
|
|
52
|
-
filters: (t.filters ?? []).map((
|
|
53
|
-
layout:
|
|
54
|
-
cardsInRow:
|
|
55
|
-
mobileCardsInRow:
|
|
56
|
-
mobileLayoutEnabled: !
|
|
57
|
-
previousMobileCardsInRow:
|
|
58
|
-
columnSpacing:
|
|
59
|
-
rowSpacing:
|
|
60
|
-
mobileColumnSpacing:
|
|
61
|
-
mobileRowSpacing:
|
|
52
|
+
currency: R(t.currencySettings),
|
|
53
|
+
filters: (t.filters ?? []).map((r) => ({ ...r })),
|
|
54
|
+
layout: b(t.orientation ?? o.orientation),
|
|
55
|
+
cardsInRow: e,
|
|
56
|
+
mobileCardsInRow: s,
|
|
57
|
+
mobileLayoutEnabled: ((u = (a = o.theme) == null ? void 0 : a.blockAdapt) == null ? void 0 : u.adapt) === !0,
|
|
58
|
+
previousMobileCardsInRow: s,
|
|
59
|
+
columnSpacing: l,
|
|
60
|
+
rowSpacing: f,
|
|
61
|
+
mobileColumnSpacing: c,
|
|
62
|
+
mobileRowSpacing: S,
|
|
62
63
|
omnibusPrice: { textBefore: "", textAfter: "" },
|
|
63
64
|
omnibusDiscount: { textBefore: "", textAfter: "" },
|
|
64
65
|
// Preserve the legacy price-placement toggles. Absent legacy keys map to
|
|
@@ -66,10 +67,10 @@ function O(t, o, n) {
|
|
|
66
67
|
// gated). New Guido blocks default differently (see DEFAULT_NODE_CONFIG).
|
|
67
68
|
priceMovedToNextLine: !!t.isPriceMovedToNextLine,
|
|
68
69
|
priceHideIfSameAsDiscounted: !!t.isPriceDeletedForZeroSale,
|
|
69
|
-
configVersion:
|
|
70
|
+
configVersion: p
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
R as mapCurrency,
|
|
75
|
+
U as mapSettings
|
|
75
76
|
};
|
|
@@ -1,51 +1,57 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { extractCurrencyFromBlock as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import { parseRecommendationId as
|
|
9
|
-
import { mapSettings as
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
var
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
1
|
+
import { BlockId as y } from "../../enums/block.js";
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as v } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as p } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as b } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as C } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { extractCurrencyFromBlock as M, isPriceOnNextLine as x, isOldPriceFirst as R, withRenderedTextTheme as h, extractTitleText as w, hasEmptyTitle as E, hasVisibleTitle as L, extractCardBgColor as S, isPartnerManagedBlock as A } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as H } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { parseRecommendationId as B, parseLegacyConfig as N } from "./recommendation/parseLegacyConfig.js";
|
|
9
|
+
import { mapSettings as O } from "./recommendation/settingsMapper.js";
|
|
10
|
+
const F = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
|
|
11
|
+
function I(c, e, s) {
|
|
12
|
+
var d;
|
|
13
|
+
const t = B(e);
|
|
14
|
+
if (t === null)
|
|
15
15
|
return console.warn(
|
|
16
16
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
17
17
|
), !1;
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
18
|
+
const r = N(e);
|
|
19
|
+
if (!r)
|
|
20
20
|
return console.warn(
|
|
21
|
-
`[RecommendationMigrator] Aborting block id=${
|
|
21
|
+
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` missing or unable to be parsed`
|
|
22
22
|
), !1;
|
|
23
|
-
const
|
|
24
|
-
currencySettings:
|
|
25
|
-
},
|
|
26
|
-
e.titleVariable || (e.visibility[b] = R(t));
|
|
27
|
-
const p = S(t), g = {
|
|
23
|
+
const i = s[String(t)] ?? {
|
|
24
|
+
currencySettings: M(e)
|
|
25
|
+
}, n = {
|
|
28
26
|
...i,
|
|
27
|
+
isPriceMovedToNextLine: i.isPriceMovedToNextLine ?? x(e)
|
|
28
|
+
}, a = O(n, r, t), o = C(
|
|
29
|
+
h((d = r.composition) == null ? void 0 : d.variables, e),
|
|
30
|
+
{ oldPriceFirst: R(e) }
|
|
31
|
+
), g = w(e);
|
|
32
|
+
E(e) ? o.visibility[p] = !1 : o.titleVariable || (o.visibility[p] = L(e));
|
|
33
|
+
const f = S(e), u = {
|
|
34
|
+
...a,
|
|
29
35
|
strategyId: "",
|
|
30
|
-
composition:
|
|
31
|
-
visibility:
|
|
32
|
-
previousTitleHtml:
|
|
33
|
-
textTrimming:
|
|
34
|
-
}, m =
|
|
36
|
+
composition: o.composition,
|
|
37
|
+
visibility: o.visibility,
|
|
38
|
+
previousTitleHtml: v.previousTitleHtml,
|
|
39
|
+
textTrimming: o.anyTextTrimming
|
|
40
|
+
}, m = A(e), T = `
|
|
35
41
|
<table>
|
|
36
42
|
<tbody>
|
|
37
43
|
<tr>
|
|
38
44
|
<td class="esd-structure" align="left">
|
|
39
45
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
40
46
|
<tbody>
|
|
41
|
-
<tr>${
|
|
42
|
-
nodeConfig:
|
|
43
|
-
composition:
|
|
44
|
-
cardBg:
|
|
45
|
-
titleText:
|
|
46
|
-
legacyId:
|
|
47
|
-
legacyBgColor:
|
|
48
|
-
preserveInnerHtml: m ?
|
|
47
|
+
<tr>${H({
|
|
48
|
+
nodeConfig: u,
|
|
49
|
+
composition: o,
|
|
50
|
+
cardBg: f,
|
|
51
|
+
titleText: g,
|
|
52
|
+
legacyId: e.getAttribute("id") ?? void 0,
|
|
53
|
+
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
54
|
+
preserveInnerHtml: m ? e.innerHTML : void 0,
|
|
49
55
|
skipCompile: m
|
|
50
56
|
})}</tr>
|
|
51
57
|
</tbody>
|
|
@@ -54,40 +60,40 @@ function B(n, t, c) {
|
|
|
54
60
|
</tr>
|
|
55
61
|
</tbody>
|
|
56
62
|
</table>
|
|
57
|
-
`,
|
|
58
|
-
return !
|
|
59
|
-
`[RecommendationMigrator] Aborting block id=${
|
|
60
|
-
), !1) : (
|
|
63
|
+
`, l = c.parseFromString(T, "text/html").querySelector("td.esd-structure");
|
|
64
|
+
return !l || !e.parentNode ? (console.warn(
|
|
65
|
+
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
66
|
+
), !1) : (e.parentNode.replaceChild(l, e), !0);
|
|
61
67
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
let
|
|
68
|
+
function j(c, e = {}) {
|
|
69
|
+
const s = new DOMParser();
|
|
70
|
+
let t;
|
|
65
71
|
try {
|
|
66
|
-
|
|
67
|
-
} catch (
|
|
68
|
-
return console.error("[RecommendationMigrator] Failed to parse template:",
|
|
72
|
+
t = s.parseFromString(c, "text/html");
|
|
73
|
+
} catch (n) {
|
|
74
|
+
return console.error("[RecommendationMigrator] Failed to parse template:", n), c;
|
|
69
75
|
}
|
|
70
|
-
const
|
|
76
|
+
const r = Array.from(t.querySelectorAll(F));
|
|
71
77
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...
|
|
75
|
-
[
|
|
78
|
+
b().$patch((a) => {
|
|
79
|
+
a.migrations = {
|
|
80
|
+
...a.migrations,
|
|
81
|
+
[y.Recommendation]: r.length
|
|
76
82
|
};
|
|
77
83
|
});
|
|
78
84
|
} catch {
|
|
79
85
|
}
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
82
|
-
let
|
|
83
|
-
return
|
|
86
|
+
if (r.length === 0)
|
|
87
|
+
return c;
|
|
88
|
+
let i = 0;
|
|
89
|
+
return r.forEach((n) => {
|
|
84
90
|
try {
|
|
85
|
-
|
|
86
|
-
} catch (
|
|
87
|
-
console.error("[RecommendationMigrator] Unexpected error migrating block:",
|
|
91
|
+
I(s, n, e) && (i += 1);
|
|
92
|
+
} catch (a) {
|
|
93
|
+
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
88
94
|
}
|
|
89
|
-
}),
|
|
95
|
+
}), i > 0 && console.info(`[RecommendationMigrator] Migrated ${i} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
90
96
|
}
|
|
91
97
|
export {
|
|
92
|
-
|
|
98
|
+
j as migrateRecommendation
|
|
93
99
|
};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { CommonControl as
|
|
2
|
-
import { ItemsBlockControlId as
|
|
3
|
-
import { getItemsBlockConfig as
|
|
4
|
-
const
|
|
1
|
+
import { CommonControl as r } from "../../../common-control.js";
|
|
2
|
+
import { ItemsBlockControlId as i } from "../../enums/controlEnums.js";
|
|
3
|
+
import { getItemsBlockConfig as o } from "../../utils/nodeConfigUtils.js";
|
|
4
|
+
const s = i.BUTTON_LINK, n = {
|
|
5
5
|
LINK: "link"
|
|
6
6
|
};
|
|
7
|
-
class
|
|
7
|
+
class m extends r {
|
|
8
8
|
getId() {
|
|
9
|
-
return
|
|
9
|
+
return s;
|
|
10
10
|
}
|
|
11
11
|
getTemplate() {
|
|
12
12
|
return `
|
|
13
|
-
<div class="container ${
|
|
13
|
+
<div class="container ${s}">
|
|
14
14
|
${this._getLink()}
|
|
15
15
|
</div>
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
onRender() {
|
|
19
|
-
this.
|
|
19
|
+
const t = o(this.currentNode);
|
|
20
|
+
this.api.updateValues({
|
|
21
|
+
[n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
|
-
onTemplateNodeUpdated(
|
|
22
|
-
super.onTemplateNodeUpdated(
|
|
23
|
-
const
|
|
24
|
+
onTemplateNodeUpdated(t) {
|
|
25
|
+
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
26
|
+
const e = o(this.currentNode);
|
|
24
27
|
this.api.updateValues({
|
|
25
|
-
[n.LINK]: (
|
|
28
|
+
[n.LINK]: (e == null ? void 0 : e.buttonLink) ?? ""
|
|
26
29
|
});
|
|
27
30
|
});
|
|
28
31
|
}
|
|
@@ -41,6 +44,6 @@ class L extends s {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
m as ButtonLinkControl,
|
|
48
|
+
s as CONTROL_BLOCK_ID
|
|
46
49
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var I = Object.defineProperty;
|
|
2
2
|
var U = (d, a, t) => a in d ? I(d, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[a] = t;
|
|
3
|
-
var
|
|
3
|
+
var p = (d, a, t) => U(d, typeof a != "symbol" ? a + "" : a, t);
|
|
4
4
|
import { ModificationDescription as c } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as b } from "../../common-control.js";
|
|
6
6
|
import { ItemsBlockId as r } from "../enums/controlEnums.js";
|
|
7
7
|
import { SETTINGS_ENUMS as h } from "../enums/settingsEnums.js";
|
|
8
8
|
import { getItemsBlockConfig as R, setItemsBlockConfig as m } from "../utils/nodeConfigUtils.js";
|
|
9
|
-
const
|
|
9
|
+
const g = "ui-elements-items-card-composition-block", i = {
|
|
10
10
|
PRODUCT_IMAGE: "image",
|
|
11
11
|
PRODUCT_NAME: "name",
|
|
12
12
|
PRODUCT_QUANTITY: "quantity",
|
|
@@ -17,7 +17,7 @@ const N = "ui-elements-items-card-composition-block", i = {
|
|
|
17
17
|
class M extends b {
|
|
18
18
|
constructor() {
|
|
19
19
|
super(...arguments);
|
|
20
|
-
|
|
20
|
+
p(this, "visibilityState", {
|
|
21
21
|
[i.PRODUCT_IMAGE]: !0,
|
|
22
22
|
[i.PRODUCT_NAME]: !0,
|
|
23
23
|
[i.PRODUCT_QUANTITY]: !0,
|
|
@@ -27,7 +27,7 @@ class M extends b {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
getId() {
|
|
30
|
-
return
|
|
30
|
+
return g;
|
|
31
31
|
}
|
|
32
32
|
getTemplate() {
|
|
33
33
|
return `
|
|
@@ -44,7 +44,7 @@ class M extends b {
|
|
|
44
44
|
`;
|
|
45
45
|
}
|
|
46
46
|
onRender() {
|
|
47
|
-
this.
|
|
47
|
+
this._syncVisibilityFromAttributes(), this._handleBrowsedItemsQuantity(), this._initializeToggles(), this._listenToFormUpdates();
|
|
48
48
|
}
|
|
49
49
|
onTemplateNodeUpdated(t) {
|
|
50
50
|
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
@@ -61,6 +61,9 @@ class M extends b {
|
|
|
61
61
|
</div>
|
|
62
62
|
`;
|
|
63
63
|
}
|
|
64
|
+
_initializeToggles() {
|
|
65
|
+
this._updateTogglesFromState();
|
|
66
|
+
}
|
|
64
67
|
_updateTogglesFromState() {
|
|
65
68
|
this.api.updateValues({
|
|
66
69
|
[i.PRODUCT_IMAGE]: this.visibilityState[i.PRODUCT_IMAGE],
|
|
@@ -221,21 +224,21 @@ class M extends b {
|
|
|
221
224
|
* - When both are visible, they share 50% each
|
|
222
225
|
*/
|
|
223
226
|
_updatePriceCellWidthsForVerticalLayout(t) {
|
|
224
|
-
var O,
|
|
227
|
+
var O, y;
|
|
225
228
|
const e = R(this.currentNode);
|
|
226
229
|
if (!((e == null ? void 0 : e.orientation) === h.ORIENTATION.VERTICAL))
|
|
227
230
|
return;
|
|
228
|
-
const n = (O = this.currentNode) == null ? void 0 : O.querySelectorAll(".product-price-class"), s = (
|
|
231
|
+
const n = (O = this.currentNode) == null ? void 0 : O.querySelectorAll(".product-price-class"), s = (y = this.currentNode) == null ? void 0 : y.querySelectorAll(".product-original-price-class"), l = (e == null ? void 0 : e.priceOrientation) === "vertical", P = this.visibilityState[i.PRODUCT_PRICE], C = this.visibilityState[i.PRODUCT_ORIGINAL_PRICE], T = t ?? this.api.getDocumentModifier();
|
|
229
232
|
if (n && n.length > 0) {
|
|
230
|
-
const
|
|
231
|
-
n.forEach((
|
|
232
|
-
T.modifyHtml(
|
|
233
|
+
const _ = l || !C ? "100%" : "50%";
|
|
234
|
+
n.forEach((u) => {
|
|
235
|
+
T.modifyHtml(u).setStyle("width", _);
|
|
233
236
|
});
|
|
234
237
|
}
|
|
235
238
|
if (s && s.length > 0) {
|
|
236
|
-
const
|
|
237
|
-
s.forEach((
|
|
238
|
-
T.modifyHtml(
|
|
239
|
+
const _ = l || !P ? "100%" : "50%";
|
|
240
|
+
s.forEach((u) => {
|
|
241
|
+
T.modifyHtml(u).setStyle("width", _);
|
|
239
242
|
});
|
|
240
243
|
}
|
|
241
244
|
t || T.apply(new c("Updated price cell widths for vertical layout"));
|
|
@@ -253,6 +256,6 @@ class M extends b {
|
|
|
253
256
|
}
|
|
254
257
|
}
|
|
255
258
|
export {
|
|
256
|
-
|
|
259
|
+
g as COMPOSITION_CONTROL_BLOCK_ID,
|
|
257
260
|
M as ItemsBlockCardCompositionControl
|
|
258
261
|
};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { CommonControl as
|
|
2
|
-
import { ItemsBlockControlId as
|
|
3
|
-
import { getItemsBlockConfig as
|
|
4
|
-
const
|
|
1
|
+
import { CommonControl as a } from "../../../common-control.js";
|
|
2
|
+
import { ItemsBlockControlId as i } from "../../enums/controlEnums.js";
|
|
3
|
+
import { getItemsBlockConfig as o } from "../../utils/nodeConfigUtils.js";
|
|
4
|
+
const s = i.IMAGE_LINK, n = {
|
|
5
5
|
LINK: "link"
|
|
6
6
|
};
|
|
7
|
-
class
|
|
7
|
+
class p extends a {
|
|
8
8
|
getId() {
|
|
9
|
-
return
|
|
9
|
+
return s;
|
|
10
10
|
}
|
|
11
11
|
getTemplate() {
|
|
12
12
|
return `
|
|
13
|
-
<div class="container ${
|
|
13
|
+
<div class="container ${s}">
|
|
14
14
|
${this._getLink()}
|
|
15
15
|
</div>
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
onRender() {
|
|
19
|
-
this.
|
|
19
|
+
const e = o(this.currentNode);
|
|
20
|
+
this.api.updateValues({
|
|
21
|
+
[n.LINK]: (e == null ? void 0 : e.imageLink) ?? ""
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
|
-
onTemplateNodeUpdated(
|
|
22
|
-
super.onTemplateNodeUpdated(
|
|
23
|
-
const
|
|
24
|
+
onTemplateNodeUpdated(e) {
|
|
25
|
+
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
26
|
+
const t = o(this.currentNode);
|
|
24
27
|
this.api.updateValues({
|
|
25
|
-
[n.LINK]: (
|
|
28
|
+
[n.LINK]: (t == null ? void 0 : t.imageLink) ?? ""
|
|
26
29
|
});
|
|
27
30
|
});
|
|
28
31
|
}
|
|
@@ -41,6 +44,6 @@ class L extends s {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
s as CONTROL_BLOCK_ID,
|
|
48
|
+
p as ImageLinkControl
|
|
46
49
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ModificationDescription as d, UIElementType as
|
|
1
|
+
import { ModificationDescription as d, UIElementType as s, UEAttr as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CommonControl as T } from "../../../common-control.js";
|
|
3
3
|
import { nameMaxWidthFor as h } from "../../constants/cardLayout.js";
|
|
4
4
|
import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
|
|
5
5
|
import { findNameTextNode as c } from "../../utils/nameNode.js";
|
|
6
|
-
import { getItemsBlockConfig as
|
|
6
|
+
import { getItemsBlockConfig as r, setItemsBlockConfig as g } from "../../utils/nodeConfigUtils.js";
|
|
7
7
|
const I = a.NAME_TRIMMING, n = {
|
|
8
8
|
TRIMMING: "trimming"
|
|
9
9
|
};
|
|
@@ -19,13 +19,14 @@ class E extends T {
|
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
onRender() {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const e = r(this.currentNode);
|
|
23
|
+
this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.TRIMMING, (t) => {
|
|
24
|
+
this._onTrimmingChange(t);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
onTemplateNodeUpdated(e) {
|
|
27
28
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
29
|
+
const t = r(this.currentNode);
|
|
29
30
|
this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -36,16 +37,16 @@ class E extends T {
|
|
|
36
37
|
const t = c(this.currentNode);
|
|
37
38
|
if (!t)
|
|
38
39
|
return;
|
|
39
|
-
const i =
|
|
40
|
-
|
|
40
|
+
const i = r(this.currentNode), m = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, l = h(i == null ? void 0 : i.orientation), o = this.api.getDocumentModifier().modifyHtml(t);
|
|
41
|
+
m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", l).apply(new d(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
|
|
41
42
|
}
|
|
42
43
|
_getTextTrimming() {
|
|
43
44
|
return `
|
|
44
45
|
<div class="display-flex align-items-center justify-content-between">
|
|
45
|
-
<${
|
|
46
|
+
<${s.LABEL}
|
|
46
47
|
${p.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
48
|
>
|
|
48
|
-
</${
|
|
49
|
+
</${s.LABEL}>
|
|
49
50
|
${this._GuToggle(n.TRIMMING)}
|
|
50
51
|
</div>
|
|
51
52
|
`;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { currencyLocationMaps as
|
|
2
|
-
import { UEAttr as
|
|
3
|
-
import { CommonControl as
|
|
1
|
+
import { currencyLocationMaps as p } from "../../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { CommonControl as L } from "../../../common-control.js";
|
|
4
4
|
import { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
|
|
5
|
-
import { ItemsBlockControlId as
|
|
6
|
-
import { getItemsBlockConfig as
|
|
7
|
-
const b =
|
|
5
|
+
import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
|
|
6
|
+
import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
|
|
7
|
+
const b = m.PRICE_CURRENCY_LOCATION, c = {
|
|
8
8
|
CURRENCY_LOCATION: "currencyLocation"
|
|
9
9
|
};
|
|
10
|
-
class
|
|
10
|
+
class Y extends L {
|
|
11
11
|
getId() {
|
|
12
12
|
return b;
|
|
13
13
|
}
|
|
14
14
|
getTemplate() {
|
|
15
15
|
return `
|
|
16
|
-
<div class="container ${
|
|
16
|
+
<div class="container ${m.PRICE_CURRENCY_LOCATION}">
|
|
17
17
|
${this._getCurrencyLocation()}
|
|
18
18
|
</div>
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
onRender() {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const e = l(this.currentNode);
|
|
23
|
+
this.api.setUIEAttribute(c.CURRENCY_LOCATION, N.SELECTPICKER.items, p), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
|
|
24
|
+
this._onCurrencyLocationChange(t);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
onTemplateNodeUpdated(e) {
|
|
27
28
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
29
|
-
this.api.updateValues({ [
|
|
29
|
+
const t = l(this.currentNode);
|
|
30
|
+
this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
_onCurrencyLocationChange(e) {
|
|
@@ -35,15 +36,15 @@ class B extends N {
|
|
|
35
36
|
const t = this._getPriceBlocks();
|
|
36
37
|
if (!t || t.length === 0)
|
|
37
38
|
return;
|
|
38
|
-
const r =
|
|
39
|
+
const r = l(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = E(n), s = this.api.getDocumentModifier();
|
|
39
40
|
t.forEach((h) => {
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
41
|
+
const a = this._getParagraph(h);
|
|
42
|
+
if (!a)
|
|
42
43
|
return;
|
|
43
|
-
const d =
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
`Updated currency location to ${
|
|
44
|
+
const d = a.getInnerHTML().trim() || "", C = a.getInnerText().trim() || "", u = (o == null ? void 0 : o.trim()) || "", _ = this._removeCurrencySymbol(C, u), g = this._detectSymbolInText(C) || u, R = this._buildPriceContent(_, g, n), y = d.replace(C, f(R));
|
|
45
|
+
s.modifyHtml(a).setInnerHtml(y).setAttribute(T.POSITION, i);
|
|
46
|
+
}), s.apply(new I(
|
|
47
|
+
`Updated currency location to ${i}`
|
|
47
48
|
));
|
|
48
49
|
}
|
|
49
50
|
_getPriceBlocks() {
|
|
@@ -65,8 +66,8 @@ class B extends N {
|
|
|
65
66
|
} else {
|
|
66
67
|
const o = r.match(/([^0-9.,\s]+)/);
|
|
67
68
|
if (o && o[1]) {
|
|
68
|
-
const
|
|
69
|
-
n = r.replace(
|
|
69
|
+
const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
|
|
70
|
+
n = r.replace(s, "").trim();
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
return n;
|
|
@@ -83,9 +84,9 @@ class B extends N {
|
|
|
83
84
|
${this._GuTwoColumns([
|
|
84
85
|
this._GuLabel({ text: "Currency Location" }),
|
|
85
86
|
this._GuSelect({
|
|
86
|
-
name:
|
|
87
|
+
name: c.CURRENCY_LOCATION,
|
|
87
88
|
placeholder: "",
|
|
88
|
-
options:
|
|
89
|
+
options: p
|
|
89
90
|
})
|
|
90
91
|
])}
|
|
91
92
|
`;
|
|
@@ -93,5 +94,5 @@ class B extends N {
|
|
|
93
94
|
}
|
|
94
95
|
export {
|
|
95
96
|
b as CONTROL_BLOCK_ID,
|
|
96
|
-
|
|
97
|
+
Y as PriceCurrencyLocationControl
|
|
97
98
|
};
|