@useinsider/guido 3.20.0-beta.30c96fc → 3.20.0-beta.3ad13f5
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/useStripo.js +4 -3
- package/dist/config/compiler/itemsCompilerRules.js +5 -14
- package/dist/config/compiler/utils/itemsCompilerUtils.js +21 -48
- package/dist/config/migrator/itemsBlockMigrator.js +108 -112
- package/dist/extensions/Blocks/Items/block.js +67 -78
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- 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 +0 -5
- 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 +0 -5
- 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/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/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/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/title/index.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/static/styles/components/button.css.js +5 -0
- package/package.json +3 -3
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +0 -20
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +0 -12
- package/dist/src/utils/liquidProtection.d.ts +0 -3
- package/dist/utils/liquidProtection.js +0 -5
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BlockId as
|
|
2
|
+
var D = (l, a, t) => a in l ? k(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
|
|
3
|
+
var y = (l, a, t) => D(l, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { BlockId as N } from "../../../enums/block.js";
|
|
5
5
|
import { useOnboardingStore as T } from "../../../stores/onboarding.js";
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { SETTINGS_ENUMS as b, DefaultConfigValues as p } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getMigrationBannerHtml as S } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as A, BlockCompositionType as M, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { currencyAttrTargets as H, ITEMS_CURRENCY_ATTR as m } from "./constants/currency.js";
|
|
9
|
+
import { ItemsBlockId as R } from "./enums/controlEnums.js";
|
|
10
|
+
import { SETTINGS_ENUMS as C, DefaultConfigValues as g } from "./enums/settingsEnums.js";
|
|
12
11
|
import { getDefaultTemplate as O } from "./template.js";
|
|
13
|
-
import { getItemsBlockContainer as
|
|
14
|
-
const
|
|
15
|
-
class
|
|
12
|
+
import { getItemsBlockContainer as b, getItemsBlockConfig as h, deriveItemNumber as B, generateBlockInstanceId as E, getDefaultItemsBlockConfig as w } from "./utils/nodeConfigUtils.js";
|
|
13
|
+
const _ = N.Items, P = "Reconcile Items currency DOM attributes";
|
|
14
|
+
class K extends A {
|
|
16
15
|
constructor() {
|
|
17
16
|
super(...arguments);
|
|
18
17
|
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
19
|
-
|
|
18
|
+
y(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
20
19
|
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
21
|
-
|
|
20
|
+
y(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
|
|
22
21
|
}
|
|
23
22
|
getId() {
|
|
24
|
-
return
|
|
23
|
+
return _;
|
|
25
24
|
}
|
|
26
25
|
getIcon() {
|
|
27
26
|
return "items-icon";
|
|
28
27
|
}
|
|
29
28
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
29
|
+
return M.CONTAINER;
|
|
31
30
|
}
|
|
32
31
|
getName() {
|
|
33
32
|
return this.api.translate("Items");
|
|
@@ -36,20 +35,20 @@ class $ extends H {
|
|
|
36
35
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
37
36
|
}
|
|
38
37
|
getSettingsPanelTitleHtml() {
|
|
39
|
-
return
|
|
40
|
-
|
|
38
|
+
return S(
|
|
39
|
+
_,
|
|
41
40
|
this.api.translate("Items"),
|
|
42
41
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
43
42
|
);
|
|
44
43
|
}
|
|
45
44
|
getTemplate() {
|
|
46
45
|
return O({
|
|
47
|
-
orientation:
|
|
48
|
-
itemsType:
|
|
46
|
+
orientation: C.ORIENTATION.VERTICAL,
|
|
47
|
+
itemsType: C.ITEMS_TYPE.CART_ITEMS,
|
|
49
48
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
50
|
-
currencySymbol:
|
|
51
|
-
currencyLocation:
|
|
52
|
-
formattedPrice:
|
|
49
|
+
currencySymbol: g.productPriceCurrencySymbolControlValue,
|
|
50
|
+
currencyLocation: g.productPriceCurrencyLocationControlValue,
|
|
51
|
+
formattedPrice: g.productPriceFormattedControlValue === "1"
|
|
53
52
|
});
|
|
54
53
|
}
|
|
55
54
|
allowInnerBlocksDND() {
|
|
@@ -58,27 +57,27 @@ class $ extends H {
|
|
|
58
57
|
canBeSavedAsModule() {
|
|
59
58
|
return !0;
|
|
60
59
|
}
|
|
61
|
-
onCreated(
|
|
62
|
-
const
|
|
63
|
-
c.querySelector('[product-attr="imageSrc"] img') ||
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
60
|
+
onCreated(t) {
|
|
61
|
+
const o = this.api.getDocumentModifier(), c = this.api.getDocumentRootCssNode();
|
|
62
|
+
c.querySelector('[product-attr="imageSrc"] img') || o.modifyCss(c).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
63
|
+
const i = b(t);
|
|
64
|
+
if (!i)
|
|
66
65
|
return;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
66
|
+
const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, e = h(t);
|
|
67
|
+
if (e != null && e.initialized) {
|
|
69
68
|
if (!s) {
|
|
70
|
-
const
|
|
71
|
-
|
|
69
|
+
const d = this.api.getDocumentModifier();
|
|
70
|
+
d.modifyHtml(i).setNodeConfig(e), this._stampProductTdDomAttributes(i, e, d), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(i, e, d), d.apply(new u("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(e.blockInstanceId);
|
|
72
71
|
return;
|
|
73
72
|
}
|
|
74
73
|
} else {
|
|
75
|
-
const
|
|
76
|
-
|
|
74
|
+
const d = w(), p = this.api.getDocumentModifier();
|
|
75
|
+
p.modifyHtml(i).setNodeConfig(d), this._stampProductTdDomAttributes(i, d, p, !0), p.apply(new u("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
79
|
-
const n = this._resolveInstanceId(
|
|
80
|
-
let
|
|
81
|
-
n !==
|
|
78
|
+
const n = this._resolveInstanceId(e.blockInstanceId), f = this.api.getDocumentModifier();
|
|
79
|
+
let I = !1;
|
|
80
|
+
n !== e.blockInstanceId && (f.modifyHtml(i).setNodeConfig({ ...e, blockInstanceId: n }), I = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(i, e, f) && (I = !0), I && f.apply(new u("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
82
81
|
}
|
|
83
82
|
/**
|
|
84
83
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -86,24 +85,24 @@ class $ extends H {
|
|
|
86
85
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
87
86
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
88
87
|
*/
|
|
89
|
-
onDocumentChanged(
|
|
90
|
-
const
|
|
91
|
-
if (!
|
|
88
|
+
onDocumentChanged(t) {
|
|
89
|
+
const o = b(t);
|
|
90
|
+
if (!o)
|
|
92
91
|
return;
|
|
93
|
-
const c =
|
|
92
|
+
const c = o.getNodeConfig();
|
|
94
93
|
if (c && Object.keys(c).length > 0) {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
94
|
+
const e = h(t);
|
|
95
|
+
if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
|
|
97
96
|
const n = this.api.getDocumentModifier();
|
|
98
|
-
this._reconcileCurrencyDomAttributes(
|
|
97
|
+
this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new u(P)), this._markCurrencyHealed(e.blockInstanceId);
|
|
99
98
|
}
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
|
-
const
|
|
103
|
-
if (!(
|
|
101
|
+
const r = h(t);
|
|
102
|
+
if (!(r != null && r.initialized))
|
|
104
103
|
return;
|
|
105
104
|
const s = this.api.getDocumentModifier();
|
|
106
|
-
s.modifyHtml(
|
|
105
|
+
s.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, s), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, s), s.apply(new u("Recover Items block config from saved module")), this._markCurrencyHealed(r.blockInstanceId);
|
|
107
106
|
}
|
|
108
107
|
/**
|
|
109
108
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -113,21 +112,11 @@ class $ extends H {
|
|
|
113
112
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
114
113
|
* relies on this td-level fallback in pairProductVariables.
|
|
115
114
|
*/
|
|
116
|
-
_stampProductTdDomAttributes(
|
|
117
|
-
const
|
|
118
|
-
|
|
115
|
+
_stampProductTdDomAttributes(t, o, c, i = !1) {
|
|
116
|
+
const r = B(o.itemsSelectValue, o.type), s = (e, n) => {
|
|
117
|
+
i && t.getAttribute(e) || c.modifyHtml(t).setAttribute(e, n);
|
|
119
118
|
};
|
|
120
|
-
s("data-type",
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Repairs a saved module's collapsed card into the state the load migrator produces. Acts only
|
|
124
|
-
* on a zero width, so Stripo's non-zero drop-time width never triggers it and a healed block no-ops.
|
|
125
|
-
*/
|
|
126
|
-
_healCollapsedWidths(e, t) {
|
|
127
|
-
const r = e.querySelectorAll(M).filter((o) => m(o.getAttribute("width")) || m(o.getStyle("width")));
|
|
128
|
-
return !m(e.getAttribute("width")) && !r.length ? !1 : (e.hasClass("esd-container-frame") && t.modifyHtml(e).removeClass("esd-container-frame"), e.getAttribute("width") !== null && t.modifyHtml(e).removeAttribute("width"), r.forEach((o) => {
|
|
129
|
-
m(o.getAttribute("width")) && t.modifyHtml(o).setAttribute("width", "100%"), m(o.getStyle("width")) && t.modifyHtml(o).setStyle("width", "100%");
|
|
130
|
-
}), !0);
|
|
119
|
+
s("data-type", o.type), s("data-number", r), s("data-nodup", String(o.priceHideDiscount));
|
|
131
120
|
}
|
|
132
121
|
/**
|
|
133
122
|
* Whether a currency self-heal pass should run for this block (SD-147588). The only gate here is
|
|
@@ -137,12 +126,12 @@ class $ extends H {
|
|
|
137
126
|
* the symbol write alone is skipped for the 'USD' sentinel — so we must NOT gate the whole pass
|
|
138
127
|
* on symbol customization here, or a default-symbol block with a toggled location never heals.
|
|
139
128
|
*/
|
|
140
|
-
_shouldReconcileCurrency(
|
|
141
|
-
return !
|
|
129
|
+
_shouldReconcileCurrency(t) {
|
|
130
|
+
return !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
|
|
142
131
|
}
|
|
143
132
|
/** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
|
|
144
|
-
_markCurrencyHealed(
|
|
145
|
-
|
|
133
|
+
_markCurrencyHealed(t) {
|
|
134
|
+
t && this._currencyHealed.add(t);
|
|
146
135
|
}
|
|
147
136
|
/**
|
|
148
137
|
* Resolves the id for a just-created block to one that is unique per live instance.
|
|
@@ -151,13 +140,13 @@ class $ extends H {
|
|
|
151
140
|
* currency heal guard and settings-panel switch detection. Mint a fresh id on absence
|
|
152
141
|
* or collision, otherwise keep the existing one. Registers the result as claimed.
|
|
153
142
|
*/
|
|
154
|
-
_resolveInstanceId(
|
|
155
|
-
let
|
|
156
|
-
if (!
|
|
143
|
+
_resolveInstanceId(t) {
|
|
144
|
+
let o = t;
|
|
145
|
+
if (!o || this._seenInstanceIds.has(o))
|
|
157
146
|
do
|
|
158
|
-
|
|
159
|
-
while (this._seenInstanceIds.has(
|
|
160
|
-
return this._seenInstanceIds.add(
|
|
147
|
+
o = E();
|
|
148
|
+
while (this._seenInstanceIds.has(o));
|
|
149
|
+
return this._seenInstanceIds.add(o), o;
|
|
161
150
|
}
|
|
162
151
|
/**
|
|
163
152
|
* Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
|
|
@@ -170,15 +159,15 @@ class $ extends H {
|
|
|
170
159
|
* Returns true only when an attr actually changed, so the caller can skip an empty apply that
|
|
171
160
|
* would otherwise re-trigger onDocumentChanged and loop.
|
|
172
161
|
*/
|
|
173
|
-
_reconcileCurrencyDomAttributes(
|
|
174
|
-
const { position:
|
|
175
|
-
let
|
|
162
|
+
_reconcileCurrencyDomAttributes(t, o, c) {
|
|
163
|
+
const { position: i, symbol: r } = H(o), s = t.querySelectorAll(`.${R.PRICE} p`);
|
|
164
|
+
let e = !1;
|
|
176
165
|
return s.forEach((n) => {
|
|
177
|
-
|
|
178
|
-
}),
|
|
166
|
+
i !== void 0 && n.getAttribute(m.POSITION) !== i && (c.modifyHtml(n).setAttribute(m.POSITION, i), e = !0), r !== void 0 && n.getAttribute(m.SYMBOL) !== r && (c.modifyHtml(n).setAttribute(m.SYMBOL, r), e = !0);
|
|
167
|
+
}), e;
|
|
179
168
|
}
|
|
180
169
|
}
|
|
181
170
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
_ as BLOCK_ID,
|
|
172
|
+
K as ItemsBlock
|
|
184
173
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const t = `{-{-TEMPLATE_FIRST_LINE-}-}
|
|
2
|
-
<table class="es-left ins-product-wrapper" cellspacing="0" cellpadding="0" align="left" width="100%"
|
|
2
|
+
<table class="es-left ins-product-wrapper" cellspacing="0" cellpadding="0" align="left" width="100%">
|
|
3
3
|
<tbody>
|
|
4
4
|
<tr>
|
|
5
5
|
<td class="es-p20b es-p10r es-p10l es-m-p20b es-p10t" width="100%" align="center">
|