@useinsider/guido 2.1.0-beta.bc18abc → 2.1.0-beta.e2d48fe

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 +140 -123
  2. package/dist/extensions/Blocks/Items/block.js +19 -28
  3. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  4. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  5. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  6. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  7. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -46
  8. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +45 -50
  9. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +40 -51
  10. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -35
  11. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  12. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -62
  13. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  14. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  15. package/dist/extensions/Blocks/Items/extension.js +8 -9
  16. package/dist/extensions/Blocks/Items/template.js +181 -175
  17. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  18. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
  19. package/dist/extensions/Blocks/common-control.js +91 -92
  20. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  21. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  22. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  23. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  24. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  25. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  26. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  27. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  28. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  29. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  30. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  31. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  32. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  33. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  34. package/package.json +1 -1
  35. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  36. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -1,93 +1,73 @@
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 = {
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 = {
11
7
  SINGLE_PRICE: "singlePrice"
12
8
  };
13
- class k extends u {
14
- constructor() {
15
- super(...arguments);
16
- d(this, "store", A());
17
- }
9
+ class M extends m {
18
10
  getId() {
19
- return D;
11
+ return h;
20
12
  }
21
13
  getTemplate() {
22
14
  return `
23
- <div class="container ${m.PRICE_SINGLE_PRICE}">
15
+ <div class="container ${T.PRICE_SINGLE_PRICE}">
24
16
  ${this._getSinglePrice()}
25
17
  </div>
26
18
  `;
27
19
  }
28
20
  onRender() {
29
- this.api.updateValues({ [l.SINGLE_PRICE]: this.store.singlePrice }), this.api.onValueChanged(l.SINGLE_PRICE, (e) => {
30
- this._onSinglePriceChange(e);
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);
31
24
  });
32
25
  }
33
26
  onTemplateNodeUpdated(e) {
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);
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
+ });
51
31
  }
52
32
  _onSinglePriceChange(e) {
53
- if (console.debug("Single price changed to: ", e), this.store.setSinglePrice(e), f(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
33
+ if (console.debug("Single price changed to: ", e), u(this.currentNode, this.api, { priceSinglePrice: e }), !this.currentNode)
54
34
  return;
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
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
58
38
  ] : [
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");
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
+ });
71
51
  }
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"));
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
+ });
77
57
  }
78
58
  _getSinglePrice() {
79
59
  return `
80
60
  <div class="display-flex align-items-center justify-content-between">
81
- <${g.LABEL}
82
- ${h.LABEL.text}="${this.api.translate("Show Single Product Price")}"
61
+ <${_.LABEL}
62
+ ${S.LABEL.text}="${this.api.translate("Show Single Product Price")}"
83
63
  >
84
- </${g.LABEL}>
64
+ </${_.LABEL}>
85
65
  ${this._GuToggle(l.SINGLE_PRICE)}
86
66
  </div>
87
67
  `;
88
68
  }
89
69
  }
90
70
  export {
91
- D as CONTROL_BLOCK_ID,
92
- k as PriceSinglePriceControl
71
+ h as CONTROL_BLOCK_ID,
72
+ M as PriceSinglePriceControl
93
73
  };