@useinsider/guido 3.22.0-beta.0951deb → 3.22.0-beta.7c8fae0
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/README.md +0 -1
- package/dist/@types/config/schemas.js +39 -41
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +79 -81
- package/dist/composables/useBlocksConfig.js +24 -32
- 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/enums/academy.js +0 -1
- package/dist/extensions/Blocks/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +20 -19
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +148 -163
- 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/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
- package/dist/node_modules/valibot/dist/index.js +261 -297
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- 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/enums/academy.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -8
- 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/stores/config.d.ts +0 -166
- package/dist/stores/config.js +6 -13
- package/dist/utils/pairProductVariables.js +29 -30
- package/package.json +1 -1
- package/dist/@types/display-condition.js +0 -25
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -20
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -30
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -71
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -34
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -57
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
- package/dist/composables/useDisplayConditions.js +0 -102
- package/dist/enums/display-condition.js +0 -12
- package/dist/extensions/DisplayConditions/bridge.js +0 -17
- package/dist/extensions/DisplayConditions/constants.js +0 -17
- package/dist/extensions/DisplayConditions/control.js +0 -178
- package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -201
- package/dist/extensions/DisplayConditions/extension.js +0 -28
- package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
- package/dist/extensions/DisplayConditions/library.js +0 -27
- package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
- package/dist/services/displayConditionApi.js +0 -39
- package/dist/src/@types/display-condition.d.ts +0 -59
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
- package/dist/src/composables/useDisplayConditions.d.ts +0 -16
- package/dist/src/enums/display-condition.d.ts +0 -15
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -6
- package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -14
- package/dist/src/extensions/DisplayConditions/control.d.ts +0 -23
- package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
- package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
- package/dist/src/mock/api/display-conditions.d.ts +0 -2
- package/dist/src/services/displayConditionApi.d.ts +0 -8
- package/dist/src/stores/display-condition.d.ts +0 -81
- package/dist/src/utils/displayCondition.d.ts +0 -10
- package/dist/src/utils/protectTableText.d.ts +0 -2
- package/dist/stores/display-condition.js +0 -28
- package/dist/utils/displayCondition.js +0 -26
- package/dist/utils/protectTableText.js +0 -22
|
@@ -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
|
};
|
package/dist/enums/academy.js
CHANGED
|
@@ -2,7 +2,6 @@ const e = "https://academy.insiderone.com", o = {
|
|
|
2
2
|
EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
|
|
3
3
|
GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
|
|
4
4
|
AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
|
|
5
|
-
EMAIL_DISPLAY_CONDITIONS: `${e}/docs/new-editor-add-display-conditions-to-an-email`,
|
|
6
5
|
EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
|
|
7
6
|
};
|
|
8
7
|
export {
|
|
@@ -2,23 +2,24 @@ var b = Object.defineProperty;
|
|
|
2
2
|
var A = (m, c, e) => c in m ? b(m, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[c] = e;
|
|
3
3
|
var u = (m, c, e) => A(m, typeof c != "symbol" ? c + "" : c, e);
|
|
4
4
|
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
5
|
+
import { BlockId as E } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as D } from "../../../utils/migrationBannerHtml.js";
|
|
7
7
|
import { Block as S, BlockCompositionType as v, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as M, PRE_RRS_CONFIG_VERSION as N } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as f } from "./constants/selectors.js";
|
|
10
|
-
import { ensureMobileFitRule as
|
|
11
|
-
import { regenerateMobileProductRows as
|
|
12
|
-
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as
|
|
10
|
+
import { ensureMobileFitRule as T, syncHeightBound as w } from "./controls/image/index.js";
|
|
11
|
+
import { regenerateMobileProductRows as O } from "./controls/main/utils.js";
|
|
12
|
+
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as x } from "./controls/mobileLayout/cssRules.js";
|
|
13
|
+
import { CSS_CLASS_TEXT_TRIM as H, ensureTextTrimCssRulesExist as $ } from "./controls/shared/textTrimCssRules.js";
|
|
13
14
|
import { RecommendationConfigService as a } from "./services/configService.js";
|
|
14
15
|
import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
|
|
15
|
-
import { getDefaultTemplate as
|
|
16
|
+
import { getDefaultTemplate as q } from "./templates/grid/template.js";
|
|
16
17
|
import { useRecommendationBlockWarning as F } from "./useRecommendationBlockWarning.js";
|
|
17
|
-
import { registerNodeConfigWriter as y, readBlockNodeConfigs as
|
|
18
|
-
import { refreshArrivedStrategyBlocks as
|
|
19
|
-
const k =
|
|
18
|
+
import { registerNodeConfigWriter as y, readBlockNodeConfigs as L } from "./utils/nodeConfigWriter.js";
|
|
19
|
+
import { refreshArrivedStrategyBlocks as P, resolveSourceConfig as V, refreshDuplicatedStrategyBlocks as W } from "./utils/strategyCommit.js";
|
|
20
|
+
const k = E.Recommendation, h = "recommendation-block-v2", C = "hide-price";
|
|
20
21
|
let B = !1;
|
|
21
|
-
class
|
|
22
|
+
class ae extends S {
|
|
22
23
|
constructor() {
|
|
23
24
|
super();
|
|
24
25
|
/**
|
|
@@ -52,7 +53,7 @@ class se extends S {
|
|
|
52
53
|
);
|
|
53
54
|
}
|
|
54
55
|
getSettingsPanelTitleHtml() {
|
|
55
|
-
return
|
|
56
|
+
return D(
|
|
56
57
|
k,
|
|
57
58
|
this.api.translate("Recommendation Block"),
|
|
58
59
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
@@ -76,7 +77,7 @@ class se extends S {
|
|
|
76
77
|
*/
|
|
77
78
|
getTemplate() {
|
|
78
79
|
const e = this._generateNextId();
|
|
79
|
-
return this._pendingBlockId = e,
|
|
80
|
+
return this._pendingBlockId = e, q(e);
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
83
|
* Called when a new block is dropped into the template
|
|
@@ -110,7 +111,7 @@ class se extends S {
|
|
|
110
111
|
e,
|
|
111
112
|
{
|
|
112
113
|
recommendationId: i,
|
|
113
|
-
configVersion: r ?
|
|
114
|
+
configVersion: r ? M : N,
|
|
114
115
|
...s ? { partnerName: g().partnerName.value } : {},
|
|
115
116
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
116
117
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
@@ -121,7 +122,7 @@ class se extends S {
|
|
|
121
122
|
if (l.setCurrentBlock(i), this._stampHidePrice(e, n.priceHideIfSameAsDiscounted), o) {
|
|
122
123
|
I(this.api);
|
|
123
124
|
const d = this._getBlockElement(e);
|
|
124
|
-
d && (R(this.api, d, !0),
|
|
125
|
+
d && (R(this.api, d, !0), O({
|
|
125
126
|
currentNode: e,
|
|
126
127
|
documentModifier: this.api.getDocumentModifier()
|
|
127
128
|
}));
|
|
@@ -155,13 +156,13 @@ class se extends S {
|
|
|
155
156
|
"Assign recommendation ID to legacy block"
|
|
156
157
|
);
|
|
157
158
|
}
|
|
158
|
-
this._healLingeringDuplicate(e), a.needsMigration(e) && this._migrateFromLegacy(e), this._healHidePriceAttr(e), this._ensureMobileFitRule(e), this._syncHeightBound(e);
|
|
159
|
+
this._healLingeringDuplicate(e), a.needsMigration(e) && this._migrateFromLegacy(e), this._healHidePriceAttr(e), this._ensureMobileFitRule(e), this._syncHeightBound(e), this._ensureTextTrimCss(e);
|
|
159
160
|
try {
|
|
160
161
|
B || (I(this.api), B = !0);
|
|
161
162
|
const t = a.getConfig(e), i = this._getBlockElement(e);
|
|
162
163
|
if (i) {
|
|
163
164
|
const r = !t.mobileLayoutEnabled;
|
|
164
|
-
|
|
165
|
+
x(i) !== r && R(this.api, i, r);
|
|
165
166
|
}
|
|
166
167
|
} catch {
|
|
167
168
|
}
|
|
@@ -179,7 +180,15 @@ class se extends S {
|
|
|
179
180
|
}
|
|
180
181
|
_ensureMobileFitRule(e) {
|
|
181
182
|
try {
|
|
182
|
-
|
|
183
|
+
T(this.api, e);
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// A migrated block arrives with trimmed cells but without the stylesheet rules the toggle would have added.
|
|
188
|
+
_ensureTextTrimCss(e) {
|
|
189
|
+
var t;
|
|
190
|
+
try {
|
|
191
|
+
(t = this._getBlockElement(e)) != null && t.querySelector(`.${H}`) && $(this.api);
|
|
183
192
|
} catch {
|
|
184
193
|
}
|
|
185
194
|
}
|
|
@@ -187,7 +196,7 @@ class se extends S {
|
|
|
187
196
|
const t = this._getBlockElement(e);
|
|
188
197
|
if (t)
|
|
189
198
|
try {
|
|
190
|
-
|
|
199
|
+
w(this.api, t);
|
|
191
200
|
} catch {
|
|
192
201
|
}
|
|
193
202
|
}
|
|
@@ -270,7 +279,7 @@ class se extends S {
|
|
|
270
279
|
const d = { strategyId: l.strategyId };
|
|
271
280
|
return t.add(n), this._refreshClaims.set(n, d), [{ id: n, config: l, claim: d }];
|
|
272
281
|
});
|
|
273
|
-
i.length &&
|
|
282
|
+
i.length && P(i.map(({ id: r, config: s }) => ({ id: r, config: s }))).catch((r) => console.error("[recommendation] refreshing an arrived strategy failed", r)).finally(() => i.forEach(({ id: r, claim: s }) => this._releaseRefreshClaim(r, s)));
|
|
274
283
|
}
|
|
275
284
|
/**
|
|
276
285
|
* A new document reports each block to onCreated and onDocumentInit, not always in one batch, so a
|
|
@@ -282,7 +291,7 @@ class se extends S {
|
|
|
282
291
|
return !0;
|
|
283
292
|
if (i.strategyId === t)
|
|
284
293
|
return !1;
|
|
285
|
-
const r =
|
|
294
|
+
const r = L(e);
|
|
286
295
|
return r.length > 0 && r.every((s) => s.strategyId === t);
|
|
287
296
|
}
|
|
288
297
|
_releaseRefreshClaim(e, t) {
|
|
@@ -344,10 +353,10 @@ class se extends S {
|
|
|
344
353
|
if (r.cloneBlockState(t, i), r.setCurrentBlock(i), g().isFeatureEnabled("reusableRecommendationStrategy")) {
|
|
345
354
|
this._resetSourceIds.add(t), y(this.api);
|
|
346
355
|
const s = a.getConfig(e), n = [
|
|
347
|
-
{ id: t, claim: { strategyId:
|
|
356
|
+
{ id: t, claim: { strategyId: V(t, s).strategyId } },
|
|
348
357
|
{ id: i, claim: { strategyId: s.strategyId } }
|
|
349
358
|
].filter(({ id: o }) => !this._refreshClaims.has(o));
|
|
350
|
-
n.forEach(({ id: o, claim: l }) => this._refreshClaims.set(o, l)),
|
|
359
|
+
n.forEach(({ id: o, claim: l }) => this._refreshClaims.set(o, l)), W(t, i, s).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o)).finally(() => n.forEach(({ id: o, claim: l }) => this._releaseRefreshClaim(o, l)));
|
|
351
360
|
}
|
|
352
361
|
this._warnIfMultipleBlocks();
|
|
353
362
|
}
|
|
@@ -451,5 +460,5 @@ class se extends S {
|
|
|
451
460
|
}
|
|
452
461
|
export {
|
|
453
462
|
k as BLOCK_ID,
|
|
454
|
-
|
|
463
|
+
ae as RecommendationBlock
|
|
455
464
|
};
|
|
@@ -11,10 +11,11 @@ import { useRecommendationExtensionStore as ft } from "../../store/recommendatio
|
|
|
11
11
|
import { ATTRIBUTE_CELL_CLASS as bt, gridElementRenderer as yt, DEFAULT_CELL_PADDING as Tt, buildFillerCell as Ct } from "../../templates/grid/elementRenderer.js";
|
|
12
12
|
import { listElementRenderer as St } from "../../templates/list/elementRenderer.js";
|
|
13
13
|
import { buildTitleRows as At, DEFAULT_TITLE_PARAGRAPH as It, DEFAULT_TITLE_TEXT as $t } from "../../templates/titleRows.js";
|
|
14
|
-
import {
|
|
15
|
-
import { normalizeCompositionKeys as
|
|
16
|
-
import { getTableDisplayValue as
|
|
17
|
-
import { isPartnerManagedBlock as
|
|
14
|
+
import { toDisplayName as vt, toDisplayableAttributeValue as Nt, buildElementRenderer as J } from "../../templates/utils.js";
|
|
15
|
+
import { normalizeCompositionKeys as Et, normalizeCustomAttrValues as Rt, compositionKeyToProductAttr as k, resolveRowVisibilityKeys as Lt, filterToProductAttrValue as C, findAttributeRow as Ot, rewriteLegacyRowKeyHtml as Q, bareAttributeName as H, isDefaultProductAttr as Dt, productAttrToCompositionKey as M } from "../../utils/compositionKeys.js";
|
|
16
|
+
import { getTableDisplayValue as Ht } from "../../utils/tagName.js";
|
|
17
|
+
import { isPartnerManagedBlock as Pt, regenerateProductRowsWithStyles as wt, getMainContainerTbody as Bt, getCurrentLayout as kt } from "../main/utils.js";
|
|
18
|
+
import { resolveInlinePriceOrder as Mt } from "../../utils/inlinePriceOrder.js";
|
|
18
19
|
const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wrapper > tbody", Z = ".product-info-cell > table > tbody", tt = {
|
|
19
20
|
ADD_ATTRIBUTE: "addAttribute"
|
|
20
21
|
}, b = 5, P = "reorderIcon_", qt = '<svg width="14" height="10" viewBox="0 0 14 10" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2.5" r="1.2"/><circle cx="7" cy="2.5" r="1.2"/><circle cx="12" cy="2.5" r="1.2"/><circle cx="2" cy="7.5" r="1.2"/><circle cx="7" cy="7.5" r="1.2"/><circle cx="12" cy="7.5" r="1.2"/></svg>', m = [
|
|
@@ -26,7 +27,7 @@ const Ut = "ui-elements-recommendation-card-composition", U = ".product-card-wra
|
|
|
26
27
|
{ key: pt, label: "Omnibus Discount" },
|
|
27
28
|
{ key: F, label: "Product Button" }
|
|
28
29
|
], L = { key: $, label: "Title" }, Ft = new Set(m.map((_) => _.key)), A = "customAttr_", w = "deleteAttr_";
|
|
29
|
-
class
|
|
30
|
+
class oe extends ut {
|
|
30
31
|
constructor() {
|
|
31
32
|
super(...arguments);
|
|
32
33
|
v(this, "store", ft());
|
|
@@ -155,7 +156,7 @@ class se extends ut {
|
|
|
155
156
|
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector("[data-card-composition-control]");
|
|
156
157
|
if (!t)
|
|
157
158
|
return;
|
|
158
|
-
const e =
|
|
159
|
+
const e = Pt(this.currentNode);
|
|
159
160
|
t.style.pointerEvents = e ? "none" : "", t.style.opacity = e ? "0.5" : "";
|
|
160
161
|
}
|
|
161
162
|
onTemplateNodeUpdated(t) {
|
|
@@ -198,7 +199,7 @@ class se extends ut {
|
|
|
198
199
|
}
|
|
199
200
|
/** Upgrades legacy bare-name custom keys to the canonical form. (SD-147101) */
|
|
200
201
|
_normalizeComposition(t) {
|
|
201
|
-
return
|
|
202
|
+
return Et(t, this.currentNode, this.store.filterList);
|
|
202
203
|
}
|
|
203
204
|
_readCustomAttributesFromNode() {
|
|
204
205
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
@@ -206,7 +207,7 @@ class se extends ut {
|
|
|
206
207
|
const t = this.currentNode.getAttribute(W);
|
|
207
208
|
if (t)
|
|
208
209
|
try {
|
|
209
|
-
return
|
|
210
|
+
return Rt(
|
|
210
211
|
JSON.parse(t).map((e) => String(e)),
|
|
211
212
|
this.currentNode,
|
|
212
213
|
this.store.filterList
|
|
@@ -241,7 +242,7 @@ class se extends ut {
|
|
|
241
242
|
if (!("getAttribute" in r))
|
|
242
243
|
return;
|
|
243
244
|
const i = r.getAttribute(D);
|
|
244
|
-
i !== null &&
|
|
245
|
+
i !== null && Lt(r).forEach((s) => {
|
|
245
246
|
e[s] = this._parseVisibilityValue(i);
|
|
246
247
|
});
|
|
247
248
|
}), e;
|
|
@@ -276,7 +277,7 @@ class se extends ut {
|
|
|
276
277
|
if (!(i.dataset.inlinePrices !== String(s)) && this._tryReorderInPlace(i, t))
|
|
277
278
|
return !1;
|
|
278
279
|
i.dataset.inlinePrices = String(s);
|
|
279
|
-
const n = new Set(e), l =
|
|
280
|
+
const n = new Set(e), l = Mt(t);
|
|
280
281
|
let a = 0, d = 0;
|
|
281
282
|
const c = t.map((u) => {
|
|
282
283
|
if (s && (u === p || u === I))
|
|
@@ -653,7 +654,7 @@ class se extends ut {
|
|
|
653
654
|
try {
|
|
654
655
|
this._updateBothAttributes(t, e);
|
|
655
656
|
const r = this._isInlinePrices();
|
|
656
|
-
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode &&
|
|
657
|
+
this._getCurrentLayout() === "grid" && !r ? this._reorderProductAttributes(t) : this.currentNode && wt({
|
|
657
658
|
currentNode: this.currentNode,
|
|
658
659
|
documentModifier: this.api.getDocumentModifier()
|
|
659
660
|
});
|
|
@@ -671,7 +672,7 @@ class se extends ut {
|
|
|
671
672
|
* DOM converge on the next composition change without writing on open.
|
|
672
673
|
*/
|
|
673
674
|
_getExistingRowHtml(t, e) {
|
|
674
|
-
const r =
|
|
675
|
+
const r = Ot(t, e);
|
|
675
676
|
if (r && "getOuterHTML" in r)
|
|
676
677
|
return Q(r.getOuterHTML(), e);
|
|
677
678
|
const i = t.querySelector(
|
|
@@ -815,7 +816,7 @@ class se extends ut {
|
|
|
815
816
|
return;
|
|
816
817
|
const o = e ? "1" : "0", n = e ? this.api.translate("visible") : this.api.translate("hidden"), l = `${this.api.translate("Set visibility")}: ${t} → ${n}`, a = this.api.getDocumentModifier();
|
|
817
818
|
s.forEach((c) => {
|
|
818
|
-
const u =
|
|
819
|
+
const u = Ht(c), h = e ? u : "none";
|
|
819
820
|
a.modifyHtml(c).setStyle("display", h).setAttribute(D, o);
|
|
820
821
|
});
|
|
821
822
|
const d = {
|
|
@@ -877,7 +878,7 @@ class se extends ut {
|
|
|
877
878
|
return "children" in t && t.children().some((e) => "hasClass" in e && e.hasClass(_t));
|
|
878
879
|
}
|
|
879
880
|
_findTitleContainerBody() {
|
|
880
|
-
return (this.currentNode ?
|
|
881
|
+
return (this.currentNode ? Bt(this.currentNode) : null) ?? void 0;
|
|
881
882
|
}
|
|
882
883
|
_readInnerHtml(t) {
|
|
883
884
|
return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : null;
|
|
@@ -904,7 +905,7 @@ class se extends ut {
|
|
|
904
905
|
return -1;
|
|
905
906
|
}
|
|
906
907
|
_getCurrentLayout() {
|
|
907
|
-
return this.store.recommendationConfigs.orientation ||
|
|
908
|
+
return this.store.recommendationConfigs.orientation || kt(this.currentNode);
|
|
908
909
|
}
|
|
909
910
|
/**
|
|
910
911
|
* Extracts background color properties from existing card elements.
|
|
@@ -1000,7 +1001,7 @@ class se extends ut {
|
|
|
1000
1001
|
*/
|
|
1001
1002
|
_getDisplayNameForAttribute(t) {
|
|
1002
1003
|
const e = Object.values(this.store.filterList).find((r) => C(r) === t);
|
|
1003
|
-
return e ? e.displayName :
|
|
1004
|
+
return e ? e.displayName : vt(H(t));
|
|
1004
1005
|
}
|
|
1005
1006
|
/**
|
|
1006
1007
|
* Resolves the display content for a custom attribute cell.
|
|
@@ -1008,8 +1009,8 @@ class se extends ut {
|
|
|
1008
1009
|
*/
|
|
1009
1010
|
_resolveAttributeContent(t, e, r) {
|
|
1010
1011
|
var l;
|
|
1011
|
-
const s = this.store.recommendationProducts[r], o = H(t), n =
|
|
1012
|
-
return
|
|
1012
|
+
const s = this.store.recommendationProducts[r], o = H(t), n = Dt(t) ? s == null ? void 0 : s[o] : (l = s == null ? void 0 : s.product_attributes) == null ? void 0 : l[o];
|
|
1013
|
+
return Nt(n) ?? e;
|
|
1013
1014
|
}
|
|
1014
1015
|
_getGridCellHtml(t, e, r, i = "", s = "", o = "") {
|
|
1015
1016
|
const n = M(t), l = H(t), a = J(yt, [n], this.store.filterList), d = {
|
|
@@ -1032,5 +1033,5 @@ class se extends ut {
|
|
|
1032
1033
|
}
|
|
1033
1034
|
export {
|
|
1034
1035
|
Ut as COMPOSITION_CONTROL_BLOCK_ID,
|
|
1035
|
-
|
|
1036
|
+
oe as RecommendationCardCompositionControl
|
|
1036
1037
|
};
|