@useinsider/guido 3.16.0-beta.20cd2fe → 3.16.0-beta.77f2873
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/@types/config/schemas.js +23 -25
- package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
- package/dist/components/organisms/header/EditorActions.vue.js +11 -11
- package/dist/components/organisms/header/EditorActions.vue2.js +50 -34
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +23 -28
- package/dist/components/organisms/header/MiddleSlot.vue.js +4 -4
- package/dist/components/organisms/header/MiddleSlot.vue2.js +7 -8
- package/dist/components/organisms/header/RightSlot.vue.js +6 -6
- package/dist/components/organisms/header/RightSlot.vue2.js +15 -17
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +34 -43
- package/dist/composables/useRecommendation.js +20 -19
- package/dist/config/i18n/en/labels.json.js +4 -28
- package/dist/config/migrator/itemsBlockMigrator.js +1 -1
- package/dist/enums/recommendation.js +17 -17
- package/dist/extensions/Blocks/Items/block.js +98 -49
- package/dist/extensions/Blocks/Items/constants/currency.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
- package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
- package/dist/extensions/Blocks/Items/template.js +103 -102
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +21 -21
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -12
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@vueuse/shared/index.js +28 -40
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useActionsApi.d.ts +2 -2
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/extensions/Blocks/Items/block.d.ts +21 -0
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/src/stores/config.d.ts +0 -18
- package/dist/src/stores/editor.d.ts +0 -107
- package/dist/src/stores/onboarding.d.ts +0 -377
- package/dist/src/stores/version-history.d.ts +1 -1
- package/dist/src/utils/timeUtil.d.ts +0 -10
- package/dist/stores/editor.js +1 -5
- package/dist/stores/onboarding.js +11 -16
- package/dist/utils/pairProductVariables.js +60 -59
- package/dist/utils/timeUtil.js +17 -6
- package/package.json +1 -1
- package/dist/components/organisms/header/AutoSaveStatus.vue.js +0 -17
- package/dist/components/organisms/header/AutoSaveStatus.vue2.js +0 -21
- package/dist/components/organisms/header/EditorActionsMenu.vue.js +0 -20
- package/dist/components/organisms/header/EditorActionsMenu.vue2.js +0 -39
- package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue.js +0 -18
- package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue2.js +0 -37
- package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue.js +0 -24
- package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue2.js +0 -48
- package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue.js +0 -18
- package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue2.js +0 -74
- package/dist/composables/useAccessibilityApi.js +0 -31
- package/dist/node_modules/@vueuse/core/index.js +0 -102
- package/dist/src/components/organisms/header/EditorActionsMenu.vue.d.ts +0 -2
- package/dist/src/components/organisms/header/accessibility/AccessibilityToolbar.vue.d.ts +0 -2
- package/dist/src/components/organisms/header/accessibility/ColorVisionSelect.vue.d.ts +0 -2
- package/dist/src/components/organisms/onboarding/EditorTabBarOnboarding.vue.d.ts +0 -2
- package/dist/src/composables/useAccessibilityApi.d.ts +0 -15
- /package/dist/src/components/organisms/header/{AutoSaveStatus.vue.d.ts → AutoSaveToggle.vue.d.ts} +0 -0
|
@@ -3,20 +3,21 @@ import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommenda
|
|
|
3
3
|
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
5
|
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
|
|
7
|
+
import { useConfigStore as P } from "../stores/config.js";
|
|
8
|
+
const B = () => ({
|
|
8
9
|
calculateCardWidth: ({
|
|
9
10
|
mobileLeftPadding: a,
|
|
10
11
|
mobileRightPadding: s,
|
|
11
12
|
cardsInRow: c,
|
|
12
|
-
unresponsive:
|
|
13
|
+
unresponsive: n
|
|
13
14
|
}) => {
|
|
14
|
-
const r =
|
|
15
|
+
const r = n ? c : 1, e = a + s + (r - 1) * b;
|
|
15
16
|
return (C - e) / r;
|
|
16
17
|
},
|
|
17
18
|
getRecommendationCampaignData: (a) => {
|
|
18
|
-
const s = l(), c = Number(a),
|
|
19
|
-
if (!
|
|
19
|
+
const s = l(), c = Number(a), n = s.blockStates[c];
|
|
20
|
+
if (!n)
|
|
20
21
|
return {
|
|
21
22
|
textTrimming: !1,
|
|
22
23
|
orientation: "vertical",
|
|
@@ -29,7 +30,7 @@ const k = () => ({
|
|
|
29
30
|
discountBeforeTextValue: "",
|
|
30
31
|
discountAfterTextValue: ""
|
|
31
32
|
};
|
|
32
|
-
const { recommendationConfigs: r } =
|
|
33
|
+
const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
33
34
|
return {
|
|
34
35
|
textTrimming: r.textTrimming,
|
|
35
36
|
orientation: e,
|
|
@@ -45,7 +46,7 @@ const k = () => ({
|
|
|
45
46
|
},
|
|
46
47
|
buildCampaignUrl: (a, s) => {
|
|
47
48
|
var m;
|
|
48
|
-
const c = l(),
|
|
49
|
+
const c = l(), n = P(), r = Number(a);
|
|
49
50
|
let e;
|
|
50
51
|
if (s)
|
|
51
52
|
e = s;
|
|
@@ -53,25 +54,25 @@ const k = () => ({
|
|
|
53
54
|
const i = c.blockStates[r];
|
|
54
55
|
if (!i)
|
|
55
56
|
return "";
|
|
56
|
-
const { recommendationConfigs:
|
|
57
|
+
const { recommendationConfigs: o } = i;
|
|
57
58
|
e = {
|
|
58
|
-
strategy:
|
|
59
|
-
language:
|
|
60
|
-
currencyCode:
|
|
61
|
-
size:
|
|
62
|
-
productIds:
|
|
63
|
-
filters:
|
|
64
|
-
shuffleProducts:
|
|
59
|
+
strategy: o.strategy,
|
|
60
|
+
language: o.language,
|
|
61
|
+
currencyCode: o.currencySettings.value,
|
|
62
|
+
size: o.size,
|
|
63
|
+
productIds: o.productIds,
|
|
64
|
+
filters: o.filters,
|
|
65
|
+
shuffleProducts: o.shuffleProducts
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
68
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName",
|
|
69
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
69
70
|
const g = e.filters.filter((i) => i.isValid), d = h(g);
|
|
70
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(
|
|
71
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
|
|
71
72
|
const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
72
73
|
return c.recommendationCampaignUrls[a] = u, u;
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
export {
|
|
76
|
-
|
|
77
|
+
B as useRecommendation
|
|
77
78
|
};
|
|
@@ -1,43 +1,19 @@
|
|
|
1
|
-
const e = "Items", o = "Default",
|
|
1
|
+
const e = "Items", o = "Default", t = "Custom", s = {
|
|
2
2
|
"Global Styles & Layout": "Global Styles and Layout",
|
|
3
3
|
"Structures & Modules": "Structures and Modules",
|
|
4
4
|
"Recommendation Block": "Recommendation",
|
|
5
5
|
Items: e,
|
|
6
6
|
"This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.": "This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.",
|
|
7
7
|
"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.": "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.",
|
|
8
|
-
"email-editor.a11y-hide-images": "Hide images",
|
|
9
|
-
"email-editor.a11y-show-images": "Show images",
|
|
10
|
-
"email-editor.cvd-none": "No Color Deficiency",
|
|
11
|
-
"email-editor.cvd-protanopia": "Protanopia",
|
|
12
|
-
"email-editor.cvd-protanopia-description": "Causes red-green confusion and makes reds appear darker.",
|
|
13
|
-
"email-editor.cvd-deuteranopia": "Deuteranopia",
|
|
14
|
-
"email-editor.cvd-deuteranopia-description": "Causes red-green confusion.",
|
|
15
|
-
"email-editor.cvd-tritanopia": "Tritanopia",
|
|
16
|
-
"email-editor.cvd-tritanopia-description": "Causes blue-yellow confusion.",
|
|
17
|
-
"email-editor.cvd-achromatopsia": "Achromatopsia",
|
|
18
|
-
"email-editor.cvd-achromatopsia-description": "Causes complete color blindness.",
|
|
19
|
-
"email-editor.more-actions": "More actions",
|
|
20
|
-
"email-editor.preferences": "Preferences",
|
|
21
|
-
"email-editor.actions": "Actions",
|
|
22
|
-
"email-editor.accessibility-test": "Accessibility Test",
|
|
23
|
-
"email-editor.autosaved-at-today": "Autosaved at {time}, Today",
|
|
24
|
-
"email-editor.autosaved-at-date": "Autosaved at {date}",
|
|
25
|
-
"email-editor.export-html": "Export HTML",
|
|
26
|
-
"email-editor.onboarding-kebab-title": "Discover Preferences and Actions",
|
|
27
|
-
"email-editor.onboarding-kebab-description": "You can now access your Preferences and Actions easily such as Autosave, Export HTML, Version History, Accessibility Test and Save As Template.",
|
|
28
|
-
"email-editor.onboarding-autosave-title": "Autosave Your Design",
|
|
29
|
-
"email-editor.onboarding-autosave-description": "You can save your design automatically by enabling Autosave without losing your work.",
|
|
30
|
-
"email-editor.onboarding-accessibility-title": "Test Accessibility of Your Design",
|
|
31
|
-
"email-editor.onboarding-accessibility-description": "You can test the accessibility of your design to see the Failed, Passed items and update the Failed ones accordingly.",
|
|
32
8
|
"Pixel Tracking Opt-in": "Pixel Tracking Opt-in",
|
|
33
9
|
"OPT-IN SELECTION": "OPT-IN SELECTION",
|
|
34
10
|
"UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS",
|
|
35
11
|
Default: o,
|
|
36
|
-
Custom:
|
|
12
|
+
Custom: t
|
|
37
13
|
};
|
|
38
14
|
export {
|
|
39
|
-
|
|
15
|
+
t as Custom,
|
|
40
16
|
o as Default,
|
|
41
17
|
e as Items,
|
|
42
|
-
|
|
18
|
+
s as default
|
|
43
19
|
};
|
|
@@ -381,7 +381,7 @@ class H {
|
|
|
381
381
|
* Supports all block types by detecting prefix and using appropriate type:
|
|
382
382
|
*
|
|
383
383
|
* Examples:
|
|
384
|
-
* - {{ins_apr_img_1}} → https://
|
|
384
|
+
* - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
|
|
385
385
|
* - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
|
|
386
386
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
387
|
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const e = 20,
|
|
1
|
+
const e = 20, t = 320, s = "vertical", m = {
|
|
2
2
|
CART_ABANDONMENT: {
|
|
3
|
-
ins_apr_img_1: "https://
|
|
4
|
-
ins_apr_img_2: "https://
|
|
5
|
-
ins_apr_img_3: "https://
|
|
6
|
-
ins_apr_img_4: "https://
|
|
3
|
+
ins_apr_img_1: "https://web-image.useinsider.com/email-assets/dummyImages/ins_apr_img_1.png",
|
|
4
|
+
ins_apr_img_2: "https://web-image.useinsider.com/email-assets/dummyImages/ins_apr_img_2.png",
|
|
5
|
+
ins_apr_img_3: "https://web-image.useinsider.com/email-assets/dummyImages/ins_apr_img_3.png",
|
|
6
|
+
ins_apr_img_4: "https://web-image.useinsider.com/email-assets/dummyImages/ins_apr_img_4.png"
|
|
7
7
|
},
|
|
8
8
|
BROWSE_ABANDONMENT: {
|
|
9
|
-
browsed_item_img_1: "https://
|
|
10
|
-
browsed_item_img_2: "https://
|
|
11
|
-
browsed_item_img_3: "https://
|
|
12
|
-
browsed_item_img_4: "https://
|
|
9
|
+
browsed_item_img_1: "https://web-image.useinsider.com/email-assets/dummyImages/browsed_item_img_1.jpg",
|
|
10
|
+
browsed_item_img_2: "https://web-image.useinsider.com/email-assets/dummyImages/browsed_item_img_2.jpg",
|
|
11
|
+
browsed_item_img_3: "https://web-image.useinsider.com/email-assets/dummyImages/browsed_item_img_3.jpg",
|
|
12
|
+
browsed_item_img_4: "https://web-image.useinsider.com/email-assets/dummyImages/browsed_item_img_4.jpg"
|
|
13
13
|
}
|
|
14
14
|
}, i = {
|
|
15
15
|
DISCOUNT: "discount",
|
|
@@ -23,7 +23,7 @@ const e = 20, s = 320, t = "vertical", m = {
|
|
|
23
23
|
},
|
|
24
24
|
ELSE: "{% else %}",
|
|
25
25
|
END_IF: "{% endif %}"
|
|
26
|
-
},
|
|
26
|
+
}, n = {
|
|
27
27
|
ID: /recommendation-id="(.*?)"/gi,
|
|
28
28
|
ATTRIBUTE_PARAGRAPH: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>[\S\s]*?<\/p>/gm,
|
|
29
29
|
ATTRIBUTE_PARAGRAPH_START_TAG: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>/gm,
|
|
@@ -31,9 +31,9 @@ const e = 20, s = 320, t = "vertical", m = {
|
|
|
31
31
|
CUSTOM_FIELD: /{{(?:reco_)?[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
|
|
32
32
|
CUSTOM_FIELD_INDEXES_PART: /{{(?:reco_)?[0-9]+_[0-8]_/gm,
|
|
33
33
|
CUSTOM_FIELD_NAME_PART: /_(discount|omnibus_discount|omnibus_price)}}/gm
|
|
34
|
-
}, n = {
|
|
35
|
-
PARAGRAPH_END_TAG: "</p>"
|
|
36
34
|
}, o = {
|
|
35
|
+
PARAGRAPH_END_TAG: "</p>"
|
|
36
|
+
}, a = {
|
|
37
37
|
REGULAR_NAME_HEIGHT: ".ext-product-name.ins-vertical p { height:90px!important;",
|
|
38
38
|
TRIMMED_NAME_HEIGHT: ".ext-product-name.ins-vertical p { height:18px!important;",
|
|
39
39
|
ELLIPSIS: "text-overflow:ellipsis!important; white-space:nowrap!important;",
|
|
@@ -47,11 +47,11 @@ const e = 20, s = 320, t = "vertical", m = {
|
|
|
47
47
|
export {
|
|
48
48
|
i as ATTRIBUTES,
|
|
49
49
|
_ as CONDITIONS,
|
|
50
|
-
|
|
50
|
+
a as CSS,
|
|
51
51
|
m as DUMMY_IMAGE_MAPPINGS,
|
|
52
52
|
e as DefaultPadding,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
o as HTML,
|
|
54
|
+
t as MinDeviceViewport,
|
|
55
|
+
n as REGEX,
|
|
56
|
+
s as VerticalOrientation
|
|
57
57
|
};
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var k = (l, a, t) => a in l ? D(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
|
|
3
|
+
var I = (l, a, t) => k(l, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { BlockId as N } from "../../../enums/block.js";
|
|
5
|
+
import { useOnboardingStore as T } from "../../../stores/onboarding.js";
|
|
6
|
+
import { getMigrationBannerHtml as _ } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as A, BlockCompositionType as M, ModificationDescription as m } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { currencyPositionFromLocation as O, ITEMS_CURRENCY_ATTR as d } from "./constants/currency.js";
|
|
9
|
+
import { ItemsBlockId as R } from "./enums/controlEnums.js";
|
|
10
|
+
import { SETTINGS_ENUMS as b, DefaultConfigValues as f } from "./enums/settingsEnums.js";
|
|
11
|
+
import { getDefaultTemplate as E } from "./template.js";
|
|
12
|
+
import { getItemsBlockContainer as h, getItemsBlockConfig as C, deriveItemNumber as H, getDefaultItemsBlockConfig as B } from "./utils/nodeConfigUtils.js";
|
|
13
|
+
const S = N.Items, P = "Reconcile Items currency DOM attributes";
|
|
14
|
+
class G extends A {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
18
|
+
I(this, "_currencyHealed", /* @__PURE__ */ new Set());
|
|
19
|
+
}
|
|
10
20
|
getId() {
|
|
11
|
-
return
|
|
21
|
+
return S;
|
|
12
22
|
}
|
|
13
23
|
getIcon() {
|
|
14
24
|
return "items-icon";
|
|
15
25
|
}
|
|
16
26
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
27
|
+
return M.CONTAINER;
|
|
18
28
|
}
|
|
19
29
|
getName() {
|
|
20
30
|
return this.api.translate("Items");
|
|
@@ -23,20 +33,20 @@ class E extends C {
|
|
|
23
33
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
34
|
}
|
|
25
35
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
27
|
-
|
|
36
|
+
return _(
|
|
37
|
+
S,
|
|
28
38
|
this.api.translate("Items"),
|
|
29
39
|
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
40
|
);
|
|
31
41
|
}
|
|
32
42
|
getTemplate() {
|
|
33
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
43
|
+
return E({
|
|
44
|
+
orientation: b.ORIENTATION.VERTICAL,
|
|
45
|
+
itemsType: b.ITEMS_TYPE.CART_ITEMS,
|
|
36
46
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
47
|
+
currencySymbol: f.productPriceCurrencySymbolControlValue,
|
|
48
|
+
currencyLocation: f.productPriceCurrencyLocationControlValue,
|
|
49
|
+
formattedPrice: f.productPriceFormattedControlValue === "1"
|
|
40
50
|
});
|
|
41
51
|
}
|
|
42
52
|
allowInnerBlocksDND() {
|
|
@@ -45,24 +55,27 @@ class E extends C {
|
|
|
45
55
|
canBeSavedAsModule() {
|
|
46
56
|
return !0;
|
|
47
57
|
}
|
|
48
|
-
onCreated(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
58
|
+
onCreated(t) {
|
|
59
|
+
const o = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
|
|
60
|
+
s.querySelector('[product-attr="imageSrc"] img') || o.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
61
|
+
const r = h(t);
|
|
62
|
+
if (!r)
|
|
53
63
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
|
|
64
|
+
const i = r.getNodeConfig(), c = i && Object.keys(i).length > 0, e = C(t);
|
|
65
|
+
if (e != null && e.initialized) {
|
|
66
|
+
if (!c) {
|
|
67
|
+
const u = this.api.getDocumentModifier();
|
|
68
|
+
u.modifyHtml(r).setNodeConfig(e), this._stampProductTdDomAttributes(r, e, u), u.apply(new m("Migrate legacy config to nodeConfig"));
|
|
69
|
+
return;
|
|
61
70
|
}
|
|
62
|
-
else {
|
|
63
|
-
const
|
|
64
|
-
|
|
71
|
+
} else {
|
|
72
|
+
const u = B(), g = this.api.getDocumentModifier();
|
|
73
|
+
g.modifyHtml(r).setNodeConfig(u), this._stampProductTdDomAttributes(r, u, g, !0), g.apply(new m("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
|
|
74
|
+
return;
|
|
65
75
|
}
|
|
76
|
+
const n = e.blockInstanceId || String(Date.now()), p = this.api.getDocumentModifier();
|
|
77
|
+
let y = !1;
|
|
78
|
+
e.blockInstanceId || (p.modifyHtml(r).setNodeConfig({ ...e, blockInstanceId: n }), y = !0), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(r, e, p) && (y = !0), y && p.apply(new m("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
|
|
66
79
|
}
|
|
67
80
|
/**
|
|
68
81
|
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
@@ -70,18 +83,24 @@ class E extends C {
|
|
|
70
83
|
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
71
84
|
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
72
85
|
*/
|
|
73
|
-
onDocumentChanged(
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
86
|
+
onDocumentChanged(t) {
|
|
87
|
+
const o = h(t);
|
|
88
|
+
if (!o)
|
|
76
89
|
return;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
90
|
+
const s = o.getNodeConfig();
|
|
91
|
+
if (s && Object.keys(s).length > 0) {
|
|
92
|
+
const e = C(t);
|
|
93
|
+
if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
|
|
94
|
+
const n = this.api.getDocumentModifier();
|
|
95
|
+
this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new m(P)), this._markCurrencyHealed(e.blockInstanceId);
|
|
96
|
+
}
|
|
79
97
|
return;
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
}
|
|
99
|
+
const i = C(t);
|
|
100
|
+
if (!(i != null && i.initialized))
|
|
82
101
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
102
|
+
const c = this.api.getDocumentModifier();
|
|
103
|
+
c.modifyHtml(o).setNodeConfig(i), this._stampProductTdDomAttributes(o, i, c), c.apply(new m("Recover Items block config from saved module"));
|
|
85
104
|
}
|
|
86
105
|
/**
|
|
87
106
|
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
@@ -91,14 +110,44 @@ class E extends C {
|
|
|
91
110
|
* restored before export. The name `<a>` carries no data-type/data-number of its own and
|
|
92
111
|
* relies on this td-level fallback in pairProductVariables.
|
|
93
112
|
*/
|
|
94
|
-
_stampProductTdDomAttributes(
|
|
95
|
-
const
|
|
96
|
-
|
|
113
|
+
_stampProductTdDomAttributes(t, o, s, r = !1) {
|
|
114
|
+
const i = H(o.itemsSelectValue, o.type), c = (e, n) => {
|
|
115
|
+
r && t.getAttribute(e) || s.modifyHtml(t).setAttribute(e, n);
|
|
97
116
|
};
|
|
98
|
-
|
|
117
|
+
c("data-type", o.type), c("data-number", i), c("data-nodup", String(o.priceHideDiscount));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Whether the currency self-heal should run for this block. Two guards (SD-147588):
|
|
121
|
+
* 1. Config is only authoritative when the symbol was actually customized — a symbol still at
|
|
122
|
+
* the 'USD' sentinel may be a migrator default, so we trust the DOM's real value over a
|
|
123
|
+
* defaulted config and never overwrite it.
|
|
124
|
+
* 2. Heal each instance at most once per session, so the auto-fix can't fight undo (undo
|
|
125
|
+
* re-drifts the attr, which would otherwise re-trigger the heal forever).
|
|
126
|
+
*/
|
|
127
|
+
_shouldReconcileCurrency(t) {
|
|
128
|
+
const o = (t.priceCurrencySymbol ?? "").trim();
|
|
129
|
+
return !o || o === f.productPriceCurrencySymbolControlValue ? !1 : !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
|
|
130
|
+
}
|
|
131
|
+
/** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
|
|
132
|
+
_markCurrencyHealed(t) {
|
|
133
|
+
t && this._currencyHealed.add(t);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
|
|
137
|
+
* attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
|
|
138
|
+
* Config is the source of truth — never derive from visible text. Callers gate this with
|
|
139
|
+
* `_shouldReconcileCurrency`. Returns true only when an attr actually changed, so the caller can
|
|
140
|
+
* skip an empty apply that would otherwise re-trigger onDocumentChanged and loop (SD-147588).
|
|
141
|
+
*/
|
|
142
|
+
_reconcileCurrencyDomAttributes(t, o, s) {
|
|
143
|
+
const r = O(o.priceCurrencyLocation), i = (o.priceCurrencySymbol ?? "").trim(), c = t.querySelectorAll(`.${R.PRICE} p`);
|
|
144
|
+
let e = !1;
|
|
145
|
+
return c.forEach((n) => {
|
|
146
|
+
n.getAttribute(d.POSITION) !== r && (s.modifyHtml(n).setAttribute(d.POSITION, r), e = !0), i && n.getAttribute(d.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(d.SYMBOL, i), e = !0);
|
|
147
|
+
}), e;
|
|
99
148
|
}
|
|
100
149
|
}
|
|
101
150
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
151
|
+
S as BLOCK_ID,
|
|
152
|
+
G as ItemsBlock
|
|
104
153
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { currencyLocationMaps as
|
|
2
|
-
import { UEAttr as
|
|
3
|
-
import { CommonControl as
|
|
1
|
+
import { currencyLocationMaps as p } from "../../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { CommonControl as L } from "../../../common-control.js";
|
|
4
|
+
import { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
|
|
4
5
|
import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
|
|
5
|
-
import { getItemsBlockConfig as
|
|
6
|
-
const
|
|
6
|
+
import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
|
|
7
|
+
const b = m.PRICE_CURRENCY_LOCATION, c = {
|
|
7
8
|
CURRENCY_LOCATION: "currencyLocation"
|
|
8
9
|
};
|
|
9
|
-
class
|
|
10
|
+
class Y extends L {
|
|
10
11
|
getId() {
|
|
11
|
-
return
|
|
12
|
+
return b;
|
|
12
13
|
}
|
|
13
14
|
getTemplate() {
|
|
14
15
|
return `
|
|
@@ -18,32 +19,32 @@ class A extends N {
|
|
|
18
19
|
`;
|
|
19
20
|
}
|
|
20
21
|
onRender() {
|
|
21
|
-
const e =
|
|
22
|
-
this.api.setUIEAttribute(c.CURRENCY_LOCATION,
|
|
22
|
+
const e = l(this.currentNode);
|
|
23
|
+
this.api.setUIEAttribute(c.CURRENCY_LOCATION, N.SELECTPICKER.items, p), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
|
|
23
24
|
this._onCurrencyLocationChange(t);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
onTemplateNodeUpdated(e) {
|
|
27
28
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
|
|
28
|
-
const t =
|
|
29
|
+
const t = l(this.currentNode);
|
|
29
30
|
this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
_onCurrencyLocationChange(e) {
|
|
33
|
-
if (console.debug("Currency location changed to: ", e),
|
|
34
|
+
if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
|
|
34
35
|
return;
|
|
35
36
|
const t = this._getPriceBlocks();
|
|
36
37
|
if (!t || t.length === 0)
|
|
37
38
|
return;
|
|
38
|
-
const r =
|
|
39
|
-
t.forEach((
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
39
|
+
const r = l(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = E(n), s = this.api.getDocumentModifier();
|
|
40
|
+
t.forEach((h) => {
|
|
41
|
+
const a = this._getParagraph(h);
|
|
42
|
+
if (!a)
|
|
42
43
|
return;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
`Updated currency location to ${
|
|
44
|
+
const d = a.getInnerHTML().trim() || "", C = a.getInnerText().trim() || "", u = (o == null ? void 0 : o.trim()) || "", _ = this._removeCurrencySymbol(C, u), g = this._detectSymbolInText(C) || u, R = this._buildPriceContent(_, g, n), y = d.replace(C, f(R));
|
|
45
|
+
s.modifyHtml(a).setInnerHtml(y).setAttribute(T.POSITION, i);
|
|
46
|
+
}), s.apply(new I(
|
|
47
|
+
`Updated currency location to ${i}`
|
|
47
48
|
));
|
|
48
49
|
}
|
|
49
50
|
_getPriceBlocks() {
|
|
@@ -65,8 +66,8 @@ class A extends N {
|
|
|
65
66
|
} else {
|
|
66
67
|
const o = r.match(/([^0-9.,\s]+)/);
|
|
67
68
|
if (o && o[1]) {
|
|
68
|
-
const i = o[1].trim(),
|
|
69
|
-
n = r.replace(
|
|
69
|
+
const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
|
|
70
|
+
n = r.replace(s, "").trim();
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
return n;
|
|
@@ -85,13 +86,13 @@ class A extends N {
|
|
|
85
86
|
this._GuSelect({
|
|
86
87
|
name: c.CURRENCY_LOCATION,
|
|
87
88
|
placeholder: "",
|
|
88
|
-
options:
|
|
89
|
+
options: p
|
|
89
90
|
})
|
|
90
91
|
])}
|
|
91
92
|
`;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
b as CONTROL_BLOCK_ID,
|
|
97
|
+
Y as PriceCurrencyLocationControl
|
|
97
98
|
};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
var R = Object.defineProperty;
|
|
2
2
|
var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
|
|
3
3
|
var h = (s, c, e) => N(s, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
-
import { ModificationDescription as
|
|
5
|
-
import { CommonControl as
|
|
4
|
+
import { ModificationDescription as E } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as B } from "../../../common-control.js";
|
|
6
|
+
import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
|
|
6
7
|
import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
|
|
7
|
-
import { getItemsBlockConfig as p, setItemsBlockConfig as
|
|
8
|
-
const
|
|
8
|
+
import { getItemsBlockConfig as p, setItemsBlockConfig as Y, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
|
|
9
|
+
const x = y.PRICE_CURRENCY_SYMBOL, u = {
|
|
9
10
|
CURRENCY_SYMBOL: "currencySymbol"
|
|
10
11
|
};
|
|
11
|
-
class
|
|
12
|
+
class $ extends B {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
14
15
|
h(this, "originalPriceContents", /* @__PURE__ */ new Map());
|
|
15
16
|
}
|
|
16
17
|
getId() {
|
|
17
|
-
return
|
|
18
|
+
return x;
|
|
18
19
|
}
|
|
19
20
|
getTemplate() {
|
|
20
21
|
return `
|
|
@@ -42,7 +43,7 @@ class P extends E {
|
|
|
42
43
|
var a;
|
|
43
44
|
console.debug("Currency symbol changed to: ", e);
|
|
44
45
|
const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
|
|
45
|
-
if (
|
|
46
|
+
if (Y(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
|
|
46
47
|
return;
|
|
47
48
|
const r = this._getPriceBlocks();
|
|
48
49
|
if (!r || r.length === 0)
|
|
@@ -53,8 +54,8 @@ class P extends E {
|
|
|
53
54
|
if (!m)
|
|
54
55
|
return;
|
|
55
56
|
const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
|
|
56
|
-
i.modifyHtml(m).setInnerHtml(b).setAttribute(
|
|
57
|
-
}), i.apply(new
|
|
57
|
+
i.modifyHtml(m).setInnerHtml(b).setAttribute(T.SYMBOL, n);
|
|
58
|
+
}), i.apply(new E(
|
|
58
59
|
`Updated currency symbol to ${n || "removed"}`
|
|
59
60
|
));
|
|
60
61
|
}
|
|
@@ -115,6 +116,6 @@ class P extends E {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
x as CONTROL_BLOCK_ID,
|
|
120
|
+
$ as PriceCurrencySymbolControl
|
|
120
121
|
};
|