@useinsider/guido 3.14.0 → 3.15.0-beta.0b5dc39
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/useEmailTemplateApplier.js +46 -32
- package/dist/composables/useHtmlValidator.js +105 -100
- package/dist/composables/useStripo.js +30 -29
- package/dist/config/compiler/itemsCompilerRules.js +25 -4
- package/dist/config/compiler/utils/itemsCompilerUtils.js +28 -0
- package/dist/config/i18n/en/labels.json.js +7 -3
- package/dist/config/migrator/index.js +9 -8
- package/dist/config/migrator/itemsBlockMigrator.js +47 -45
- package/dist/config/migrator/productNameLinkMigrator.js +27 -0
- package/dist/config/migrator/recommendation/compositionMapper.js +26 -23
- package/dist/config/migrator/recommendation/htmlBuilder.js +156 -155
- package/dist/extensions/Blocks/Items/block.js +30 -30
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +16 -16
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +26 -22
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +36 -35
- package/dist/extensions/Blocks/Items/template.js +228 -263
- package/dist/extensions/Blocks/Items/utils/nameNode.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +18 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +363 -322
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +271 -231
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +16 -16
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +16 -16
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +120 -120
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +55 -54
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +89 -0
- package/dist/extensions/Blocks/common-control.js +42 -35
- package/dist/src/composables/useHtmlValidator.d.ts +3 -2
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +12 -0
- package/dist/src/config/migrator/productNameLinkMigrator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/utils/nameNode.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +27 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +47 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +3 -1
- package/dist/src/stores/dynamic-content.d.ts +8 -0
- package/dist/src/utils/registerUsedDynamicContent.d.ts +8 -0
- package/dist/src/utils/unwrapProductNameLink.d.ts +15 -0
- package/dist/stores/dynamic-content.js +12 -2
- package/dist/utils/pairProductVariables.js +75 -72
- package/dist/utils/registerUsedDynamicContent.js +23 -0
- package/dist/utils/unwrapProductNameLink.js +37 -0
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { useOnboardingStore as
|
|
1
|
+
import { BlockId as f } from "../../../enums/block.js";
|
|
2
|
+
import { useOnboardingStore as g } from "../../../stores/onboarding.js";
|
|
3
3
|
import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
|
|
4
4
|
import { Block as I, BlockCompositionType as C, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
5
|
+
import { SETTINGS_ENUMS as d, DefaultConfigValues as m } from "./enums/settingsEnums.js";
|
|
6
6
|
import { getDefaultTemplate as b } from "./template.js";
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class
|
|
7
|
+
import { getItemsBlockContainer as l, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const p = f.Items;
|
|
9
|
+
class O extends I {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return p;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
@@ -24,15 +24,15 @@ class P extends I {
|
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
26
|
return y(
|
|
27
|
-
|
|
27
|
+
p,
|
|
28
28
|
this.api.translate("Items"),
|
|
29
29
|
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.")
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
getTemplate() {
|
|
33
33
|
return b({
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
34
|
+
orientation: d.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: d.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
37
|
currencySymbol: m.productPriceCurrencySymbolControlValue,
|
|
38
38
|
currencyLocation: m.productPriceCurrencyLocationControlValue,
|
|
@@ -45,23 +45,23 @@ class P extends I {
|
|
|
45
45
|
canBeSavedAsModule() {
|
|
46
46
|
return !0;
|
|
47
47
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const t = this.api.getDocumentModifier(),
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
48
|
+
onCreated(e) {
|
|
49
|
+
const t = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
|
|
50
|
+
o.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
+
const i = l(e);
|
|
52
|
+
if (!i)
|
|
53
53
|
return;
|
|
54
|
-
const r =
|
|
54
|
+
const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(e);
|
|
55
55
|
if (n != null && n.initialized)
|
|
56
56
|
if (s)
|
|
57
|
-
n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(
|
|
57
|
+
n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(i).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
|
|
58
58
|
else {
|
|
59
59
|
const a = this.api.getDocumentModifier();
|
|
60
|
-
a.modifyHtml(
|
|
60
|
+
a.modifyHtml(i).setNodeConfig(n), this._stampProductTdDomAttributes(i, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
const a = N();
|
|
64
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
64
|
+
this.api.getDocumentModifier().modifyHtml(i).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -70,33 +70,33 @@ class P extends I {
|
|
|
70
70
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
71
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
72
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const t =
|
|
73
|
+
onDocumentChanged(e) {
|
|
74
|
+
const t = l(e);
|
|
75
75
|
if (!t)
|
|
76
76
|
return;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
77
|
+
const o = t.getNodeConfig();
|
|
78
|
+
if (o && Object.keys(o).length > 0)
|
|
79
79
|
return;
|
|
80
|
-
const r = u(
|
|
80
|
+
const r = u(e);
|
|
81
81
|
if (!(r != null && r.initialized))
|
|
82
82
|
return;
|
|
83
83
|
const s = this.api.getDocumentModifier();
|
|
84
84
|
s.modifyHtml(t).setNodeConfig(r), this._stampProductTdDomAttributes(t, r, s), s.apply(new c("Recover Items block config from saved module"));
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
|
|
87
|
+
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
88
88
|
* `.ins-product-td` container from the recovered config. Required for saved modules:
|
|
89
89
|
* `migrate()` (which backfills these) only runs at template load — never when a module
|
|
90
90
|
* is dropped into a live editor — so this is the one place the namespace + index get
|
|
91
91
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
92
|
* relies on this td-level fallback in pairProductVariables.
|
|
93
93
|
*/
|
|
94
|
-
_stampProductTdDomAttributes(
|
|
95
|
-
const
|
|
96
|
-
|
|
94
|
+
_stampProductTdDomAttributes(e, t, o) {
|
|
95
|
+
const i = h(t.itemsSelectValue, t.type);
|
|
96
|
+
o.modifyHtml(e).setAttribute("data-type", t.type), o.modifyHtml(e).setAttribute("data-number", i), o.modifyHtml(e).setAttribute("data-nodup", String(t.priceHideDiscount));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
p as BLOCK_ID,
|
|
101
|
+
O as ItemsBlock
|
|
102
102
|
};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { ModificationDescription as l, UIElementType as s, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
|
|
4
|
+
import { findNameTextNode as T } from "../../utils/nameNode.js";
|
|
5
|
+
import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
|
|
6
|
+
const g = a.NAME_TRIMMING, i = {
|
|
6
7
|
TRIMMING: "trimming"
|
|
7
8
|
};
|
|
8
|
-
class y extends
|
|
9
|
+
class y extends p {
|
|
9
10
|
getId() {
|
|
10
11
|
return g;
|
|
11
12
|
}
|
|
12
13
|
getTemplate() {
|
|
13
14
|
return `
|
|
14
|
-
<div class="container ${
|
|
15
|
+
<div class="container ${a.NAME_TRIMMING}">
|
|
15
16
|
${this._getTextTrimming()}
|
|
16
17
|
</div>
|
|
17
18
|
`;
|
|
18
19
|
}
|
|
19
20
|
onRender() {
|
|
20
|
-
const e =
|
|
21
|
+
const e = r(this.currentNode);
|
|
21
22
|
this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.TRIMMING, (t) => {
|
|
22
23
|
this._onTrimmingChange(t);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
onTemplateNodeUpdated(e) {
|
|
26
27
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
27
|
-
const t =
|
|
28
|
+
const t = r(this.currentNode);
|
|
28
29
|
this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -32,20 +33,19 @@ class y extends T {
|
|
|
32
33
|
c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
33
34
|
}
|
|
34
35
|
_applyTrimmingStyles(e) {
|
|
35
|
-
|
|
36
|
-
const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
|
|
36
|
+
const t = T(this.currentNode);
|
|
37
37
|
if (!t)
|
|
38
38
|
return;
|
|
39
|
-
const n =
|
|
40
|
-
|
|
39
|
+
const n = r(this.currentNode), m = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, o = this.api.getDocumentModifier().modifyHtml(t);
|
|
40
|
+
m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", "100%").apply(new l(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
|
|
41
41
|
}
|
|
42
42
|
_getTextTrimming() {
|
|
43
43
|
return `
|
|
44
44
|
<div class="display-flex align-items-center justify-content-between">
|
|
45
|
-
<${
|
|
46
|
-
${
|
|
45
|
+
<${s.LABEL}
|
|
46
|
+
${d.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
47
47
|
>
|
|
48
|
-
</${
|
|
48
|
+
</${s.LABEL}>
|
|
49
49
|
${this._GuToggle(i.TRIMMING)}
|
|
50
50
|
</div>
|
|
51
51
|
`;
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import { UIElementType as
|
|
2
|
-
import { CommonControl as
|
|
3
|
-
import { ItemsBlockControlId as
|
|
4
|
-
import { getItemsBlockConfig as
|
|
5
|
-
const
|
|
1
|
+
import { ModificationDescription as c, UIElementType as s, UEAttr as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { CommonControl as p } from "../../../common-control.js";
|
|
3
|
+
import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
|
|
4
|
+
import { getItemsBlockConfig as d, setItemsBlockConfig as u } from "../../utils/nodeConfigUtils.js";
|
|
5
|
+
const D = r.PRICE_HIDE_DISCOUNT, i = {
|
|
6
6
|
HIDE_DISCOUNT: "hideDiscount"
|
|
7
7
|
};
|
|
8
|
-
class
|
|
8
|
+
class E extends p {
|
|
9
9
|
getId() {
|
|
10
|
-
return
|
|
10
|
+
return D;
|
|
11
11
|
}
|
|
12
12
|
getTemplate() {
|
|
13
13
|
return `
|
|
14
|
-
<div class="container ${
|
|
14
|
+
<div class="container ${r.PRICE_HIDE_DISCOUNT}">
|
|
15
15
|
${this._getHideDiscount()}
|
|
16
16
|
</div>
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
19
19
|
onRender() {
|
|
20
|
-
const
|
|
21
|
-
this.api.updateValues({ [i.HIDE_DISCOUNT]: (
|
|
22
|
-
this._onHideDiscountChange(
|
|
20
|
+
const t = d(this.currentNode);
|
|
21
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (e) => {
|
|
22
|
+
this._onHideDiscountChange(e);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
onTemplateNodeUpdated(
|
|
26
|
-
super.onTemplateNodeUpdated(
|
|
27
|
-
const
|
|
28
|
-
this.api.updateValues({ [i.HIDE_DISCOUNT]: (
|
|
25
|
+
onTemplateNodeUpdated(t) {
|
|
26
|
+
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
27
|
+
const e = d(this.currentNode);
|
|
28
|
+
this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 });
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
_onHideDiscountChange(
|
|
32
|
-
|
|
31
|
+
_onHideDiscountChange(t) {
|
|
32
|
+
var n;
|
|
33
|
+
const e = this.api.getDocumentModifier();
|
|
34
|
+
u(this.currentNode, this.api, { priceHideDiscount: t }, e);
|
|
35
|
+
const o = (n = this.currentNode) == null ? void 0 : n.closest(".ins-product-td");
|
|
36
|
+
o && e.modifyHtml(o).setAttribute("data-nodup", String(t)), e.apply(new c("Update hide-discount setting")), this.api.updateValues({ [i.HIDE_DISCOUNT]: t });
|
|
33
37
|
}
|
|
34
38
|
_getHideDiscount() {
|
|
35
39
|
return `
|
|
36
40
|
<div class="display-flex align-items-center justify-content-between">
|
|
37
|
-
<${
|
|
38
|
-
${
|
|
41
|
+
<${s.LABEL}
|
|
42
|
+
${a.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
|
|
39
43
|
>
|
|
40
|
-
</${
|
|
44
|
+
</${s.LABEL}>
|
|
41
45
|
${this._GuToggle(i.HIDE_DISCOUNT)}
|
|
42
46
|
</div>
|
|
43
47
|
</div>
|
|
@@ -45,6 +49,6 @@ class C extends r {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
D as CONTROL_BLOCK_ID,
|
|
53
|
+
E as PriceHideDiscountControl
|
|
50
54
|
};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
1
|
+
import { ModificationDescription as S, UEAttr as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { CommonControl as k } from "../../common-control.js";
|
|
3
3
|
import { ItemsBlockId as I } from "../enums/controlEnums.js";
|
|
4
|
-
import { productPairs as
|
|
4
|
+
import { productPairs as y, templateFirstLine as D } from "../enums/productEnums.js";
|
|
5
5
|
import { SETTINGS_ENUMS as d, ItemTypeOptions as x, OrientationOptions as F, ItemInCartOptions as O, DefaultConfigValues as H } from "../enums/settingsEnums.js";
|
|
6
6
|
import $ from "../layouts/horizontal.html.js";
|
|
7
|
-
import
|
|
8
|
-
import { getDefaultTemplate as
|
|
9
|
-
import {
|
|
10
|
-
|
|
7
|
+
import w from "../layouts/vertical.html.js";
|
|
8
|
+
import { getDefaultTemplate as q, wrapInTableRow as C } from "../template.js";
|
|
9
|
+
import { findNameTextNode as V } from "../utils/nameNode.js";
|
|
10
|
+
import { getItemsBlockConfig as _, setItemsBlockConfig as M, escapeReplacement as g, deriveItemNumber as B } from "../utils/nodeConfigUtils.js";
|
|
11
|
+
const G = "ui-elements-items-block", m = {
|
|
11
12
|
ITEMS_TYPE: "itemsType",
|
|
12
13
|
ORIENTATION: "orientation",
|
|
13
14
|
ITEM_IDS: "itemIds"
|
|
14
15
|
};
|
|
15
|
-
class
|
|
16
|
+
class te extends k {
|
|
16
17
|
getId() {
|
|
17
|
-
return
|
|
18
|
+
return G;
|
|
18
19
|
}
|
|
19
20
|
getTemplate() {
|
|
20
21
|
return `
|
|
@@ -86,7 +87,7 @@ class Z extends k {
|
|
|
86
87
|
M(this.currentNode, this.api, {
|
|
87
88
|
orientation: e,
|
|
88
89
|
priceOrientation: "horizontal"
|
|
89
|
-
}, r), r.apply(new
|
|
90
|
+
}, r), r.apply(new S("Changed orientation")), this._reOrderTemplate(), setTimeout(() => {
|
|
90
91
|
this._recalculateTrimming();
|
|
91
92
|
}, 50);
|
|
92
93
|
}
|
|
@@ -103,7 +104,7 @@ class Z extends k {
|
|
|
103
104
|
buttonLink: n
|
|
104
105
|
}, o), this._updateDataTypeAttributes(r, o), this._initializeSelectItems();
|
|
105
106
|
const c = this._getTemplateData(r, i.value);
|
|
106
|
-
this._updateImageSrc(c.imageSrc, o), this._updateName(c.name, o), this._updatePrice(c.price, o), this._updateOriginalPrice(c.originalPrice, o), this._updateQuantity(c.quantity, r, o), o.apply(new
|
|
107
|
+
this._updateImageSrc(c.imageSrc, o), this._updateName(c.name, o), this._updatePrice(c.price, o), this._updateOriginalPrice(c.originalPrice, o), this._updateQuantity(c.quantity, r, o), o.apply(new S("Updated items type"));
|
|
107
108
|
}
|
|
108
109
|
_onItemIdsChange(e) {
|
|
109
110
|
this.api.updateValues({ [m.ITEM_IDS]: e });
|
|
@@ -114,7 +115,7 @@ class Z extends k {
|
|
|
114
115
|
buttonLink: r
|
|
115
116
|
}, i), this._updateDataNumberAttributes(e, i);
|
|
116
117
|
const n = this._getTemplateData(void 0, e);
|
|
117
|
-
this._updateImageSrc(n.imageSrc, i), this._updateName(n.name, i), this._updatePrice(n.price, i), this._updateOriginalPrice(n.originalPrice, i), this._updateQuantity(n.quantity, void 0, i), i.apply(new
|
|
118
|
+
this._updateImageSrc(n.imageSrc, i), this._updateName(n.name, i), this._updatePrice(n.price, i), this._updateOriginalPrice(n.originalPrice, i), this._updateQuantity(n.quantity, void 0, i), i.apply(new S("Updated item selection"));
|
|
118
119
|
}
|
|
119
120
|
_initializeSelectItems() {
|
|
120
121
|
this.api.setUIEAttribute(
|
|
@@ -149,25 +150,25 @@ class Z extends k {
|
|
|
149
150
|
}
|
|
150
151
|
_renderTemplate() {
|
|
151
152
|
const e = _(this.currentNode), r = (e == null ? void 0 : e.orientation) ?? d.ORIENTATION.VERTICAL, t = (e == null ? void 0 : e.type) ?? d.ITEMS_TYPE.CART_ITEMS, i = (e == null ? void 0 : e.itemsSelectValue) ?? "", n = (e == null ? void 0 : e.priceCurrencySymbol) ?? "", s = (e == null ? void 0 : e.priceCurrencyLocation) ?? "0", o = (e == null ? void 0 : e.priceFormatted) ?? !1;
|
|
152
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
153
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(q({
|
|
153
154
|
orientation: r,
|
|
154
155
|
itemsType: t,
|
|
155
156
|
itemId: i,
|
|
156
157
|
currencySymbol: n,
|
|
157
158
|
currencyLocation: s,
|
|
158
159
|
formattedPrice: o
|
|
159
|
-
})).apply(new
|
|
160
|
+
})).apply(new S("Updated template"));
|
|
160
161
|
}
|
|
161
162
|
_getTemplateData(e, r) {
|
|
162
|
-
const t = _(this.currentNode), i = e ?? (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = r ?? (t == null ? void 0 : t.itemsSelectValue) ?? "", s = (t == null ? void 0 : t.priceFormatted) ?? !1, o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, c = O[i].findIndex((h) => h.value === n), a = c > -1 ? c : 0, l =
|
|
163
|
+
const t = _(this.currentNode), i = e ?? (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = r ?? (t == null ? void 0 : t.itemsSelectValue) ?? "", s = (t == null ? void 0 : t.priceFormatted) ?? !1, o = (t == null ? void 0 : t.priceSinglePrice) ?? !1, c = O[i].findIndex((h) => h.value === n), a = c > -1 ? c : 0, l = y.PAIRS_FOR_EXTENSION.price[i], T = y.PAIRS_FOR_EXTENSION.originalPrice[i];
|
|
163
164
|
let u, p;
|
|
164
165
|
return o ? (u = s ? l.DEFAULT_SINGLE_PRICE_FORMATTED : l.DEFAULT_SINGLE_PRICE, p = s ? T.DEFAULT_SINGLE_PRICE_FORMATTED : T.DEFAULT_SINGLE_PRICE) : (u = s ? l.DEFAULT_PRICE_FORMATTED : l.DEFAULT_PRICE, p = s ? T.DEFAULT_PRICE_FORMATTED : T.DEFAULT_PRICE), {
|
|
165
|
-
imageSrc:
|
|
166
|
-
name:
|
|
166
|
+
imageSrc: y.PAIRS_FOR_EXTENSION.imageSrc[i].DEFAULT[a],
|
|
167
|
+
name: y.PAIRS_FOR_EXTENSION.name[i].DEFAULT[a],
|
|
167
168
|
price: u,
|
|
168
169
|
originalPrice: p,
|
|
169
|
-
quantity:
|
|
170
|
-
button:
|
|
170
|
+
quantity: y.PAIRS_FOR_EXTENSION.quantity[i].DEFAULT,
|
|
171
|
+
button: y.PAIRS_FOR_EXTENSION.button[i].DEFAULT_LABEL
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
_updateImageSrc(e, r) {
|
|
@@ -193,8 +194,8 @@ class Z extends k {
|
|
|
193
194
|
const a = this._getParagraphFromBlock(c);
|
|
194
195
|
if (!a)
|
|
195
196
|
return;
|
|
196
|
-
const l = a.getInnerHTML().trim() || "", T = a.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", p = this._removeCurrencySymbol(T, u), h = this._replacePriceNumber(p, e), E = this._buildPriceContent(h, u, s),
|
|
197
|
-
r.modifyHtml(a).setInnerHtml(
|
|
197
|
+
const l = a.getInnerHTML().trim() || "", T = a.getInnerText().trim() || "", u = (n == null ? void 0 : n.trim()) || "", p = this._removeCurrencySymbol(T, u), h = this._replacePriceNumber(p, e), E = this._buildPriceContent(h, u, s), N = l.replace(T, g(E));
|
|
198
|
+
r.modifyHtml(a).setInnerHtml(N);
|
|
198
199
|
});
|
|
199
200
|
}
|
|
200
201
|
_updateOriginalPrice(e, r) {
|
|
@@ -209,7 +210,7 @@ class Z extends k {
|
|
|
209
210
|
const l = a.querySelector("s");
|
|
210
211
|
if (!l)
|
|
211
212
|
return;
|
|
212
|
-
const T = l.getInnerHTML().trim() || "", u = l.getInnerText().trim() || "", p = (n == null ? void 0 : n.trim()) || "", h = this._removeCurrencySymbol(u, p), E = this._replacePriceNumber(h, e),
|
|
213
|
+
const T = l.getInnerHTML().trim() || "", u = l.getInnerText().trim() || "", p = (n == null ? void 0 : n.trim()) || "", h = this._removeCurrencySymbol(u, p), E = this._replacePriceNumber(h, e), N = this._buildPriceContent(E, p, s), R = `<s>${T.replace(u, g(N))}</s>`;
|
|
213
214
|
r.modifyHtml(a).setInnerHtml(R);
|
|
214
215
|
});
|
|
215
216
|
}
|
|
@@ -223,17 +224,17 @@ class Z extends k {
|
|
|
223
224
|
return;
|
|
224
225
|
const T = l.getInnerText().trim();
|
|
225
226
|
let u = l.getInnerHTML().trim();
|
|
226
|
-
function p(E,
|
|
227
|
+
function p(E, N, A) {
|
|
227
228
|
return E.replace(
|
|
228
|
-
new RegExp(`(>\\s*)?${
|
|
229
|
+
new RegExp(`(>\\s*)?${N}(\\s*<)?`, "g"),
|
|
229
230
|
`$1${A}$2`
|
|
230
231
|
);
|
|
231
232
|
}
|
|
232
233
|
u = p(u, T, e), t.modifyHtml(l).setInnerHtml(u), t.modifyHtml(a).setStyle("display", c ? "table-cell" : "none");
|
|
233
234
|
}
|
|
234
235
|
_reOrderTemplate(e) {
|
|
235
|
-
var h, E,
|
|
236
|
-
const r = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${I.IMAGE}"]`), t = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${I.NAME}"]`), i = ((
|
|
236
|
+
var h, E, N, A, R, b;
|
|
237
|
+
const r = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${I.IMAGE}"]`), t = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${I.NAME}"]`), i = ((N = this.currentNode) == null ? void 0 : N.querySelectorAll(
|
|
237
238
|
`[esd-extension-block-id="${I.PRICE}"]`
|
|
238
239
|
)) || [], n = ((A = this.currentNode) == null ? void 0 : A.querySelectorAll(
|
|
239
240
|
`[esd-extension-block-id="${I.ORIGINAL_PRICE}"]`
|
|
@@ -241,12 +242,12 @@ class Z extends k {
|
|
|
241
242
|
if (!r || !t || !s || !o || !c || !a)
|
|
242
243
|
return;
|
|
243
244
|
const l = _(this.currentNode), u = ((l == null ? void 0 : l.orientation) ?? d.ORIENTATION.VERTICAL) === d.ORIENTATION.VERTICAL;
|
|
244
|
-
let p = u ?
|
|
245
|
+
let p = u ? w : $;
|
|
245
246
|
setTimeout(() => {
|
|
246
|
-
const
|
|
247
|
-
p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? D : "").replace("{-{-PRODUCT_IMAGE-}-}", C(r.getOuterHTML())).replace("{-{-PRODUCT_NAME-}-}", C(t.getOuterHTML())).replaceAll("{-{-PRODUCT_PRICE-}-}", C(
|
|
247
|
+
const f = g(s.getOuterHTML()), U = g(o.getOuterHTML());
|
|
248
|
+
p = p.replace("{-{-TEMPLATE_FIRST_LINE-}-}", u ? D : "").replace("{-{-PRODUCT_IMAGE-}-}", C(r.getOuterHTML())).replace("{-{-PRODUCT_NAME-}-}", C(t.getOuterHTML())).replaceAll("{-{-PRODUCT_PRICE-}-}", C(f)).replaceAll("{-{-PRODUCT_ORIGINAL_PRICE-}-}", C(U)).replace("{-{-PRODUCT_QUANTITY-}-}", C(c.getOuterHTML())).replace("{-{-PRODUCT_BUTTON-}-}", C(a.getOuterHTML())), p = p.trim().replace(D, "").slice(0, -5);
|
|
248
249
|
const P = e ?? this.api.getDocumentModifier();
|
|
249
|
-
P.modifyHtml(r.querySelector("img")).setAttribute("width", H.productImageWidth).setAttribute("height", H.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new
|
|
250
|
+
P.modifyHtml(r.querySelector("img")).setAttribute("width", H.productImageWidth).setAttribute("height", H.productImageWidth), P.modifyHtml(this.currentNode).setInnerHtml(p), e || P.apply(new S("Reordered template"));
|
|
250
251
|
}, 50);
|
|
251
252
|
}
|
|
252
253
|
_updateDataTypeAttributes(e, r) {
|
|
@@ -261,7 +262,7 @@ class Z extends k {
|
|
|
261
262
|
_updateDataNumberAttributes(e, r) {
|
|
262
263
|
if (!this.currentNode)
|
|
263
264
|
return;
|
|
264
|
-
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n =
|
|
265
|
+
const t = _(this.currentNode), i = (t == null ? void 0 : t.type) ?? d.ITEMS_TYPE.CART_ITEMS, n = B(e, i), s = this.currentNode.closest(".ins-product-td");
|
|
265
266
|
s && r.modifyHtml(s).setAttribute("data-number", n), this.currentNode.querySelectorAll("[data-number]").forEach((c) => {
|
|
266
267
|
const a = c;
|
|
267
268
|
r.modifyHtml(a).setAttribute("data-number", n);
|
|
@@ -269,7 +270,7 @@ class Z extends k {
|
|
|
269
270
|
}
|
|
270
271
|
_reFillTemplate(e) {
|
|
271
272
|
const r = this._getTemplateData(e), t = this.api.getDocumentModifier();
|
|
272
|
-
this._updateImageSrc(r.imageSrc, t), this._updateName(r.name, t), this._updatePrice(r.price, t), this._updateOriginalPrice(r.originalPrice, t), this._updateQuantity(r.quantity, e, t), t.apply(new
|
|
273
|
+
this._updateImageSrc(r.imageSrc, t), this._updateName(r.name, t), this._updatePrice(r.price, t), this._updateOriginalPrice(r.originalPrice, t), this._updateQuantity(r.quantity, e, t), t.apply(new S("Refilled template"));
|
|
273
274
|
}
|
|
274
275
|
_recalculateTrimming() {
|
|
275
276
|
var n;
|
|
@@ -278,11 +279,11 @@ class Z extends k {
|
|
|
278
279
|
const e = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${I.NAME}"]`);
|
|
279
280
|
if (!e)
|
|
280
281
|
return;
|
|
281
|
-
const r = e
|
|
282
|
+
const r = V(e);
|
|
282
283
|
if (!r)
|
|
283
284
|
return;
|
|
284
285
|
const t = _(this.currentNode), i = (t == null ? void 0 : t.nameTrimming) ?? !0;
|
|
285
|
-
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space", i ? "nowrap" : "normal").setStyle("text-overflow", i ? "ellipsis" : "unset").setStyle("max-width", "100%").setStyle("width", "100%").apply(new
|
|
286
|
+
this.api.getDocumentModifier().modifyHtml(r).setStyle("overflow", "hidden").setStyle("white-space", i ? "nowrap" : "normal").setStyle("text-overflow", i ? "ellipsis" : "unset").setStyle("max-width", "100%").setStyle("width", "100%").apply(new S("Recalculated trimming after orientation change"));
|
|
286
287
|
}
|
|
287
288
|
_getParagraphFromBlock(e) {
|
|
288
289
|
return e.querySelector("p");
|
|
@@ -314,6 +315,6 @@ class Z extends k {
|
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
317
|
export {
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
G as CONTROL_BLOCK_ID,
|
|
319
|
+
te as ItemsBlockControl
|
|
319
320
|
};
|