@useinsider/guido 2.0.0-beta.b46bbf6 → 2.0.0-beta.b889d81

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 (35) hide show
  1. package/dist/composables/useStripo.js +37 -35
  2. package/dist/config/migrator/index.js +8 -9
  3. package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
  4. package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
  5. package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
  6. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
  7. package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
  8. package/dist/extensions/Blocks/Items/block.js +40 -39
  9. package/dist/extensions/Blocks/Items/controls/cardComposition.js +49 -46
  10. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +26 -28
  11. package/dist/extensions/Blocks/Items/controls/settingsControl.js +127 -132
  12. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
  13. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +48 -58
  14. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +58 -48
  15. package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
  16. package/dist/extensions/Blocks/Items/template.js +123 -296
  17. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +20 -11
  18. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  19. package/dist/extensions/Blocks/common-control.js +53 -64
  20. package/dist/extensions/Blocks/controlFactories.js +122 -111
  21. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +290 -364
  22. package/dist/package.json.js +7 -0
  23. package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
  24. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
  25. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
  26. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  27. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +4 -0
  28. package/dist/src/extensions/Blocks/Items/template.d.ts +1 -20
  29. package/dist/src/extensions/Blocks/common-control.d.ts +8 -13
  30. package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
  31. package/package.json +3 -3
  32. package/dist/config/migrator/itemsBlockMigrator.js +0 -283
  33. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +0 -172
  34. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +0 -6
  35. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -71
@@ -1,25 +1,26 @@
1
- import { useActionsApi as _ } from "./useActionsApi.js";
2
- import { useBlocksConfig as k } from "./useBlocksConfig.js";
3
- import { useConfig as B } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as V } from "./useCustomInterfaceAppearance.js";
5
- import { useStripoEventHandler as A } from "./useStripoEventHandler.js";
6
- import { useToaster as v } from "./useToaster.js";
1
+ import { useActionsApi as T } from "./useActionsApi.js";
2
+ import { useBlocksConfig as V } from "./useBlocksConfig.js";
3
+ import { useConfig as _ } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as B } from "./useCustomInterfaceAppearance.js";
5
+ import { useStripoEventHandler as v } from "./useStripoEventHandler.js";
6
+ import { useToaster as A } from "./useToaster.js";
7
7
  import { displayConditions as F } from "../enums/displayConditions.js";
8
8
  import { useStripoApi as D } from "../services/stripoApi.js";
9
9
  import I from "../static/styles/customEditorStyle.css.js";
10
10
  import { useEditorStore as M } from "../stores/editor.js";
11
11
  import { dynamicContentToMergeTags as U } from "../utils/genericUtil.js";
12
- const $ = (a) => {
13
- const { features: d } = B(), { handleError: c } = v(), { getToken: g, getCustomFonts: f } = D(), { handleEvent: y } = A(), { getStripoBlocksConfig: C } = k(), S = async (i, n = []) => {
14
- var p, m;
15
- const o = M(), { html: s, css: t, forceRecreate: h } = i, { baseBlocks: l, extensions: w } = await C(), u = ((p = d.value) == null ? void 0 : p.displayConditions) ?? !0, b = ((m = d.value) == null ? void 0 : m.modulesDisabled) ?? !1;
12
+ import P from "../package.json.js";
13
+ const K = (c) => {
14
+ const { features: l } = _(), { handleError: u } = A(), { getToken: y, getCustomFonts: S } = D(), { handleEvent: C } = v(), { getStripoBlocksConfig: E } = V(), h = async (i, n = []) => {
15
+ var g, f;
16
+ const o = M(), { html: r, css: p, forceRecreate: a } = i, { baseBlocks: t, extensions: d } = await E(), m = ((g = l.value) == null ? void 0 : g.displayConditions) ?? !0, b = ((f = l.value) == null ? void 0 : f.modulesDisabled) ?? !1;
16
17
  window.UIEditor.initEditor(
17
18
  document.querySelector("#guido-editor"),
18
19
  {
19
- metadata: a,
20
- html: s,
21
- css: t,
22
- forceRecreate: h,
20
+ metadata: c,
21
+ html: r,
22
+ css: p,
23
+ forceRecreate: a,
23
24
  locale: "en",
24
25
  undoButtonSelector: "#guido__undo-button",
25
26
  redoButtonSelector: "#guido__redo-button",
@@ -30,8 +31,8 @@ const $ = (a) => {
30
31
  customAppearanceMergetagsBorderColor: "#f1f3fe",
31
32
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
32
33
  customViewStyles: I,
33
- conditionsEnabled: u,
34
- customConditionsEnabled: u,
34
+ conditionsEnabled: m,
35
+ customConditionsEnabled: m,
35
36
  conditionCategories: F,
36
37
  enableXSSSecurity: !0,
37
38
  modulesDisabled: b,
@@ -41,7 +42,7 @@ const $ = (a) => {
41
42
  displayTitle: !1,
42
43
  displayUTM: !1,
43
44
  selectElementAfterDrop: !0,
44
- ...l ? { baseBlocks: l } : {},
45
+ ...t ? { baseBlocks: t } : {},
45
46
  editorFonts: {
46
47
  showDefaultStandardFonts: !0,
47
48
  showDefaultNotStandardFonts: !0,
@@ -49,25 +50,25 @@ const $ = (a) => {
49
50
  },
50
51
  mergeTags: [
51
52
  {
52
- entries: U(a.preselectedDynamicContentList)
53
+ entries: U(c.preselectedDynamicContentList)
53
54
  }
54
55
  ],
55
56
  async onTokenRefreshRequest(e) {
56
57
  try {
57
- const r = await g();
58
- e(r);
59
- } catch (r) {
60
- c(r, "Failed to refresh token");
58
+ const s = await y();
59
+ e(s);
60
+ } catch (s) {
61
+ u(s, "Failed to refresh token");
61
62
  }
62
63
  },
63
64
  onTemplateLoaded() {
64
65
  try {
65
- const { importCss: e } = V(), { activateCustomViewStyles: r, updateTimerInClonedTemplate: T } = _();
66
- e(), r(), T(), a.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
66
+ const { importCss: e } = B(), { activateCustomViewStyles: s, updateTimerInClonedTemplate: k } = T();
67
+ e(), s(), k(), c.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
67
68
  o.hasChanges = !1;
68
69
  }, 1e3);
69
70
  } catch (e) {
70
- c(e, "Failed to load custom interface appearance");
71
+ u(e, "Failed to load custom interface appearance");
71
72
  }
72
73
  },
73
74
  onCodeEditorVisibilityChanged(e) {
@@ -82,34 +83,35 @@ const $ = (a) => {
82
83
  onDataChanged() {
83
84
  o.hasChanges = !0;
84
85
  },
85
- onEvent: y,
86
+ onEvent: C,
86
87
  ignoreClickOutsideSelectors: [
87
88
  "#guido-dynamic-content-modal",
88
89
  ".in-on-board-wrapper",
89
90
  ".in-drawer__container"
90
91
  ],
91
- extensions: w
92
+ extensions: d
92
93
  }
93
94
  );
94
- }, E = (i) => new Promise((n, o) => {
95
+ }, w = (i) => new Promise((n, o) => {
96
+ var d;
95
97
  if (document.getElementById("UiEditorScript")) {
96
98
  i(), n();
97
99
  return;
98
100
  }
99
- const s = "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js", t = document.createElement("script");
100
- t.id = "UiEditorScript", t.type = "module", t.src = s, t.onload = () => {
101
+ const r = P.guido, a = `https://email-static.useinsider.com/guido/${(d = r == null ? void 0 : r.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
102
+ t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
101
103
  i(), n();
102
104
  }, t.onerror = () => {
103
- o(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
105
+ o(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
104
106
  }, document.body.appendChild(t);
105
107
  });
106
108
  return { initPlugin: async (i) => {
107
- await E(async () => {
108
- const n = await f();
109
- await S(i, n);
109
+ await w(async () => {
110
+ const n = await S();
111
+ await h(i, n);
110
112
  });
111
113
  } };
112
114
  };
113
115
  export {
114
- $ as useStripo
116
+ K as useStripo
115
117
  };
@@ -1,13 +1,12 @@
1
- import { migrateCheckbox as t } from "./checkboxMigrator.js";
1
+ import { migrateCheckbox as m } from "./checkboxMigrator.js";
2
2
  import { migrateCouponBlock as o } from "./couponBlockMigrator.js";
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;
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;
10
9
  };
11
10
  export {
12
- u as migrate
11
+ s as migrate
13
12
  };
@@ -0,0 +1,4 @@
1
+ var t = /* @__PURE__ */ ((c) => (c.TEXT_ALIGN = "coupon-block-text-align-control", c.TEXT_COLOR = "coupon-block-text-color-control", c.TEXT_SIZE = "coupon-block-text-size-control", c.TEXT_STYLE = "coupon-block-text-style-control", c.TEXT_FONT_FAMILY = "coupon-block-text-font-family-control", c.TEXT_BACKGROUND = "coupon-block-text-background-control", c.TEXT_PADDINGS = "coupon-block-text-paddings-control", c.TEXT_LINE_SPACING = "coupon-block-text-line-spacing-control", c))(t || {});
2
+ export {
3
+ t as CouponControlId
4
+ };
@@ -0,0 +1,29 @@
1
+ import { createTextAlignControl as t, createTextColorControl as e, createTextSizeControl as n, createTextStyleControl as r, createTextFontFamilyControl as T, createTextBackgroundColorControl as l, createPaddingsControl as C, createTextLineSpacingControl as c } from "../../controlFactories.js";
2
+ import { CouponControlId as o } from "../constants.js";
3
+ const i = t(
4
+ o.TEXT_ALIGN
5
+ ), E = e(
6
+ o.TEXT_COLOR
7
+ ), s = n(
8
+ o.TEXT_SIZE
9
+ ), S = r(
10
+ o.TEXT_STYLE
11
+ ), _ = T(
12
+ o.TEXT_FONT_FAMILY
13
+ ), g = l(
14
+ o.TEXT_BACKGROUND
15
+ ), X = C(
16
+ o.TEXT_PADDINGS
17
+ ), d = c(
18
+ o.TEXT_LINE_SPACING
19
+ );
20
+ export {
21
+ i as TextAlignControl,
22
+ g as TextBackgroundControl,
23
+ E as TextColorControl,
24
+ _ as TextFontFamilyControl,
25
+ d as TextLineSpacingControl,
26
+ X as TextPaddingsControl,
27
+ s as TextSizeControl,
28
+ S as TextStyleControl
29
+ };
@@ -1,8 +1,9 @@
1
1
  import { ExtensionBuilder as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { CouponBlock as t } from "./block.js";
3
- import { CouponIconsRegistry as i } from "./iconsRegistry.js";
4
- import { CouponBlockSettings as n } from "./settingsPanel.js";
5
- const p = new o().addBlock(t).withSettingsPanelRegistry(n).withIconsRegistry(i).build();
3
+ import { TextAlignControl as n, TextColorControl as r, TextSizeControl as l, TextStyleControl as d, TextFontFamilyControl as e, TextBackgroundControl as i, TextPaddingsControl as C, TextLineSpacingControl as a } from "./controls/index.js";
4
+ import { CouponIconsRegistry as s } from "./iconsRegistry.js";
5
+ import { CouponBlockSettings as m } from "./settingsPanel.js";
6
+ const u = new o().addBlock(t).withSettingsPanelRegistry(m).addControl(n).addControl(r).addControl(l).addControl(d).addControl(e).addControl(i).addControl(C).addControl(a).withIconsRegistry(s).build();
6
7
  export {
7
- p as default
8
+ u as default
8
9
  };
@@ -1,24 +1,30 @@
1
- import { SettingsPanelRegistry as T, SettingsPanelTab as o, SettingsTab as O, TextControls as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { COUPON_BLOCK_ID as N } from "./block.js";
3
- class _ extends T {
1
+ import { SettingsPanelRegistry as n, SettingsPanelTab as o, SettingsTab as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { COUPON_BLOCK_ID as E } from "./block.js";
3
+ import { CouponControlId as T } from "./constants.js";
4
+ class i extends n {
4
5
  registerBlockControls(e) {
5
- e[N] = [
6
+ e[E] = [
6
7
  new o(
7
- O.SETTINGS,
8
+ t.SETTINGS,
8
9
  [
9
- t.FONT_FAMILY,
10
- t.FONT_SIZE,
11
- t.FORMAT,
12
- t.FONT_COLOR,
13
- t.TEXT_BLOCK_BACKGROUND_COLOR,
14
- t.ALIGN,
15
- t.LINE_HEIGHT,
16
- t.INTERNAL_INDENTS
10
+ T.TEXT_STYLE,
11
+ T.TEXT_ALIGN,
12
+ T.TEXT_PADDINGS
13
+ ]
14
+ ),
15
+ new o(
16
+ t.STYLES,
17
+ [
18
+ T.TEXT_BACKGROUND,
19
+ T.TEXT_FONT_FAMILY,
20
+ T.TEXT_LINE_SPACING,
21
+ T.TEXT_SIZE,
22
+ T.TEXT_COLOR
17
23
  ]
18
24
  )
19
25
  ];
20
26
  }
21
27
  }
22
28
  export {
23
- _ as CouponBlockSettings
29
+ i as CouponBlockSettings
24
30
  };
@@ -1,18 +1,29 @@
1
- const o = `
2
- <td class="coupon-block ins-coupon-code esd-block-text coupon-block-v2">
3
- <p class="ins-title" contenteditable="false">{@COUPON_CODE}</p>
4
- </td>`, e = `
5
- <td
6
- class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block"
7
- esd-extension-block-id="coupon-block"
1
+ import { BlockType as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { COUPON_BLOCK_ID as e } from "./block.js";
3
+ const t = `
4
+ <${o.BLOCK_TEXT}
5
+ class="coupon-block ins-coupon-code coupon-block-v2 es-p10"
6
+ align="center"
7
+ esd-extension-block-id="${e}">
8
+ <p
9
+ path="1"
10
+ contenteditable="false"
11
+ style="font-size: 16px; color: #333333;">
12
+ <strong path="1,0">{@COUPON_CODE}</strong>
13
+ </p>
14
+ </${o.BLOCK_TEXT}>
15
+ `, l = `
16
+ <td
17
+ class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block"
18
+ esd-extension-block-id="${e}"
8
19
  >
9
20
  <p class="ins-title" contenteditable="false">{@COUPON_CODE}</p>
10
21
  </td>
11
22
  `;
12
- function t() {
13
- return o;
23
+ function s() {
24
+ return t;
14
25
  }
15
26
  export {
16
- e as default,
17
- t as getDefaultTemplate
27
+ l as default,
28
+ s as getDefaultTemplate
18
29
  };
@@ -1,20 +1,20 @@
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 {
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 {
10
10
  getId() {
11
- return b;
11
+ return M;
12
12
  }
13
13
  getIcon() {
14
14
  return "items-icon";
15
15
  }
16
16
  getBlockCompositionType() {
17
- return p.CONTAINER;
17
+ return L.CONTAINER;
18
18
  }
19
19
  getName() {
20
20
  return this.api.translate("Items");
@@ -23,44 +23,45 @@ class O extends u {
23
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
24
  }
25
25
  getTemplate() {
26
- return y({
27
- orientation: c.ORIENTATION.VERTICAL,
28
- itemsType: c.ITEMS_TYPE.CART_ITEMS,
26
+ return V({
27
+ orientation: l.ORIENTATION.HORIZONTAL,
28
+ itemsType: l.ITEMS_TYPE.CART_ITEMS,
29
29
  itemId: "{{Abandoned Cart Item (1) Url}}",
30
- currencySymbol: o.productPriceCurrencySymbolControlValue,
31
- currencyLocation: o.productPriceCurrencyLocationControlValue,
32
- formattedPrice: o.productPriceFormattedControlValue === "1"
30
+ currencySymbol: e.productPriceCurrencySymbolControlValue,
31
+ currencyLocation: e.productPriceCurrencyLocationControlValue,
32
+ formattedPrice: e.productPriceFormattedControlValue === "1"
33
33
  });
34
34
  }
35
35
  allowInnerBlocksDND() {
36
36
  return !1;
37
37
  }
38
- onCreated(i) {
39
- const e = C(i);
40
- if (!e)
38
+ onCreated(r) {
39
+ const n = r.querySelector("esd-config-block");
40
+ if (!n)
41
41
  return;
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 esd-config-block 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");
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");
48
54
  }
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"));
51
55
  }
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
- ));
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);
61
62
  }
62
63
  }
63
64
  export {
64
- b as BLOCK_ID,
65
- O as ItemsBlock
65
+ M as BLOCK_ID,
66
+ x as ItemsBlock
66
67
  };
@@ -1,13 +1,14 @@
1
- var P = Object.defineProperty;
2
- var _ = (a, n, t) => n in a ? P(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
- var d = (a, n, t) => _(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { ModificationDescription as r } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as u } from "../../common-control.js";
1
+ var c = Object.defineProperty;
2
+ var I = (a, n, t) => n in a ? c(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
+ var _ = (a, n, t) => I(a, typeof n != "symbol" ? n + "" : n, t);
4
+ import { ModificationDescription as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as R } from "../../common-control.js";
6
6
  import { ItemsBlockId as s } from "../enums/controlEnums.js";
7
- import { SETTINGS_ENUMS as R } from "../enums/settingsEnums.js";
7
+ import { configAttributes as C } from "../enums/productEnums.js";
8
+ import { SETTINGS_ENUMS as u } from "../enums/settingsEnums.js";
8
9
  import { useItemsBlockStore as O } from "../store/items-block.js";
9
- import { getItemsBlockConfig as C, setItemsBlockConfig as h } from "../utils/nodeConfigUtils.js";
10
- const I = "ui-elements-items-card-composition-block", i = {
10
+ import { getConfigBlock as P, attributeToBoolean as U } from "../utils/configBlockUtils.js";
11
+ const h = "ui-elements-items-card-composition-block", i = {
11
12
  PRODUCT_IMAGE: "image",
12
13
  PRODUCT_NAME: "name",
13
14
  PRODUCT_QUANTITY: "quantity",
@@ -15,11 +16,11 @@ const I = "ui-elements-items-card-composition-block", i = {
15
16
  PRODUCT_ORIGINAL_PRICE: "originalPrice",
16
17
  PRODUCT_BUTTON: "button"
17
18
  };
18
- class N extends u {
19
+ class g extends R {
19
20
  constructor() {
20
21
  super(...arguments);
21
- d(this, "store", O());
22
- d(this, "visibilityState", {
22
+ _(this, "store", O());
23
+ _(this, "visibilityState", {
23
24
  [i.PRODUCT_IMAGE]: !0,
24
25
  [i.PRODUCT_NAME]: !0,
25
26
  [i.PRODUCT_QUANTITY]: !0,
@@ -29,7 +30,7 @@ class N extends u {
29
30
  });
30
31
  }
31
32
  getId() {
32
- return I;
33
+ return h;
33
34
  }
34
35
  getTemplate() {
35
36
  return `
@@ -82,20 +83,20 @@ class N extends u {
82
83
  });
83
84
  }
84
85
  _syncVisibilityFromAttributes() {
85
- const t = C(this.currentNode);
86
+ const t = P(this.currentNode);
86
87
  if (!t)
87
88
  return;
88
89
  const e = {
89
- [i.PRODUCT_IMAGE]: "imageVisible",
90
- [i.PRODUCT_NAME]: "nameVisible",
91
- [i.PRODUCT_QUANTITY]: "quantityControlEnabled",
92
- [i.PRODUCT_PRICE]: "priceVisible",
93
- [i.PRODUCT_ORIGINAL_PRICE]: "originalPriceVisible",
94
- [i.PRODUCT_BUTTON]: "buttonVisible"
90
+ [i.PRODUCT_IMAGE]: "PRODUCT_IMAGE_VISIBLE",
91
+ [i.PRODUCT_NAME]: "PRODUCT_NAME_VISIBLE",
92
+ [i.PRODUCT_QUANTITY]: "PRODUCT_QUANTITY_VISIBLE",
93
+ [i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
94
+ [i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
95
+ [i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
95
96
  };
96
- Object.entries(e).forEach(([o, l]) => {
97
- const T = t[l];
98
- this.visibilityState[o] = T !== !1;
97
+ Object.entries(e).forEach(([o, r]) => {
98
+ const T = t.getAttribute(C[r]);
99
+ this.visibilityState[o] = U(T, !0);
99
100
  });
100
101
  }
101
102
  /**
@@ -104,10 +105,11 @@ class N extends u {
104
105
  * and mark it as '0'
105
106
  */
106
107
  _handleBrowsedItemsQuantity() {
107
- const t = this.store.itemsType !== R.ITEMS_TYPE.BROWSED_ITEMS, e = C(this.currentNode);
108
+ var r;
109
+ const t = this.store.itemsType !== u.ITEMS_TYPE.BROWSED_ITEMS, e = (r = this.currentNode) == null ? void 0 : r.querySelector("esd-config-block");
108
110
  if (!e)
109
111
  return;
110
- const o = e.quantityControlEnabled !== !1;
112
+ const o = e.getAttribute(C.PRODUCT_QUANTITY_VISIBLE) === "1";
111
113
  this.visibilityState[i.PRODUCT_QUANTITY] = t && o, this.api.setVisibility(`${i.PRODUCT_QUANTITY}Container`, t), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t && o);
112
114
  }
113
115
  _applyVisibilityStyles() {
@@ -120,26 +122,27 @@ class N extends u {
120
122
  [i.PRODUCT_BUTTON]: s.BUTTON
121
123
  };
122
124
  Object.entries(t).forEach(([e, o]) => {
123
- var c;
124
- const l = (c = this.currentNode) == null ? void 0 : c.querySelector(`[esd-extension-block-id="${o}"]`);
125
- if (!l)
125
+ var d;
126
+ const r = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${o}"]`);
127
+ if (!r)
126
128
  return;
127
129
  const T = this.visibilityState[e];
128
- this.api.getDocumentModifier().modifyHtml(l).setStyle("display", T ? "table-cell" : "none").apply(new r(`Applied ${e} visibility from attributes`));
130
+ this.api.getDocumentModifier().modifyHtml(r).setStyle("display", T ? "table-cell" : "none").apply(new l(`Applied ${e} visibility from attributes`));
129
131
  });
130
132
  }
131
133
  _updateVisibilityAttribute(t, e) {
132
- const l = {
133
- [i.PRODUCT_IMAGE]: "imageVisible",
134
- [i.PRODUCT_NAME]: "nameVisible",
135
- [i.PRODUCT_QUANTITY]: "quantityControlEnabled",
136
- [i.PRODUCT_PRICE]: "priceVisible",
137
- [i.PRODUCT_ORIGINAL_PRICE]: "originalPriceVisible",
138
- [i.PRODUCT_BUTTON]: "buttonVisible"
134
+ const o = P(this.currentNode);
135
+ if (!o)
136
+ return;
137
+ const T = {
138
+ [i.PRODUCT_IMAGE]: "PRODUCT_IMAGE_VISIBLE",
139
+ [i.PRODUCT_NAME]: "PRODUCT_NAME_VISIBLE",
140
+ [i.PRODUCT_QUANTITY]: "PRODUCT_QUANTITY_VISIBLE",
141
+ [i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
142
+ [i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
143
+ [i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
139
144
  }[t];
140
- l && h(this.currentNode, this.api, {
141
- [l]: e
142
- });
145
+ T && this.api.getDocumentModifier().modifyHtml(o).setAttribute(C[T], e ? "1" : "0").apply(new l(`Updated ${t} visibility attribute`));
143
146
  }
144
147
  _listenToFormUpdates() {
145
148
  this.api.onValueChanged(i.PRODUCT_IMAGE, (t) => this._onProductImageChange(t)), this.api.onValueChanged(i.PRODUCT_NAME, (t) => this._onProductNameChange(t)), this.api.onValueChanged(i.PRODUCT_QUANTITY, (t) => this._onProductQuantityChange(t)), this.api.onValueChanged(i.PRODUCT_PRICE, (t) => this._onProductPriceChange(t)), this.api.onValueChanged(
@@ -150,41 +153,41 @@ class N extends u {
150
153
  _onProductImageChange(t) {
151
154
  var o;
152
155
  const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.IMAGE}"]`);
153
- e && (this.visibilityState[i.PRODUCT_IMAGE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new r(`Product image visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_IMAGE, t));
156
+ e && (this.visibilityState[i.PRODUCT_IMAGE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product image visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_IMAGE, t));
154
157
  }
155
158
  _onProductNameChange(t) {
156
159
  var o;
157
160
  const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.NAME}"]`);
158
- e && (this.visibilityState[i.PRODUCT_NAME] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new r(`Product name visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_NAME, t));
161
+ e && (this.visibilityState[i.PRODUCT_NAME] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product name visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_NAME, t));
159
162
  }
160
163
  _onProductQuantityChange(t) {
161
164
  var o;
162
165
  const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.QUANTITY}"]`);
163
- e && (this.visibilityState[i.PRODUCT_QUANTITY] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new r(
166
+ e && (this.visibilityState[i.PRODUCT_QUANTITY] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
164
167
  `Product quantity visibility changed to ${t ? "visible" : "hidden"}`
165
168
  )), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t));
166
169
  }
167
170
  _onProductPriceChange(t) {
168
171
  var o;
169
172
  const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.PRICE}"]`);
170
- e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new r(`Product price visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_PRICE, t));
173
+ e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product price visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_PRICE, t));
171
174
  }
172
175
  _onProductOriginalPriceChange(t) {
173
176
  var o;
174
177
  const e = (o = this.currentNode) == null ? void 0 : o.querySelector(
175
178
  `[esd-extension-block-id="${s.ORIGINAL_PRICE}"]`
176
179
  );
177
- e && (this.visibilityState[i.PRODUCT_ORIGINAL_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new r(
180
+ e && (this.visibilityState[i.PRODUCT_ORIGINAL_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
178
181
  `Product original price visibility changed to ${t ? "visible" : "hidden"}`
179
182
  )), this._updateVisibilityAttribute(i.PRODUCT_ORIGINAL_PRICE, t));
180
183
  }
181
184
  _onProductButtonChange(t) {
182
185
  var o;
183
186
  const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.BUTTON}"]`);
184
- e && (this.visibilityState[i.PRODUCT_BUTTON] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new r(`Product button visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_BUTTON, t));
187
+ e && (this.visibilityState[i.PRODUCT_BUTTON] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product button visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_BUTTON, t));
185
188
  }
186
189
  }
187
190
  export {
188
- I as COMPOSITION_CONTROL_BLOCK_ID,
189
- N as ItemsBlockCardCompositionControl
191
+ h as COMPOSITION_CONTROL_BLOCK_ID,
192
+ g as ItemsBlockCardCompositionControl
190
193
  };