@useinsider/guido 3.23.0-beta.86bed27 → 3.23.0-beta.9f6bfbf
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 +1 -0
- package/dist/@types/config/schemas.js +17 -15
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +58 -56
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +100 -40
- package/dist/config/migrator/recommendation/htmlBuilder.js +285 -207
- package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
- package/dist/config/migrator/recommendation/themeMapper.js +53 -41
- package/dist/config/migrator/recommendationMigrator.js +68 -61
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
- package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +40 -30
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +63 -53
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +31 -31
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -32
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +145 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +160 -144
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
- package/dist/extensions/Blocks/Items/extension.js +9 -8
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +34 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- 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 +165 -175
- 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/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/common-control.js +62 -55
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +35 -6
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/types.d.ts +11 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +23 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +61 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -10
- 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/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/unsubscribe.d.ts +10 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/stores/unsubscribe.js +33 -29
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/pairProductVariables.js +119 -99
- package/package.json +2 -2
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
var E = (h, d, t) => d in h ? k(h, d, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[d] = t;
|
|
3
|
+
var C = (h, d, t) => E(h, typeof d != "symbol" ? d + "" : d, t);
|
|
4
|
+
import { useConfig as P } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as H } from "../../../enums/block.js";
|
|
6
|
+
import { useOnboardingStore as N } from "../../../stores/onboarding.js";
|
|
7
|
+
import { getMigrationBannerHtml as R } from "../../../utils/migrationBannerHtml.js";
|
|
8
|
+
import { Block as M, BlockCompositionType as O, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
9
|
+
import { PRODUCT_WRAPPER_SELECTOR as w, isZeroWidthValue as g } from "./constants/cardWidth.js";
|
|
10
|
+
import { DEFAULT_ITEMS_PRICE_FORMAT as I, isNewPriceFormatRoot as v, currencyAttrTargets as B, ITEMS_CURRENCY_ATTR as y } from "./constants/currency.js";
|
|
11
|
+
import { ItemsBlockId as A } from "./enums/controlEnums.js";
|
|
12
|
+
import { SETTINGS_ENUMS as S, DefaultConfigValues as b } from "./enums/settingsEnums.js";
|
|
13
|
+
import { getDefaultTemplate as F } from "./template.js";
|
|
14
|
+
import { getItemsBlockContainer as T, getItemsBlockConfig as _, deriveItemNumber as L, generateBlockInstanceId as x, getDefaultItemsBlockConfig as V } from "./utils/nodeConfigUtils.js";
|
|
15
|
+
import { buildPriceFormatSnapshot as W, planPriceFormatOps as z, samePriceText as U, replacePriceText as Y, paragraphKindOf as j } from "./utils/priceFormatOps.js";
|
|
16
|
+
const D = H.Items, q = "Reconcile Items currency DOM attributes";
|
|
17
|
+
function K() {
|
|
18
|
+
return {
|
|
19
|
+
priceThousandSeparator: I.thousandSeparator,
|
|
20
|
+
priceDecimalSeparator: I.decimalSeparator,
|
|
21
|
+
priceDecimalCount: I.decimalCount
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
class at extends M {
|
|
16
25
|
constructor() {
|
|
17
26
|
super(...arguments);
|
|
18
27
|
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
19
|
-
|
|
28
|
+
C(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
20
29
|
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
21
|
-
|
|
30
|
+
C(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
|
|
22
31
|
}
|
|
23
32
|
getId() {
|
|
24
|
-
return
|
|
33
|
+
return D;
|
|
25
34
|
}
|
|
26
35
|
getIcon() {
|
|
27
36
|
return "items-icon";
|
|
28
37
|
}
|
|
29
38
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
39
|
+
return O.CONTAINER;
|
|
31
40
|
}
|
|
32
41
|
getName() {
|
|
33
42
|
return this.api.translate("Items");
|
|
@@ -36,20 +45,21 @@ class $ extends H {
|
|
|
36
45
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
37
46
|
}
|
|
38
47
|
getSettingsPanelTitleHtml() {
|
|
39
|
-
return
|
|
40
|
-
|
|
48
|
+
return R(
|
|
49
|
+
D,
|
|
41
50
|
this.api.translate("Items"),
|
|
42
51
|
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
52
|
);
|
|
44
53
|
}
|
|
45
54
|
getTemplate() {
|
|
46
|
-
return
|
|
47
|
-
orientation:
|
|
48
|
-
itemsType:
|
|
55
|
+
return F({
|
|
56
|
+
orientation: S.ORIENTATION.VERTICAL,
|
|
57
|
+
itemsType: S.ITEMS_TYPE.CART_ITEMS,
|
|
49
58
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
50
|
-
currencySymbol:
|
|
51
|
-
currencyLocation:
|
|
52
|
-
formattedPrice:
|
|
59
|
+
currencySymbol: b.productPriceCurrencySymbolControlValue,
|
|
60
|
+
currencyLocation: b.productPriceCurrencyLocationControlValue,
|
|
61
|
+
formattedPrice: b.productPriceFormattedControlValue === "1",
|
|
62
|
+
priceFormat: this._isPriceFormattingEnabled() ? I : void 0
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
allowInnerBlocksDND() {
|
|
@@ -59,26 +69,29 @@ class $ extends H {
|
|
|
59
69
|
return !0;
|
|
60
70
|
}
|
|
61
71
|
onCreated(t) {
|
|
62
|
-
const e = this.api.getDocumentModifier(),
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
72
|
+
const e = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
|
|
73
|
+
s.querySelector('[product-attr="imageSrc"] img') || e.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
74
|
+
const o = T(t);
|
|
75
|
+
if (!o)
|
|
66
76
|
return;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
if (!
|
|
70
|
-
const
|
|
71
|
-
|
|
77
|
+
const i = o.getNodeConfig(), c = i && Object.keys(i).length > 0, r = _(t);
|
|
78
|
+
if (r != null && r.initialized) {
|
|
79
|
+
if (!c) {
|
|
80
|
+
const l = this.api.getDocumentModifier();
|
|
81
|
+
l.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, l), this._healCollapsedWidths(o, l), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, l), l.apply(new p("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(r.blockInstanceId);
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
84
|
} else {
|
|
75
|
-
const
|
|
76
|
-
|
|
85
|
+
const l = {
|
|
86
|
+
...V(),
|
|
87
|
+
...this._isPriceFormattingEnabled() ? K() : {}
|
|
88
|
+
}, f = this.api.getDocumentModifier();
|
|
89
|
+
f.modifyHtml(o).setNodeConfig(l), this._stampProductTdDomAttributes(o, l, f, !0), f.apply(new p("Initialize Items block with default configuration")), N().startOnboarding("itemsOnboarding");
|
|
77
90
|
return;
|
|
78
91
|
}
|
|
79
|
-
const
|
|
80
|
-
let
|
|
81
|
-
|
|
92
|
+
const n = this._resolveInstanceId(r.blockInstanceId), a = { ...r, blockInstanceId: n }, u = this.api.getDocumentModifier();
|
|
93
|
+
let m = !1;
|
|
94
|
+
n !== r.blockInstanceId && (u.modifyHtml(o).setNodeConfig(a), m = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(o, a, u) && (m = !0), this._healCollapsedWidths(o, u) && (m = !0), m && u.apply(new p("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
82
95
|
}
|
|
83
96
|
/**
|
|
84
97
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -87,23 +100,23 @@ class $ extends H {
|
|
|
87
100
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
88
101
|
*/
|
|
89
102
|
onDocumentChanged(t) {
|
|
90
|
-
const e =
|
|
103
|
+
const e = T(t);
|
|
91
104
|
if (!e)
|
|
92
105
|
return;
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
this._reconcileCurrencyDomAttributes(e,
|
|
106
|
+
const s = e.getNodeConfig();
|
|
107
|
+
if (s && Object.keys(s).length > 0) {
|
|
108
|
+
const r = _(t);
|
|
109
|
+
if (r != null && r.initialized && this._shouldReconcileCurrency(r)) {
|
|
110
|
+
const n = this.api.getDocumentModifier();
|
|
111
|
+
this._reconcileCurrencyDomAttributes(e, r, n) && n.apply(new p(q)), this._markCurrencyHealed(r.blockInstanceId);
|
|
99
112
|
}
|
|
100
113
|
return;
|
|
101
114
|
}
|
|
102
|
-
const
|
|
103
|
-
if (!(
|
|
115
|
+
const i = _(t);
|
|
116
|
+
if (!(i != null && i.initialized))
|
|
104
117
|
return;
|
|
105
|
-
const
|
|
106
|
-
|
|
118
|
+
const c = this.api.getDocumentModifier();
|
|
119
|
+
c.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, c), this._healCollapsedWidths(e, c), this._shouldReconcileCurrency(i) && this._reconcileCurrencyDomAttributes(e, i, c), c.apply(new p("Recover Items block config from saved module")), this._markCurrencyHealed(i.blockInstanceId);
|
|
107
120
|
}
|
|
108
121
|
/**
|
|
109
122
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -113,21 +126,21 @@ class $ extends H {
|
|
|
113
126
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
114
127
|
* relies on this td-level fallback in pairProductVariables.
|
|
115
128
|
*/
|
|
116
|
-
_stampProductTdDomAttributes(t, e,
|
|
117
|
-
const
|
|
118
|
-
|
|
129
|
+
_stampProductTdDomAttributes(t, e, s, o = !1) {
|
|
130
|
+
const i = L(e.itemsSelectValue, e.type), c = (r, n) => {
|
|
131
|
+
o && t.getAttribute(r) || s.modifyHtml(t).setAttribute(r, n);
|
|
119
132
|
};
|
|
120
|
-
|
|
133
|
+
c("data-type", e.type), c("data-number", i), c("data-nodup", String(e.priceHideDiscount));
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
123
136
|
* Repairs a saved module's collapsed card into the state the load migrator produces. Acts only
|
|
124
137
|
* on a zero width, so Stripo's non-zero drop-time width never triggers it and a healed block no-ops.
|
|
125
138
|
*/
|
|
126
139
|
_healCollapsedWidths(t, e) {
|
|
127
|
-
const
|
|
128
|
-
return !
|
|
129
|
-
const
|
|
130
|
-
(
|
|
140
|
+
const o = t.querySelectorAll(w).filter((i) => g(i.getAttribute("width")) || g(i.getStyle("width")));
|
|
141
|
+
return !g(t.getAttribute("width")) && !o.length ? !1 : (t.hasClass("esd-container-frame") && e.modifyHtml(t).removeClass("esd-container-frame"), t.getAttribute("width") !== null && e.modifyHtml(t).removeAttribute("width"), o.forEach((i) => {
|
|
142
|
+
const c = i.getAttribute("width");
|
|
143
|
+
(c === null || g(c)) && e.modifyHtml(i).setAttribute("width", "100%"), g(i.getStyle("width")) && e.modifyHtml(i).setStyle("width", "100%");
|
|
131
144
|
}), !0);
|
|
132
145
|
}
|
|
133
146
|
/**
|
|
@@ -156,30 +169,55 @@ class $ extends H {
|
|
|
156
169
|
let e = t;
|
|
157
170
|
if (!e || this._seenInstanceIds.has(e))
|
|
158
171
|
do
|
|
159
|
-
e =
|
|
172
|
+
e = x();
|
|
160
173
|
while (this._seenInstanceIds.has(e));
|
|
161
174
|
return this._seenInstanceIds.add(e), e;
|
|
162
175
|
}
|
|
163
176
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* Config is the source of truth — never derive from visible text.
|
|
167
|
-
*
|
|
168
|
-
* Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
|
|
169
|
-
* is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
|
|
170
|
-
*
|
|
171
|
-
* Returns true only when an attr actually changed, so the caller can skip an empty apply that
|
|
172
|
-
* would otherwise re-trigger onDocumentChanged and loop.
|
|
177
|
+
* Single self-heal slot: the flag only decides whether a legacy root is converted; a root
|
|
178
|
+
* already in the new format is reconciled from config regardless. Returns whether anything was queued.
|
|
173
179
|
*/
|
|
174
|
-
_reconcileCurrencyDomAttributes(t, e,
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
_reconcileCurrencyDomAttributes(t, e, s) {
|
|
181
|
+
const o = this._isPriceFormattingEnabled();
|
|
182
|
+
if (!o && !v(t))
|
|
183
|
+
return this._reconcileLegacyCurrencyAttributes(t, e, s);
|
|
184
|
+
const i = this._priceParagraphs(t), c = W({
|
|
185
|
+
rootAttr: (n) => t.getAttribute(n),
|
|
186
|
+
config: e,
|
|
187
|
+
paragraphs: i.map(({ kind: n, node: a }) => ({
|
|
188
|
+
kind: n,
|
|
189
|
+
attr: (u) => a.getAttribute(u),
|
|
190
|
+
text: a.getInnerText()
|
|
191
|
+
}))
|
|
192
|
+
}), r = z(c, { convertLegacy: o });
|
|
193
|
+
return r.changed ? (Object.entries(r.rootSet).forEach(([n, a]) => {
|
|
194
|
+
s.modifyHtml(t).setAttribute(n, a);
|
|
195
|
+
}), i.forEach(({ kind: n, node: a }) => {
|
|
196
|
+
var l;
|
|
197
|
+
r.paragraphRemove.filter((f) => a.getAttribute(f) !== null).forEach((f) => s.modifyHtml(a).removeAttribute(f));
|
|
198
|
+
const u = (l = r.texts) == null ? void 0 : l[n], m = a.getInnerText();
|
|
199
|
+
u !== void 0 && !U(m, u) && s.modifyHtml(a).setInnerHtml(Y(a.getInnerHTML(), m, u));
|
|
200
|
+
}), r.configPatch && s.modifyHtml(t).setNodeConfig({ ...e, ...r.configPatch }), !0) : !1;
|
|
201
|
+
}
|
|
202
|
+
/** Legacy `<p>` contract via `currencyAttrTargets`: position when recorded, symbol only when custom. */
|
|
203
|
+
_reconcileLegacyCurrencyAttributes(t, e, s) {
|
|
204
|
+
const { position: o, symbol: i } = B(e), c = t.querySelectorAll(`.${A.PRICE} p`);
|
|
205
|
+
let r = !1;
|
|
206
|
+
return c.forEach((n) => {
|
|
207
|
+
o !== void 0 && n.getAttribute(y.POSITION) !== o && (s.modifyHtml(n).setAttribute(y.POSITION, o), r = !0), i !== void 0 && n.getAttribute(y.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(y.SYMBOL, i), r = !0);
|
|
208
|
+
}), r;
|
|
209
|
+
}
|
|
210
|
+
_priceParagraphs(t) {
|
|
211
|
+
return t.querySelectorAll(`.${A.PRICE} p`).flatMap((s) => {
|
|
212
|
+
const o = j(s.getAttribute("product-attr"));
|
|
213
|
+
return o ? [{ kind: o, node: s }] : [];
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
_isPriceFormattingEnabled() {
|
|
217
|
+
return P().isFeatureEnabled("itemsPriceFormatting");
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
221
|
+
D as BLOCK_ID,
|
|
222
|
+
at as ItemsBlock
|
|
185
223
|
};
|
|
@@ -1,25 +1,70 @@
|
|
|
1
1
|
import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
|
|
2
|
-
const
|
|
2
|
+
const n = {
|
|
3
3
|
POSITION: "data-curency",
|
|
4
4
|
SYMBOL: "data-currency_symbol"
|
|
5
5
|
};
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function u(t) {
|
|
7
|
+
return t === "1" ? "after" : "before";
|
|
8
8
|
}
|
|
9
|
-
function i(
|
|
10
|
-
const
|
|
11
|
-
return
|
|
9
|
+
function i(t) {
|
|
10
|
+
const r = (t ?? "").trim();
|
|
11
|
+
return r !== "" && r !== c.productPriceCurrencySymbolControlValue;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function p(t) {
|
|
14
|
+
const r = t.priceCurrencyLocation, e = typeof r == "string" && r.trim() !== "", a = (t.priceCurrencySymbol ?? "").trim();
|
|
15
15
|
return {
|
|
16
|
-
position:
|
|
17
|
-
symbol: i(
|
|
16
|
+
position: e ? u(r) : void 0,
|
|
17
|
+
symbol: i(a) ? a : void 0
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
const s = {
|
|
21
|
+
SYMBOL: "currency-symbol",
|
|
22
|
+
ALIGNMENT: "currency-alignment",
|
|
23
|
+
THOUSAND_SEPARATOR: "currency-thousand-separator",
|
|
24
|
+
DECIMAL_SEPARATOR: "currency-decimal-separator",
|
|
25
|
+
DECIMAL_COUNT: "currency-decimal-count",
|
|
26
|
+
SINGLE_PRICE: "data-single_price"
|
|
27
|
+
}, C = [
|
|
28
|
+
"data-formated",
|
|
29
|
+
"data-single_price",
|
|
30
|
+
n.POSITION,
|
|
31
|
+
n.SYMBOL
|
|
32
|
+
], o = {
|
|
33
|
+
thousandSeparator: ",",
|
|
34
|
+
decimalSeparator: ".",
|
|
35
|
+
decimalCount: 2
|
|
36
|
+
};
|
|
37
|
+
function m(t) {
|
|
38
|
+
const r = typeof t == "string" ? parseInt(t) : t;
|
|
39
|
+
return typeof r == "number" && Number.isFinite(r) && r >= 0 ? Math.trunc(r) : o.decimalCount;
|
|
40
|
+
}
|
|
41
|
+
function d(t) {
|
|
42
|
+
const r = t == null ? void 0 : t.priceThousandSeparator, e = t == null ? void 0 : t.priceDecimalSeparator;
|
|
43
|
+
return {
|
|
44
|
+
thousandSeparator: typeof r == "string" && r !== "" ? r : o.thousandSeparator,
|
|
45
|
+
decimalSeparator: typeof e == "string" && e !== "" ? e : o.decimalSeparator,
|
|
46
|
+
decimalCount: (t == null ? void 0 : t.priceDecimalCount) === void 0 ? o.decimalCount : m(t.priceDecimalCount)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function y(t) {
|
|
50
|
+
return typeof (t == null ? void 0 : t.priceDecimalCount) == "number";
|
|
51
|
+
}
|
|
52
|
+
function S(t) {
|
|
53
|
+
if (!t || typeof t.getAttribute != "function")
|
|
54
|
+
return !1;
|
|
55
|
+
const r = t.getAttribute(s.DECIMAL_COUNT);
|
|
56
|
+
return r != null;
|
|
57
|
+
}
|
|
20
58
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
59
|
+
o as DEFAULT_ITEMS_PRICE_FORMAT,
|
|
60
|
+
n as ITEMS_CURRENCY_ATTR,
|
|
61
|
+
s as ITEMS_PRICE_FORMAT_ATTR,
|
|
62
|
+
C as LEGACY_PRICE_PARAGRAPH_ATTRS,
|
|
63
|
+
p as currencyAttrTargets,
|
|
64
|
+
u as currencyPositionFromLocation,
|
|
65
|
+
i as isCustomCurrencySymbol,
|
|
66
|
+
y as isNewPriceFormatConfig,
|
|
67
|
+
S as isNewPriceFormatRoot,
|
|
68
|
+
m as normalizeDecimalCount,
|
|
69
|
+
d as priceFormatFromConfig
|
|
25
70
|
};
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
import { CommonControl as
|
|
2
|
-
import { ItemsBlockControlId as
|
|
3
|
-
import { getItemsBlockConfig as
|
|
4
|
-
const
|
|
1
|
+
import { CommonControl as s } from "../../../common-control.js";
|
|
2
|
+
import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
|
|
3
|
+
import { getItemsBlockConfig as a } from "../../utils/nodeConfigUtils.js";
|
|
4
|
+
const e = r.BUTTON_LINK, n = {
|
|
5
5
|
LINK: "link"
|
|
6
6
|
};
|
|
7
|
-
class
|
|
7
|
+
class L extends s {
|
|
8
8
|
getId() {
|
|
9
|
-
return
|
|
9
|
+
return e;
|
|
10
10
|
}
|
|
11
11
|
getTemplate() {
|
|
12
12
|
return `
|
|
13
|
-
<div class="container ${
|
|
13
|
+
<div class="container ${e}">
|
|
14
14
|
${this._getLink()}
|
|
15
15
|
</div>
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
onRender() {
|
|
19
|
-
|
|
20
|
-
this.api.updateValues({
|
|
21
|
-
[n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
|
|
22
|
-
});
|
|
19
|
+
this.forgetLastPanelNode();
|
|
23
20
|
}
|
|
24
|
-
onTemplateNodeUpdated(
|
|
25
|
-
super.onTemplateNodeUpdated(
|
|
26
|
-
const
|
|
21
|
+
onTemplateNodeUpdated(o) {
|
|
22
|
+
super.onTemplateNodeUpdated(o), this.handleBlockInstanceChange(() => {
|
|
23
|
+
const t = a(this.currentNode);
|
|
27
24
|
this.api.updateValues({
|
|
28
|
-
[n.LINK]: (
|
|
25
|
+
[n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
28
|
}
|
|
@@ -44,6 +41,6 @@ class m extends r {
|
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
L as ButtonLinkControl,
|
|
45
|
+
e as CONTROL_BLOCK_ID
|
|
49
46
|
};
|
|
@@ -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 y = (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 N = "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 g = "ui-elements-items-card-composition-block", i = {
|
|
|
17
17
|
class M extends b {
|
|
18
18
|
constructor() {
|
|
19
19
|
super(...arguments);
|
|
20
|
-
|
|
20
|
+
y(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 N;
|
|
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.forgetLastPanelNode(), this._listenToFormUpdates();
|
|
48
48
|
}
|
|
49
49
|
onTemplateNodeUpdated(t) {
|
|
50
50
|
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
@@ -61,9 +61,6 @@ class M extends b {
|
|
|
61
61
|
</div>
|
|
62
62
|
`;
|
|
63
63
|
}
|
|
64
|
-
_initializeToggles() {
|
|
65
|
-
this._updateTogglesFromState();
|
|
66
|
-
}
|
|
67
64
|
_updateTogglesFromState() {
|
|
68
65
|
this.api.updateValues({
|
|
69
66
|
[i.PRODUCT_IMAGE]: this.visibilityState[i.PRODUCT_IMAGE],
|
|
@@ -224,21 +221,21 @@ class M extends b {
|
|
|
224
221
|
* - When both are visible, they share 50% each
|
|
225
222
|
*/
|
|
226
223
|
_updatePriceCellWidthsForVerticalLayout(t) {
|
|
227
|
-
var O,
|
|
224
|
+
var O, p;
|
|
228
225
|
const e = R(this.currentNode);
|
|
229
226
|
if (!((e == null ? void 0 : e.orientation) === h.ORIENTATION.VERTICAL))
|
|
230
227
|
return;
|
|
231
|
-
const n = (O = this.currentNode) == null ? void 0 : O.querySelectorAll(".product-price-class"), s = (
|
|
228
|
+
const n = (O = this.currentNode) == null ? void 0 : O.querySelectorAll(".product-price-class"), s = (p = this.currentNode) == null ? void 0 : p.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();
|
|
232
229
|
if (n && n.length > 0) {
|
|
233
|
-
const
|
|
234
|
-
n.forEach((
|
|
235
|
-
T.modifyHtml(
|
|
230
|
+
const u = l || !C ? "100%" : "50%";
|
|
231
|
+
n.forEach((_) => {
|
|
232
|
+
T.modifyHtml(_).setStyle("width", u);
|
|
236
233
|
});
|
|
237
234
|
}
|
|
238
235
|
if (s && s.length > 0) {
|
|
239
|
-
const
|
|
240
|
-
s.forEach((
|
|
241
|
-
T.modifyHtml(
|
|
236
|
+
const u = l || !P ? "100%" : "50%";
|
|
237
|
+
s.forEach((_) => {
|
|
238
|
+
T.modifyHtml(_).setStyle("width", u);
|
|
242
239
|
});
|
|
243
240
|
}
|
|
244
241
|
t || T.apply(new c("Updated price cell widths for vertical layout"));
|
|
@@ -256,6 +253,6 @@ class M extends b {
|
|
|
256
253
|
}
|
|
257
254
|
}
|
|
258
255
|
export {
|
|
259
|
-
|
|
256
|
+
N as COMPOSITION_CONTROL_BLOCK_ID,
|
|
260
257
|
M as ItemsBlockCardCompositionControl
|
|
261
258
|
};
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
import { CommonControl as
|
|
2
|
-
import { ItemsBlockControlId as
|
|
3
|
-
import { getItemsBlockConfig as
|
|
4
|
-
const
|
|
1
|
+
import { CommonControl as s } from "../../../common-control.js";
|
|
2
|
+
import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
|
|
3
|
+
import { getItemsBlockConfig as a } from "../../utils/nodeConfigUtils.js";
|
|
4
|
+
const t = r.IMAGE_LINK, n = {
|
|
5
5
|
LINK: "link"
|
|
6
6
|
};
|
|
7
|
-
class
|
|
7
|
+
class L extends s {
|
|
8
8
|
getId() {
|
|
9
|
-
return
|
|
9
|
+
return t;
|
|
10
10
|
}
|
|
11
11
|
getTemplate() {
|
|
12
12
|
return `
|
|
13
|
-
<div class="container ${
|
|
13
|
+
<div class="container ${t}">
|
|
14
14
|
${this._getLink()}
|
|
15
15
|
</div>
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
onRender() {
|
|
19
|
-
|
|
20
|
-
this.api.updateValues({
|
|
21
|
-
[n.LINK]: (e == null ? void 0 : e.imageLink) ?? ""
|
|
22
|
-
});
|
|
19
|
+
this.forgetLastPanelNode();
|
|
23
20
|
}
|
|
24
|
-
onTemplateNodeUpdated(
|
|
25
|
-
super.onTemplateNodeUpdated(
|
|
26
|
-
const
|
|
21
|
+
onTemplateNodeUpdated(o) {
|
|
22
|
+
super.onTemplateNodeUpdated(o), this.handleBlockInstanceChange(() => {
|
|
23
|
+
const e = a(this.currentNode);
|
|
27
24
|
this.api.updateValues({
|
|
28
|
-
[n.LINK]: (
|
|
25
|
+
[n.LINK]: (e == null ? void 0 : e.imageLink) ?? ""
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
28
|
}
|
|
@@ -44,6 +41,6 @@ class p extends a {
|
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
t as CONTROL_BLOCK_ID,
|
|
45
|
+
L as ImageLinkControl
|
|
49
46
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ModificationDescription as d, UIElementType as
|
|
1
|
+
import { ModificationDescription as d, UIElementType as m, 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 s, setItemsBlockConfig as g } from "../../utils/nodeConfigUtils.js";
|
|
7
7
|
const I = a.NAME_TRIMMING, n = {
|
|
8
8
|
TRIMMING: "trimming"
|
|
9
9
|
};
|
|
@@ -19,14 +19,13 @@ class E extends T {
|
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
onRender() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this._onTrimmingChange(t);
|
|
22
|
+
this.forgetLastPanelNode(), this.api.onValueChanged(n.TRIMMING, (e) => {
|
|
23
|
+
this._onTrimmingChange(e);
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
onTemplateNodeUpdated(e) {
|
|
28
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
29
|
-
const t =
|
|
28
|
+
const t = s(this.currentNode);
|
|
30
29
|
this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
31
30
|
});
|
|
32
31
|
}
|
|
@@ -37,16 +36,16 @@ class E extends T {
|
|
|
37
36
|
const t = c(this.currentNode);
|
|
38
37
|
if (!t)
|
|
39
38
|
return;
|
|
40
|
-
const i =
|
|
41
|
-
|
|
39
|
+
const i = s(this.currentNode), r = 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);
|
|
40
|
+
r ? 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 ${r ? "Enabled" : "Disabled"}`));
|
|
42
41
|
}
|
|
43
42
|
_getTextTrimming() {
|
|
44
43
|
return `
|
|
45
44
|
<div class="display-flex align-items-center justify-content-between">
|
|
46
|
-
<${
|
|
45
|
+
<${m.LABEL}
|
|
47
46
|
${p.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
48
47
|
>
|
|
49
|
-
</${
|
|
48
|
+
</${m.LABEL}>
|
|
50
49
|
${this._GuToggle(n.TRIMMING)}
|
|
51
50
|
</div>
|
|
52
51
|
`;
|