@useinsider/guido 3.23.0-beta.86bed27 → 3.23.0-beta.9f6bfbf

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 (88) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +17 -15
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +58 -56
  5. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
  6. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
  7. package/dist/composables/useModuleRepair.js +14 -12
  8. package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
  9. package/dist/config/migrator/index.js +16 -15
  10. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  11. package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
  12. package/dist/config/migrator/recommendation/extractors.js +100 -40
  13. package/dist/config/migrator/recommendation/htmlBuilder.js +285 -207
  14. package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
  15. package/dist/config/migrator/recommendation/themeMapper.js +53 -41
  16. package/dist/config/migrator/recommendationMigrator.js +68 -61
  17. package/dist/extensions/Blocks/Items/block.js +115 -77
  18. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  19. package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
  20. package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
  21. package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
  22. package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
  23. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +40 -30
  24. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +63 -53
  25. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +31 -31
  26. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
  27. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
  28. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -32
  29. package/dist/extensions/Blocks/Items/controls/priceFormat.js +145 -0
  30. package/dist/extensions/Blocks/Items/controls/settingsControl.js +160 -144
  31. package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
  32. package/dist/extensions/Blocks/Items/extension.js +9 -8
  33. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  34. package/dist/extensions/Blocks/Items/settingsPanel.js +34 -25
  35. package/dist/extensions/Blocks/Items/template.js +250 -212
  36. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  37. package/dist/extensions/Blocks/Recommendation/block.js +33 -24
  38. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
  39. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +27 -26
  40. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
  41. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +165 -175
  42. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  43. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
  44. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
  46. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
  47. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
  48. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
  49. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
  50. package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
  51. package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
  52. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +3 -2
  53. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  54. package/dist/extensions/Blocks/common-control.js +62 -55
  55. package/dist/guido.css +1 -1
  56. package/dist/package.json.js +2 -2
  57. package/dist/src/@types/config/schemas.d.ts +4 -0
  58. package/dist/src/composables/useConfig.d.ts +2 -0
  59. package/dist/src/config/migrator/index.d.ts +4 -1
  60. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  61. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
  62. package/dist/src/config/migrator/recommendation/extractors.d.ts +35 -6
  63. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +3 -1
  64. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +3 -1
  65. package/dist/src/config/migrator/recommendation/types.d.ts +11 -1
  66. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  67. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  68. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
  69. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +23 -0
  70. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  71. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  72. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  73. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  74. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +61 -0
  75. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  76. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -10
  77. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
  78. package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
  79. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -19
  80. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  81. package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
  82. package/dist/src/stores/config.d.ts +20 -0
  83. package/dist/src/stores/unsubscribe.d.ts +10 -0
  84. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  85. package/dist/stores/unsubscribe.js +33 -29
  86. package/dist/utils/itemsCurrencyRepair.js +29 -24
  87. package/dist/utils/pairProductVariables.js +119 -99
  88. package/package.json +2 -2
@@ -1,75 +1,85 @@
1
- import { ModificationDescription as S, UIElementType as d, UEAttr as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as A } from "../../../common-control.js";
3
- import { ItemsBlockControlId as T, ItemsBlockId as p } from "../../enums/controlEnums.js";
4
- import { productPairs as R } from "../../enums/productEnums.js";
5
- import { getItemsBlockConfig as I, setItemsBlockConfig as N, escapeReplacement as h } from "../../utils/nodeConfigUtils.js";
6
- const u = T.PRICE_SINGLE_PRICE, l = {
1
+ import { ModificationDescription as S, UIElementType as _, UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as N } from "../../../common-control.js";
3
+ import { ItemsBlockControlId as L, ItemsBlockId as g } from "../../enums/controlEnums.js";
4
+ import { productPairs as T } from "../../enums/productEnums.js";
5
+ import { getItemsBlockConfig as a, setItemsBlockConfig as A, escapeReplacement as F } from "../../utils/nodeConfigUtils.js";
6
+ import { isNewPriceFormatBlock as u, applyPriceFormatChange as D } from "../priceFormat.js";
7
+ const f = L.PRICE_SINGLE_PRICE, P = {
7
8
  SINGLE_PRICE: "singlePrice"
8
9
  };
9
- class k extends A {
10
+ class x extends N {
10
11
  getId() {
11
- return u;
12
+ return f;
12
13
  }
13
14
  getTemplate() {
14
15
  return `
15
- <div class="container ${T.PRICE_SINGLE_PRICE}">
16
+ <div class="container ${L.PRICE_SINGLE_PRICE}">
16
17
  ${this._getSinglePrice()}
17
18
  </div>
18
19
  `;
19
20
  }
20
21
  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, (i) => {
23
- this._onSinglePriceChange(i);
22
+ this.forgetLastPanelNode(), this.api.onValueChanged(P.SINGLE_PRICE, (e) => {
23
+ this._onSinglePriceChange(e);
24
24
  });
25
25
  }
26
26
  onTemplateNodeUpdated(e) {
27
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
- const i = I(this.currentNode);
29
- this.api.updateValues({ [l.SINGLE_PRICE]: (i == null ? void 0 : i.priceSinglePrice) ?? !1 });
28
+ const i = a(this.currentNode);
29
+ this.api.updateValues({ [P.SINGLE_PRICE]: (i == null ? void 0 : i.priceSinglePrice) ?? !1 });
30
30
  });
31
31
  }
32
32
  _onSinglePriceChange(e) {
33
- if (console.debug("Single price changed to: ", e), !this.currentNode)
33
+ var I;
34
+ if (console.debug("Single price changed to: ", e), u(this.currentNode)) {
35
+ ((I = a(this.currentNode)) == null ? void 0 : I.priceSinglePrice) !== e && D(
36
+ this.currentNode,
37
+ this.api,
38
+ { priceSinglePrice: e },
39
+ `Updated price to ${e ? "single" : "total"} price`
40
+ );
34
41
  return;
35
- const i = I(this.currentNode), c = (i == null ? void 0 : i.type) ?? "CART_ITEMS", r = (i == null ? void 0 : i.priceFormatted) ?? !1, t = R.PAIRS_FOR_EXTENSION.price[c], n = R.PAIRS_FOR_EXTENSION.originalPrice[c], [E, g] = e ? [
42
+ }
43
+ if (!this.currentNode)
44
+ return;
45
+ const i = a(this.currentNode), c = (i == null ? void 0 : i.type) ?? "CART_ITEMS", r = (i == null ? void 0 : i.priceFormatted) ?? !1, t = T.PAIRS_FOR_EXTENSION.price[c], n = T.PAIRS_FOR_EXTENSION.originalPrice[c], [l, R] = e ? [
36
46
  r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE,
37
47
  r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE
38
48
  ] : [
39
49
  r ? t.DEFAULT_SINGLE_PRICE_FORMATTED : t.DEFAULT_SINGLE_PRICE,
40
50
  r ? t.DEFAULT_PRICE_FORMATTED : t.DEFAULT_PRICE
41
- ], P = r ? n.DEFAULT_PRICE_FORMATTED : n.DEFAULT_PRICE, _ = r ? n.DEFAULT_SINGLE_PRICE_FORMATTED : n.DEFAULT_SINGLE_PRICE, [L, C] = e ? [P, _] : [_, P], s = this.api.getDocumentModifier();
42
- N(this.currentNode, this.api, { priceSinglePrice: e }, s);
51
+ ], p = r ? n.DEFAULT_PRICE_FORMATTED : n.DEFAULT_PRICE, d = r ? n.DEFAULT_SINGLE_PRICE_FORMATTED : n.DEFAULT_SINGLE_PRICE, [C, m] = e ? [p, d] : [d, p], s = this.api.getDocumentModifier();
52
+ A(this.currentNode, this.api, { priceSinglePrice: e }, s);
43
53
  const o = this.currentNode.closest(".items-block");
44
54
  ((o == null ? void 0 : o.querySelectorAll(
45
- `[esd-extension-block-id="${p.PRICE}"]`
46
- )) || []).forEach((a) => {
47
- this._updatePriceBlock(s, a, E, g, e);
55
+ `[esd-extension-block-id="${g.PRICE}"]`
56
+ )) || []).forEach((E) => {
57
+ this._updatePriceBlock(s, E, l, R, e);
48
58
  }), ((o == null ? void 0 : o.querySelectorAll(
49
- `[esd-extension-block-id="${p.ORIGINAL_PRICE}"]`
50
- )) || []).forEach((a) => {
51
- this._updatePriceBlock(s, a, L, C, e);
59
+ `[esd-extension-block-id="${g.ORIGINAL_PRICE}"]`
60
+ )) || []).forEach((E) => {
61
+ this._updatePriceBlock(s, E, C, m, e);
52
62
  }), s.apply(new S(
53
63
  `Updated price to ${e ? "single" : "total"} price`
54
64
  ));
55
65
  }
56
66
  _updatePriceBlock(e, i, c, r, t) {
57
- const n = `data-single_price="${t ? "true" : "false"}"`, E = i.getInnerHTML().trim().replace(c, h(r)).replace(/data-single_price=(?:"[^"]*"|'[^']*')/g, n);
58
- e.modifyHtml(i).setInnerHtml(E);
67
+ const n = `data-single_price="${t ? "true" : "false"}"`, l = i.getInnerHTML().trim().replace(c, F(r)).replace(/data-single_price=(?:"[^"]*"|'[^']*')/g, n);
68
+ e.modifyHtml(i).setInnerHtml(l);
59
69
  }
60
70
  _getSinglePrice() {
61
71
  return `
62
72
  <div class="display-flex align-items-center justify-content-between">
63
- <${d.LABEL}
64
- ${m.LABEL.text}="${this.api.translate("Show Single Product Price")}"
73
+ <${_.LABEL}
74
+ ${h.LABEL.text}="${this.api.translate("Show Single Product Price")}"
65
75
  >
66
- </${d.LABEL}>
67
- ${this._GuToggle(l.SINGLE_PRICE)}
76
+ </${_.LABEL}>
77
+ ${this._GuToggle(P.SINGLE_PRICE)}
68
78
  </div>
69
79
  `;
70
80
  }
71
81
  }
72
82
  export {
73
- u as CONTROL_BLOCK_ID,
74
- k as PriceSinglePriceControl
83
+ f as CONTROL_BLOCK_ID,
84
+ x as PriceSinglePriceControl
75
85
  };
@@ -0,0 +1,145 @@
1
+ var f = Object.defineProperty;
2
+ var P = (o, i, t) => i in o ? f(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
+ var E = (o, i, t) => P(o, typeof i != "symbol" ? i + "" : i, t);
4
+ import { currencyOperators as m, currencyDecimalCounts as _ } from "../../../../enums/extensions/recommendationBlock.js";
5
+ import { UEAttr as d, ModificationDescription as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as N } from "../../common-control.js";
7
+ import { priceFormatFromConfig as T, normalizeDecimalCount as U, isNewPriceFormatRoot as M } from "../constants/currency.js";
8
+ import { ItemsBlockControlId as I, ItemsBlockId as R } from "../enums/controlEnums.js";
9
+ import { getItemsBlockConfig as h, getItemsBlockContainer as g, setItemsBlockConfig as F } from "../utils/nodeConfigUtils.js";
10
+ import { planPriceFormatOps as w, buildPriceFormatSnapshot as b, priceTextsFromConfig as x, samePriceText as y, replacePriceText as k } from "../utils/priceFormatOps.js";
11
+ const B = I.PRICE_FORMAT, a = {
12
+ THOUSAND_SEPARATOR: "priceThousandSeparator",
13
+ DECIMAL_SEPARATOR: "priceDecimalSeparator",
14
+ DECIMAL_COUNT: "priceDecimalCount"
15
+ }, H = [
16
+ ["price", R.PRICE],
17
+ ["originalPrice", R.ORIGINAL_PRICE]
18
+ ];
19
+ function V(o) {
20
+ return H.flatMap(([i, t]) => o.querySelectorAll(
21
+ `[esd-extension-block-id="${t}"]`
22
+ ).flatMap((r) => {
23
+ const c = r.querySelector("p");
24
+ return c ? [{ kind: i, paragraph: c }] : [];
25
+ }));
26
+ }
27
+ function Q(o) {
28
+ return M(g(o));
29
+ }
30
+ function K(o, i, t, e) {
31
+ const r = g(o);
32
+ if (!r)
33
+ return;
34
+ const c = { ...h(o), ...t }, C = V(r), p = w(b({
35
+ rootAttr: (n) => r.getAttribute(n),
36
+ config: c,
37
+ paragraphs: C.map(({ kind: n, paragraph: s }) => ({
38
+ kind: n,
39
+ attr: (u) => s.getAttribute(u),
40
+ text: s.getInnerText()
41
+ }))
42
+ }), { convertLegacy: !0 }), S = p.texts ?? x(c), l = i.getDocumentModifier();
43
+ F(o, i, { ...t, ...p.configPatch }, l);
44
+ const D = l.modifyHtml(r);
45
+ Object.entries(p.rootSet).forEach(([n, s]) => {
46
+ D.setAttribute(n, s);
47
+ }), C.forEach(({ kind: n, paragraph: s }) => {
48
+ const u = l.modifyHtml(s), A = s.getInnerText().trim();
49
+ p.paragraphRemove.forEach((O) => {
50
+ u.removeAttribute(O);
51
+ }), y(A, S[n]) || u.setInnerHtml(k(s.getInnerHTML(), A, S[n]));
52
+ }), l.apply(new L(e));
53
+ }
54
+ class X extends N {
55
+ constructor() {
56
+ super(...arguments);
57
+ // The format of the last write, until Stripo hands back the updated node: guards the echo
58
+ // of the select this control itself repaints on an auto-swap.
59
+ E(this, "lastWritten", null);
60
+ }
61
+ getId() {
62
+ return B;
63
+ }
64
+ getTemplate() {
65
+ return `
66
+ <div class="${I.PRICE_FORMAT}">
67
+ ${this._getSelectRow("Thousand Separator", a.THOUSAND_SEPARATOR, m)}
68
+ ${this._getSelectRow("Decimal Separator", a.DECIMAL_SEPARATOR, m)}
69
+ ${this._getSelectRow("Decimal Count", a.DECIMAL_COUNT, _)}
70
+ </div>
71
+ `;
72
+ }
73
+ onRender() {
74
+ this.forgetLastPanelNode(), this.api.setUIEAttribute(a.THOUSAND_SEPARATOR, d.SELECTPICKER.items, m), this.api.setUIEAttribute(a.DECIMAL_SEPARATOR, d.SELECTPICKER.items, m), this.api.setUIEAttribute(a.DECIMAL_COUNT, d.SELECTPICKER.items, _), this.api.onValueChanged(a.THOUSAND_SEPARATOR, (t) => {
75
+ this._onThousandSeparatorChange(t);
76
+ }), this.api.onValueChanged(a.DECIMAL_SEPARATOR, (t) => {
77
+ this._onDecimalSeparatorChange(t);
78
+ }), this.api.onValueChanged(a.DECIMAL_COUNT, (t) => {
79
+ this._onDecimalCountChange(t);
80
+ });
81
+ }
82
+ onTemplateNodeUpdated(t) {
83
+ super.onTemplateNodeUpdated(t), this.lastWritten = null, this.handleBlockInstanceChange(() => {
84
+ this.api.updateValues(this._formValues(T(h(this.currentNode))));
85
+ });
86
+ }
87
+ onDestroy() {
88
+ super.onDestroy(), this.lastWritten = null;
89
+ }
90
+ _onThousandSeparatorChange(t) {
91
+ const e = this._currentFormat();
92
+ if (t === e.thousandSeparator)
93
+ return;
94
+ const r = t === e.decimalSeparator;
95
+ this._write({
96
+ ...e,
97
+ thousandSeparator: t,
98
+ decimalSeparator: r ? e.thousandSeparator : e.decimalSeparator
99
+ }, "Updated price thousand separator"), r && this.api.updateValues({ [a.DECIMAL_SEPARATOR]: e.thousandSeparator });
100
+ }
101
+ _onDecimalSeparatorChange(t) {
102
+ const e = this._currentFormat();
103
+ if (t === e.decimalSeparator)
104
+ return;
105
+ const r = t === e.thousandSeparator;
106
+ this._write({
107
+ ...e,
108
+ decimalSeparator: t,
109
+ thousandSeparator: r ? e.decimalSeparator : e.thousandSeparator
110
+ }, "Updated price decimal separator"), r && this.api.updateValues({ [a.THOUSAND_SEPARATOR]: e.decimalSeparator });
111
+ }
112
+ _onDecimalCountChange(t) {
113
+ const e = this._currentFormat(), r = U(t);
114
+ r !== e.decimalCount && this._write({ ...e, decimalCount: r }, "Updated price decimal count");
115
+ }
116
+ _currentFormat() {
117
+ return this.lastWritten ?? T(h(this.currentNode));
118
+ }
119
+ _write(t, e) {
120
+ this.lastWritten = t, K(this.currentNode, this.api, {
121
+ priceThousandSeparator: t.thousandSeparator,
122
+ priceDecimalSeparator: t.decimalSeparator,
123
+ priceDecimalCount: t.decimalCount
124
+ }, e);
125
+ }
126
+ _formValues(t) {
127
+ return {
128
+ [a.THOUSAND_SEPARATOR]: t.thousandSeparator,
129
+ [a.DECIMAL_SEPARATOR]: t.decimalSeparator,
130
+ [a.DECIMAL_COUNT]: String(t.decimalCount)
131
+ };
132
+ }
133
+ _getSelectRow(t, e, r) {
134
+ return this._GuTwoColumns([
135
+ this._GuLabel({ text: this.api.translate(t) }),
136
+ this._GuSelect({ name: e, placeholder: "", options: r })
137
+ ], "no-separator");
138
+ }
139
+ }
140
+ export {
141
+ B as CONTROL_BLOCK_ID,
142
+ X as ItemsBlockPriceFormatControl,
143
+ K as applyPriceFormatChange,
144
+ Q as isNewPriceFormatBlock
145
+ };