@useinsider/guido 2.1.0-beta.411f2a9 → 2.1.0-beta.425dfd0

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 (36) hide show
  1. package/dist/config/migrator/itemsBlockMigrator.js +123 -140
  2. package/dist/extensions/Blocks/Items/block.js +28 -19
  3. package/dist/extensions/Blocks/Items/controls/button/link.js +31 -19
  4. package/dist/extensions/Blocks/Items/controls/cardComposition.js +81 -97
  5. package/dist/extensions/Blocks/Items/controls/image/link.js +31 -19
  6. package/dist/extensions/Blocks/Items/controls/name/trimming.js +40 -28
  7. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +46 -34
  8. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +50 -45
  9. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +51 -40
  10. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +35 -23
  11. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +57 -45
  12. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +62 -42
  13. package/dist/extensions/Blocks/Items/controls/settingsControl.js +191 -184
  14. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -0
  15. package/dist/extensions/Blocks/Items/extension.js +9 -8
  16. package/dist/extensions/Blocks/Items/store/items-block.js +79 -0
  17. package/dist/extensions/Blocks/Items/template.js +175 -181
  18. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  19. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
  20. package/dist/extensions/Blocks/common-control.js +92 -91
  21. package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
  22. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +1 -0
  23. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
  24. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +1 -0
  25. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +1 -0
  26. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +1 -0
  27. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +1 -0
  28. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +1 -0
  30. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -0
  31. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +5 -0
  32. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +12 -10
  33. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +45 -0
  34. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -2
  35. package/dist/src/extensions/Blocks/common-control.d.ts +5 -4
  36. package/package.json +1 -1
@@ -1,73 +1,93 @@
1
- import { ModificationDescription as P, UIElementType as _, UEAttr as S } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as m } from "../../../common-control.js";
3
- import { ItemsBlockControlId as T, ItemsBlockId as g } from "../../enums/controlEnums.js";
4
- import { productPairs as R } from "../../enums/productEnums.js";
5
- import { getItemsBlockConfig as I, setItemsBlockConfig as u, escapeReplacement as A } from "../../utils/nodeConfigUtils.js";
6
- const h = T.PRICE_SINGLE_PRICE, l = {
1
+ var C = Object.defineProperty;
2
+ var R = (n, r, e) => r in n ? C(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
3
+ var d = (n, r, e) => R(n, typeof r != "symbol" ? r + "" : r, e);
4
+ import { ModificationDescription as _, UIElementType as g, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as u } from "../../../common-control.js";
6
+ import { ItemsBlockControlId as m, ItemsBlockId as N } from "../../enums/controlEnums.js";
7
+ import { productPairs as S } from "../../enums/productEnums.js";
8
+ import { useItemsBlockStore as A } from "../../store/items-block.js";
9
+ import { setItemsBlockConfig as f } from "../../utils/nodeConfigUtils.js";
10
+ const D = m.PRICE_SINGLE_PRICE, l = {
7
11
  SINGLE_PRICE: "singlePrice"
8
12
  };
9
- class M extends m {
13
+ class k extends u {
14
+ constructor() {
15
+ super(...arguments);
16
+ d(this, "store", A());
17
+ }
10
18
  getId() {
11
- return h;
19
+ return D;
12
20
  }
13
21
  getTemplate() {
14
22
  return `
15
- <div class="container ${T.PRICE_SINGLE_PRICE}">
23
+ <div class="container ${m.PRICE_SINGLE_PRICE}">
16
24
  ${this._getSinglePrice()}
17
25
  </div>
18
26
  `;
19
27
  }
20
28
  onRender() {
21
- const e = I(this.currentNode);
22
- this.api.updateValues({ [l.SINGLE_PRICE]: (e == null ? void 0 : e.priceSinglePrice) ?? !1 }), this.api.onValueChanged(l.SINGLE_PRICE, (t) => {
23
- this._onSinglePriceChange(t);
29
+ this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice }), this.api.onValueChanged(l.SINGLE_PRICE, (e) => {
30
+ this._onSinglePriceChange(e);
24
31
  });
25
32
  }
26
33
  onTemplateNodeUpdated(e) {
27
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
- const t = I(this.currentNode);
29
- this.api.updateValues({ [l.SINGLE_PRICE]: (t == null ? void 0 : t.priceSinglePrice) ?? !1 });
30
- });
34
+ super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
35
+ () => this._syncSinglePriceFromNodeConfig(),
36
+ () => {
37
+ this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice });
38
+ }
39
+ );
40
+ }
41
+ /**
42
+ * Syncs single price state from nodeConfig.
43
+ */
44
+ _syncSinglePriceFromNodeConfig() {
45
+ var i;
46
+ const e = (i = this.currentNode) == null ? void 0 : i.closest(".items-block");
47
+ if (!e)
48
+ return;
49
+ const o = e.getNodeConfig(), t = (o == null ? void 0 : o.priceSinglePrice) ?? !1;
50
+ this.store.setSinglePrice(t);
31
51
  }
32
52
  _onSinglePriceChange(e) {
33
- if (console.debug("Single price changed to: ", e), u(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
53
+ if (console.debug("Single price changed to: ", e), this.store.setSinglePrice(e), f(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
34
54
  return;
35
- const t = I(this.currentNode), n = (t == null ? void 0 : t.type) ?? "CART_ITEMS", r = (t == null ? void 0 : t.priceFormatted) ?? !1, i = R.PAIRS_FOR_EXTENSION.price[n], c = R.PAIRS_FOR_EXTENSION.originalPrice[n], [E, d] = e ? [
36
- r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
37
- r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
55
+ const { itemsType: o, formattedPrice: t } = this.store, i = S.PAIRS_FOR_EXTENSION.price[o], c = S.PAIRS_FOR_EXTENSION.originalPrice[o], [E, a] = e ? [
56
+ t ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE,
57
+ t ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE
38
58
  ] : [
39
- r ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
40
- r ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
41
- ], a = r ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, s = r ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, [L, C] = e ? [a, s] : [s, a], o = this.currentNode.closest(".items-block");
42
- ((o == null ? void 0 : o.querySelectorAll(
43
- `[esd-extension-block-id="${g.PRICE}"]`
44
- )) || []).forEach((p) => {
45
- this._updatePriceBlock(p, E, d, e, "price");
46
- }), ((o == null ? void 0 : o.querySelectorAll(
47
- `[esd-extension-block-id="${g.ORIGINAL_PRICE}"]`
48
- )) || []).forEach((p) => {
49
- this._updatePriceBlock(p, L, C, e, "original price");
50
- });
59
+ t ? i.DEFAULT_SINGLE_PRICE_FORMATTED : i.DEFAULT_SINGLE_PRICE,
60
+ t ? i.DEFAULT_PRICE_FORMATTED : i.DEFAULT_PRICE
61
+ ], P = t ? c.DEFAULT_PRICE_FORMATTED : c.DEFAULT_PRICE, s = t ? c.DEFAULT_SINGLE_PRICE_FORMATTED : c.DEFAULT_SINGLE_PRICE, [L, T] = e ? [P, s] : [s, P];
62
+ this._updatePriceBlock(
63
+ this.currentNode,
64
+ E,
65
+ a,
66
+ e,
67
+ "price"
68
+ );
69
+ const p = this.currentNode.closest(".items-block"), I = p == null ? void 0 : p.querySelector(`[esd-extension-block-id="${N.ORIGINAL_PRICE}"]`);
70
+ I && this._updatePriceBlock(I, L, T, e, "original price");
51
71
  }
52
- _updatePriceBlock(e, t, n, r, i) {
53
- const c = e.getInnerHTML().trim().replace(t, A(n)), E = `Updated ${i} to ${r ? "single" : "total"} price`;
54
- this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(c).apply(new P(E)), e.querySelectorAll('[product-attr="price"], [product-attr="originalPrice"]').forEach((s) => {
55
- this.api.getDocumentModifier().modifyHtml(s).setAttribute("data-single_price", r ? "true" : "false").apply(new P("Update single price attribute"));
56
- });
72
+ _updatePriceBlock(e, o, t, i, c) {
73
+ const E = e.getInnerHTML().replace(o, t), a = `Updated ${c} to ${i ? "single" : "total"} price`;
74
+ this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(E).apply(new _(a));
75
+ const s = e.querySelector('[product-attr="price"], [product-attr="originalPrice"]');
76
+ s && this.api.getDocumentModifier().modifyHtml(s).setAttribute("data-single_price", i ? "true" : "false").apply(new _("Update single price attribute"));
57
77
  }
58
78
  _getSinglePrice() {
59
79
  return `
60
80
  <div class="display-flex align-items-center justify-content-between">
61
- <${_.LABEL}
62
- ${S.LABEL.text}="${this.api.translate("Show Single Product Price")}"
81
+ <${g.LABEL}
82
+ ${h.LABEL.text}="${this.api.translate("Show Single Product Price")}"
63
83
  >
64
- </${_.LABEL}>
84
+ </${g.LABEL}>
65
85
  ${this._GuToggle(l.SINGLE_PRICE)}
66
86
  </div>
67
87
  `;
68
88
  }
69
89
  }
70
90
  export {
71
- h as CONTROL_BLOCK_ID,
72
- M as PriceSinglePriceControl
91
+ D as CONTROL_BLOCK_ID,
92
+ k as PriceSinglePriceControl
73
93
  };