@useinsider/guido 3.20.0 → 3.20.1-beta.04cd240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/composables/useStripo.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +42 -37
- package/dist/config/compiler/itemsCompilerRules.js +21 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +64 -17
- package/dist/config/migrator/itemsBlockMigrator.js +112 -108
- package/dist/extensions/Blocks/Items/block.js +76 -64
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +60 -49
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +163 -149
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +102 -78
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +313 -210
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +15 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +17 -12
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +92 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +219 -193
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +23 -18
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +12 -9
- package/dist/extensions/Blocks/Recommendation/extension.js +4 -2
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +240 -190
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/extensions/Blocks/Recommendation/utils/followUpApply.js +34 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +73 -28
- package/dist/extensions/Blocks/Recommendation/utils/restoreRefresh.js +36 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +39 -20
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
- package/dist/package.json.js +1 -1
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +10 -0
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +22 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +1 -18
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +10 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +2 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +28 -6
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/followUpApply.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +15 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/restoreRefresh.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
- package/dist/src/stores/editor.d.ts +3 -1
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/static/styles/components/button.css.js +5 -0
- package/dist/stores/editor.js +5 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +3 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useRecommendationExtensionStore as d } from "../store/recommendation.js";
|
|
2
|
+
import { commitBlockChangeOutsidePanel as l } from "./nodeConfigWriter.js";
|
|
3
|
+
async function S(e, { pickUpdates: r, description: i, fetch: a = !0, followUpAnchor: s = null }) {
|
|
4
|
+
const o = d(), n = o.blockStates[e];
|
|
5
|
+
if (!n)
|
|
6
|
+
return !1;
|
|
7
|
+
const { configVersion: c, adoptedSizeVersion: m } = n, f = r(n.recommendationConfigs);
|
|
8
|
+
if (a)
|
|
9
|
+
try {
|
|
10
|
+
await o.fetchRecommendationProductsForBlock(e);
|
|
11
|
+
} catch (u) {
|
|
12
|
+
console.error("[recommendation] product refetch outside the panel failed", u);
|
|
13
|
+
}
|
|
14
|
+
const t = o.blockStates[e];
|
|
15
|
+
return t ? t.configVersion !== c || t.adoptedSizeVersion !== m ? S(e, { pickUpdates: r, description: i, followUpAnchor: s }) : l(e, f, t.recommendationProducts, i, s) : !1;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
S as refreshBlockOutsidePanel
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RRS_CONFIG_VERSION as d, DEFAULT_CURRENCY as t, DEFAULT_NODE_CONFIG as e } from "../constants/defaultConfig.js";
|
|
2
|
+
import { mapLegacyStrategy as n } from "./legacyStrategyMap.js";
|
|
3
|
+
function S(r) {
|
|
4
|
+
var a, u, c, s, l, o;
|
|
5
|
+
const y = !!r.strategyId || (r.configVersion ?? 0) >= d;
|
|
6
|
+
return {
|
|
7
|
+
strategy: n(r.strategy) || (y ? "" : e.strategy),
|
|
8
|
+
strategyId: r.strategyId ?? e.strategyId,
|
|
9
|
+
language: r.language ?? e.language,
|
|
10
|
+
size: r.size ?? e.size,
|
|
11
|
+
// Copied: the source can be a live node config or the shared defaults.
|
|
12
|
+
productIds: [...r.productIds ?? e.productIds],
|
|
13
|
+
filters: structuredClone(r.filters ?? e.filters),
|
|
14
|
+
shuffleProducts: r.shuffleProducts ?? e.shuffleProducts,
|
|
15
|
+
currencyCode: ((a = r.currency) == null ? void 0 : a.code) ?? t.code,
|
|
16
|
+
currencySymbol: ((u = r.currency) == null ? void 0 : u.symbol) ?? t.symbol,
|
|
17
|
+
currencyAlignment: ((c = r.currency) == null ? void 0 : c.alignment) ?? t.alignment,
|
|
18
|
+
currencyDecimalCount: ((s = r.currency) == null ? void 0 : s.decimalCount) ?? t.decimalCount,
|
|
19
|
+
currencyDecimalSeparator: ((l = r.currency) == null ? void 0 : l.decimalSeparator) ?? t.decimalSeparator,
|
|
20
|
+
currencyThousandSeparator: ((o = r.currency) == null ? void 0 : o.thousandSeparator) ?? t.thousandSeparator
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
S as toBlockUrlConfig
|
|
25
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { extractWrapperTags as
|
|
1
|
+
import { extractWrapperTags as A } from "../../../../utils/preserveTextStyles.js";
|
|
2
2
|
import { RecommendationBlockId as c } from "../constants/blockIds.js";
|
|
3
|
-
import {
|
|
4
|
-
import { CSS_CLASS_TEXT_TRIM as
|
|
5
|
-
import { toCustomCompositionKey as
|
|
6
|
-
import {
|
|
7
|
-
import { hasQuerySelectorAll as
|
|
3
|
+
import { ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as y, ATTR_PRODUCT_OLD_PRICE as p, ATTR_PRODUCT_OMNIBUS_PRICE as R, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as x, ATTR_PRODUCT_IMAGE as q, DESKTOP_CONTAINER_SELECTOR as b, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
|
|
4
|
+
import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
|
|
5
|
+
import { toCustomCompositionKey as U } from "../templates/utils.js";
|
|
6
|
+
import { resolveRowVisibilityKeys as N, isMergedInlinePriceRow as C } from "./compositionKeys.js";
|
|
7
|
+
import { hasQuerySelectorAll as I, hasGetAttribute as l, hasGetStyle as O, hasGetComputedStyle as M } from "./tagName.js";
|
|
8
8
|
const s = [
|
|
9
9
|
"font-size",
|
|
10
10
|
"font-family",
|
|
@@ -14,14 +14,14 @@ const s = [
|
|
|
14
14
|
"text-align",
|
|
15
15
|
"line-height",
|
|
16
16
|
"text-decoration"
|
|
17
|
-
],
|
|
17
|
+
], D = [
|
|
18
18
|
"background",
|
|
19
19
|
"background-color",
|
|
20
20
|
"border-width",
|
|
21
21
|
"border-color",
|
|
22
22
|
"border-style",
|
|
23
23
|
"border-radius"
|
|
24
|
-
],
|
|
24
|
+
], w = [
|
|
25
25
|
...s,
|
|
26
26
|
"background",
|
|
27
27
|
"background-color",
|
|
@@ -40,47 +40,47 @@ const s = [
|
|
|
40
40
|
"border-radius",
|
|
41
41
|
"margin"
|
|
42
42
|
], g = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), L = [
|
|
43
|
-
{ attrKey:
|
|
44
|
-
{ attrKey:
|
|
45
|
-
{ attrKey:
|
|
46
|
-
{ attrKey:
|
|
47
|
-
{ attrKey:
|
|
48
|
-
{ attrKey:
|
|
43
|
+
{ attrKey: k, blockId: c.NAME, kind: "text" },
|
|
44
|
+
{ attrKey: y, blockId: c.PRICE, kind: "text" },
|
|
45
|
+
{ attrKey: p, blockId: c.OLD_PRICE, kind: "text" },
|
|
46
|
+
{ attrKey: R, blockId: c.OMNIBUS_PRICE, kind: "text" },
|
|
47
|
+
{ attrKey: _, blockId: c.OMNIBUS_DISCOUNT, kind: "text" },
|
|
48
|
+
{ attrKey: x, blockId: c.BUTTON, kind: "button" },
|
|
49
49
|
{ attrKey: q, blockId: c.IMAGE, kind: "image" }
|
|
50
50
|
];
|
|
51
|
-
function
|
|
51
|
+
function h(t) {
|
|
52
52
|
return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function K(t) {
|
|
55
55
|
return t && "getInnerText" in t && typeof t.getInnerText == "function" ? t.getInnerText().trim() : "";
|
|
56
56
|
}
|
|
57
57
|
function a(t, e, r) {
|
|
58
|
-
!e || !
|
|
58
|
+
!e || !O(e) || r.forEach((n) => {
|
|
59
59
|
const o = e.getStyle(n);
|
|
60
60
|
o && o !== "inherit" && o !== "initial" && (t[n] = o);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function E(t) {
|
|
64
64
|
return Object.entries(t).map(([e, r]) => `${e}: ${r};`).join(" ");
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
if (!t || !
|
|
66
|
+
function P(t) {
|
|
67
|
+
if (!t || !O(t))
|
|
68
68
|
return;
|
|
69
69
|
const e = t.getStyle("background-color") || t.getStyle("background");
|
|
70
70
|
return e && !g.has(e) ? e : void 0;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function S(t, e) {
|
|
73
73
|
const r = {};
|
|
74
|
-
return a(r, t, e),
|
|
74
|
+
return a(r, t, e), E(r);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function $(t) {
|
|
77
77
|
const e = t.querySelector("p"), r = {};
|
|
78
78
|
a(r, t, s), a(r, e, s), a(r, t.querySelector("strong"), s), a(r, t.querySelector("em"), s), a(r, t.querySelector("s"), s);
|
|
79
|
-
const n =
|
|
79
|
+
const n = E(r), { openTags: o, closeTags: i } = A(h(e));
|
|
80
80
|
return !n && !o ? null : { pStyle: n || void 0, openTags: o, closeTags: i };
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n =
|
|
82
|
+
function H(t) {
|
|
83
|
+
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = S(e, D), o = S(r, w), i = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(i), { openTags: T, closeTags: d } = A(h(r)), m = K(r);
|
|
84
84
|
return !n && !o && !u && !T && !m ? null : {
|
|
85
85
|
buttonBorderStyle: n || void 0,
|
|
86
86
|
buttonAnchorStyle: o || void 0,
|
|
@@ -90,44 +90,44 @@ function $(t) {
|
|
|
90
90
|
closeTags: d
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const e =
|
|
93
|
+
function F(t) {
|
|
94
|
+
const e = S(t.querySelector("img"), G);
|
|
95
95
|
return e ? { imgStyle: e } : null;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return e === "button" ?
|
|
97
|
+
function j(t, e) {
|
|
98
|
+
return e === "button" ? H(t) : e === "image" ? F(t) : $(t);
|
|
99
99
|
}
|
|
100
100
|
function f(t, e) {
|
|
101
101
|
if (!t || !("querySelector" in t))
|
|
102
102
|
return;
|
|
103
|
-
const r = t.querySelector(
|
|
103
|
+
const r = t.querySelector(b) ?? t;
|
|
104
104
|
if (L.forEach(({ attrKey: i, blockId: u, kind: T }) => {
|
|
105
105
|
const d = r.querySelector(`[esd-extension-block-id="${u}"]`);
|
|
106
106
|
d && e(d, i, T);
|
|
107
|
-
}), !
|
|
107
|
+
}), !I(r))
|
|
108
108
|
return;
|
|
109
109
|
const n = /* @__PURE__ */ new Set();
|
|
110
110
|
r.querySelectorAll(
|
|
111
111
|
`[esd-extension-block-id="${c.CUSTOM_ATTRIBUTE}"]`
|
|
112
112
|
).forEach((i) => {
|
|
113
|
-
const u = l(i) ? i.getAttribute(
|
|
114
|
-
!u || n.has(u) || (n.add(u), e(i,
|
|
113
|
+
const u = l(i) ? i.getAttribute(v) : null;
|
|
114
|
+
!u || n.has(u) || (n.add(u), e(i, U(u), "text"));
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function V(t) {
|
|
118
118
|
const e = {};
|
|
119
119
|
return f(t, (r, n, o) => {
|
|
120
120
|
if (!("querySelector" in r))
|
|
121
121
|
return;
|
|
122
|
-
const i =
|
|
122
|
+
const i = j(r, o);
|
|
123
123
|
i && (e[n] = i);
|
|
124
124
|
}), e;
|
|
125
125
|
}
|
|
126
126
|
function X(t) {
|
|
127
127
|
if (!t || !("querySelector" in t))
|
|
128
128
|
return;
|
|
129
|
-
const e = t.querySelector(
|
|
130
|
-
return
|
|
129
|
+
const e = t.querySelector(b) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
|
|
130
|
+
return P(r);
|
|
131
131
|
}
|
|
132
132
|
function z(t) {
|
|
133
133
|
if (!t)
|
|
@@ -135,10 +135,10 @@ function z(t) {
|
|
|
135
135
|
const e = l(t) ? t.getAttribute("bgcolor") : null;
|
|
136
136
|
if (e && !g.has(e))
|
|
137
137
|
return e;
|
|
138
|
-
const r =
|
|
138
|
+
const r = P(t);
|
|
139
139
|
if (r)
|
|
140
140
|
return r;
|
|
141
|
-
const n =
|
|
141
|
+
const n = M(t) ? t.getComputedStyle("background-color") : void 0;
|
|
142
142
|
return n && !g.has(n) ? n : void 0;
|
|
143
143
|
}
|
|
144
144
|
function Q(t) {
|
|
@@ -150,7 +150,7 @@ function Q(t) {
|
|
|
150
150
|
i && (e[n] = i);
|
|
151
151
|
}), e;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function W(t) {
|
|
154
154
|
const e = {};
|
|
155
155
|
return f(t, (r, n, o) => {
|
|
156
156
|
if (o === "image")
|
|
@@ -159,68 +159,70 @@ function V(t) {
|
|
|
159
159
|
i && (e[n] = i);
|
|
160
160
|
}), e;
|
|
161
161
|
}
|
|
162
|
-
const
|
|
163
|
-
function
|
|
162
|
+
const Y = /^es-[pm]\d+[trbl]?$/;
|
|
163
|
+
function J(t) {
|
|
164
164
|
const e = l(t) ? t.getAttribute("class") : null;
|
|
165
165
|
if (!e)
|
|
166
166
|
return;
|
|
167
|
-
const r = e.split(/\s+/).filter((n) =>
|
|
167
|
+
const r = e.split(/\s+/).filter((n) => Y.test(n) || n === B);
|
|
168
168
|
return r.length ? r.join(" ") : void 0;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function Z(t) {
|
|
171
171
|
if (!t || !("querySelector" in t))
|
|
172
172
|
return !1;
|
|
173
|
-
const e = t.querySelector(
|
|
174
|
-
return
|
|
173
|
+
const e = t.querySelector(b) ?? t;
|
|
174
|
+
return C(e.querySelector(`[data-attribute-type="${y}"]`)) || C(e.querySelector(`[data-attribute-type="${p}"]`));
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
const e = {}, r =
|
|
176
|
+
function tt(t) {
|
|
177
|
+
const e = {}, r = Z(t);
|
|
178
178
|
return f(t, (n, o, i) => {
|
|
179
|
-
if (i === "image" || r && (o ===
|
|
179
|
+
if (i === "image" || r && (o === y || o === p))
|
|
180
180
|
return;
|
|
181
|
-
const u =
|
|
181
|
+
const u = J(n);
|
|
182
182
|
u && (e[o] = u);
|
|
183
183
|
}), e;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function et(t) {
|
|
186
186
|
const e = {};
|
|
187
187
|
return f(t, (r, n) => {
|
|
188
|
-
if (n !==
|
|
188
|
+
if (n !== R && n !== _ || !l(r))
|
|
189
189
|
return;
|
|
190
190
|
const o = r.getAttribute("data-text-before"), i = r.getAttribute("data-text-after");
|
|
191
191
|
(o != null || i != null) && (e[n] = { before: o ?? void 0, after: i ?? void 0 });
|
|
192
192
|
}), e;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function rt(t) {
|
|
195
195
|
const e = {};
|
|
196
196
|
if (!t || !("querySelector" in t))
|
|
197
197
|
return e;
|
|
198
|
-
const r = t.querySelector(
|
|
199
|
-
return
|
|
198
|
+
const r = t.querySelector(b) ?? t;
|
|
199
|
+
return I(r) && r.querySelectorAll(".recommendation-attribute-row").forEach((n) => {
|
|
200
200
|
if (!l(n))
|
|
201
201
|
return;
|
|
202
|
-
const o =
|
|
203
|
-
o
|
|
202
|
+
const o = n.getAttribute("data-visibility");
|
|
203
|
+
o != null && N(n).forEach((i) => {
|
|
204
|
+
e[i] = o !== "0";
|
|
205
|
+
});
|
|
204
206
|
}), e;
|
|
205
207
|
}
|
|
206
|
-
function
|
|
208
|
+
function lt(t) {
|
|
207
209
|
return {
|
|
208
|
-
styleTemplates:
|
|
210
|
+
styleTemplates: V(t),
|
|
209
211
|
cardBackgroundColor: X(t),
|
|
210
212
|
cellBackgroundColors: Q(t),
|
|
211
|
-
cellAlignments:
|
|
212
|
-
cellClasses:
|
|
213
|
-
omnibusTexts:
|
|
214
|
-
visibility:
|
|
213
|
+
cellAlignments: W(t),
|
|
214
|
+
cellClasses: tt(t),
|
|
215
|
+
omnibusTexts: et(t),
|
|
216
|
+
visibility: rt(t)
|
|
215
217
|
};
|
|
216
218
|
}
|
|
217
219
|
export {
|
|
218
|
-
|
|
220
|
+
V as captureAttributeStyleTemplates,
|
|
219
221
|
X as captureCardBackgroundColor,
|
|
220
|
-
|
|
222
|
+
W as captureCellAlignments,
|
|
221
223
|
Q as captureCellBackgroundColors,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
tt as captureCellClasses,
|
|
225
|
+
et as captureOmnibusTexts,
|
|
226
|
+
lt as captureStyles,
|
|
227
|
+
rt as captureVisibility
|
|
226
228
|
};
|
|
@@ -1,89 +1,98 @@
|
|
|
1
|
-
import { ATTR_CUSTOM_PREFIX as
|
|
2
|
-
function
|
|
3
|
-
return !t.startsWith(
|
|
1
|
+
import { ATTR_CUSTOM_PREFIX as o, ATTR_PRODUCT_PRICE as g, ATTR_PRODUCT_OLD_PRICE as d, PRODUCT_ATTRIBUTE_PREFIX as a, ATTR_DATA_ATTRIBUTE_TYPE as f, ATTR_PRODUCT_ATTR as c, SELECTOR_ATTRIBUTE_ROW as y } from "../constants/selectors.js";
|
|
2
|
+
function q(t) {
|
|
3
|
+
return !t.startsWith(a);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return t.startsWith(
|
|
7
|
-
}
|
|
8
|
-
function T(t) {
|
|
9
|
-
return t.startsWith(s) ? t.substring(s.length) : t;
|
|
5
|
+
function $(t) {
|
|
6
|
+
return t.startsWith(a) ? t.substring(a.length) : t;
|
|
10
7
|
}
|
|
11
8
|
function A(t) {
|
|
12
|
-
return
|
|
9
|
+
return t.startsWith(o) ? t.substring(o.length) : t;
|
|
10
|
+
}
|
|
11
|
+
function T(t) {
|
|
12
|
+
return `${o}${t}`;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return t.type === "defaultAttribute" ? t.attributeName : `${
|
|
14
|
+
function C(t) {
|
|
15
|
+
return t.type === "defaultAttribute" ? t.attributeName : `${a}${t.attributeName}`;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function h(t, r) {
|
|
18
18
|
const n = Object.values(r).filter((e) => e.attributeName === t);
|
|
19
19
|
return n.find((e) => e.type === "defaultAttribute") ?? n[0];
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function l(t, r) {
|
|
22
22
|
return t && "getAttribute" in t ? t.getAttribute(r) : null;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const e = `${
|
|
26
|
-
`${
|
|
27
|
-
),
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
const
|
|
31
|
-
return
|
|
24
|
+
function S(t, r, n = {}) {
|
|
25
|
+
const e = `${o}${t}`, u = r == null ? void 0 : r.querySelector(
|
|
26
|
+
`${y}[${f}="${e}"]`
|
|
27
|
+
), i = l(u, c) ?? l(u == null ? void 0 : u.querySelector(`[${c}]`), c);
|
|
28
|
+
if (i)
|
|
29
|
+
return i;
|
|
30
|
+
const s = h(t, n);
|
|
31
|
+
return s ? C(s) : t;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return t.startsWith(
|
|
33
|
+
function P(t, r, n = {}) {
|
|
34
|
+
return t.startsWith(a) ? t : S(t, r, n);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function O(t, r, n = {}) {
|
|
37
37
|
return t.map((e) => {
|
|
38
|
-
if (!e.startsWith(
|
|
38
|
+
if (!e.startsWith(o))
|
|
39
39
|
return e;
|
|
40
|
-
const u =
|
|
41
|
-
return
|
|
40
|
+
const u = A(e);
|
|
41
|
+
return T(P(u, r, n));
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
return t.map((e) =>
|
|
44
|
+
function p(t, r, n = {}) {
|
|
45
|
+
return t.map((e) => P(e, r, n));
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
const r =
|
|
49
|
-
if (!(r != null && r.startsWith(
|
|
47
|
+
function b(t) {
|
|
48
|
+
const r = l(t, f);
|
|
49
|
+
if (!(r != null && r.startsWith(o)))
|
|
50
50
|
return r;
|
|
51
|
-
const n = "querySelector" in t ? t.querySelector(`[${
|
|
52
|
-
return e ?
|
|
51
|
+
const n = "querySelector" in t ? t.querySelector(`[${c}]`) : void 0, e = l(n, c);
|
|
52
|
+
return e ? T(e) : r;
|
|
53
|
+
}
|
|
54
|
+
function m(t) {
|
|
55
|
+
return !!(t && "querySelector" in t && t.querySelector(".product-price") && t.querySelector(".product-old-price"));
|
|
56
|
+
}
|
|
57
|
+
function D(t) {
|
|
58
|
+
const r = b(t);
|
|
59
|
+
return r ? m(t) ? [g, d] : [r] : [];
|
|
53
60
|
}
|
|
54
|
-
function
|
|
55
|
-
const e =
|
|
56
|
-
return
|
|
61
|
+
function R(t, r, n) {
|
|
62
|
+
const e = l(t, c), u = l(t.querySelector(`[${c}]`), c), i = e ?? u;
|
|
63
|
+
return i === null ? n : i === r;
|
|
57
64
|
}
|
|
58
|
-
function
|
|
59
|
-
const n = (
|
|
60
|
-
`${
|
|
65
|
+
function I(t, r) {
|
|
66
|
+
const n = (_) => t.querySelector(
|
|
67
|
+
`${y}[${f}="${_}"]`
|
|
61
68
|
);
|
|
62
|
-
if (!r.startsWith(
|
|
69
|
+
if (!r.startsWith(o))
|
|
63
70
|
return n(r) ?? null;
|
|
64
|
-
const e =
|
|
65
|
-
if (u &&
|
|
71
|
+
const e = A(r), u = n(r);
|
|
72
|
+
if (u && R(u, e, !0))
|
|
66
73
|
return u;
|
|
67
|
-
const
|
|
68
|
-
return
|
|
74
|
+
const i = T($(e)), s = i === r ? void 0 : n(i);
|
|
75
|
+
return s && R(s, e, !1) ? s : null;
|
|
69
76
|
}
|
|
70
|
-
function
|
|
71
|
-
const n =
|
|
77
|
+
function U(t, r) {
|
|
78
|
+
const n = A(r), e = T($(n));
|
|
72
79
|
return e === r ? t : t.replace(
|
|
73
|
-
`${
|
|
74
|
-
`${
|
|
80
|
+
`${f}="${e}"`,
|
|
81
|
+
`${f}="${r}"`
|
|
75
82
|
);
|
|
76
83
|
}
|
|
77
84
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
$ as bareAttributeName,
|
|
86
|
+
A as compositionKeyToProductAttr,
|
|
87
|
+
C as filterToProductAttrValue,
|
|
88
|
+
I as findAttributeRow,
|
|
89
|
+
h as findFilterByBareName,
|
|
90
|
+
q as isDefaultProductAttr,
|
|
91
|
+
m as isMergedInlinePriceRow,
|
|
92
|
+
O as normalizeCompositionKeys,
|
|
93
|
+
p as normalizeCustomAttrValues,
|
|
94
|
+
T as productAttrToCompositionKey,
|
|
95
|
+
b as resolveRowCompositionKey,
|
|
96
|
+
D as resolveRowVisibilityKeys,
|
|
97
|
+
U as rewriteLegacyRowKeyHtml
|
|
89
98
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEditorStore as i } from "../../../../stores/editor.js";
|
|
2
|
+
import { ModificationDescription as p } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { watch as f } from "vue";
|
|
4
|
+
function h(e, o, t = !1) {
|
|
5
|
+
if (!t) {
|
|
6
|
+
e.apply(new p(o));
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
e.apply(new p(o).asHidden()), i().markChanged();
|
|
10
|
+
}
|
|
11
|
+
function l() {
|
|
12
|
+
return i().changeSeq;
|
|
13
|
+
}
|
|
14
|
+
function S(e) {
|
|
15
|
+
return e !== null && i().changeSeq === e;
|
|
16
|
+
}
|
|
17
|
+
function d(e, o) {
|
|
18
|
+
const t = i();
|
|
19
|
+
return t.changeSeq > e ? Promise.resolve(t.changeSeq) : new Promise((u) => {
|
|
20
|
+
const n = {}, a = (r) => {
|
|
21
|
+
var c;
|
|
22
|
+
clearTimeout(n.timer), (c = n.stopWatching) == null || c.call(n), u(r);
|
|
23
|
+
};
|
|
24
|
+
n.timer = setTimeout(() => a(t.changeSeq), o), n.stopWatching = f(() => t.changeSeq, (r) => {
|
|
25
|
+
r > e && a(r);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
h as applyFollowUp,
|
|
31
|
+
l as captureUndoTop,
|
|
32
|
+
S as isUndoTopUnchanged,
|
|
33
|
+
d as waitForChangeAfter
|
|
34
|
+
};
|
|
@@ -1,32 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { RECOMMENDATION_ID_ATTR as l } from "../constants/selectors.js";
|
|
2
|
+
import { isPartnerManagedBlock as N, updateProductContentInPlace as y, regenerateProductRowsWithStyles as S } from "../controls/main/utils.js";
|
|
3
|
+
import { RecommendationConfigService as c } from "../services/configService.js";
|
|
4
|
+
import { useRecommendationExtensionStore as h } from "../store/recommendation.js";
|
|
5
|
+
import { isUndoTopUnchanged as R, applyFollowUp as d } from "./followUpApply.js";
|
|
6
|
+
let r = null;
|
|
7
|
+
function P(e) {
|
|
8
|
+
r = e;
|
|
9
|
+
}
|
|
10
|
+
function m(e) {
|
|
11
|
+
const t = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
12
|
+
return !t || !("querySelector" in t) ? null : t.querySelector(`[${l}="${e}"]`) ?? null;
|
|
13
|
+
}
|
|
14
|
+
function B(e, t) {
|
|
15
|
+
const o = c.getConfig(e);
|
|
16
|
+
return Object.keys(t).some((n) => JSON.stringify(o[n]) !== JSON.stringify(t[n]));
|
|
17
|
+
}
|
|
18
|
+
function a(e, t) {
|
|
19
|
+
const o = c.getConfig(e);
|
|
20
|
+
return ["filters", "strategy", "strategyId", "size"].some((n) => n in t && JSON.stringify(o[n]) !== JSON.stringify(t[n]));
|
|
21
|
+
}
|
|
22
|
+
function $(e, t, o) {
|
|
23
|
+
const n = m(e);
|
|
24
|
+
return !r || !n ? !1 : (a(n, t) && c.updateConfig(r, n, t, o), !0);
|
|
25
|
+
}
|
|
26
|
+
function O(e, t) {
|
|
27
|
+
const o = h(), n = o.currentRecommendationId;
|
|
28
|
+
if (n === e || !o.blockStates[e]) {
|
|
29
|
+
t();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
o.setCurrentBlock(e);
|
|
33
|
+
try {
|
|
34
|
+
t();
|
|
35
|
+
} finally {
|
|
36
|
+
o.$patch({ currentRecommendationId: n });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function A(e) {
|
|
40
|
+
const t = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
41
|
+
return !t || !("querySelectorAll" in t) ? [] : t.querySelectorAll(`[${l}="${e}"]`).map((o) => c.getConfig(o));
|
|
42
|
+
}
|
|
43
|
+
function E() {
|
|
44
|
+
const e = r == null ? void 0 : r.getDocumentRootHtmlNode(), t = /* @__PURE__ */ new Map();
|
|
45
|
+
return !e || !("querySelectorAll" in e) || e.querySelectorAll(`[${l}]`).forEach((o) => {
|
|
46
|
+
const n = "getAttribute" in o ? Number(o.getAttribute(l)) : 0;
|
|
47
|
+
n > 0 && t.set(n, [...t.get(n) ?? [], c.getConfig(o)]);
|
|
48
|
+
}), t;
|
|
49
|
+
}
|
|
50
|
+
function k(e, t, o, n, C = null) {
|
|
51
|
+
const i = m(e);
|
|
52
|
+
if (!r || !i)
|
|
15
53
|
return !1;
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
-
let
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
const f = r.getDocumentModifier(), s = B(i, t), u = R(C) && !a(i, t);
|
|
55
|
+
if (c.stageConfig(f, i, t), N(i))
|
|
56
|
+
return s && d(f, n, u), !0;
|
|
57
|
+
let g = !1;
|
|
58
|
+
return O(e, () => {
|
|
59
|
+
y({
|
|
60
|
+
currentNode: i,
|
|
61
|
+
documentModifier: f,
|
|
62
|
+
products: o,
|
|
63
|
+
hidden: u,
|
|
64
|
+
onApplied: () => {
|
|
65
|
+
g = !0;
|
|
66
|
+
}
|
|
67
|
+
}) || (g = S({ currentNode: i, documentModifier: f, products: o, hidden: u }));
|
|
68
|
+
}), !g && s && d(f, n, u), !0;
|
|
28
69
|
}
|
|
29
70
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
71
|
+
k as commitBlockChangeOutsidePanel,
|
|
72
|
+
a as hasEditedConfigChange,
|
|
73
|
+
E as readAllBlockNodeConfigs,
|
|
74
|
+
A as readBlockNodeConfigs,
|
|
75
|
+
P as registerNodeConfigWriter,
|
|
76
|
+
$ as writeBlockConfigOutsidePanel
|
|
32
77
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useRecommendationExtensionStore as s } from "../store/recommendation.js";
|
|
2
|
+
import { toBlockUrlConfig as i } from "./blockUrlConfig.js";
|
|
3
|
+
import { waitForChangeAfter as a, isUndoTopUnchanged as f, captureUndoTop as m } from "./followUpApply.js";
|
|
4
|
+
import { readAllBlockNodeConfigs as d, readBlockNodeConfigs as u, commitBlockChangeOutsidePanel as h } from "./nodeConfigWriter.js";
|
|
5
|
+
const g = 1e3, k = "Refresh recommendation products";
|
|
6
|
+
async function p(o, r) {
|
|
7
|
+
if (r.length !== 1)
|
|
8
|
+
return null;
|
|
9
|
+
const n = s(), c = i(r[0]);
|
|
10
|
+
n.reseedBlockFromNode(o, c);
|
|
11
|
+
const { configVersion: t } = n.blockStates[o];
|
|
12
|
+
try {
|
|
13
|
+
await n.fetchRecommendationProductsForBlock(o);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return console.error("[recommendation] product refetch after version restore failed", e), null;
|
|
16
|
+
}
|
|
17
|
+
return { id: o, seededKey: JSON.stringify(c), configVersion: t };
|
|
18
|
+
}
|
|
19
|
+
function R({ id: o, seededKey: r, configVersion: n }, c) {
|
|
20
|
+
const t = s().blockStates[o], e = u(o);
|
|
21
|
+
!t || t.configVersion !== n || e.length !== 1 || JSON.stringify(i(e[0])) !== r || h(o, {}, t.recommendationProducts, k, c);
|
|
22
|
+
}
|
|
23
|
+
async function N(o) {
|
|
24
|
+
try {
|
|
25
|
+
const r = await a(o, g), n = d(), c = await Promise.all([...n].map(([e, l]) => p(e, l)));
|
|
26
|
+
let t = f(r) ? r : null;
|
|
27
|
+
c.filter((e) => e !== null).forEach((e) => {
|
|
28
|
+
R(e, t), t !== null && (t = m());
|
|
29
|
+
});
|
|
30
|
+
} catch (r) {
|
|
31
|
+
console.error("[recommendation] refresh after version restore failed", r);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
N as refreshRecommendationBlocksAfterRestore
|
|
36
|
+
};
|