@useinsider/guido 1.0.3-beta.cafee45 → 1.0.3-beta.cc614d6

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 (194) hide show
  1. package/README.md +0 -3
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +41 -44
  4. package/dist/components/organisms/header/RightSlot.vue.js +1 -1
  5. package/dist/components/organisms/header/RightSlot.vue2.js +22 -23
  6. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +18 -20
  7. package/dist/composables/useActionsApi.js +24 -33
  8. package/dist/composables/useBlocksConfig.js +2 -1
  9. package/dist/composables/useGuidoActions.js +9 -19
  10. package/dist/composables/useHtmlCompiler.js +13 -15
  11. package/dist/composables/useHtmlValidator.js +35 -36
  12. package/dist/composables/useStripo.js +55 -63
  13. package/dist/config/compiler/unsubscribeCompilerRules.js +28 -33
  14. package/dist/enums/defaults.js +1 -2
  15. package/dist/enums/extensions/recommendationBlock.js +2 -2
  16. package/dist/enums/onboarding.js +3 -7
  17. package/dist/enums/unsubscribe.js +25 -27
  18. package/dist/extensions/Blocks/Checkbox/block.js +2 -5
  19. package/dist/extensions/Blocks/Checkbox/control.js +14 -15
  20. package/dist/extensions/Blocks/Checkbox/template.js +9 -14
  21. package/dist/extensions/Blocks/RadioButton/block.js +2 -5
  22. package/dist/extensions/Blocks/RadioButton/control.js +17 -18
  23. package/dist/extensions/Blocks/RadioButton/template.js +9 -18
  24. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +43 -43
  25. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -1
  26. package/dist/extensions/Blocks/Unsubscribe/block.js +27 -27
  27. package/dist/extensions/Blocks/common-control.js +110 -174
  28. package/dist/guido.css +1 -1
  29. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +168 -213
  30. package/dist/node_modules/lodash-es/_arrayLikeKeys.js +12 -13
  31. package/dist/node_modules/lodash-es/keysIn.js +3 -3
  32. package/dist/package.json.js +1 -1
  33. package/dist/services/recommendationApi.js +19 -13
  34. package/dist/src/@types/generic.d.ts +0 -1
  35. package/dist/src/components/Guido.vue.d.ts +0 -1
  36. package/dist/src/composables/useActionsApi.d.ts +0 -1
  37. package/dist/src/composables/useGuidoActions.d.ts +0 -9
  38. package/dist/src/enums/onboarding.d.ts +0 -4
  39. package/dist/src/extensions/Blocks/Checkbox/block.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Checkbox/template.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/RadioButton/block.d.ts +0 -1
  42. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -1
  44. package/dist/src/extensions/Blocks/common-control.d.ts +7 -44
  45. package/dist/src/stores/config.d.ts +1 -2
  46. package/dist/src/stores/dynamic-content.d.ts +1 -1
  47. package/dist/src/stores/editor.d.ts +1 -1
  48. package/dist/src/stores/onboarding.d.ts +1 -335
  49. package/dist/src/stores/preview.d.ts +1 -1
  50. package/dist/src/stores/recommendation.d.ts +1 -1
  51. package/dist/src/stores/save-as-template.d.ts +1 -1
  52. package/dist/src/stores/toaster.d.ts +1 -1
  53. package/dist/src/stores/unsubscribe.d.ts +1 -1
  54. package/dist/src/stores/version-history.d.ts +1 -1
  55. package/dist/static/styles/customEditorStyle.css.js +1 -1
  56. package/dist/stores/config.js +5 -5
  57. package/dist/stores/dynamic-content.js +1 -1
  58. package/dist/stores/editor.js +1 -1
  59. package/dist/stores/onboarding.js +36 -44
  60. package/dist/stores/preview.js +1 -1
  61. package/dist/stores/recommendation.js +3 -3
  62. package/dist/stores/save-as-template.js +2 -2
  63. package/dist/stores/toaster.js +1 -1
  64. package/dist/stores/unsubscribe.js +1 -1
  65. package/dist/stores/version-history.js +4 -4
  66. package/dist/utils/genericUtil.js +17 -16
  67. package/package.json +4 -4
  68. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +0 -21
  69. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +0 -99
  70. package/dist/composables/useTimerClone.js +0 -67
  71. package/dist/config/compiler/itemsCompilerRules.js +0 -14
  72. package/dist/extensions/Blocks/Items/block.js +0 -67
  73. package/dist/extensions/Blocks/Items/controls/button/link.js +0 -68
  74. package/dist/extensions/Blocks/Items/controls/cardComposition.js +0 -193
  75. package/dist/extensions/Blocks/Items/controls/image/link.js +0 -68
  76. package/dist/extensions/Blocks/Items/controls/index.js +0 -217
  77. package/dist/extensions/Blocks/Items/controls/name/trimming.js +0 -70
  78. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +0 -107
  79. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +0 -123
  80. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +0 -76
  81. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +0 -61
  82. package/dist/extensions/Blocks/Items/controls/settingsControl.js +0 -312
  83. package/dist/extensions/Blocks/Items/enums/controlEnums.js +0 -5
  84. package/dist/extensions/Blocks/Items/enums/productEnums.js +0 -273
  85. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -76
  86. package/dist/extensions/Blocks/Items/extension.js +0 -19
  87. package/dist/extensions/Blocks/Items/iconsRegistry.js +0 -32
  88. package/dist/extensions/Blocks/Items/items.css.js +0 -23
  89. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +0 -62
  90. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +0 -60
  91. package/dist/extensions/Blocks/Items/settingsPanel.js +0 -131
  92. package/dist/extensions/Blocks/Items/store/items-block.js +0 -71
  93. package/dist/extensions/Blocks/Items/template.js +0 -189
  94. package/dist/extensions/Blocks/Items/utils/configBlockUtils.js +0 -17
  95. package/dist/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.js +0 -28
  96. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +0 -67
  97. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +0 -44
  98. package/dist/extensions/Blocks/controlFactories.js +0 -223
  99. package/dist/node_modules/lodash-es/_DataView.js +0 -6
  100. package/dist/node_modules/lodash-es/_Promise.js +0 -6
  101. package/dist/node_modules/lodash-es/_Set.js +0 -6
  102. package/dist/node_modules/lodash-es/_SetCache.js +0 -13
  103. package/dist/node_modules/lodash-es/_WeakMap.js +0 -6
  104. package/dist/node_modules/lodash-es/_arrayFilter.js +0 -10
  105. package/dist/node_modules/lodash-es/_arrayMap.js +0 -8
  106. package/dist/node_modules/lodash-es/_arrayPush.js +0 -8
  107. package/dist/node_modules/lodash-es/_arraySome.js +0 -9
  108. package/dist/node_modules/lodash-es/_baseEach.js +0 -6
  109. package/dist/node_modules/lodash-es/_baseFlatten.js +0 -13
  110. package/dist/node_modules/lodash-es/_baseForOwn.js +0 -8
  111. package/dist/node_modules/lodash-es/_baseGet.js +0 -11
  112. package/dist/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
  113. package/dist/node_modules/lodash-es/_baseHasIn.js +0 -6
  114. package/dist/node_modules/lodash-es/_baseIsEqual.js +0 -8
  115. package/dist/node_modules/lodash-es/_baseIsEqualDeep.js +0 -32
  116. package/dist/node_modules/lodash-es/_baseIsMatch.js +0 -29
  117. package/dist/node_modules/lodash-es/_baseIteratee.js +0 -11
  118. package/dist/node_modules/lodash-es/_baseKeys.js +0 -14
  119. package/dist/node_modules/lodash-es/_baseMap.js +0 -11
  120. package/dist/node_modules/lodash-es/_baseMatches.js +0 -12
  121. package/dist/node_modules/lodash-es/_baseMatchesProperty.js +0 -17
  122. package/dist/node_modules/lodash-es/_baseProperty.js +0 -8
  123. package/dist/node_modules/lodash-es/_basePropertyDeep.js +0 -9
  124. package/dist/node_modules/lodash-es/_baseRange.js +0 -9
  125. package/dist/node_modules/lodash-es/_baseToString.js +0 -18
  126. package/dist/node_modules/lodash-es/_baseTrim.js +0 -8
  127. package/dist/node_modules/lodash-es/_cacheHas.js +0 -6
  128. package/dist/node_modules/lodash-es/_castPath.js +0 -10
  129. package/dist/node_modules/lodash-es/_createBaseEach.js +0 -15
  130. package/dist/node_modules/lodash-es/_createRange.js +0 -11
  131. package/dist/node_modules/lodash-es/_equalArrays.js +0 -40
  132. package/dist/node_modules/lodash-es/_equalByTag.js +0 -45
  133. package/dist/node_modules/lodash-es/_equalObjects.js +0 -36
  134. package/dist/node_modules/lodash-es/_getAllKeys.js +0 -9
  135. package/dist/node_modules/lodash-es/_getMatchData.js +0 -12
  136. package/dist/node_modules/lodash-es/_getSymbols.js +0 -10
  137. package/dist/node_modules/lodash-es/_getTag.js +0 -28
  138. package/dist/node_modules/lodash-es/_hasPath.js +0 -19
  139. package/dist/node_modules/lodash-es/_isFlattenable.js +0 -10
  140. package/dist/node_modules/lodash-es/_isKey.js +0 -12
  141. package/dist/node_modules/lodash-es/_isStrictComparable.js +0 -7
  142. package/dist/node_modules/lodash-es/_mapToArray.js +0 -9
  143. package/dist/node_modules/lodash-es/_matchesStrictComparable.js +0 -8
  144. package/dist/node_modules/lodash-es/_memoizeCapped.js +0 -11
  145. package/dist/node_modules/lodash-es/_nativeKeys.js +0 -5
  146. package/dist/node_modules/lodash-es/_setCacheAdd.js +0 -7
  147. package/dist/node_modules/lodash-es/_setCacheHas.js +0 -6
  148. package/dist/node_modules/lodash-es/_setToArray.js +0 -9
  149. package/dist/node_modules/lodash-es/_stringToPath.js +0 -10
  150. package/dist/node_modules/lodash-es/_toKey.js +0 -10
  151. package/dist/node_modules/lodash-es/_trimmedEndIndex.js +0 -9
  152. package/dist/node_modules/lodash-es/flatMap.js +0 -8
  153. package/dist/node_modules/lodash-es/get.js +0 -8
  154. package/dist/node_modules/lodash-es/hasIn.js +0 -8
  155. package/dist/node_modules/lodash-es/isSymbol.js +0 -9
  156. package/dist/node_modules/lodash-es/keys.js +0 -9
  157. package/dist/node_modules/lodash-es/map.js +0 -11
  158. package/dist/node_modules/lodash-es/property.js +0 -10
  159. package/dist/node_modules/lodash-es/range.js +0 -5
  160. package/dist/node_modules/lodash-es/stubArray.js +0 -6
  161. package/dist/node_modules/lodash-es/toFinite.js +0 -14
  162. package/dist/node_modules/lodash-es/toNumber.js +0 -22
  163. package/dist/node_modules/lodash-es/toString.js +0 -7
  164. package/dist/src/components/organisms/onboarding/ItemsOnboarding.vue.d.ts +0 -2
  165. package/dist/src/composables/useTimerClone.d.ts +0 -5
  166. package/dist/src/config/compiler/itemsCompilerRules.d.ts +0 -2
  167. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -27
  168. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -14
  169. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -33
  170. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -14
  171. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +0 -501
  172. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -14
  173. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -19
  174. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -21
  175. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -14
  176. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -13
  177. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -48
  178. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +0 -61
  179. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -162
  180. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +0 -49
  181. package/dist/src/extensions/Blocks/Items/extension.d.ts +0 -2
  182. package/dist/src/extensions/Blocks/Items/iconsRegistry.d.ts +0 -4
  183. package/dist/src/extensions/Blocks/Items/settingsPanel.d.ts +0 -4
  184. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -41
  185. package/dist/src/extensions/Blocks/Items/template.d.ts +0 -24
  186. package/dist/src/extensions/Blocks/Items/utils/configBlockUtils.d.ts +0 -23
  187. package/dist/src/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.d.ts +0 -32
  188. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +0 -44
  189. package/dist/src/extensions/Blocks/Items/utils/updateAttributes.d.ts +0 -8
  190. package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -312
  191. package/dist/src/utils/environmentUtil.d.ts +0 -5
  192. package/dist/src/utils/pairProductVariables.d.ts +0 -7
  193. package/dist/utils/environmentUtil.js +0 -4
  194. package/dist/utils/pairProductVariables.js +0 -136
@@ -1,123 +0,0 @@
1
- var S = Object.defineProperty;
2
- var _ = (c, s, e) => s in c ? S(c, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[s] = e;
3
- var u = (c, s, e) => _(c, typeof s != "symbol" ? s + "" : s, e);
4
- import { ModificationDescription as b } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as R } from "../../../common-control.js";
6
- import { ItemsBlockControlId as h } from "../../enums/controlEnums.js";
7
- import { useItemsBlockStore as f } from "../../store/items-block.js";
8
- import { syncCurrencySymbolFromAttributes as N } from "../../utils/syncAttributesFromConfigBlock.js";
9
- import { updateConfigBlockAttributes as B } from "../../utils/updateAttributes.js";
10
- const E = h.PRICE_CURRENCY_SYMBOL, m = {
11
- CURRENCY_SYMBOL: "currencySymbol"
12
- };
13
- class P extends R {
14
- constructor() {
15
- super(...arguments);
16
- u(this, "store", f());
17
- u(this, "originalPriceContents", /* @__PURE__ */ new Map());
18
- }
19
- getId() {
20
- return E;
21
- }
22
- getTemplate() {
23
- return `
24
- <div class="${h.PRICE_CURRENCY_SYMBOL}">
25
- ${this._getCurrencySymbol()}
26
- </div>
27
- `;
28
- }
29
- onRender() {
30
- this.api.updateValues({ [m.CURRENCY_SYMBOL]: this.store.currencySymbol }), this._storeOriginalContents(), this.api.onValueChanged(m.CURRENCY_SYMBOL, (e) => {
31
- this._onCurrencySymbolChange(e);
32
- });
33
- }
34
- onDestroy() {
35
- super.onDestroy(), this.originalPriceContents.clear();
36
- }
37
- onTemplateNodeUpdated(e) {
38
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
39
- () => N(this.currentNode),
40
- () => {
41
- this.api.updateValues({ [m.CURRENCY_SYMBOL]: this.store.currencySymbol }), this._storeOriginalContents();
42
- }
43
- );
44
- }
45
- _onCurrencySymbolChange(e) {
46
- var i;
47
- console.debug("Currency symbol changed to: ", e);
48
- const r = ((i = this.store.currencySymbol) == null ? void 0 : i.trim()) || "";
49
- if (this.store.setCurrencySymbol(e), B(this.currentNode, this.api), !this.currentNode)
50
- return;
51
- const t = this._getPriceBlocks();
52
- if (!t || t.length === 0)
53
- return;
54
- const o = (e == null ? void 0 : e.trim()) || "", { currencyLocation: n } = this.store;
55
- t.forEach((l) => {
56
- const a = this._getParagraph(l);
57
- if (!a)
58
- return;
59
- const y = a.getInnerHTML() || "", p = a.getInnerText() || "", C = this._removeCurrencySymbol(p, r), g = this._buildPriceContent(C, o, n), d = y.replace(p, g);
60
- this.api.getDocumentModifier().modifyHtml(a).setInnerHtml(d).apply(new b(
61
- `Updated currency symbol to ${o || "removed"}`
62
- ));
63
- });
64
- }
65
- _storeOriginalContents() {
66
- if (!this.currentNode)
67
- return;
68
- this.currentNode.querySelectorAll(
69
- ".items-block-price"
70
- ).forEach((r) => {
71
- var o;
72
- const t = r.querySelector("p");
73
- if (t && !this.originalPriceContents.has(t)) {
74
- const n = t.getInnerText() || "", i = ((o = this.store.currencySymbol) == null ? void 0 : o.trim()) || "", l = this._removeCurrencySymbol(n, i);
75
- this.originalPriceContents.set(t, l);
76
- }
77
- });
78
- }
79
- _getPriceBlocks() {
80
- var e, r;
81
- return ((r = (e = this.currentNode) == null ? void 0 : e.closest(".items-block")) == null ? void 0 : r.querySelectorAll(".items-block-price")) || [];
82
- }
83
- _getParagraph(e) {
84
- return e.querySelector("p");
85
- }
86
- _escapeRegex(e) {
87
- return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
88
- }
89
- _removeCurrencySymbol(e, r) {
90
- const t = e || "";
91
- let o = t;
92
- if (r) {
93
- const n = new RegExp(`\\s*${this._escapeRegex(r)}\\s*`);
94
- o = t.replace(n, "").trim();
95
- } else {
96
- const n = t.match(/([^0-9.,\s]+)/);
97
- if (n && n[1]) {
98
- const i = n[1].trim(), l = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
99
- o = t.replace(l, "").trim();
100
- }
101
- }
102
- return o;
103
- }
104
- _buildPriceContent(e, r, t) {
105
- return r ? t === "1" ? `${e}&nbsp;${r}` : `${r}&nbsp;${e}` : e;
106
- }
107
- _getCurrencySymbol() {
108
- return `
109
- ${this._GuTwoColumns([
110
- this._GuLabel({ text: "Currency Symbol" }),
111
- this._GuTextInput({
112
- name: m.CURRENCY_SYMBOL,
113
- placeholder: "Enter Currency Symbol",
114
- className: "es-180w"
115
- })
116
- ])}
117
- `;
118
- }
119
- }
120
- export {
121
- E as CONTROL_BLOCK_ID,
122
- P as PriceCurrencySymbolControl
123
- };
@@ -1,76 +0,0 @@
1
- var _ = Object.defineProperty;
2
- var I = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var P = (r, e, t) => I(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { ModificationDescription as F, UIElementType as m, UEAttr as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as h } from "../../../common-control.js";
6
- import { ItemsBlockControlId as l, ItemsBlockId as A } from "../../enums/controlEnums.js";
7
- import { productPairs as T } from "../../enums/productEnums.js";
8
- import { useItemsBlockStore as u } from "../../store/items-block.js";
9
- import { syncFormattedPriceFromAttributes as g } from "../../utils/syncAttributesFromConfigBlock.js";
10
- import { updateConfigBlockAttributes as D } from "../../utils/updateAttributes.js";
11
- const f = l.PRICE_FORMATTED_PRICE, n = {
12
- FORMATTED_PRICE: "formattedPrice"
13
- };
14
- class y extends h {
15
- constructor() {
16
- super(...arguments);
17
- P(this, "store", u());
18
- }
19
- getId() {
20
- return f;
21
- }
22
- getTemplate() {
23
- return `
24
- <div class="${l.PRICE_FORMATTED_PRICE}">
25
- ${this._getFormattedPrice()}
26
- </div>
27
- `;
28
- }
29
- onRender() {
30
- this.api.updateValues({ [n.FORMATTED_PRICE]: this.store.formattedPrice }), this.api.onValueChanged(n.FORMATTED_PRICE, (t) => {
31
- this._onFormattedPriceChange(t);
32
- });
33
- }
34
- onTemplateNodeUpdated(t) {
35
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
36
- () => g(this.currentNode),
37
- () => {
38
- this.api.updateValues({ [n.FORMATTED_PRICE]: this.store.formattedPrice });
39
- }
40
- );
41
- }
42
- _onFormattedPriceChange(t) {
43
- if (console.debug("Formatted price changed to: ", t), this.store.setFormattedPrice(t), D(this.currentNode, this.api), !this.currentNode)
44
- return;
45
- const { itemsType: s } = this.store, i = T.PAIRS_FOR_EXTENSION.price[s], o = T.PAIRS_FOR_EXTENSION.originalPrice[s], [c, a] = t ? [i.DEFAULT_PRICE, i.DEFAULT_PRICE_FORMATTED] : [i.DEFAULT_PRICE_FORMATTED, i.DEFAULT_PRICE], [p, R] = t ? [o.DEFAULT_PRICE, o.DEFAULT_PRICE_FORMATTED] : [o.DEFAULT_PRICE_FORMATTED, o.DEFAULT_PRICE];
46
- this._updatePriceBlock(
47
- this.currentNode,
48
- c,
49
- a,
50
- "price"
51
- );
52
- const d = this.currentNode.closest(".items-block"), E = d == null ? void 0 : d.querySelector(`[esd-extension-block-id="${A.ORIGINAL_PRICE}"]`);
53
- E && this._updatePriceBlock(E, p, R, "original price");
54
- }
55
- _updatePriceBlock(t, s, i, o) {
56
- const c = t.getInnerHTML().replace(s, i), a = `Updated ${o} to ${this.store.formattedPrice ? "formatted" : "unformatted"}`;
57
- this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(c).apply(new F(a));
58
- }
59
- _getFormattedPrice() {
60
- return `
61
- <div class="container">
62
- <div class="display-flex align-items-center justify-content-between">
63
- <${m.LABEL}
64
- ${C.LABEL.text}="${this.api.translate("Formatted Price (e.g. $9.90)")}"
65
- >
66
- </${m.LABEL}>
67
- ${this._GuToggle(n.FORMATTED_PRICE)}
68
- </div>
69
- </div>
70
- `;
71
- }
72
- }
73
- export {
74
- f as CONTROL_BLOCK_ID,
75
- y as PriceFormattedPriceControl
76
- };
@@ -1,61 +0,0 @@
1
- var d = Object.defineProperty;
2
- var a = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var o = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { UIElementType as n, UEAttr as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as u } from "../../../common-control.js";
6
- import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
7
- import { useItemsBlockStore as D } from "../../store/items-block.js";
8
- import { syncHideDiscountFromAttributes as p } from "../../utils/syncAttributesFromConfigBlock.js";
9
- import { updateConfigBlockAttributes as I } from "../../utils/updateAttributes.js";
10
- const l = r.PRICE_HIDE_DISCOUNT, s = {
11
- HIDE_DISCOUNT: "hideDiscount"
12
- };
13
- class N extends u {
14
- constructor() {
15
- super(...arguments);
16
- o(this, "store", D());
17
- }
18
- getId() {
19
- return l;
20
- }
21
- getTemplate() {
22
- return `
23
- <div class="${r.PRICE_HIDE_DISCOUNT}">
24
- ${this._getHideDiscount()}
25
- </div>
26
- `;
27
- }
28
- onRender() {
29
- this.api.updateValues({ [s.HIDE_DISCOUNT]: this.store.hideDiscount }), this.api.onValueChanged(s.HIDE_DISCOUNT, (t) => {
30
- this._onHideDiscountChange(t);
31
- });
32
- }
33
- onTemplateNodeUpdated(t) {
34
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
35
- () => p(this.currentNode),
36
- () => {
37
- this.api.updateValues({ [s.HIDE_DISCOUNT]: this.store.hideDiscount });
38
- }
39
- );
40
- }
41
- _onHideDiscountChange(t) {
42
- this.store.setHideDiscount(t), I(this.currentNode, this.api), this.api.updateValues({ [s.HIDE_DISCOUNT]: t });
43
- }
44
- _getHideDiscount() {
45
- return `
46
- <div class="container">
47
- <div class="display-flex align-items-center justify-content-between">
48
- <${n.LABEL}
49
- ${c.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
50
- >
51
- </${n.LABEL}>
52
- ${this._GuToggle(s.HIDE_DISCOUNT)}
53
- </div>
54
- </div>
55
- `;
56
- }
57
- }
58
- export {
59
- l as CONTROL_BLOCK_ID,
60
- N as PriceHideDiscountControl
61
- };
@@ -1,312 +0,0 @@
1
- var P = Object.defineProperty;
2
- var M = (T, u, e) => u in T ? P(T, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : T[u] = e;
3
- var C = (T, u, e) => M(T, typeof u != "symbol" ? u + "" : u, e);
4
- import { UEAttr as b, ModificationDescription as d } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as D } from "../../common-control.js";
6
- import { ItemsBlockId as m } from "../enums/controlEnums.js";
7
- import { productPairs as p, templateFirstLine as A } from "../enums/productEnums.js";
8
- import { ItemTypeOptions as R, OrientationOptions as L, ItemInCartOptions as N, SETTINGS_ENUMS as S } from "../enums/settingsEnums.js";
9
- import x from "../layouts/horizontal.html.js";
10
- import H from "../layouts/vertical.html.js";
11
- import { useItemsBlockStore as U } from "../store/items-block.js";
12
- import { getDefaultTemplate as F } from "../template.js";
13
- import { syncCurrencySymbolFromAttributes as $, syncCurrencyLocationFromAttributes as k, syncFormattedPriceFromAttributes as q } from "../utils/syncAttributesFromConfigBlock.js";
14
- import { updateConfigBlockAttributes as f } from "../utils/updateAttributes.js";
15
- const w = "ui-elements-items-block", o = {
16
- ITEMS_TYPE: "itemsType",
17
- ORIENTATION: "orientation",
18
- ITEM_IDS: "itemIds"
19
- };
20
- class Z extends D {
21
- constructor() {
22
- super(...arguments);
23
- C(this, "store", U());
24
- }
25
- getId() {
26
- return w;
27
- }
28
- getTemplate() {
29
- return `
30
- <div class="items-controls-container">
31
- ${this._getItemsType()}
32
- ${this._getItemInCart()}
33
- ${this._getOrientation()}
34
- </div>
35
- `;
36
- }
37
- onRender() {
38
- this.api.updateValues({
39
- [o.ORIENTATION]: this.store.orientation,
40
- [o.ITEMS_TYPE]: this.store.itemsType,
41
- [o.ITEM_IDS]: this.store.itemIds
42
- }), this._listenToFormUpdates();
43
- }
44
- onTemplateNodeUpdated(e) {
45
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
46
- () => {
47
- $(this.currentNode), k(this.currentNode), q(this.currentNode);
48
- },
49
- () => {
50
- this.api.updateValues({
51
- [o.ORIENTATION]: this.store.orientation,
52
- [o.ITEMS_TYPE]: this.store.itemsType,
53
- [o.ITEM_IDS]: this.store.itemIds
54
- }), this._initializeSelectItems();
55
- }
56
- );
57
- }
58
- onDestroy() {
59
- const e = this._getTemplateData();
60
- this.store.setTemplateData(e);
61
- }
62
- _getItemsType() {
63
- return `
64
- ${this._GuOneColumn([
65
- this._GuLabel({ text: "Item Type" }),
66
- this._GuSelect({
67
- name: o.ITEMS_TYPE,
68
- className: "es-100",
69
- placeholder: "Select Item Type",
70
- options: R
71
- })
72
- ])}
73
- `;
74
- }
75
- _getOrientation() {
76
- return `
77
- ${this._GuTwoColumns([
78
- this._GuLabel({ text: "Orientation" }),
79
- this._GuRadioButton({
80
- name: o.ORIENTATION,
81
- buttons: L
82
- })
83
- ])}
84
- `;
85
- }
86
- _getItemInCart() {
87
- return `
88
- ${this._GuTwoColumns([
89
- this._GuLabel({ text: "Item in Cart" }),
90
- this._GuSelect({
91
- name: o.ITEM_IDS,
92
- className: "es-100",
93
- placeholder: "Select Item In Cart",
94
- options: []
95
- })
96
- ])}
97
- `;
98
- }
99
- _onOrientationChange(e) {
100
- console.debug("Orientation changed to: ", e), this.store.setOrientation(e), this.api.updateValues({ [o.ORIENTATION]: e }), f(this.currentNode, this.api), this._reOrderTemplate(), this._recalculateTrimming();
101
- }
102
- _onItemsTypeChange(e) {
103
- const i = S.ITEMS_TYPE[e], t = N[e], r = t == null ? void 0 : t[0];
104
- !i || !r || (this.store.setItemsType(i), this.store.setItemIds(r.value), f(this.currentNode, this.api), this._updateDataTypeAttributes(i), this._initializeSelectItems(), this._reFillTemplate());
105
- }
106
- _onItemIdsChange(e) {
107
- console.debug("Item ids changed to: ", e), this.store.setItemIds(e), this.api.updateValues({ [o.ITEM_IDS]: e }), f(this.currentNode, this.api), this._updateDataNumberAttributes(e), this._reFillTemplate();
108
- }
109
- _initializeSelectItems() {
110
- this.api.setUIEAttribute(
111
- o.ITEMS_TYPE,
112
- b.SELECTPICKER.items,
113
- R
114
- );
115
- const { itemsType: e, itemIds: i } = this.store;
116
- this.api.updateValues({
117
- [o.ITEMS_TYPE]: e
118
- });
119
- const t = N[e];
120
- this.api.setUIEAttribute(
121
- o.ITEM_IDS,
122
- b.SELECTPICKER.items,
123
- t
124
- ), this.api.updateValues({
125
- [o.ITEM_IDS]: i
126
- });
127
- }
128
- _listenToFormUpdates() {
129
- this.api.onValueChanged(
130
- o.ITEMS_TYPE,
131
- (e) => this._onItemsTypeChange(e)
132
- ), this.api.onValueChanged(
133
- o.ORIENTATION,
134
- (e) => this._onOrientationChange(e)
135
- ), this.api.onValueChanged(
136
- o.ITEM_IDS,
137
- (e) => this._onItemIdsChange(e)
138
- );
139
- }
140
- _renderTemplate() {
141
- const {
142
- orientation: e,
143
- itemsType: i,
144
- itemIds: t,
145
- currencySymbol: r,
146
- currencyLocation: n,
147
- formattedPrice: s
148
- } = this.store;
149
- this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(F({
150
- orientation: e,
151
- itemsType: i,
152
- itemId: t,
153
- currencySymbol: r,
154
- currencyLocation: n,
155
- formattedPrice: s
156
- })).apply(new d("Updated template"));
157
- }
158
- _getTemplateData() {
159
- const { itemsType: e, itemIds: i, formattedPrice: t } = this.store, r = N[e].findIndex((s) => s.value === i), n = r > -1 ? r : 0;
160
- return {
161
- imageSrc: p.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[n],
162
- name: p.PAIRS_FOR_EXTENSION.name[e].DEFAULT[n],
163
- price: t ? p.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE_FORMATTED : p.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE,
164
- originalPrice: t ? p.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE_FORMATTED : p.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE,
165
- quantity: p.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT,
166
- button: p.PAIRS_FOR_EXTENSION.button[e].DEFAULT_LABEL
167
- };
168
- }
169
- _updateImageSrc(e) {
170
- var t;
171
- const i = (t = this.currentNode) == null ? void 0 : t.querySelector(`[esd-extension-block-id="${m.IMAGE}"] img`);
172
- i && this.api.getDocumentModifier().modifyHtml(i).setAttribute("src", e).apply(new d("Updated image src"));
173
- }
174
- _updateName(e) {
175
- var n;
176
- const i = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
177
- if (!i)
178
- return;
179
- const t = i.getInnerText().trim();
180
- let r = i.getInnerHTML();
181
- r = r.replace(t, e), this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(r).apply(new d("Updated name"));
182
- }
183
- _updatePrice(e) {
184
- var E;
185
- const i = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${m.PRICE}"]`);
186
- if (!i)
187
- return;
188
- const t = this._getParagraphFromBlock(i);
189
- if (!t)
190
- return;
191
- const r = t.getInnerHTML() || "", n = t.getInnerText() || "", { currencySymbol: s, currencyLocation: a } = this.store, l = (s == null ? void 0 : s.trim()) || "", c = this._removeCurrencySymbol(n, l), h = this._replacePriceNumber(c, e), I = this._buildPriceContent(h, l, a), _ = r.replace(n, I);
192
- this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(_).apply(new d("Updated price"));
193
- }
194
- _updateOriginalPrice(e) {
195
- var y;
196
- const i = (y = this.currentNode) == null ? void 0 : y.querySelector(
197
- `[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
198
- );
199
- if (!i)
200
- return;
201
- const t = this._getParagraphFromBlock(i);
202
- if (!t)
203
- return;
204
- const r = t.querySelector("s");
205
- if (!r)
206
- return;
207
- const n = r.getInnerHTML() || "", s = r.getInnerText() || "", { currencySymbol: a, currencyLocation: l } = this.store, c = (a == null ? void 0 : a.trim()) || "", h = this._removeCurrencySymbol(s, c), I = this._replacePriceNumber(h, e), _ = this._buildPriceContent(I, c, l), g = `<s>${n.replace(s, _)}</s>`;
208
- this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(g).apply(new d("Updated original price"));
209
- }
210
- _updateQuantity(e) {
211
- var a;
212
- const i = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, t = (a = this.currentNode) == null ? void 0 : a.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`);
213
- if (!t)
214
- return;
215
- const r = t.getStyle("display") === "none", n = t.getInnerText().trim();
216
- let s = t.getInnerHTML();
217
- s = s.replace(n, e), this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(s).setStyle("display", i && !r ? "table-cell" : "none").apply(new d("Updated quantity"));
218
- }
219
- /**
220
- * @todo Optimize template reordering for performance.
221
- * @description Reorders the template structure based on current orientation and visibility settings.
222
- */
223
- _reOrderTemplate() {
224
- var h, I, _, E, g, y, O;
225
- const e = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${m.IMAGE}"]`), i = (I = this.currentNode) == null ? void 0 : I.querySelector(`[esd-extension-block-id="${m.NAME}"]`), t = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${m.PRICE}"]`), r = (E = this.currentNode) == null ? void 0 : E.querySelector(
226
- `[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
227
- ), n = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`), s = (y = this.currentNode) == null ? void 0 : y.querySelector(`[esd-extension-block-id="${m.BUTTON}"]`), a = (O = this.currentNode) == null ? void 0 : O.querySelector("esd-config-block");
228
- if (!e || !i || !t || !r || !n || !s || !a)
229
- return;
230
- const { orientation: l } = this.store;
231
- let c = l === S.ORIENTATION.VERTICAL ? H : x;
232
- c = c.replace("{-{-TEMPLATE_FIRST_LINE-}-}", A).replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", i.getOuterHTML()).replace("{-{-PRODUCT_PRICE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_ORIGINAL_PRICE-}-}", r.getOuterHTML()).replace("{-{-PRODUCT_QUANTITY-}-}", n.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", s.getOuterHTML()).replace("{-{-CONFIG_BLOCK-}-}", a.getOuterHTML()), c = c.trim().replace(A, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(c).apply(new d("Reordered template"));
233
- }
234
- _updateDataTypeAttributes(e) {
235
- if (!this.currentNode)
236
- return;
237
- const i = this.currentNode.closest(".ins-product-td"), t = this.api.getDocumentModifier();
238
- i && t.modifyHtml(i).setAttribute("data-type", e), this.currentNode.querySelectorAll("[data-type]").forEach((n) => {
239
- const s = n;
240
- t.modifyHtml(s).setAttribute("data-type", e);
241
- }), t.apply(new d("Updated data-type attribute"));
242
- }
243
- _updateDataNumberAttributes(e) {
244
- if (!this.currentNode)
245
- return;
246
- const { itemsType: i } = this.store, t = N[i].findIndex((l) => l.value === e);
247
- let r = "1";
248
- if (t >= 0)
249
- r = String(t + 1);
250
- else if (e) {
251
- const l = e.match(/\((\d+)\)/);
252
- if (l) {
253
- const [, c] = l;
254
- r = c;
255
- }
256
- }
257
- const n = this.currentNode.closest(".ins-product-td"), s = this.api.getDocumentModifier();
258
- n && s.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((l) => {
259
- const c = l;
260
- s.modifyHtml(c).setAttribute("data-number", r);
261
- }), s.apply(new d("Updated data-number attribute"));
262
- }
263
- _reFillTemplate() {
264
- const e = this._getTemplateData();
265
- this._updateImageSrc(e.imageSrc), this._updateName(e.name), this._updatePrice(e.price), this._updateOriginalPrice(e.originalPrice), this._updateQuantity(e.quantity);
266
- }
267
- _recalculateTrimming() {
268
- var r;
269
- if (!this.store.nameTrimming || !this.currentNode)
270
- return;
271
- const e = (r = this.currentNode) == null ? void 0 : r.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
272
- if (!e)
273
- return;
274
- const i = e.querySelector("p");
275
- if (!i)
276
- return;
277
- const t = this.store.orientation === S.ORIENTATION.VERTICAL;
278
- this.api.getDocumentModifier().modifyHtml(i).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", t ? "130px" : "100%").apply(new d("Recalculated trimming after orientation change"));
279
- }
280
- _getParagraphFromBlock(e) {
281
- return e.querySelector("p");
282
- }
283
- _escapeRegex(e) {
284
- return e.replace(/[-\\^$*+?().|[\]{}]/g, "\\$&");
285
- }
286
- _removeCurrencySymbol(e, i) {
287
- const t = e || "";
288
- let r = t;
289
- if (i) {
290
- const n = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
291
- r = t.replace(n, "").trim();
292
- } else {
293
- const n = t.match(/([^0-9.,\s]+)/);
294
- if (n && n[1]) {
295
- const s = n[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(s)}\\s*`);
296
- r = t.replace(a, "").trim();
297
- }
298
- }
299
- return r;
300
- }
301
- _replacePriceNumber(e, i) {
302
- const t = /([0-9][0-9,.]*)/;
303
- return e.replace(t, i).trim();
304
- }
305
- _buildPriceContent(e, i, t) {
306
- return i ? t === "1" ? `${e}&nbsp;${i}&nbsp;` : `${i}&nbsp;${e}` : e;
307
- }
308
- }
309
- export {
310
- w as CONTROL_BLOCK_ID,
311
- Z as ItemsBlockControl
312
- };
@@ -1,5 +0,0 @@
1
- var c = /* @__PURE__ */ ((i) => (i.BUTTON = "items-block-button", i.IMAGE = "items-block-image", i.ORIGINAL_PRICE = "items-block-original-price", i.PRICE = "items-block-price", i.QUANTITY = "items-block-quantity", i.NAME = "items-block-name", i))(c || {}), b = /* @__PURE__ */ ((i) => (i.BUTTON_ALIGN = "items-block-button-align-control", i.BUTTON_BORDER = "items-block-button-border-control", i.BUTTON_BORDER_RADIUS = "items-block-button-border-radius-control", i.BUTTON_COLOR = "items-block-button-color-control", i.BUTTON_FIT_TO_CONTENT = "items-block-button-fit-to-content-control", i.BUTTON_FONT_FAMILY = "items-block-button-font-family-control", i.BUTTON_MARGINS = "items-block-button-margins-control", i.BUTTON_PADDINGS = "items-block-button-paddings-control", i.BUTTON_TEXT = "items-block-button-text-control", i.BUTTON_TEXT_SIZE = "items-block-button-text-size-control", i.BUTTON_TEXT_STYLE_AND_FONT_COLOR = "items-block-button-text-style-and-font-color-control", i.BUTTON_LINK = "items-block-button-link-control", i.IMAGE_SIZE = "items-block-image-size-control", i.IMAGE_MARGINS = "items-block-image-margins-control", i.IMAGE_LINK = "items-block-image-link-control", i.ORIGINAL_PRICE_ALIGN = "items-block-original-price-align-control", i.ORIGINAL_PRICE_COLOR = "items-block-original-price-color-control", i.ORIGINAL_PRICE_SIZE = "items-block-original-price-size-control", i.ORIGINAL_PRICE_STYLE = "items-block-original-price-style-control", i.ORIGINAL_PRICE_FONT_FAMILY = "items-block-original-price-font-family-control", i.ORIGINAL_PRICE_BACKGROUND = "items-block-original-price-background-control", i.ORIGINAL_PRICE_PADDINGS = "items-block-original-price-paddings-control", i.PRICE_ALIGN = "items-block-price-align-control", i.PRICE_COLOR = "items-block-price-color-control", i.PRICE_SIZE = "items-block-price-size-control", i.PRICE_STYLE = "items-block-price-style-control", i.PRICE_FONT_FAMILY = "items-block-price-font-family-control", i.PRICE_BACKGROUND = "items-block-price-background-control", i.PRICE_PADDINGS = "items-block-price-paddings-control", i.PRICE_HIDE_DISCOUNT = "items-block-price-hide-discount-control", i.PRICE_FORMATTED_PRICE = "items-block-price-formatted-price-control", i.PRICE_CURRENCY_SYMBOL = "items-block-price-currency-symbol-control", i.PRICE_CURRENCY_LOCATION = "items-block-price-currency-location-control", i.NAME_ALIGN = "items-block-name-align-control", i.NAME_COLOR = "items-block-name-color-control", i.NAME_SIZE = "items-block-name-size-control", i.NAME_STYLE = "items-block-name-style-control", i.NAME_FONT_FAMILY = "items-block-name-font-family-control", i.NAME_BACKGROUND = "items-block-name-background-control", i.NAME_TRIMMING = "items-block-name-trimming-control", i.NAME_PADDINGS = "items-block-name-paddings-control", i.QUANTITY_ALIGN = "items-block-quantity-align-control", i.QUANTITY_COLOR = "items-block-quantity-color-control", i.QUANTITY_FONT_FAMILY = "items-block-quantity-font-family-control", i.QUANTITY_PADDINGS = "items-block-quantity-paddings-control", i.QUANTITY_SIZE = "items-block-quantity-size-control", i.QUANTITY_STYLE = "items-block-quantity-style-control", i))(b || {});
2
- export {
3
- b as ItemsBlockControlId,
4
- c as ItemsBlockId
5
- };