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

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 (183) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  6. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  9. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
  10. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  11. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  12. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  13. package/dist/composables/useActionsApi.js +15 -13
  14. package/dist/composables/useBlocksConfig.js +26 -16
  15. package/dist/composables/useHtmlValidator.js +114 -104
  16. package/dist/composables/useRecommendation.js +54 -21
  17. package/dist/composables/useStripo.js +25 -23
  18. package/dist/composables/useVersionHistoryApi.js +1 -1
  19. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  20. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  21. package/dist/config/i18n/en/index.js +11 -0
  22. package/dist/config/i18n/en/labels.json.js +7 -0
  23. package/dist/config/i18n/en/toasters.json.js +56 -0
  24. package/dist/config/i18n/en/tooltips.json.js +82 -0
  25. package/dist/config/i18n/index.js +7 -0
  26. package/dist/config/migrator/itemsBlockMigrator.js +127 -122
  27. package/dist/config/migrator/recommendationMigrator.js +2 -2
  28. package/dist/enums/defaults.js +8 -4
  29. package/dist/enums/extensions/recommendationBlock.js +1 -1
  30. package/dist/enums/recommendation.js +16 -15
  31. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +29 -29
  32. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +29 -29
  33. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +31 -29
  34. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +0 -1
  35. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +29 -27
  36. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  37. package/dist/extensions/Blocks/Recommendation/block.js +133 -9
  38. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  39. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  40. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +69 -0
  41. package/dist/extensions/Blocks/Recommendation/constants/layout.js +24 -0
  42. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +22 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  44. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  45. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +102 -0
  48. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
  49. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +207 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
  51. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +321 -0
  52. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
  53. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +168 -0
  54. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
  55. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +361 -0
  56. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  57. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  58. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
  59. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  60. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  61. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  62. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  63. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  64. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  65. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  66. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  67. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +345 -0
  68. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  69. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  70. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  71. package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
  72. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  73. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +297 -209
  74. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
  75. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  76. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
  77. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  78. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
  79. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  80. package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
  81. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  82. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  83. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
  84. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  85. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  86. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  87. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  88. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  89. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  90. package/dist/extensions/Blocks/controlFactories.js +125 -93
  91. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  92. package/dist/guido.css +1 -1
  93. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +317 -193
  94. package/dist/services/recommendationApi.js +11 -8
  95. package/dist/services/stripoApi.js +20 -17
  96. package/dist/services/templateLibraryApi.js +16 -13
  97. package/dist/src/@types/config/schemas.d.ts +8 -0
  98. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  99. package/dist/src/composables/useConfig.d.ts +4 -0
  100. package/dist/src/composables/useRecommendation.d.ts +1 -0
  101. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  102. package/dist/src/config/i18n/en/index.d.ts +1 -0
  103. package/dist/src/config/i18n/index.d.ts +16 -0
  104. package/dist/src/enums/defaults.d.ts +4 -0
  105. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
  106. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  107. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  108. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +55 -0
  109. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  110. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +45 -0
  111. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +40 -0
  112. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  113. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  114. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  115. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  116. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  117. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  118. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  119. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
  120. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  121. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +102 -0
  122. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  123. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
  124. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  125. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +231 -0
  126. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  127. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  128. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
  129. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  130. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  131. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  132. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  133. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  134. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  135. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  136. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  137. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +115 -0
  138. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  139. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  140. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  141. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +139 -468
  142. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  143. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  144. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  145. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
  146. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  147. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  148. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  149. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
  150. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  151. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +174 -0
  152. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  153. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  154. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  155. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  156. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  157. package/dist/src/stores/config.d.ts +36 -0
  158. package/dist/static/styles/components/notification.css.js +19 -0
  159. package/dist/static/styles/components/tools.css.js +6 -2
  160. package/dist/static/styles/components/version-history.css.js +10 -2
  161. package/dist/static/styles/components/wide-panel.css.js +18 -2
  162. package/dist/static/styles/customEditorStyle.css.js +35 -11
  163. package/dist/static/styles/variables.css.js +2 -0
  164. package/dist/static/templates/empty/index.html.js +74 -0
  165. package/dist/static/templates/empty/style.css.js +779 -0
  166. package/dist/stores/unsubscribe.js +37 -34
  167. package/dist/utils/pairProductVariables.js +57 -56
  168. package/dist/utils/templatePreparation.js +15 -14
  169. package/package.json +1 -1
  170. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  171. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  172. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  173. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  174. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  175. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  176. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  177. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  178. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  179. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  180. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  181. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
  182. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  183. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,168 @@
1
+ var u = Object.defineProperty;
2
+ var _ = (n, r, t) => r in n ? u(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t;
3
+ var a = (n, r, t) => _(n, typeof r != "symbol" ? r + "" : r, t);
4
+ import { EditorStatePropertyType as c, PreviewDeviceMode as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as R } from "../../../common-control.js";
6
+ import { MAX_PRODUCT_COUNT as h, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as g, DEFAULT_COLUMN_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as O } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as i } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { ensureMobileCssRulesExist as I } from "../mobileLayout/cssRules.js";
10
+ import { getCurrentLayout as N, regenerateMobileProductRows as f, adjustProductsToSize as b, regenerateProductRowsWithStyles as P } from "./utils.js";
11
+ import { useDebounceFn as L } from "../../../../../node_modules/@vueuse/shared/index.js";
12
+ const M = "recommendation-product-layout-control", e = {
13
+ PRODUCT_COUNT: "size",
14
+ PRODUCT_IN_ROW: "cardsInRow",
15
+ PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
16
+ MOBILE_CARDS_IN_ROW: "mobileCardsInRow",
17
+ MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel"
18
+ };
19
+ class V extends R {
20
+ constructor() {
21
+ super(...arguments);
22
+ // Store is used for backward compatibility with product fetching and regeneration
23
+ a(this, "store", l());
24
+ a(this, "storeUnsubscription", () => {
25
+ });
26
+ a(this, "_debouncedRegenerateProductRows", L(() => {
27
+ this._regenerateProductRows();
28
+ }, 500));
29
+ }
30
+ getId() {
31
+ return M;
32
+ }
33
+ getTemplate() {
34
+ return `
35
+ <div class="product-layout-control-container">
36
+ ${this._GuTwoColumns([
37
+ this._GuLabel({ text: "Number of Products" }),
38
+ this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: h }),
39
+ this._GuLabel({
40
+ text: "Products in One Row on Desktop",
41
+ name: e.PRODUCT_IN_ROW_LABEL
42
+ }),
43
+ this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: p }),
44
+ this._GuLabel({
45
+ text: "Products in One Row on Mobile",
46
+ name: e.MOBILE_CARDS_IN_ROW_LABEL
47
+ }),
48
+ this._GuCounter({
49
+ name: e.MOBILE_CARDS_IN_ROW,
50
+ maxValue: g
51
+ })
52
+ ])}
53
+ </div>
54
+ `;
55
+ }
56
+ onRender() {
57
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._subscribeToEditorModeChanges();
58
+ }
59
+ onTemplateNodeUpdated(t) {
60
+ super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
61
+ }
62
+ onDestroy() {
63
+ this.storeUnsubscription();
64
+ }
65
+ _setFormValues() {
66
+ const t = i.getConfig(this.currentNode);
67
+ this.api.updateValues({
68
+ [e.PRODUCT_COUNT]: t.size,
69
+ [e.PRODUCT_IN_ROW]: t.cardsInRow,
70
+ [e.MOBILE_CARDS_IN_ROW]: t.mobileCardsInRow
71
+ });
72
+ }
73
+ /**
74
+ * Checks if the editor is currently in mobile preview mode
75
+ * using Stripo's EditorStatePropertyType API.
76
+ */
77
+ _isMobileMode() {
78
+ return this.api.getEditorState()[c.previewDeviceMode] === C.MOBILE;
79
+ }
80
+ /**
81
+ * Updates counter visibility based on layout orientation and editor mode.
82
+ * - List layout: hide both counters (products always full-width)
83
+ * - Grid + desktop mode: show desktop counter, hide mobile counter
84
+ * - Grid + mobile mode: show mobile counter, hide desktop counter
85
+ */
86
+ _updateProductsInRowVisibility() {
87
+ const o = (i.getConfig(this.currentNode).layout || N(this.currentNode)) === "grid", d = this._isMobileMode();
88
+ this.api.setVisibility(e.PRODUCT_IN_ROW, o && !d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, o && !d), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, o && d), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, o && d);
89
+ }
90
+ /**
91
+ * Subscribes to editor preview mode changes via Stripo API.
92
+ * When the user switches between desktop/mobile preview, toggles
93
+ * which "Products in One Row" counter is visible.
94
+ */
95
+ _subscribeToEditorModeChanges() {
96
+ this.api.onEditorStatePropUpdated(
97
+ c.previewDeviceMode,
98
+ () => {
99
+ this._updateProductsInRowVisibility();
100
+ }
101
+ );
102
+ }
103
+ _onProductCountChange(t) {
104
+ !this.currentNode || i.getConfig(this.currentNode).size === t || (i.updateConfig(
105
+ this.api,
106
+ this.currentNode,
107
+ { size: t },
108
+ `Changed product count to ${t}`
109
+ ), this.store.patchCurrentBlockConfig({ size: t }));
110
+ }
111
+ _onProductsInRowChange(t) {
112
+ if (!this.currentNode || i.getConfig(this.currentNode).cardsInRow === t)
113
+ return;
114
+ const o = t === 1 ? 0 : m;
115
+ i.updateConfig(
116
+ this.api,
117
+ this.currentNode,
118
+ { cardsInRow: t, columnSpacing: o },
119
+ `Changed products per row to ${t}`
120
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
121
+ }
122
+ _onMobileCardsInRowChange(t) {
123
+ if (!this.currentNode || i.getConfig(this.currentNode).mobileCardsInRow === t)
124
+ return;
125
+ const o = t === 1 ? 0 : O;
126
+ i.updateConfig(
127
+ this.api,
128
+ this.currentNode,
129
+ { mobileCardsInRow: t, mobileColumnSpacing: o },
130
+ `Changed mobile products per row to ${t}`
131
+ ), I(this.api), f({
132
+ currentNode: this.currentNode,
133
+ documentModifier: this.api.getDocumentModifier()
134
+ });
135
+ }
136
+ _regenerateProductRows() {
137
+ const t = i.getConfig(this.currentNode), s = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, s);
138
+ P({
139
+ currentNode: this.currentNode,
140
+ documentModifier: this.api.getDocumentModifier(),
141
+ products: o
142
+ });
143
+ }
144
+ _listenToFormUpdates() {
145
+ this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
146
+ this._onProductCountChange(t.toString());
147
+ }), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
148
+ this._onProductsInRowChange(Number(t));
149
+ }), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
150
+ this._onMobileCardsInRowChange(Number(t));
151
+ });
152
+ }
153
+ /**
154
+ * Subscribe to store changes to update visibility when layout changes
155
+ * This is still needed because layout changes come from LayoutControl
156
+ */
157
+ _listenStateUpdates() {
158
+ let t = this.store.recommendationConfigs.orientation;
159
+ this.storeUnsubscription = this.store.$subscribe(() => {
160
+ const s = this.store.recommendationConfigs.orientation;
161
+ s !== t && (t = s, this._updateProductsInRowVisibility());
162
+ });
163
+ }
164
+ }
165
+ export {
166
+ M as PRODUCT_LAYOUT_CONTROL_ID,
167
+ V as ProductLayoutControl
168
+ };
@@ -0,0 +1,67 @@
1
+ var r = Object.defineProperty;
2
+ var f = (o, t, e) => t in o ? r(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var n = (o, t, e) => f(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as l } from "../../../common-control.js";
6
+ import { RecommendationConfigService as s } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
+ const h = "recommendation-shuffle-control", i = {
9
+ SHUFFLE_PRODUCTS: "shuffleProducts"
10
+ };
11
+ class S extends l {
12
+ constructor() {
13
+ super(...arguments);
14
+ // Store is used for backward compatibility with product fetching
15
+ n(this, "store", d());
16
+ }
17
+ getId() {
18
+ return h;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="shuffle-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Shuffle Recommended Products" }),
25
+ this._GuToggle(i.SHUFFLE_PRODUCTS)
26
+ ])}
27
+ </div>
28
+ `;
29
+ }
30
+ onRender() {
31
+ this._initializeToggle(), this._setFormValues(), this._listenToFormUpdates();
32
+ }
33
+ onTemplateNodeUpdated(e) {
34
+ super.onTemplateNodeUpdated(e), this._setFormValues();
35
+ }
36
+ _setFormValues() {
37
+ const e = s.getConfig(this.currentNode);
38
+ this.api.updateValues({
39
+ [i.SHUFFLE_PRODUCTS]: e.shuffleProducts
40
+ });
41
+ }
42
+ _initializeToggle() {
43
+ const e = s.getConfig(this.currentNode);
44
+ this.api.setUIEAttribute(
45
+ i.SHUFFLE_PRODUCTS,
46
+ u.SELECTPICKER.items,
47
+ e.shuffleProducts
48
+ );
49
+ }
50
+ _onShuffleChange(e) {
51
+ !this.currentNode || s.getConfig(this.currentNode).shuffleProducts === e || (s.updateConfig(
52
+ this.api,
53
+ this.currentNode,
54
+ { shuffleProducts: e },
55
+ `${e ? "Enabled" : "Disabled"} product shuffle`
56
+ ), this.store.patchCurrentBlockConfig({ shuffleProducts: e }));
57
+ }
58
+ _listenToFormUpdates() {
59
+ this.api.onValueChanged(i.SHUFFLE_PRODUCTS, (e) => {
60
+ this._onShuffleChange(!!e);
61
+ });
62
+ }
63
+ }
64
+ export {
65
+ h as SHUFFLE_CONTROL_ID,
66
+ S as ShuffleControl
67
+ };
@@ -0,0 +1,361 @@
1
+ import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RecommendationBlockId as m } from "../../constants/blockIds.js";
3
+ import { MOBILE_CONTAINER_SELECTOR as g, CURRENCY_ATTR as p, DESKTOP_CONTAINER_SELECTOR as C, CONTAINER_SELECTOR as $ } from "../../constants/selectors.js";
4
+ import { RecommendationConfigService as k } from "../../services/configService.js";
5
+ import { useRecommendationExtensionStore as b } from "../../store/recommendation.js";
6
+ import { prepareProductRows as N } from "../../templates/index.js";
7
+ import { formatPrice as H } from "../../utils/priceFormatter.js";
8
+ import { isTdNode as B } from "../../utils/tagName.js";
9
+ import { getDefaultProducts as T, DEFAULT_CARD_COMPOSITION as q, sanitizeImageUrl as v } from "../../templates/utils.js";
10
+ const M = "ins-recommendation-v3-block-v2";
11
+ function A(t) {
12
+ if (!t)
13
+ return null;
14
+ if ("getAttribute" in t) {
15
+ const e = t.getAttribute("class");
16
+ if (e && e.includes(M))
17
+ return t;
18
+ }
19
+ return "querySelector" in t ? t.querySelector(`.${M}`) : null;
20
+ }
21
+ function P(t) {
22
+ const e = A(t);
23
+ if (!e || !("getAttribute" in e))
24
+ return "grid";
25
+ const o = e.getAttribute("data-layout");
26
+ return o === "list" || o === "horizontal" ? "list" : "grid";
27
+ }
28
+ function w(t) {
29
+ const e = A(t);
30
+ if (!e || !("getAttribute" in e))
31
+ return q;
32
+ const o = e.getAttribute("data-card-composition");
33
+ return o ? o.split(",").filter(Boolean) : q;
34
+ }
35
+ function S(t, e, o) {
36
+ if (!e || !("childNodes" in e))
37
+ return !1;
38
+ const i = e.childNodes().find(
39
+ (c) => "getType" in c && c.getType() === "text"
40
+ );
41
+ return i ? (t.modifyHtml(i).setText(o), !0) : !1;
42
+ }
43
+ function _(t, e) {
44
+ return t && t.length > 0 ? t : e.length > 0 ? e : T();
45
+ }
46
+ function j(t) {
47
+ const { currentNode: e, documentModifier: o, products: n, layout: i } = t;
48
+ if (!e || !("querySelector" in e))
49
+ return;
50
+ const c = e.querySelector(g);
51
+ if (!c)
52
+ return;
53
+ const r = b(), s = k.getConfig(e), u = _(n, r.recommendationProducts), l = w(e), f = i ?? P(e), a = N(u, f, {
54
+ productsPerRow: s.mobileCardsInRow,
55
+ composition: l
56
+ });
57
+ o.modifyHtml(c).setInnerHtml(a).apply(new y("Updated mobile product rows"));
58
+ }
59
+ function V(t) {
60
+ const {
61
+ currentNode: e,
62
+ documentModifier: o,
63
+ afterRegenerate: n,
64
+ products: i,
65
+ layout: c
66
+ } = t;
67
+ if (!e || !("querySelector" in e))
68
+ return;
69
+ const r = e.querySelector(C) ?? e.querySelector($);
70
+ if (!r)
71
+ return;
72
+ const s = b(), u = _(i, s.recommendationProducts), { cardsInRow: l } = s.recommendationConfigs, f = w(e), a = c ?? P(e), d = N(u, a, {
73
+ productsPerRow: l,
74
+ composition: f
75
+ });
76
+ o.modifyHtml(r).setInnerHtml(d).apply(new y("Updated product")), j(t), n == null || n();
77
+ }
78
+ function h(t, e, o, n) {
79
+ const c = `0 ${Math.floor(o / 2)}px`;
80
+ let r = !1;
81
+ return n === "grid" ? Array.from(
82
+ t.querySelectorAll(".attribute-cell")
83
+ ).forEach((u) => {
84
+ e.modifyHtml(u).setStyle("padding", c), r = !0;
85
+ }) : Array.from(
86
+ t.querySelectorAll(".product-card-wrapper")
87
+ ).forEach((u) => {
88
+ const l = "parentNode" in u ? u.parentNode : null;
89
+ l && B(l) && (e.modifyHtml(l).setStyle("padding", c), r = !0);
90
+ }), r;
91
+ }
92
+ function R(t, e, o) {
93
+ const n = `${o}px`, i = Array.from(t.querySelectorAll(".spacer"));
94
+ let c = !1;
95
+ return i.forEach((r) => {
96
+ e.modifyHtml(r).setStyle("height", n), c = !0;
97
+ }), c;
98
+ }
99
+ function G(t) {
100
+ const { currentNode: e, documentModifier: o } = t;
101
+ if (!e)
102
+ return;
103
+ const n = k.getConfig(e), i = P(e);
104
+ let c = !1;
105
+ const r = e.querySelector(C);
106
+ if (r) {
107
+ c = h(
108
+ r,
109
+ o,
110
+ n.columnSpacing,
111
+ i
112
+ );
113
+ const l = R(
114
+ r,
115
+ o,
116
+ n.rowSpacing
117
+ );
118
+ c = c || l;
119
+ }
120
+ const s = e.querySelector(g);
121
+ if (s) {
122
+ const u = h(
123
+ s,
124
+ o,
125
+ n.mobileColumnSpacing,
126
+ i
127
+ );
128
+ c = c || u;
129
+ const l = R(
130
+ s,
131
+ o,
132
+ n.mobileRowSpacing
133
+ );
134
+ c = c || l;
135
+ }
136
+ c && o.apply(new y("Reapply spacing after regeneration"));
137
+ }
138
+ function oe(t) {
139
+ const { currentNode: e, documentModifier: o, afterRegenerate: n, products: i, layout: c } = t;
140
+ e && V({
141
+ currentNode: e,
142
+ documentModifier: o,
143
+ products: i,
144
+ layout: c,
145
+ afterRegenerate: () => {
146
+ setTimeout(() => {
147
+ G({ currentNode: e, documentModifier: o });
148
+ }, 0), n == null || n();
149
+ }
150
+ });
151
+ }
152
+ function ne(t, e) {
153
+ return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...T(e - t.length)];
154
+ }
155
+ function x() {
156
+ const t = b(), { currencySettings: e } = t.recommendationConfigs, o = parseInt(e.decimalCount);
157
+ return {
158
+ code: e.value,
159
+ symbol: e.symbol,
160
+ alignment: e.alignment === "0" ? "before" : "after",
161
+ decimalCount: Number.isNaN(o) ? 2 : o,
162
+ decimalSeparator: e.decimalSeparator,
163
+ thousandSeparator: e.thousandSeparator
164
+ };
165
+ }
166
+ function E(t, e = "price") {
167
+ const o = x(), n = t[e], i = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
168
+ return H({
169
+ price: i,
170
+ currency: o
171
+ });
172
+ }
173
+ function W(t) {
174
+ var c, r;
175
+ const e = x(), o = ((c = t.original_price) == null ? void 0 : c[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((r = t.price) == null ? void 0 : r[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, i = o > 0 ? Math.round((o - n) / o * 100) : 0;
176
+ return i > 0 ? `-${i}%` : "0%";
177
+ }
178
+ function D(t) {
179
+ const { documentModifier: e, product: o, priceEl: n, oldPriceEl: i, omnibusPriceEl: c, omnibusDiscountEl: r } = t;
180
+ let s = !1;
181
+ if (n && "querySelector" in n) {
182
+ const u = n.querySelector("strong"), l = E(o, "price");
183
+ S(e, u, l) && (s = !0);
184
+ }
185
+ if (i && "querySelector" in i) {
186
+ const u = i.querySelector("strong"), l = E(o, "original_price");
187
+ S(e, u, l) && (s = !0);
188
+ }
189
+ if (c && "querySelector" in c) {
190
+ const u = c.querySelector(".omnibus-price-value"), l = E(o, "original_price");
191
+ S(e, u, l) && (s = !0);
192
+ }
193
+ if (r && "querySelector" in r) {
194
+ const u = r.querySelector(".omnibus-discount-value"), l = W(o);
195
+ S(e, u, l) && (s = !0);
196
+ }
197
+ return s;
198
+ }
199
+ function Y(t) {
200
+ const {
201
+ documentModifier: e,
202
+ product: o,
203
+ imageEl: n,
204
+ nameEl: i,
205
+ priceEl: c,
206
+ oldPriceEl: r,
207
+ omnibusPriceEl: s,
208
+ omnibusDiscountEl: u,
209
+ buttonEl: l
210
+ } = t;
211
+ let f = !1;
212
+ if (n && "querySelector" in n) {
213
+ const a = n.querySelector("img");
214
+ a && (e.modifyHtml(a).setAttribute("src", v(o.image_url)).setAttribute("alt", o.name), f = !0);
215
+ const d = n.querySelector("a");
216
+ d && (e.modifyHtml(d).setAttribute("href", o.url), f = !0);
217
+ }
218
+ if (i && "querySelector" in i) {
219
+ const a = i.querySelector("strong");
220
+ S(e, a, o.name) && (f = !0);
221
+ }
222
+ if (D({
223
+ documentModifier: e,
224
+ product: o,
225
+ priceEl: c,
226
+ oldPriceEl: r,
227
+ omnibusPriceEl: s,
228
+ omnibusDiscountEl: u
229
+ }) && (f = !0), l && "querySelector" in l) {
230
+ const a = l.querySelector("a.es-button") || l.querySelector("a");
231
+ a && (e.modifyHtml(a).setAttribute("href", o.url), f = !0);
232
+ }
233
+ return f;
234
+ }
235
+ function L(t) {
236
+ return "querySelector" in t ? t.querySelector(C) ?? t : t;
237
+ }
238
+ function I(t, e, o) {
239
+ if (!("querySelectorAll" in t))
240
+ return !1;
241
+ const n = t.querySelectorAll(
242
+ `[esd-extension-block-id="${m.IMAGE}"]`
243
+ ), i = t.querySelectorAll(
244
+ `[esd-extension-block-id="${m.NAME}"]`
245
+ ), c = t.querySelectorAll(
246
+ `[esd-extension-block-id="${m.PRICE}"]`
247
+ ), r = t.querySelectorAll(
248
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
249
+ ), s = t.querySelectorAll(
250
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
251
+ ), u = t.querySelectorAll(
252
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
253
+ ), l = t.querySelectorAll(
254
+ `[esd-extension-block-id="${m.BUTTON}"]`
255
+ ), f = Math.min(n.length, o.length);
256
+ let a = !1;
257
+ for (let d = 0; d < f; d++) {
258
+ const U = Y({
259
+ documentModifier: e,
260
+ product: o[d],
261
+ imageEl: n[d] ?? null,
262
+ nameEl: i[d] ?? null,
263
+ priceEl: c[d] ?? null,
264
+ oldPriceEl: r[d] ?? null,
265
+ omnibusPriceEl: s[d] ?? null,
266
+ omnibusDiscountEl: u[d] ?? null,
267
+ buttonEl: l[d] ?? null
268
+ });
269
+ a = a || U;
270
+ }
271
+ return a;
272
+ }
273
+ function re(t) {
274
+ const { currentNode: e, documentModifier: o, products: n } = t;
275
+ if (!e || !("querySelectorAll" in e))
276
+ return !1;
277
+ const i = L(e);
278
+ if (!("querySelectorAll" in i) || i.querySelectorAll(
279
+ `[esd-extension-block-id="${m.IMAGE}"]`
280
+ ).length !== n.length)
281
+ return !1;
282
+ let r = I(i, o, n);
283
+ if ("querySelector" in e) {
284
+ const s = e.querySelector(g);
285
+ if (s) {
286
+ const u = I(
287
+ s,
288
+ o,
289
+ n
290
+ );
291
+ r = r || u;
292
+ }
293
+ }
294
+ return r && o.apply(new y("Updated product content in-place")), !0;
295
+ }
296
+ function O(t, e, o) {
297
+ if (!("querySelectorAll" in t))
298
+ return !1;
299
+ const n = t.querySelectorAll(
300
+ `[esd-extension-block-id="${m.PRICE}"]`
301
+ ), i = t.querySelectorAll(
302
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
303
+ ), c = t.querySelectorAll(
304
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
305
+ ), r = t.querySelectorAll(
306
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
307
+ ), s = Math.min(n.length, o.length);
308
+ let u = !1;
309
+ for (let l = 0; l < s; l++)
310
+ D({
311
+ documentModifier: e,
312
+ product: o[l],
313
+ priceEl: n[l] ?? null,
314
+ oldPriceEl: i[l] ?? null,
315
+ omnibusPriceEl: c[l] ?? null,
316
+ omnibusDiscountEl: r[l] ?? null
317
+ }) && (u = !0);
318
+ return u;
319
+ }
320
+ function ie(t) {
321
+ const { currentNode: e, documentModifier: o } = t;
322
+ if (!e || !("querySelectorAll" in e))
323
+ return !1;
324
+ const i = b().recommendationProducts;
325
+ if (i.length === 0)
326
+ return !1;
327
+ const c = L(e);
328
+ let r = O(c, o, i);
329
+ if ("querySelector" in e) {
330
+ const s = e.querySelector(g);
331
+ if (s) {
332
+ const u = O(s, o, i);
333
+ r = r || u;
334
+ }
335
+ }
336
+ return r && o.apply(new y("Updated price formatting in-place")), r;
337
+ }
338
+ function ce(t) {
339
+ const { currentNode: e, documentModifier: o, currency: n } = t, i = A(e);
340
+ if (!i)
341
+ return;
342
+ const c = n.alignment === "before" ? "0" : "1", r = (s, u) => {
343
+ o.modifyHtml(i).setAttribute(s, u);
344
+ };
345
+ r(p.CURRENCY, n.code), r(p.SYMBOL, n.symbol), r(p.ALIGNMENT, c), r(p.THOUSAND_SEPARATOR, n.thousandSeparator), r(p.DECIMAL_SEPARATOR, n.decimalSeparator), r(p.DECIMAL_COUNT, n.decimalCount.toString()), o.apply(new y("Update currency attributes"));
346
+ }
347
+ export {
348
+ ne as adjustProductsToSize,
349
+ E as formatProductPrice,
350
+ A as getBlockElement,
351
+ w as getCardComposition,
352
+ P as getCurrentLayout,
353
+ G as reapplySpacing,
354
+ j as regenerateMobileProductRows,
355
+ V as regenerateProductRows,
356
+ oe as regenerateProductRowsWithStyles,
357
+ ce as setCurrencyAttributes,
358
+ ie as updatePricesInPlace,
359
+ re as updateProductContentInPlace,
360
+ Y as updateSingleProductContent
361
+ };
@@ -0,0 +1,21 @@
1
+ import { ModificationDescription as r } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ const i = "ins-recommendation-desktop-container", s = "ins-recommendation-mobile-container", l = `.${s} { display: none; }`, u = `@media only screen and (max-width: 480px) { .${i} { display: none !important; } .${s} { display: table !important; } }`, c = `.${s}`;
3
+ function a(o, e) {
4
+ return !!o.querySelector(e);
5
+ }
6
+ function d(o) {
7
+ return o.querySelectorAll(`*${i}`).length > 0;
8
+ }
9
+ function p(o) {
10
+ const e = o.getDocumentRootCssNode();
11
+ if (!e)
12
+ return;
13
+ const n = o.getDocumentModifier();
14
+ let t = !1;
15
+ a(e, c) || (n.modifyCss(e).appendRule(l), t = !0), d(e) || (n.modifyCss(e).appendRule(u), t = !0), t && n.apply(new r("Add mobile layout CSS rules"));
16
+ }
17
+ export {
18
+ i as CSS_CLASS_DESKTOP_CONTAINER,
19
+ s as CSS_CLASS_MOBILE_CONTAINER,
20
+ p as ensureMobileCssRulesExist
21
+ };
@@ -0,0 +1,46 @@
1
+ import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as l, createTextStyleControl as C, createTextSizeControl as c, createTextColorControl as a, createTextAlignControl as i } from "../../../controlFactories.js";
2
+ import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
+ import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
+ import { BLOCK_ROOT_SELECTOR as r } from "../../constants/selectors.js";
5
+ import { NameTextTrimControl as m } from "./textTrim.js";
6
+ const A = i(
7
+ t.NAME_ALIGN,
8
+ o.NAME,
9
+ r
10
+ ), N = a(
11
+ t.NAME_COLOR,
12
+ o.NAME,
13
+ r
14
+ ), E = c(
15
+ t.NAME_SIZE,
16
+ o.NAME,
17
+ r
18
+ ), M = C(
19
+ t.NAME_STYLE,
20
+ o.NAME,
21
+ r
22
+ ), s = l(
23
+ t.NAME_FONT_FAMILY,
24
+ o.NAME,
25
+ r
26
+ ), d = e(
27
+ t.NAME_BACKGROUND,
28
+ o.NAME,
29
+ r
30
+ ), T = n(
31
+ t.NAME_PADDINGS,
32
+ o.NAME,
33
+ r
34
+ ), p = {
35
+ align: A,
36
+ color: N,
37
+ size: E,
38
+ style: M,
39
+ fontFamily: s,
40
+ background: d,
41
+ paddings: T,
42
+ textTrim: m
43
+ };
44
+ export {
45
+ p as NameControls
46
+ };