@useinsider/guido 2.0.0-beta.6ae94e5 → 2.0.0-beta.6b1a3c9

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.
Files changed (59) hide show
  1. package/dist/components/organisms/email-preview/amp/AmpToggle.vue.js +2 -2
  2. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
  3. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  4. package/dist/components/organisms/header/LeftSlot.vue.js +11 -11
  5. package/dist/components/organisms/header/LeftSlot.vue2.js +28 -23
  6. package/dist/config/migrator/index.js +9 -8
  7. package/dist/config/migrator/itemsBlockMigrator.js +342 -0
  8. package/dist/extensions/Blocks/Items/block.js +39 -40
  9. package/dist/extensions/Blocks/Items/controls/button/link.js +22 -29
  10. package/dist/extensions/Blocks/Items/controls/cardComposition.js +66 -46
  11. package/dist/extensions/Blocks/Items/controls/image/link.js +23 -30
  12. package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
  13. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +19 -17
  14. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +31 -29
  15. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +36 -36
  16. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +21 -19
  17. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +29 -27
  18. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +93 -0
  19. package/dist/extensions/Blocks/Items/controls/settingsControl.js +159 -144
  20. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  21. package/dist/extensions/Blocks/Items/enums/productEnums.js +43 -45
  22. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +4 -3
  23. package/dist/extensions/Blocks/Items/extension.js +7 -6
  24. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -49
  25. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -59
  26. package/dist/extensions/Blocks/Items/settingsPanel.js +27 -26
  27. package/dist/extensions/Blocks/Items/store/items-block.js +11 -7
  28. package/dist/extensions/Blocks/Items/template.js +366 -129
  29. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +184 -0
  30. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  31. package/dist/extensions/Blocks/common-control.js +30 -32
  32. package/dist/extensions/Blocks/controlFactories.js +55 -45
  33. package/dist/guido.css +1 -1
  34. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +364 -285
  35. package/dist/package.json.js +1 -1
  36. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
  37. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -2
  38. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +9 -0
  39. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -2
  40. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +18 -0
  42. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
  43. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  44. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +24 -26
  45. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
  46. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
  47. package/dist/src/extensions/Blocks/Items/template.d.ts +22 -1
  48. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +73 -0
  49. package/dist/src/extensions/Blocks/common-control.d.ts +10 -11
  50. package/dist/utils/pairProductVariables.js +61 -58
  51. package/package.json +3 -3
  52. package/dist/extensions/Blocks/Items/utils/configBlockUtils.js +0 -17
  53. package/dist/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.js +0 -28
  54. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +0 -76
  55. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +0 -46
  56. package/dist/src/extensions/Blocks/Items/utils/configBlockUtils.d.ts +0 -23
  57. package/dist/src/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.d.ts +0 -32
  58. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +0 -50
  59. package/dist/src/extensions/Blocks/Items/utils/updateAttributes.d.ts +0 -8
@@ -3,7 +3,7 @@ import o from "./AmpToggle.vue2.js";
3
3
  import n from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
4
  var s = function() {
5
5
  var r = this, t = r._self._c, e = r._self._setupProxy;
6
- return t("div", [t("div", { staticClass: "d-f a-i-c ml-3" }, [t(e.InSegments, { attrs: { id: "guido__amp-toggle", "segment-list": e.segmentList, selected: e.previewStore.emailFormat }, on: { click: e.handleFormatChange } }), e.previewStore.showAMPErrorButton ? t(e.InButtonV2, { staticClass: "ml-2 d-f a-i-c b-c-11 b-c-h-11 t-c-4 t-c-h-4 i-c-4 bor-w-1 bor-s-s bor-c-11 bor-r-2", attrs: { id: "guido__amp-error-button", "left-icon": "line-error-box", type: "danger", "label-text-status": !1 }, on: { click: function(l) {
6
+ return t("div", [t("div", { staticClass: "d-f a-i-c ml-3" }, [t(e.InSegments, { attrs: { id: "guido__amp-toggle", "segment-list": e.segmentList, selected: e.previewStore.emailFormat }, on: { click: e.handleFormatChange } }), e.previewStore.showAMPErrorButton ? t(e.InButtonV2, { staticClass: "ml-3 d-f a-i-c b-c-11 b-c-h-11 t-c-4 t-c-h-4 i-c-4 bor-w-1 bor-s-s bor-c-11 bor-r-2", attrs: { id: "guido__amp-error-button", "left-icon": "line-error-box", type: "danger", "label-text-status": !1 }, on: { click: function(l) {
7
7
  return e.previewStore.openErrorModal();
8
8
  } } }) : r._e()], 1)]);
9
9
  }, a = [], i = /* @__PURE__ */ n(
@@ -12,7 +12,7 @@ var s = function() {
12
12
  a,
13
13
  !1,
14
14
  null,
15
- "b5997368"
15
+ "5196584c"
16
16
  );
17
17
  const d = i.exports;
18
18
  export {
@@ -7,14 +7,14 @@ var s = function() {
7
7
  return [t(e.EmailHeaderInfo)];
8
8
  }, proxy: !0 }, { key: "headerRightSlot", fn: function() {
9
9
  return [t(e.EmailSizeIndicator)];
10
- }, proxy: !0 }]) }, [e.isContainerReady ? t("iframe", { staticClass: "email-iframe w-1 bor-w-0", style: { height: e.iframeHeight }, attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts", srcdoc: e.previewStore.previewHtml } }) : r._e()])], 1);
10
+ }, proxy: !0 }]) }, [e.isContainerReady ? t("iframe", { staticClass: "email-iframe w-1 bor-w-0", style: { height: e.iframeHeight }, attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts allow-popups-to-escape-sandbox", srcdoc: e.previewStore.previewHtml } }) : r._e()])], 1);
11
11
  }, i = [], n = /* @__PURE__ */ a(
12
12
  o,
13
13
  s,
14
14
  i,
15
15
  !1,
16
16
  null,
17
- "2dd60b0c"
17
+ "b37f3f6d"
18
18
  );
19
19
  const d = n.exports;
20
20
  export {
@@ -1,19 +1,19 @@
1
1
  import n from "./ContentView.vue2.js";
2
2
  import e from "../../../../_virtual/_plugin-vue2_normalizer.js";
3
- var c = function() {
3
+ var o = function() {
4
4
  var a = this, s = a._self._c, t = a._self._setupProxy;
5
5
  return s("div", { staticClass: "w-1 h-1 b-c-4 d-f f-d-c" }, [s("div", { staticClass: "d-f j-c-s-b a-i-c p-2 h-6-s" }, [s("div", { staticClass: "d-f a-i-c cur-p", on: { click: function(l) {
6
6
  return a.$emit("back-to-inbox");
7
- } } }, [s(t.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [a._v(a._s(t.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(t.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(t.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("iframe", { ref: "iframeRef", staticClass: "f-g-1 w-1 d-b b-c-4 bor-s-n", attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts", srcdoc: t.previewStore.previewHtml }, on: { load: t.onLoad } })]);
8
- }, i = [], o = /* @__PURE__ */ e(
7
+ } } }, [s(t.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [a._v(a._s(t.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(t.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(t.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("iframe", { ref: "iframeRef", staticClass: "f-g-1 w-1 d-b b-c-4 bor-s-n", attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts allow-popups-to-escape-sandbox", srcdoc: t.previewStore.previewHtml }, on: { load: t.onLoad } })]);
8
+ }, c = [], i = /* @__PURE__ */ e(
9
9
  n,
10
+ o,
10
11
  c,
11
- i,
12
12
  !1,
13
13
  null,
14
14
  null
15
15
  );
16
- const d = o.exports;
16
+ const d = i.exports;
17
17
  export {
18
18
  d as default
19
19
  };
@@ -1,18 +1,18 @@
1
- import s from "./LeftSlot.vue2.js";
1
+ import o from "./LeftSlot.vue2.js";
2
2
  /* empty css */
3
- import r from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var n = function() {
5
- var e = this, o = e._self._c, t = e._self._setupProxy;
6
- return o("div", { staticClass: "d-f a-i-c" }, [o(t.InButtonV2, { staticClass: "p-2", attrs: { id: "guido__back-button", "left-icon": "line-arrow-left", styling: "text", type: "secondary", "label-text": t.backButtonLabel }, on: { click: t.handleBackClick } }), t.editorStore.isVersionHistoryOpen ? o(t.RestoreButton, { staticClass: "ml-3" }) : e._e()], 1);
7
- }, a = [], i = /* @__PURE__ */ r(
8
- s,
3
+ import a from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var i = function() {
5
+ var e = this, s = e._self._c, t = e._self._setupProxy;
6
+ return s("div", { staticClass: "d-f a-i-c" }, [s(t.InButtonV2, { staticClass: "p-2", attrs: { id: "guido__back-button", "left-icon": "line-arrow-left", styling: "text", type: "secondary", "disabled-status": t.isBackButtonDisabled, "label-text": t.backButtonLabel, "skeleton-sizing": { width: 150, height: 26 }, "skeleton-status": t.editorStore.loadingStatus }, on: { click: t.handleBackClick } }), t.editorStore.isVersionHistoryOpen ? s(t.RestoreButton, { staticClass: "ml-3" }) : e._e()], 1);
7
+ }, n = [], r = /* @__PURE__ */ a(
8
+ o,
9
+ i,
9
10
  n,
10
- a,
11
11
  !1,
12
12
  null,
13
- "06e6f7a7"
13
+ "7f267190"
14
14
  );
15
- const p = i.exports;
15
+ const f = r.exports;
16
16
  export {
17
- p as default
17
+ f as default
18
18
  };
@@ -1,32 +1,37 @@
1
- import { defineComponent as u, computed as m } from "vue";
2
- import { useConfig as f } from "../../../composables/useConfig.js";
3
- import { useBack as p } from "../../../composables/useGuidoActions.js";
4
- import { usePreviewMode as l } from "../../../composables/usePreviewMode.js";
5
- import { useTranslations as d } from "../../../composables/useTranslations.js";
6
- import { useVersionHistoryApi as k } from "../../../composables/useVersionHistoryApi.js";
7
- import { useEditorStore as B } from "../../../stores/editor.js";
8
- import { InButtonV2 as b } from "@useinsider/design-system-vue";
9
- import _ from "./version-history/RestoreButton.vue.js";
10
- const h = /* @__PURE__ */ u({
1
+ import { defineComponent as l, computed as p, ref as d } from "vue";
2
+ import { useConfig as k } from "../../../composables/useConfig.js";
3
+ import { useBack as B } from "../../../composables/useGuidoActions.js";
4
+ import { usePreviewMode as b } from "../../../composables/usePreviewMode.js";
5
+ import { useTranslations as v } from "../../../composables/useTranslations.js";
6
+ import { useVersionHistoryApi as _ } from "../../../composables/useVersionHistoryApi.js";
7
+ import { useEditorStore as V } from "../../../stores/editor.js";
8
+ import { InButtonV2 as w } from "@useinsider/design-system-vue";
9
+ import y from "./version-history/RestoreButton.vue.js";
10
+ import { useDebounceFn as C } from "../../../node_modules/@vueuse/shared/index.js";
11
+ const F = /* @__PURE__ */ l({
11
12
  __name: "LeftSlot",
12
- setup(v) {
13
- const o = B(), r = p(), { closeVersionHistory: i } = k(), { closePreviewMode: n } = l(), e = d(), { config: t } = f(), c = m(() => {
14
- var s, a;
15
- return o.isVersionHistoryOpen || o.isPreviewModeOpen ? e("email-editor.back-to-editor") : (a = (s = t.value) == null ? void 0 : s.ui) != null && a.backButtonLabel ? t.value.ui.backButtonLabel : e("email-editor.back-to-design");
16
- });
17
- return { __sfc: !0, editorStore: o, handleBack: r, closeVersionHistory: i, closePreviewMode: n, trans: e, config: t, backButtonLabel: c, handleBackClick: () => {
18
- if (o.isVersionHistoryOpen) {
19
- i();
13
+ setup(H) {
14
+ const e = V(), i = B(), { closeVersionHistory: n } = _(), { closePreviewMode: s } = b(), o = v(), { config: t } = k(), f = p(() => {
15
+ var u, m;
16
+ return e.isVersionHistoryOpen || e.isPreviewModeOpen ? o("email-editor.back-to-editor") : (m = (u = t.value) == null ? void 0 : u.ui) != null && m.backButtonLabel ? t.value.ui.backButtonLabel : o("email-editor.back-to-design");
17
+ }), r = d(!1), c = () => {
18
+ if (e.isVersionHistoryOpen) {
19
+ n();
20
20
  return;
21
21
  }
22
- if (o.isPreviewModeOpen) {
23
- n();
22
+ if (e.isPreviewModeOpen) {
23
+ s();
24
24
  return;
25
25
  }
26
- r();
27
- }, InButtonV2: b, RestoreButton: _ };
26
+ i();
27
+ }, a = C(() => {
28
+ c(), r.value = !1;
29
+ }, 500);
30
+ return { __sfc: !0, editorStore: e, handleBack: i, closeVersionHistory: n, closePreviewMode: s, trans: o, config: t, backButtonLabel: f, isBackButtonDisabled: r, executeBackAction: c, debouncedBackAction: a, handleBackClick: () => {
31
+ r.value = !0, a();
32
+ }, InButtonV2: w, RestoreButton: y };
28
33
  }
29
34
  });
30
35
  export {
31
- h as default
36
+ F as default
32
37
  };
@@ -1,12 +1,13 @@
1
- import { migrateCheckbox as m } from "./checkboxMigrator.js";
1
+ import { migrateCheckbox as t } from "./checkboxMigrator.js";
2
2
  import { migrateCouponBlock as o } from "./couponBlockMigrator.js";
3
- import { migrateRadioButton as i } from "./radioButtonMigrator.js";
4
- import { migrateRecommendation as e } from "./recommendationMigrator.js";
5
- import { migrateUnsubscribe as a } from "./unsubscribeMigrator.js";
6
- const s = async (t) => {
7
- let r = t;
8
- return r = m(r), r = i(r), r = await a(r), r = o(r), r = e(r), r;
3
+ import { migrateItemsBlock as i } from "./itemsBlockMigrator.js";
4
+ import { migrateRadioButton as e } from "./radioButtonMigrator.js";
5
+ import { migrateRecommendation as a } from "./recommendationMigrator.js";
6
+ import { migrateUnsubscribe as g } from "./unsubscribeMigrator.js";
7
+ const u = async (r) => {
8
+ let m = r;
9
+ return m = t(m), m = e(m), m = await g(m), m = o(m), m = a(m), m = i(m), m;
9
10
  };
10
11
  export {
11
- s as migrate
12
+ u as migrate
12
13
  };
@@ -0,0 +1,342 @@
1
+ var L = Object.defineProperty;
2
+ var K = (r, t, o) => t in r ? L(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
3
+ var v = (r, t, o) => K(r, typeof t != "symbol" ? t + "" : t, o);
4
+ import { productPairs as B } from "../../extensions/Blocks/Items/enums/productEnums.js";
5
+ import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
+ import { getDefaultTemplate as U } from "../../extensions/Blocks/Items/template.js";
7
+ const q = {
8
+ img: {
9
+ pairsKey: "imageSrc",
10
+ defaultKey: "DEFAULT",
11
+ isArray: !0
12
+ },
13
+ name: {
14
+ pairsKey: "name",
15
+ defaultKey: "DEFAULT",
16
+ isArray: !0
17
+ },
18
+ url: {
19
+ pairsKey: "button",
20
+ defaultKey: "DEFAULT_HREF",
21
+ isArray: !1
22
+ },
23
+ formattedprice: {
24
+ pairsKey: "price",
25
+ defaultKey: "DEFAULT_PRICE_FORMATTED",
26
+ isArray: !1
27
+ },
28
+ productcurrency: {
29
+ pairsKey: "price",
30
+ defaultKey: "DEFAULT_CURRENCY",
31
+ isArray: !1
32
+ },
33
+ quantity: {
34
+ pairsKey: "quantity",
35
+ defaultKey: "DEFAULT",
36
+ isArray: !1
37
+ },
38
+ price: {
39
+ pairsKey: "price",
40
+ defaultKey: "DEFAULT_PRICE",
41
+ isArray: !1
42
+ },
43
+ originalprice: {
44
+ pairsKey: "originalPrice",
45
+ defaultKey: "DEFAULT_PRICE",
46
+ isArray: !1
47
+ },
48
+ originalformattedprice: {
49
+ pairsKey: "originalPrice",
50
+ defaultKey: "DEFAULT_PRICE_FORMATTED",
51
+ isArray: !1
52
+ },
53
+ single_price: {
54
+ pairsKey: "price",
55
+ defaultKey: "DEFAULT_SINGLE_PRICE",
56
+ isArray: !1
57
+ },
58
+ single_formattedprice: {
59
+ pairsKey: "price",
60
+ defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
61
+ isArray: !1
62
+ },
63
+ single_originalprice: {
64
+ pairsKey: "originalPrice",
65
+ defaultKey: "DEFAULT_SINGLE_PRICE",
66
+ isArray: !1
67
+ },
68
+ single_originalformattedprice: {
69
+ pairsKey: "originalPrice",
70
+ defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
71
+ isArray: !1
72
+ }
73
+ };
74
+ function w() {
75
+ return String(Date.now() + Math.floor(Math.random() * 1e3));
76
+ }
77
+ function F(r) {
78
+ return r ? {
79
+ CartItems: _.ITEMS_TYPE.CART_ITEMS,
80
+ BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
81
+ PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
82
+ CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
83
+ BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
84
+ PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
85
+ }[r] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
86
+ }
87
+ function R(r) {
88
+ const t = (e, a) => e == null ? a : e === "1" || e === "true", o = (e, a) => e || a, c = r["data-type"] || r["data-source"], n = F(c);
89
+ let i = r["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
90
+ if (i && !i.includes("{{") && /^\d+$/.test(i)) {
91
+ const e = parseInt(i) - 1, a = E[n];
92
+ a && a[e] && (i = a[e].value);
93
+ }
94
+ return {
95
+ initialized: !0,
96
+ blockInstanceId: o(r["data-block-instance-id"], w()),
97
+ source: n,
98
+ type: n,
99
+ itemsSelectValue: i,
100
+ orientation: r["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
101
+ nameTrimming: t(r["data-product_name_control_trim"], !0),
102
+ nameControlEnabled: t(r["data-product_name_control_enabled"], !0),
103
+ priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
104
+ priceFormatted: t(r["data-product_price_control_formated"], !0),
105
+ priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
106
+ priceCurrencySymbol: o(
107
+ r["data-product_price_currency_symbol"],
108
+ g.productPriceCurrencySymbolControlValue
109
+ ),
110
+ priceCurrencyLocation: o(
111
+ r["data-product_price_currency_location"],
112
+ g.productPriceCurrencyLocationControlValue
113
+ ),
114
+ priceControlOpened: t(r["data-product_price_control_opened"], !0),
115
+ priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
116
+ quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
117
+ buttonLink: o(r["data-product_button_link"], g.productButtonLinkControlValue),
118
+ imageLink: o(r["data-product_image_link"], g.productImageLinkControlValue),
119
+ buttonLabel: o(r["data-product_button_control_label"], "Buy"),
120
+ buttonFullWidth: t(r["data-product_button_control_atw"], !0),
121
+ imageVisible: t(r["data-product_image_control_enabled"], !0),
122
+ nameVisible: t(r["data-product_name_control_enabled"], !0),
123
+ quantityVisible: t(r["data-product_quantity_visible"], !0),
124
+ priceVisible: t(r["data-product_price_visible"], !0),
125
+ originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
126
+ buttonVisible: t(r["data-product_button_visible"], !0)
127
+ };
128
+ }
129
+ const x = {
130
+ ins_apr: "CART_ITEMS",
131
+ browsed_item: "BROWSED_ITEMS",
132
+ purchased_item: "PURCHASED_ITEMS"
133
+ };
134
+ class N {
135
+ constructor() {
136
+ v(this, "parser");
137
+ this.parser = new DOMParser();
138
+ }
139
+ migrate(t) {
140
+ try {
141
+ let o = this.removeJinjaConditionals(t);
142
+ o = this.replaceTemplateVariables(o);
143
+ const c = this.parser.parseFromString(o, "text/html"), n = c.querySelectorAll(
144
+ "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
145
+ );
146
+ return n.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), o) : (n.forEach((i) => {
147
+ const e = this.extractConfiguration(i), a = U({
148
+ orientation: e.orientation,
149
+ itemsType: e.itemsType,
150
+ itemId: e.itemId,
151
+ currencySymbol: e.currencySymbol,
152
+ currencyLocation: e.currencyLocation,
153
+ formattedPrice: e.formattedPrice,
154
+ configBlockAttributes: e.configBlockAttributes,
155
+ migrate: !0,
156
+ nameStyles: e.nameStyles,
157
+ buttonStyles: e.buttonStyles,
158
+ priceStyles: e.priceStyles,
159
+ originalPriceStyles: e.originalPriceStyles,
160
+ quantityStyles: e.quantityStyles,
161
+ nodeConfig: R(e.configBlockAttributes)
162
+ }), l = this.parser.parseFromString(
163
+ `<table><tbody><tr>${a}</tr></tbody></table>`,
164
+ "text/html"
165
+ ).querySelector("td");
166
+ if (l && i.parentNode) {
167
+ const f = R(e.configBlockAttributes);
168
+ l.setAttribute("esd-ext-config", JSON.stringify(f));
169
+ const u = l.querySelector("esd-config-block");
170
+ u && u.remove(), i.parentNode.replaceChild(l, i);
171
+ }
172
+ }), c.documentElement.outerHTML);
173
+ } catch (o) {
174
+ return console.error("ItemsBlockMigrator failed:", o), t;
175
+ }
176
+ }
177
+ /**
178
+ * Extracts configuration from legacy HTML block
179
+ * Parses data attributes and structure to determine:
180
+ * - orientation, itemsType, itemNumber, currency settings, esd-config-block attributes
181
+ * - UI styles from product elements (name, price, button, quantity, etc.)
182
+ */
183
+ extractConfiguration(t) {
184
+ var C, D, P;
185
+ const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", n = parseInt(c) - 1, i = E[o], e = ((P = i == null ? void 0 : i[n]) == null ? void 0 : P.value) || i[0].value, a = t.querySelector('[product-attr="price"]'), d = (a == null ? void 0 : a.getAttribute("data-currency_symbol")) || "USD", f = ((a == null ? void 0 : a.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (a == null ? void 0 : a.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, o), b = s["data-card_orientation_control_value"];
186
+ let S;
187
+ b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
188
+ const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, M = (a == null ? void 0 : a.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, I = t.querySelector('[product-attr="quantity"]'), k = (I == null ? void 0 : I.getAttribute("style")) || void 0;
189
+ return {
190
+ orientation: S,
191
+ itemsType: o,
192
+ itemId: e,
193
+ currencySymbol: d,
194
+ currencyLocation: f,
195
+ formattedPrice: u,
196
+ configBlockAttributes: s,
197
+ nameStyles: T,
198
+ buttonStyles: m,
199
+ priceStyles: M,
200
+ originalPriceStyles: h,
201
+ quantityStyles: k
202
+ };
203
+ }
204
+ /**
205
+ * Extracts all data-* attributes from the esd-config-block element
206
+ * Returns a key-value mapping of all configuration attributes
207
+ * @param block - The block element containing the esd-config-block
208
+ * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
209
+ */
210
+ extractConfigBlockAttributes(t, o) {
211
+ const c = t.querySelector("esd-config-block"), n = {};
212
+ if (!c)
213
+ return this.getDefaultConfigBlockAttributes();
214
+ if (Array.from(c.attributes).forEach((e) => {
215
+ e.name.startsWith("data-") && (n[e.name] = e.value);
216
+ }), n["data-cart_items_select_control_value"]) {
217
+ const e = n["data-cart_items_select_control_value"];
218
+ if (/^\d+$/.test(e)) {
219
+ const a = parseInt(e) - 1, d = E[o];
220
+ d && d[a] && (n["data-cart_items_select_control_value"] = d[a].value);
221
+ }
222
+ }
223
+ if (n["data-product_price_control_curency"]) {
224
+ const e = n["data-product_price_control_curency"];
225
+ let a = e;
226
+ e === "before" ? a = "0" : e === "after" && (a = "1"), n["data-product_price_control_curency"] = a, n["data-product_price_currency_location"] = a;
227
+ }
228
+ (!n["data-product_price_currency_symbol"] || n["data-product_price_currency_symbol"].trim() === "") && (n["data-product_price_currency_symbol"] = "USD");
229
+ const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
230
+ return i["data-type"] = o, i["data-source"] = o, i;
231
+ }
232
+ /**
233
+ * Returns default esd-config-block attributes based on the old template structure
234
+ * These serve as fallbacks when attributes are missing
235
+ */
236
+ getDefaultConfigBlockAttributes() {
237
+ return {
238
+ // Core settings
239
+ "data-type": "CART_ITEMS",
240
+ "data-card_orientation_control_value": "vertical",
241
+ // Image settings
242
+ "data-product_image_control_opened": "false",
243
+ "data-product_image_control_image-width": "70",
244
+ "data-product_image_control_image-height": "70",
245
+ "data-product_image_control_align_button": "true",
246
+ "data-product_image_control_padding_mobile": "true",
247
+ "data-product_image_link": "{{Abandoned Cart Item (1) Image}}",
248
+ "data-product_image_control_enabled": "1",
249
+ // Name settings
250
+ "data-product_name_control_opened": "false",
251
+ "data-product_name_control_enabled": "1",
252
+ "data-product_name_control_font_font_size": "20",
253
+ "data-product_name_control_trim": "1",
254
+ // Quantity settings
255
+ "data-product_quantity_control_opened": "true",
256
+ "data-product_quantity_control_enabled": "true",
257
+ "data-product_quantity_visible": "1",
258
+ // Price settings
259
+ "data-product_price_control_opened": "false",
260
+ "data-product_price_control_font_font_size": "20",
261
+ "data-product_price_control_color": "#060606",
262
+ "data-product_price_control_curency": "0",
263
+ "data-product_price_currency_location": "0",
264
+ "data-product_price_currency_symbol": "USD",
265
+ "data-product_price_control_formated": "1",
266
+ "data-product_price_control_nodup": "1",
267
+ "data-product_price_control_single_price": "false",
268
+ "data-product_price_visible": "1",
269
+ // Original price settings
270
+ "data-product_original_price_control_font_font_size": "19",
271
+ "data-product_original_price_control_align_align_desktop": "center",
272
+ "data-product_original_price_control_orientation": "horizontal",
273
+ "data-product_original_price_control_enabled": "true",
274
+ // Button settings
275
+ "data-product_button_control_opened": "true",
276
+ "data-product_button_control_label": "Buy",
277
+ "data-product_button_control_font_font_size": "17",
278
+ "data-product_button_control_color": "#ffffff",
279
+ "data-product_button_control_background": "#010101",
280
+ "data-product_button_control_atw": "true",
281
+ "data-product_button_link": "{{Abandoned Cart Item (1) Url}}",
282
+ "data-product_button_visible": "1"
283
+ };
284
+ }
285
+ /**
286
+ * Removes Jinja2 conditional statements from HTML
287
+ * Handles all items block types:
288
+ * - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
289
+ * - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
290
+ * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
291
+ */
292
+ removeJinjaConditionals(t) {
293
+ let o = t.replace(
294
+ /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
295
+ ""
296
+ );
297
+ return o = o.replace(
298
+ /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
299
+ ""
300
+ ), o = o.replace(/\{%\s*endif\s*%\}/g, ""), o = o.replace(/\n\s*\n\s*\n/g, `
301
+
302
+ `), o;
303
+ }
304
+ /**
305
+ * Replaces template variables with default values from productPairs
306
+ * Supports all block types by detecting prefix and using appropriate type:
307
+ *
308
+ * Examples:
309
+ * - {{ins_apr_img_1}} → https://s3.../img_1.jpeg (CART_ITEMS)
310
+ * - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
311
+ * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
312
+ */
313
+ replaceTemplateVariables(t) {
314
+ const { PAIRS_FOR_EXTENSION: o } = B;
315
+ return t.replace(/{{([^}]+)}}/g, (c, n) => {
316
+ const i = n.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
317
+ if (!i)
318
+ return c;
319
+ const [, e, a, d] = i, l = x[e];
320
+ if (!l)
321
+ return console.warn(`Unknown variable prefix: ${e}`), c;
322
+ const f = q[a];
323
+ if (!f)
324
+ return console.warn(`Unknown variable suffix mapping for: ${a}`), c;
325
+ const { pairsKey: u, defaultKey: s, isArray: b } = f, p = o[u][l];
326
+ if (!p)
327
+ return console.warn(`No data found for: ${u}.${l}`), c;
328
+ if (b) {
329
+ const y = parseInt(d) - 1, m = p[s];
330
+ return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${l}.${s}[${y}]`), c);
331
+ }
332
+ const T = p[s];
333
+ return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${l}.${s}`), c);
334
+ });
335
+ }
336
+ }
337
+ function Y(r) {
338
+ return new N().migrate(r);
339
+ }
340
+ export {
341
+ Y as migrateItemsBlock
342
+ };
@@ -1,20 +1,20 @@
1
- import { useOnboardingStore as y } from "../../../stores/onboarding.js";
2
- import { Block as R, BlockCompositionType as L, ModificationDescription as a } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- import { configAttributes as t } from "./enums/productEnums.js";
4
- import { DefaultConfigValues as e, SETTINGS_ENUMS as l } from "./enums/settingsEnums.js";
5
- import { useItemsBlockStore as S } from "./store/items-block.js";
6
- import { getDefaultTemplate as V } from "./template.js";
7
- import { syncCurrencySymbolFromAttributes as B, syncCurrencyLocationFromAttributes as U, syncFormattedPriceFromAttributes as k } from "./utils/syncAttributesFromConfigBlock.js";
8
- const M = "items-block";
9
- class x extends R {
1
+ import { useOnboardingStore as d } from "../../../stores/onboarding.js";
2
+ import { Block as u, BlockCompositionType as p, ModificationDescription as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { ItemsBlockId as f } from "./enums/controlEnums.js";
4
+ import { SETTINGS_ENUMS as c, DefaultConfigValues as o } from "./enums/settingsEnums.js";
5
+ import { useItemsBlockStore as g } from "./store/items-block.js";
6
+ import { getDefaultTemplate as y } from "./template.js";
7
+ import { getItemsBlockContainer as C, getItemsBlockConfig as a, getDefaultItemsBlockConfig as I } from "./utils/nodeConfigUtils.js";
8
+ const b = "items-block";
9
+ class O extends u {
10
10
  getId() {
11
- return M;
11
+ return b;
12
12
  }
13
13
  getIcon() {
14
14
  return "items-icon";
15
15
  }
16
16
  getBlockCompositionType() {
17
- return L.CONTAINER;
17
+ return p.CONTAINER;
18
18
  }
19
19
  getName() {
20
20
  return this.api.translate("Items");
@@ -23,45 +23,44 @@ class x extends R {
23
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
24
  }
25
25
  getTemplate() {
26
- return V({
27
- orientation: l.ORIENTATION.HORIZONTAL,
28
- itemsType: l.ITEMS_TYPE.CART_ITEMS,
26
+ return y({
27
+ orientation: c.ORIENTATION.VERTICAL,
28
+ itemsType: c.ITEMS_TYPE.CART_ITEMS,
29
29
  itemId: "{{Abandoned Cart Item (1) Url}}",
30
- currencySymbol: e.productPriceCurrencySymbolControlValue,
31
- currencyLocation: e.productPriceCurrencyLocationControlValue,
32
- formattedPrice: e.productPriceFormattedControlValue === "1"
30
+ currencySymbol: o.productPriceCurrencySymbolControlValue,
31
+ currencyLocation: o.productPriceCurrencyLocationControlValue,
32
+ formattedPrice: o.productPriceFormattedControlValue === "1"
33
33
  });
34
34
  }
35
35
  allowInnerBlocksDND() {
36
36
  return !1;
37
37
  }
38
- onCreated(r) {
39
- const n = r.querySelector("esd-config-block");
40
- if (!n)
38
+ onCreated(i) {
39
+ const e = C(i);
40
+ if (!e)
41
41
  return;
42
- const o = n, s = o.getAttribute("data-initialized") || "0", u = o.getAttribute(t.BLOCK_INSTANCE_ID), c = () => String(Date.now() + Math.floor(Math.random() * 1e3));
43
- if (Number(s)) {
44
- if (!u) {
45
- const i = c();
46
- this.api.getDocumentModifier().modifyHtml(o).setAttribute(t.BLOCK_INSTANCE_ID, i).apply(new a("Assign block instance ID to legacy block"));
47
- }
48
- } else {
49
- const i = e.itemsType, I = e.cartItemsSelectControlValue, d = e.cardOrientationControlValue, m = e.productNameTrimmingControlValue, C = e.productPriceHideDiscountControlValue, b = e.productPriceFormattedControlValue, T = e.productPriceCurrencySymbolControlValue, A = e.productPriceCurrencyLocationControlValue, E = e.productButtonLinkControlValue, O = e.productImageLinkControlValue, _ = e.productImageVisible, p = e.productNameVisible, N = e.productQuantityVisible, f = e.productPriceVisible, g = e.productOriginalPriceVisible, D = e.productButtonVisible, P = c();
50
- this.api.getDocumentModifier().modifyHtml(o).setAttribute("data-source", i).setAttribute(t.TYPE, i).setAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE, I).setAttribute(t.ORIENTATION, d).setAttribute(t.PRODUCT_NAME_TRIMMING, m).setAttribute(t.PRODUCT_PRICE_HIDE_DISCOUNT, C).setAttribute(t.PRODUCT_PRICE_FORMATTED, b).setAttribute(t.PRODUCT_PRICE_CURRENCY_SYMBOL, T).setAttribute(t.PRODUCT_PRICE_CURRENCY_LOCATION, A).setAttribute(t.PRODUCT_BUTTON_LINK, E).setAttribute(t.PRODUCT_IMAGE_LINK, O).setAttribute(t.BLOCK_INSTANCE_ID, P).setAttribute("data-initialized", "1").setAttribute(t.NAME_CONTROL_ENABLED, e.productNameControlEnabled).setAttribute(
51
- t.QUANTITY_CONTROL_ENABLED,
52
- e.productQuantityControlEnabled
53
- ).setAttribute(t.PRICE_CONTROL_OPENED, e.productPriceControlOpened).setAttribute(t.PRODUCT_IMAGE_VISIBLE, _).setAttribute(t.PRODUCT_NAME_VISIBLE, p).setAttribute(t.PRODUCT_QUANTITY_VISIBLE, N).setAttribute(t.PRODUCT_PRICE_VISIBLE, f).setAttribute(t.PRODUCT_ORIGINAL_PRICE_VISIBLE, g).setAttribute(t.PRODUCT_BUTTON_VISIBLE, D).apply(new a("Initialize config block attributes with defaults")), y().startOnboarding("itemsOnboarding");
42
+ const t = e.getNodeConfig(), l = t && Object.keys(t).length > 0, r = a(i);
43
+ if (r != null && r.initialized)
44
+ l ? r.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...r, blockInstanceId: String(Date.now()) }).apply(new n("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(r).apply(new n("Migrate legacy config to nodeConfig"));
45
+ else {
46
+ const m = I();
47
+ this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(m).apply(new n("Initialize Items block with default configuration")), d().startOnboarding("itemsOnboarding");
54
48
  }
49
+ const s = `[esd-extension-block-id="${f.IMAGE}"] img`;
50
+ this.api.getDocumentModifier().modifyHtml(i.querySelector(s)).setStyle("object-fit", "contain").apply(new n("Updated image object-fit"));
55
51
  }
56
- onSelect(r) {
57
- const n = r.querySelector("esd-config-block"), o = S();
58
- if (!n)
59
- return;
60
- const s = n, u = s.getAttribute(t.TYPE) || e.itemsType, c = s.getAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE) || e.cartItemsSelectControlValue, i = s.getAttribute(t.ORIENTATION) || e.cardOrientationControlValue;
61
- o.setItemsType(u), o.setItemIds(c), o.setOrientation(i), B(r), U(r), k(r);
52
+ onSelect(i) {
53
+ const e = g(), t = a(i);
54
+ t && (e.setItemsType(t.type || o.itemsType), e.setItemIds(t.itemsSelectValue || o.cartItemsSelectControlValue), e.setOrientation(t.orientation || o.cardOrientationControlValue), e.setCurrencySymbol(
55
+ t.priceCurrencySymbol || o.productPriceCurrencySymbolControlValue
56
+ ), e.setCurrencyLocation(
57
+ t.priceCurrencyLocation || o.productPriceCurrencyLocationControlValue
58
+ ), e.setFormattedPrice(
59
+ t.priceFormatted ?? o.productPriceFormattedControlValue === "1"
60
+ ));
62
61
  }
63
62
  }
64
63
  export {
65
- M as BLOCK_ID,
66
- x as ItemsBlock
64
+ b as BLOCK_ID,
65
+ O as ItemsBlock
67
66
  };