@useinsider/guido 1.0.3-beta.c2cbb62 → 1.0.3-beta.c4d9021

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