@useinsider/guido 1.0.3-beta.2cf8046 → 1.0.3-beta.2df2106

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 (116) hide show
  1. package/README.md +3 -32
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/organisms/LoadingWrapper.vue.js +1 -1
  4. package/dist/components/organisms/header/RightSlot.vue2.js +13 -13
  5. package/dist/composables/useActionsApi.js +1 -1
  6. package/dist/composables/useHtmlCompiler.js +15 -13
  7. package/dist/composables/useHtmlValidator.js +36 -35
  8. package/dist/composables/useStripo.js +29 -25
  9. package/dist/config/compiler/itemsCompilerRules.js +14 -0
  10. package/dist/enums/unsubscribe.js +27 -26
  11. package/dist/extensions/Blocks/Checkbox/control.js +15 -14
  12. package/dist/extensions/Blocks/Checkbox/template.js +14 -9
  13. package/dist/extensions/Blocks/Items/block.js +26 -26
  14. package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
  15. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +92 -0
  16. package/dist/extensions/Blocks/Items/controls/settingsControl.js +150 -114
  17. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  18. package/dist/extensions/Blocks/Items/enums/productEnums.js +77 -4
  19. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +3 -2
  20. package/dist/extensions/Blocks/Items/extension.js +7 -6
  21. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +57 -56
  22. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +67 -56
  23. package/dist/extensions/Blocks/Items/settingsPanel.js +69 -43
  24. package/dist/extensions/Blocks/Items/store/items-block.js +8 -4
  25. package/dist/extensions/Blocks/Items/template.js +147 -62
  26. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +35 -26
  27. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +29 -27
  28. package/dist/extensions/Blocks/RadioButton/control.js +18 -17
  29. package/dist/extensions/Blocks/RadioButton/template.js +18 -9
  30. package/dist/extensions/Blocks/Unsubscribe/block.js +45 -41
  31. package/dist/guido.css +1 -1
  32. package/dist/node_modules/lodash-es/_DataView.js +6 -0
  33. package/dist/node_modules/lodash-es/_Promise.js +6 -0
  34. package/dist/node_modules/lodash-es/_Set.js +6 -0
  35. package/dist/node_modules/lodash-es/_SetCache.js +13 -0
  36. package/dist/node_modules/lodash-es/_WeakMap.js +6 -0
  37. package/dist/node_modules/lodash-es/_arrayFilter.js +10 -0
  38. package/dist/node_modules/lodash-es/_arrayLikeKeys.js +13 -12
  39. package/dist/node_modules/lodash-es/_arrayMap.js +8 -0
  40. package/dist/node_modules/lodash-es/_arrayPush.js +8 -0
  41. package/dist/node_modules/lodash-es/_arraySome.js +9 -0
  42. package/dist/node_modules/lodash-es/_baseEach.js +6 -0
  43. package/dist/node_modules/lodash-es/_baseFlatten.js +13 -0
  44. package/dist/node_modules/lodash-es/_baseForOwn.js +8 -0
  45. package/dist/node_modules/lodash-es/_baseGet.js +11 -0
  46. package/dist/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  47. package/dist/node_modules/lodash-es/_baseHasIn.js +6 -0
  48. package/dist/node_modules/lodash-es/_baseIsEqual.js +8 -0
  49. package/dist/node_modules/lodash-es/_baseIsEqualDeep.js +32 -0
  50. package/dist/node_modules/lodash-es/_baseIsMatch.js +29 -0
  51. package/dist/node_modules/lodash-es/_baseIteratee.js +11 -0
  52. package/dist/node_modules/lodash-es/_baseKeys.js +14 -0
  53. package/dist/node_modules/lodash-es/_baseMap.js +11 -0
  54. package/dist/node_modules/lodash-es/_baseMatches.js +12 -0
  55. package/dist/node_modules/lodash-es/_baseMatchesProperty.js +17 -0
  56. package/dist/node_modules/lodash-es/_baseProperty.js +8 -0
  57. package/dist/node_modules/lodash-es/_basePropertyDeep.js +9 -0
  58. package/dist/node_modules/lodash-es/_baseRange.js +9 -0
  59. package/dist/node_modules/lodash-es/_baseToString.js +18 -0
  60. package/dist/node_modules/lodash-es/_baseTrim.js +8 -0
  61. package/dist/node_modules/lodash-es/_cacheHas.js +6 -0
  62. package/dist/node_modules/lodash-es/_castPath.js +10 -0
  63. package/dist/node_modules/lodash-es/_createBaseEach.js +15 -0
  64. package/dist/node_modules/lodash-es/_createRange.js +11 -0
  65. package/dist/node_modules/lodash-es/_equalArrays.js +40 -0
  66. package/dist/node_modules/lodash-es/_equalByTag.js +45 -0
  67. package/dist/node_modules/lodash-es/_equalObjects.js +36 -0
  68. package/dist/node_modules/lodash-es/_getAllKeys.js +9 -0
  69. package/dist/node_modules/lodash-es/_getMatchData.js +12 -0
  70. package/dist/node_modules/lodash-es/_getSymbols.js +10 -0
  71. package/dist/node_modules/lodash-es/_getTag.js +28 -0
  72. package/dist/node_modules/lodash-es/_hasPath.js +19 -0
  73. package/dist/node_modules/lodash-es/_isFlattenable.js +10 -0
  74. package/dist/node_modules/lodash-es/_isKey.js +12 -0
  75. package/dist/node_modules/lodash-es/_isStrictComparable.js +7 -0
  76. package/dist/node_modules/lodash-es/_mapToArray.js +9 -0
  77. package/dist/node_modules/lodash-es/_matchesStrictComparable.js +8 -0
  78. package/dist/node_modules/lodash-es/_memoizeCapped.js +11 -0
  79. package/dist/node_modules/lodash-es/_nativeKeys.js +5 -0
  80. package/dist/node_modules/lodash-es/_setCacheAdd.js +7 -0
  81. package/dist/node_modules/lodash-es/_setCacheHas.js +6 -0
  82. package/dist/node_modules/lodash-es/_setToArray.js +9 -0
  83. package/dist/node_modules/lodash-es/_stringToPath.js +10 -0
  84. package/dist/node_modules/lodash-es/_toKey.js +10 -0
  85. package/dist/node_modules/lodash-es/_trimmedEndIndex.js +9 -0
  86. package/dist/node_modules/lodash-es/flatMap.js +8 -0
  87. package/dist/node_modules/lodash-es/get.js +8 -0
  88. package/dist/node_modules/lodash-es/hasIn.js +8 -0
  89. package/dist/node_modules/lodash-es/isSymbol.js +9 -0
  90. package/dist/node_modules/lodash-es/keys.js +9 -0
  91. package/dist/node_modules/lodash-es/keysIn.js +3 -3
  92. package/dist/node_modules/lodash-es/map.js +11 -0
  93. package/dist/node_modules/lodash-es/property.js +10 -0
  94. package/dist/node_modules/lodash-es/range.js +5 -0
  95. package/dist/node_modules/lodash-es/stubArray.js +6 -0
  96. package/dist/node_modules/lodash-es/toFinite.js +14 -0
  97. package/dist/node_modules/lodash-es/toNumber.js +22 -0
  98. package/dist/node_modules/lodash-es/toString.js +7 -0
  99. package/dist/src/config/compiler/itemsCompilerRules.d.ts +2 -0
  100. package/dist/src/extensions/Blocks/Checkbox/template.d.ts +1 -1
  101. package/dist/src/extensions/Blocks/Items/block.d.ts +14 -0
  102. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +15 -0
  103. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +8 -2
  104. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  105. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  106. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
  107. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
  108. package/dist/src/extensions/Blocks/Items/template.d.ts +9 -1
  109. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +6 -0
  110. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  111. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +3 -4
  112. package/dist/src/utils/environmentUtil.d.ts +5 -0
  113. package/dist/src/utils/pairProductVariables.d.ts +7 -0
  114. package/dist/utils/environmentUtil.js +4 -0
  115. package/dist/utils/pairProductVariables.js +136 -0
  116. package/package.json +5 -10
@@ -1,19 +1,20 @@
1
- import { useOnboardingStore as L } from "../../../stores/onboarding.js";
2
- import { Block as S, BlockCompositionType as y, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
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
3
  import { configAttributes as t } from "./enums/productEnums.js";
4
4
  import { DefaultConfigValues as e, SETTINGS_ENUMS as l } from "./enums/settingsEnums.js";
5
- import { useItemsBlockStore as I } from "./store/items-block.js";
5
+ import { useItemsBlockStore as S } from "./store/items-block.js";
6
6
  import { getDefaultTemplate as V } from "./template.js";
7
- const B = "items-block";
8
- class z extends S {
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 {
9
10
  getId() {
10
- return B;
11
+ return M;
11
12
  }
12
13
  getIcon() {
13
14
  return "items-icon";
14
15
  }
15
16
  getBlockCompositionType() {
16
- return y.CONTAINER;
17
+ return L.CONTAINER;
17
18
  }
18
19
  getName() {
19
20
  return this.api.translate("Items");
@@ -22,46 +23,45 @@ class z extends S {
22
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
23
24
  }
24
25
  getTemplate() {
25
- const i = I();
26
26
  return V({
27
27
  orientation: l.ORIENTATION.HORIZONTAL,
28
28
  itemsType: l.ITEMS_TYPE.CART_ITEMS,
29
29
  itemId: "{{Abandoned Cart Item (1) Url}}",
30
- currencySymbol: i.currencySymbol,
31
- currencyLocation: i.currencyLocation,
32
- formattedPrice: i.formattedPrice
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 n = i.querySelector("esd-config-block");
38
+ onCreated(r) {
39
+ const n = r.querySelector("esd-config-block");
40
40
  if (!n)
41
41
  return;
42
- const o = n, s = o.getAttribute("data-initialized") || "0", a = o.getAttribute(t.BLOCK_INSTANCE_ID), c = () => String(Date.now() + Math.floor(Math.random() * 1e3));
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
43
  if (Number(s)) {
44
- if (!a) {
45
- const r = c();
46
- this.api.getDocumentModifier().modifyHtml(o).setAttribute(t.BLOCK_INSTANCE_ID, r).apply(new u("Assign block instance ID to legacy block"));
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
47
  }
48
48
  } else {
49
- const r = e.itemsType, d = e.cartItemsSelectControlValue, m = e.cardOrientationControlValue, T = e.productNameTrimmingControlValue, C = e.productPriceHideDiscountControlValue, b = e.productPriceFormattedControlValue, E = e.productPriceCurrencySymbolControlValue, O = e.productPriceCurrencyLocationControlValue, A = e.productButtonLinkControlValue, _ = e.productImageLinkControlValue, N = e.productImageVisible, p = e.productNameVisible, f = e.productQuantityVisible, g = e.productPriceVisible, D = e.productOriginalPriceVisible, R = e.productButtonVisible, P = c();
50
- this.api.getDocumentModifier().modifyHtml(o).setAttribute("data-source", r).setAttribute(t.TYPE, r).setAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE, d).setAttribute(t.ORIENTATION, m).setAttribute(t.PRODUCT_NAME_TRIMMING, T).setAttribute(t.PRODUCT_PRICE_HIDE_DISCOUNT, C).setAttribute(t.PRODUCT_PRICE_FORMATTED, b).setAttribute(t.PRODUCT_PRICE_CURRENCY_SYMBOL, E).setAttribute(t.PRODUCT_PRICE_CURRENCY_LOCATION, O).setAttribute(t.PRODUCT_BUTTON_LINK, A).setAttribute(t.PRODUCT_IMAGE_LINK, _).setAttribute(t.BLOCK_INSTANCE_ID, P).setAttribute("data-initialized", "1").setAttribute(t.NAME_CONTROL_ENABLED, e.productNameControlEnabled).setAttribute(
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
51
  t.QUANTITY_CONTROL_ENABLED,
52
52
  e.productQuantityControlEnabled
53
- ).setAttribute(t.PRICE_CONTROL_OPENED, e.productPriceControlOpened).setAttribute(t.PRODUCT_IMAGE_VISIBLE, N).setAttribute(t.PRODUCT_NAME_VISIBLE, p).setAttribute(t.PRODUCT_QUANTITY_VISIBLE, f).setAttribute(t.PRODUCT_PRICE_VISIBLE, g).setAttribute(t.PRODUCT_ORIGINAL_PRICE_VISIBLE, D).setAttribute(t.PRODUCT_BUTTON_VISIBLE, R).apply(new u("Initialize config block attributes with defaults")), L().startOnboarding("itemsOnboarding");
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");
54
54
  }
55
55
  }
56
- onSelect(i) {
57
- const n = i.querySelector("esd-config-block"), o = I();
56
+ onSelect(r) {
57
+ const n = r.querySelector("esd-config-block"), o = S();
58
58
  if (!n)
59
59
  return;
60
- const s = n, a = s.getAttribute(t.TYPE) || e.itemsType, c = s.getAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE) || e.cartItemsSelectControlValue, r = s.getAttribute(t.ORIENTATION) || e.cardOrientationControlValue;
61
- o.setItemsType(a), o.setItemIds(c), o.setOrientation(r);
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);
62
62
  }
63
63
  }
64
64
  export {
65
- B as BLOCK_ID,
66
- z as ItemsBlock
65
+ M as BLOCK_ID,
66
+ x as ItemsBlock
67
67
  };
@@ -1,70 +1,70 @@
1
1
  var d = Object.defineProperty;
2
2
  var h = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var s = (i, t, e) => h(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { ModificationDescription as n, UIElementType as a, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ var n = (i, t, e) => h(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ModificationDescription as a, UIElementType as l, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as c } from "../../../common-control.js";
6
- import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
6
+ import { ItemsBlockControlId as p } from "../../enums/controlEnums.js";
7
7
  import { SETTINGS_ENUMS as I } from "../../enums/settingsEnums.js";
8
8
  import { useItemsBlockStore as N } from "../../store/items-block.js";
9
- import { syncNameTrimmingFromAttributes as y } from "../../utils/syncAttributesFromConfigBlock.js";
10
- import { updateConfigBlockAttributes as M } from "../../utils/updateAttributes.js";
11
- const f = l.NAME_TRIMMING, r = {
9
+ import { syncNameTrimmingFromAttributes as M } from "../../utils/syncAttributesFromConfigBlock.js";
10
+ import { updateConfigBlockAttributes as u } from "../../utils/updateAttributes.js";
11
+ const y = p.NAME_TRIMMING, o = {
12
12
  TRIMMING: "trimming"
13
13
  };
14
- class R extends c {
14
+ class _ extends c {
15
15
  constructor() {
16
16
  super(...arguments);
17
- s(this, "store", N());
17
+ n(this, "store", N());
18
18
  }
19
19
  getId() {
20
- return f;
20
+ return y;
21
21
  }
22
22
  getTemplate() {
23
23
  return `
24
- <div class="${l.NAME_TRIMMING}">
24
+ <div class="${p.NAME_TRIMMING}">
25
25
  ${this._getTextTrimming()}
26
26
  </div>
27
27
  `;
28
28
  }
29
29
  onRender() {
30
- this.api.updateValues({ [r.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(r.TRIMMING, (e) => {
30
+ this.api.updateValues({ [o.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(o.TRIMMING, (e) => {
31
31
  this._onTrimmingChange(e);
32
32
  });
33
33
  }
34
34
  onTemplateNodeUpdated(e) {
35
35
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
36
- () => y(this.currentNode),
36
+ () => M(this.currentNode),
37
37
  () => {
38
- this.api.updateValues({ [r.TRIMMING]: this.store.nameTrimming });
38
+ this.api.updateValues({ [o.TRIMMING]: this.store.nameTrimming });
39
39
  }
40
- ), this.store.nameTrimming && this._applyTrimmingStyles();
40
+ );
41
41
  }
42
42
  _onTrimmingChange(e) {
43
- this.store.setNameTrimming(e), M(this.currentNode, this.api), this.api.updateValues({ [r.TRIMMING]: e }), this._applyTrimmingStyles(e);
43
+ this.store.setNameTrimming(e), u(this.currentNode, this.api), this.api.updateValues({ [o.TRIMMING]: e }), this._applyTrimmingStyles(e);
44
44
  }
45
45
  _applyTrimmingStyles(e) {
46
- var m;
47
- const o = (m = this.currentNode) == null ? void 0 : m.querySelector("p");
48
- if (!o)
46
+ var s;
47
+ const r = (s = this.currentNode) == null ? void 0 : s.querySelector("p > a");
48
+ if (!r)
49
49
  return;
50
- const p = e !== void 0 ? e : this.store.nameTrimming, T = this.store.orientation === I.ORIENTATION.VERTICAL;
51
- p ? this.api.getDocumentModifier().modifyHtml(o).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", T ? "130px" : "100%").apply(new n("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(o).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").apply(new n("Text Trimming Disabled"));
50
+ const T = e !== void 0 ? e : this.store.nameTrimming, m = this.store.orientation === I.ORIENTATION.VERTICAL;
51
+ T ? this.api.getDocumentModifier().modifyHtml(r).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", m ? "130px" : "520px").apply(new a("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(r).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", m ? "130px" : "520px").apply(new a("Text Trimming Disabled"));
52
52
  }
53
53
  _getTextTrimming() {
54
54
  return `
55
55
  <div class="container">
56
56
  <div class="display-flex align-items-center justify-content-between">
57
- <${a.LABEL}
57
+ <${l.LABEL}
58
58
  ${g.LABEL.text}="${this.api.translate("Text Trimming")}"
59
59
  >
60
- </${a.LABEL}>
61
- ${this._GuToggle(r.TRIMMING)}
60
+ </${l.LABEL}>
61
+ ${this._GuToggle(o.TRIMMING)}
62
62
  </div>
63
63
  </div>
64
64
  `;
65
65
  }
66
66
  }
67
67
  export {
68
- f as CONTROL_BLOCK_ID,
69
- R as NameTrimmingControl
68
+ y as CONTROL_BLOCK_ID,
69
+ _ as NameTrimmingControl
70
70
  };
@@ -0,0 +1,92 @@
1
+ var I = Object.defineProperty;
2
+ var y = (n, o, t) => o in n ? I(n, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[o] = t;
3
+ var m = (n, o, t) => y(n, typeof o != "symbol" ? o + "" : o, t);
4
+ import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as E } from "../../../common-control.js";
6
+ import { ItemsBlockControlId as O } from "../../enums/controlEnums.js";
7
+ import { SETTINGS_ENUMS as N } from "../../enums/settingsEnums.js";
8
+ import { useItemsBlockStore as f } from "../../store/items-block.js";
9
+ import { syncPriceOrientationFromAttributes as T } from "../../utils/syncAttributesFromConfigBlock.js";
10
+ import { updateConfigBlockAttributes as P } from "../../utils/updateAttributes.js";
11
+ const _ = O.PRICE_ORIENTATION, p = {
12
+ PRICE_ORIENTATION: "priceOrientation"
13
+ }, C = [
14
+ { icon: "vertical-orientation", value: "vertical" },
15
+ { icon: "horizontal-orientation", value: "horizontal" }
16
+ ];
17
+ class v extends E {
18
+ constructor() {
19
+ super(...arguments);
20
+ m(this, "store", f());
21
+ }
22
+ getId() {
23
+ return _;
24
+ }
25
+ getTemplate() {
26
+ return `
27
+ <div class="${O.PRICE_ORIENTATION}">
28
+ ${this._getPriceOrientation()}
29
+ </div>
30
+ `;
31
+ }
32
+ onRender() {
33
+ this.api.updateValues({ [p.PRICE_ORIENTATION]: this.store.priceOrientation }), this.api.onValueChanged(p.PRICE_ORIENTATION, (t) => {
34
+ this._onPriceOrientationChange(t);
35
+ });
36
+ }
37
+ onTemplateNodeUpdated(t) {
38
+ super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
39
+ () => {
40
+ T(this.currentNode);
41
+ },
42
+ () => {
43
+ this.api.updateValues({ [p.PRICE_ORIENTATION]: this.store.priceOrientation });
44
+ }
45
+ );
46
+ }
47
+ _onPriceOrientationChange(t) {
48
+ if (console.debug("Price orientation changed to: ", t), this.store.setPriceOrientation(t), P(this.currentNode, this.api), !this.currentNode)
49
+ return;
50
+ const { orientation: i } = this.store, r = i === N.ORIENTATION.VERTICAL, e = t === "horizontal";
51
+ r ? this._updateVerticalLayout(e) : this._updateHorizontalLayout(e);
52
+ }
53
+ _updateHorizontalLayout(t) {
54
+ var c, l, d, a;
55
+ const i = ((l = (c = this.currentNode) == null ? void 0 : c.closest(".ins-product-td")) == null ? void 0 : l.querySelectorAll(".product-price-class")) || [], r = ((a = (d = this.currentNode) == null ? void 0 : d.closest(".ins-product-td")) == null ? void 0 : a.querySelectorAll(".product-original-price-class")) || [];
56
+ if (!i || !r)
57
+ return;
58
+ const e = t ? "50%" : "100%", s = this.api.getDocumentModifier();
59
+ i.forEach((u) => {
60
+ s.modifyHtml(u).setAttribute("width", e).setStyle("width", e);
61
+ }), r.forEach((u) => {
62
+ s.modifyHtml(u).setAttribute("width", e).setStyle("width", e);
63
+ }), s.apply(new h(`Updated original price element width to ${e}`));
64
+ }
65
+ _updateVerticalLayout(t) {
66
+ var s, c, l, d;
67
+ const i = ((c = (s = this.currentNode) == null ? void 0 : s.closest(".ins-product-td")) == null ? void 0 : c.querySelectorAll(".horizontal-price")) || [], r = (d = (l = this.currentNode) == null ? void 0 : l.closest(".ins-product-td")) == null ? void 0 : d.querySelector(".vertical-price");
68
+ if (!i || !r || i.length === 0)
69
+ return;
70
+ const e = this.api.getDocumentModifier();
71
+ t ? (i.forEach((a) => {
72
+ e.modifyHtml(a).setStyle("display", "table-cell");
73
+ }), e.modifyHtml(r).setStyle("display", "none").apply(new h("Hide vertical price element"))) : (i.forEach((a) => {
74
+ e.modifyHtml(a).setStyle("display", "none");
75
+ }), e.modifyHtml(r).setStyle("display", "table-cell").apply(new h("Show vertical price element")));
76
+ }
77
+ _getPriceOrientation() {
78
+ return `
79
+ ${this._GuTwoColumns([
80
+ this._GuLabel({ text: "Price Orientation" }),
81
+ this._GuRadioButton({
82
+ name: p.PRICE_ORIENTATION,
83
+ buttons: C
84
+ })
85
+ ])}
86
+ `;
87
+ }
88
+ }
89
+ export {
90
+ _ as CONTROL_BLOCK_ID,
91
+ v as PriceOrientationControl
92
+ };