@useinsider/guido 2.1.0-beta.ff9b498 → 2.2.0-beta.071f000

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 (185) hide show
  1. package/README.md +1 -3
  2. package/dist/@types/config/schemas.js +1 -1
  3. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  4. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  6. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  7. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
  8. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
  9. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
  10. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +37 -23
  11. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  12. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
  13. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
  14. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  15. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  16. package/dist/composables/useHtmlValidator.js +114 -104
  17. package/dist/composables/useRecommendation.js +54 -21
  18. package/dist/composables/useSave.js +12 -16
  19. package/dist/composables/useStripo.js +57 -59
  20. package/dist/composables/useStripoEventHandler.js +12 -27
  21. package/dist/composables/useVersionHistoryApi.js +1 -1
  22. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  23. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  24. package/dist/config/i18n/en/index.js +11 -0
  25. package/dist/config/i18n/en/labels.json.js +7 -0
  26. package/dist/config/i18n/en/toasters.json.js +56 -0
  27. package/dist/config/i18n/en/tooltips.json.js +82 -0
  28. package/dist/config/i18n/index.js +7 -0
  29. package/dist/config/migrator/itemsBlockMigrator.js +65 -64
  30. package/dist/config/migrator/recommendationMigrator.js +3 -3
  31. package/dist/enums/extensions/recommendationBlock.js +1 -1
  32. package/dist/enums/recommendation.js +16 -15
  33. package/dist/enums/unsubscribe.js +21 -25
  34. package/dist/extensions/Blocks/Recommendation/block.js +133 -9
  35. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  36. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  37. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +69 -0
  38. package/dist/extensions/Blocks/Recommendation/constants/layout.js +24 -0
  39. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +23 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  41. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  42. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  44. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +104 -0
  45. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +207 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
  48. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +340 -0
  49. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +168 -0
  51. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
  52. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +381 -0
  53. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  54. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  55. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
  56. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  57. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  58. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  59. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  60. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  61. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  62. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +17 -15
  63. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  64. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +346 -0
  65. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  66. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  67. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  68. package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
  69. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  70. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +353 -219
  71. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
  72. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  73. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
  74. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  75. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
  76. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  77. package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
  78. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  79. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +12 -12
  80. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
  81. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  82. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  83. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
  84. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  85. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  86. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  87. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  88. package/dist/extensions/Blocks/controlFactories.js +125 -93
  89. package/dist/guido.css +1 -1
  90. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +242 -186
  91. package/dist/services/recommendationApi.js +11 -8
  92. package/dist/services/stripoApi.js +19 -52
  93. package/dist/services/templateLibraryApi.js +16 -13
  94. package/dist/src/@types/events.d.ts +2 -34
  95. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
  96. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
  97. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  98. package/dist/src/composables/useRecommendation.d.ts +1 -0
  99. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  100. package/dist/src/config/i18n/en/index.d.ts +1 -0
  101. package/dist/src/config/i18n/index.d.ts +16 -0
  102. package/dist/src/enums/unsubscribe.d.ts +0 -3
  103. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
  104. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  105. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  106. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +55 -0
  107. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  108. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +45 -0
  109. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +42 -0
  110. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  111. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  112. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  113. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  114. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  115. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  116. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  117. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
  118. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  119. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +107 -0
  120. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  121. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
  122. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  123. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +234 -0
  124. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  125. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  126. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
  127. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  128. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  129. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  130. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  131. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  132. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  133. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  134. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  135. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +116 -0
  136. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  137. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  138. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  139. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +155 -468
  140. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  141. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +23 -0
  142. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  143. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +43 -0
  144. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  145. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  146. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  147. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
  148. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  149. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +174 -0
  150. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  151. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  152. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  153. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
  154. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  155. package/dist/src/services/stripoApi.d.ts +0 -5
  156. package/dist/src/stores/editor.d.ts +0 -23
  157. package/dist/static/styles/components/notification.css.js +18 -0
  158. package/dist/static/styles/components/tools.css.js +6 -2
  159. package/dist/static/styles/customEditorStyle.css.js +62 -11
  160. package/dist/static/styles/variables.css.js +2 -0
  161. package/dist/static/templates/empty/index.html.js +74 -0
  162. package/dist/static/templates/empty/style.css.js +779 -0
  163. package/dist/stores/editor.js +1 -2
  164. package/dist/stores/unsubscribe.js +37 -34
  165. package/dist/utils/pairProductVariables.js +57 -56
  166. package/dist/utils/templatePreparation.js +15 -14
  167. package/package.json +2 -2
  168. package/dist/composables/useSyncModuleExtractor.js +0 -33
  169. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  170. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  171. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  172. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  173. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  174. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  175. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  176. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  177. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  178. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  179. package/dist/src/composables/useSyncModuleExtractor.d.ts +0 -4
  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/migrationTemplate.d.ts +0 -16
  184. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
  185. package/dist/src/mock/api/settings.d.ts +0 -2
@@ -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,381 @@
1
+ import { ModificationDescription as p } 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 y, DESKTOP_CONTAINER_SELECTOR as q, CONTAINER_SELECTOR as $, MOBILE_ROW_SELECTOR as O } from "../../constants/selectors.js";
4
+ import { RecommendationConfigService as N } from "../../services/configService.js";
5
+ import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
6
+ import { prepareProductRows as k } from "../../templates/index.js";
7
+ import { formatPrice as B } from "../../utils/priceFormatter.js";
8
+ import { isTdNode as v } from "../../utils/tagName.js";
9
+ import { getDefaultProducts as T, DEFAULT_CARD_COMPOSITION as P, sanitizeImageUrl as j } from "../../templates/utils.js";
10
+ const M = "recommendation-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 b(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 _(t) {
29
+ const e = A(t);
30
+ if (!e || !("getAttribute" in e))
31
+ return P;
32
+ const o = e.getAttribute("data-card-composition");
33
+ return o ? o.split(",").filter(Boolean) : P;
34
+ }
35
+ function S(t, e, o) {
36
+ if (!e || !("childNodes" in e))
37
+ return !1;
38
+ const r = e.childNodes().find(
39
+ (c) => "getType" in c && c.getType() === "text"
40
+ );
41
+ return r ? (t.modifyHtml(r).setText(o), !0) : !1;
42
+ }
43
+ function x(t, e) {
44
+ return t && t.length > 0 ? t : e.length > 0 ? e : T();
45
+ }
46
+ function V(t) {
47
+ const { currentNode: e, documentModifier: o } = t;
48
+ if (!e || !("querySelector" in e))
49
+ return;
50
+ const n = e.querySelector(O), r = e.querySelector(g);
51
+ n && o.modifyHtml(n).setStyle("display", "none"), r && o.modifyHtml(r).setInnerHtml(""), (n || r) && o.apply(new p("Hide mobile row for list layout"));
52
+ }
53
+ function W(t) {
54
+ const { currentNode: e, documentModifier: o } = t;
55
+ if (!e || !("querySelector" in e))
56
+ return;
57
+ const n = e.querySelector(O);
58
+ n && o.modifyHtml(n).removeStyle("display").apply(new p("Show mobile row for grid layout"));
59
+ }
60
+ function G(t) {
61
+ const { currentNode: e, documentModifier: o, products: n, layout: r } = t;
62
+ if (!e || !("querySelector" in e))
63
+ return;
64
+ const c = r ?? b(e);
65
+ if (c === "list") {
66
+ V({ currentNode: e, documentModifier: o });
67
+ return;
68
+ }
69
+ W({ currentNode: e, documentModifier: o });
70
+ const i = e.querySelector(g);
71
+ if (!i)
72
+ return;
73
+ const s = E(), u = N.getConfig(e), l = x(n, s.recommendationProducts), f = _(e), a = k(l, c, {
74
+ productsPerRow: u.mobileCardsInRow,
75
+ composition: f
76
+ });
77
+ o.modifyHtml(i).setInnerHtml(a).apply(new p("Updated mobile product rows"));
78
+ }
79
+ function Y(t) {
80
+ const {
81
+ currentNode: e,
82
+ documentModifier: o,
83
+ afterRegenerate: n,
84
+ products: r,
85
+ layout: c
86
+ } = t;
87
+ if (!e || !("querySelector" in e))
88
+ return;
89
+ const i = e.querySelector(q) ?? e.querySelector($);
90
+ if (!i)
91
+ return;
92
+ const s = E(), u = x(r, s.recommendationProducts), { cardsInRow: l } = s.recommendationConfigs, f = _(e), a = c ?? b(e), d = k(u, a, {
93
+ productsPerRow: l,
94
+ composition: f
95
+ });
96
+ o.modifyHtml(i).setInnerHtml(d).apply(new p("Updated product")), G(t), n == null || n();
97
+ }
98
+ function h(t, e, o, n) {
99
+ const c = `0 ${Math.floor(o / 2)}px`;
100
+ let i = !1;
101
+ return n === "grid" ? Array.from(
102
+ t.querySelectorAll(".attribute-cell")
103
+ ).forEach((u) => {
104
+ e.modifyHtml(u).setStyle("padding", c), i = !0;
105
+ }) : Array.from(
106
+ t.querySelectorAll(".product-card-wrapper")
107
+ ).forEach((u) => {
108
+ const l = "parentNode" in u ? u.parentNode : null;
109
+ l && v(l) && (e.modifyHtml(l).setStyle("padding", c), i = !0);
110
+ }), i;
111
+ }
112
+ function R(t, e, o) {
113
+ const n = `${o}px`, r = Array.from(t.querySelectorAll(".spacer"));
114
+ let c = !1;
115
+ return r.forEach((i) => {
116
+ e.modifyHtml(i).setStyle("height", n), c = !0;
117
+ }), c;
118
+ }
119
+ function F(t) {
120
+ const { currentNode: e, documentModifier: o } = t;
121
+ if (!e)
122
+ return;
123
+ const n = N.getConfig(e), r = b(e);
124
+ let c = !1;
125
+ const i = e.querySelector(q);
126
+ if (i) {
127
+ c = h(
128
+ i,
129
+ o,
130
+ n.columnSpacing,
131
+ r
132
+ );
133
+ const l = R(
134
+ i,
135
+ o,
136
+ n.rowSpacing
137
+ );
138
+ c = c || l;
139
+ }
140
+ const s = e.querySelector(g);
141
+ if (s) {
142
+ const u = h(
143
+ s,
144
+ o,
145
+ n.mobileColumnSpacing,
146
+ r
147
+ );
148
+ c = c || u;
149
+ const l = R(
150
+ s,
151
+ o,
152
+ n.mobileRowSpacing
153
+ );
154
+ c = c || l;
155
+ }
156
+ c && o.apply(new p("Reapply spacing after regeneration"));
157
+ }
158
+ function ie(t) {
159
+ const { currentNode: e, documentModifier: o, afterRegenerate: n, products: r, layout: c } = t;
160
+ e && Y({
161
+ currentNode: e,
162
+ documentModifier: o,
163
+ products: r,
164
+ layout: c,
165
+ afterRegenerate: () => {
166
+ setTimeout(() => {
167
+ F({ currentNode: e, documentModifier: o });
168
+ }, 0), n == null || n();
169
+ }
170
+ });
171
+ }
172
+ function ce(t, e) {
173
+ return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...T(e - t.length)];
174
+ }
175
+ function D() {
176
+ const t = E(), { currencySettings: e } = t.recommendationConfigs, o = parseInt(e.decimalCount);
177
+ return {
178
+ code: e.value,
179
+ symbol: e.symbol,
180
+ alignment: e.alignment === "0" ? "before" : "after",
181
+ decimalCount: Number.isNaN(o) ? 2 : o,
182
+ decimalSeparator: e.decimalSeparator,
183
+ thousandSeparator: e.thousandSeparator
184
+ };
185
+ }
186
+ function C(t, e = "price") {
187
+ const o = D(), n = t[e], r = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
188
+ return B({
189
+ price: r,
190
+ currency: o
191
+ });
192
+ }
193
+ function K(t) {
194
+ var c, i;
195
+ const e = D(), o = ((c = t.original_price) == null ? void 0 : c[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((i = t.price) == null ? void 0 : i[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = o > 0 ? Math.round((o - n) / o * 100) : 0;
196
+ return r > 0 ? `-${r}%` : "0%";
197
+ }
198
+ function H(t) {
199
+ const { documentModifier: e, product: o, priceEl: n, oldPriceEl: r, omnibusPriceEl: c, omnibusDiscountEl: i } = t;
200
+ let s = !1;
201
+ if (n && "querySelector" in n) {
202
+ const u = n.querySelector("strong"), l = C(o, "price");
203
+ S(e, u, l) && (s = !0);
204
+ }
205
+ if (r && "querySelector" in r) {
206
+ const u = r.querySelector("strong"), l = C(o, "original_price");
207
+ S(e, u, l) && (s = !0);
208
+ }
209
+ if (c && "querySelector" in c) {
210
+ const u = c.querySelector(".omnibus-price-value"), l = C(o, "original_price");
211
+ S(e, u, l) && (s = !0);
212
+ }
213
+ if (i && "querySelector" in i) {
214
+ const u = i.querySelector(".omnibus-discount-value"), l = K(o);
215
+ S(e, u, l) && (s = !0);
216
+ }
217
+ return s;
218
+ }
219
+ function z(t) {
220
+ const {
221
+ documentModifier: e,
222
+ product: o,
223
+ imageEl: n,
224
+ nameEl: r,
225
+ priceEl: c,
226
+ oldPriceEl: i,
227
+ omnibusPriceEl: s,
228
+ omnibusDiscountEl: u,
229
+ buttonEl: l
230
+ } = t;
231
+ let f = !1;
232
+ if (n && "querySelector" in n) {
233
+ const a = n.querySelector("img");
234
+ a && (e.modifyHtml(a).setAttribute("src", j(o.image_url)).setAttribute("alt", o.name), f = !0);
235
+ const d = n.querySelector("a");
236
+ d && (e.modifyHtml(d).setAttribute("href", o.url), f = !0);
237
+ }
238
+ if (r && "querySelector" in r) {
239
+ const a = r.querySelector("strong");
240
+ S(e, a, o.name) && (f = !0);
241
+ }
242
+ if (H({
243
+ documentModifier: e,
244
+ product: o,
245
+ priceEl: c,
246
+ oldPriceEl: i,
247
+ omnibusPriceEl: s,
248
+ omnibusDiscountEl: u
249
+ }) && (f = !0), l && "querySelector" in l) {
250
+ const a = l.querySelector("a.es-button") || l.querySelector("a");
251
+ a && (e.modifyHtml(a).setAttribute("href", o.url), f = !0);
252
+ }
253
+ return f;
254
+ }
255
+ function L(t) {
256
+ return "querySelector" in t ? t.querySelector(q) ?? t : t;
257
+ }
258
+ function I(t, e, o) {
259
+ if (!("querySelectorAll" in t))
260
+ return !1;
261
+ const n = t.querySelectorAll(
262
+ `[esd-extension-block-id="${m.IMAGE}"]`
263
+ ), r = t.querySelectorAll(
264
+ `[esd-extension-block-id="${m.NAME}"]`
265
+ ), c = t.querySelectorAll(
266
+ `[esd-extension-block-id="${m.PRICE}"]`
267
+ ), i = t.querySelectorAll(
268
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
269
+ ), s = t.querySelectorAll(
270
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
271
+ ), u = t.querySelectorAll(
272
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
273
+ ), l = t.querySelectorAll(
274
+ `[esd-extension-block-id="${m.BUTTON}"]`
275
+ ), f = Math.min(n.length, o.length);
276
+ let a = !1;
277
+ for (let d = 0; d < f; d++) {
278
+ const U = z({
279
+ documentModifier: e,
280
+ product: o[d],
281
+ imageEl: n[d] ?? null,
282
+ nameEl: r[d] ?? null,
283
+ priceEl: c[d] ?? null,
284
+ oldPriceEl: i[d] ?? null,
285
+ omnibusPriceEl: s[d] ?? null,
286
+ omnibusDiscountEl: u[d] ?? null,
287
+ buttonEl: l[d] ?? null
288
+ });
289
+ a = a || U;
290
+ }
291
+ return a;
292
+ }
293
+ function le(t) {
294
+ const { currentNode: e, documentModifier: o, products: n } = t;
295
+ if (!e || !("querySelectorAll" in e))
296
+ return !1;
297
+ const r = L(e);
298
+ if (!("querySelectorAll" in r) || r.querySelectorAll(
299
+ `[esd-extension-block-id="${m.IMAGE}"]`
300
+ ).length !== n.length)
301
+ return !1;
302
+ let i = I(r, o, n);
303
+ if (b(e) !== "list" && "querySelector" in e) {
304
+ const u = e.querySelector(g);
305
+ if (u) {
306
+ const l = I(
307
+ u,
308
+ o,
309
+ n
310
+ );
311
+ i = i || l;
312
+ }
313
+ }
314
+ return i && o.apply(new p("Updated product content in-place")), !0;
315
+ }
316
+ function w(t, e, o) {
317
+ if (!("querySelectorAll" in t))
318
+ return !1;
319
+ const n = t.querySelectorAll(
320
+ `[esd-extension-block-id="${m.PRICE}"]`
321
+ ), r = t.querySelectorAll(
322
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
323
+ ), c = t.querySelectorAll(
324
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
325
+ ), i = t.querySelectorAll(
326
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
327
+ ), s = Math.min(n.length, o.length);
328
+ let u = !1;
329
+ for (let l = 0; l < s; l++)
330
+ H({
331
+ documentModifier: e,
332
+ product: o[l],
333
+ priceEl: n[l] ?? null,
334
+ oldPriceEl: r[l] ?? null,
335
+ omnibusPriceEl: c[l] ?? null,
336
+ omnibusDiscountEl: i[l] ?? null
337
+ }) && (u = !0);
338
+ return u;
339
+ }
340
+ function ue(t) {
341
+ const { currentNode: e, documentModifier: o } = t;
342
+ if (!e || !("querySelectorAll" in e))
343
+ return !1;
344
+ const r = E().recommendationProducts;
345
+ if (r.length === 0)
346
+ return !1;
347
+ const c = L(e);
348
+ let i = w(c, o, r);
349
+ if (b(e) !== "list" && "querySelector" in e) {
350
+ const u = e.querySelector(g);
351
+ if (u) {
352
+ const l = w(u, o, r);
353
+ i = i || l;
354
+ }
355
+ }
356
+ return i && o.apply(new p("Updated price formatting in-place")), i;
357
+ }
358
+ function se(t) {
359
+ const { currentNode: e, documentModifier: o, currency: n } = t, r = A(e);
360
+ if (!r)
361
+ return;
362
+ const c = n.alignment === "before" ? "0" : "1", i = (s, u) => {
363
+ o.modifyHtml(r).setAttribute(s, u);
364
+ };
365
+ i(y.CURRENCY, n.code), i(y.SYMBOL, n.symbol), i(y.ALIGNMENT, c), i(y.THOUSAND_SEPARATOR, n.thousandSeparator), i(y.DECIMAL_SEPARATOR, n.decimalSeparator), i(y.DECIMAL_COUNT, n.decimalCount.toString()), o.apply(new p("Update currency attributes"));
366
+ }
367
+ export {
368
+ ce as adjustProductsToSize,
369
+ C as formatProductPrice,
370
+ A as getBlockElement,
371
+ _ as getCardComposition,
372
+ b as getCurrentLayout,
373
+ F as reapplySpacing,
374
+ G as regenerateMobileProductRows,
375
+ Y as regenerateProductRows,
376
+ ie as regenerateProductRowsWithStyles,
377
+ se as setCurrencyAttributes,
378
+ ue as updatePricesInPlace,
379
+ le as updateProductContentInPlace,
380
+ z as updateSingleProductContent
381
+ };
@@ -0,0 +1,21 @@
1
+ import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ const s = "ins-recommendation-desktop-container", i = "ins-recommendation-mobile-container", o = "ins-recommendation-list-layout", a = `.${i} { display: none; }`, d = `@media only screen and (max-width: 480px) { .${s} { display: none !important; } .${i} { display: table !important; } .${o} .${s} { display: table !important; } .${o} .${i}, .${o} .ins-recommendation-mobile-row { display: none !important; } .${o} .product-image-cell { width: 80px !important; } .${o} .product-image-cell img { max-width: 80px !important; } .${o} .button-cell { width: 80px !important; } .${o} .product-info-cell { padding: 5px 8px !important; } }`, p = `.${i}`;
3
+ function c(t, e) {
4
+ return !!t.querySelector(e);
5
+ }
6
+ function m(t) {
7
+ return t.querySelectorAll(`*${s}`).length > 0;
8
+ }
9
+ function S(t) {
10
+ const e = t.getDocumentRootCssNode();
11
+ if (!e)
12
+ return;
13
+ const n = t.getDocumentModifier();
14
+ let r = !1;
15
+ c(e, p) || (n.modifyCss(e).appendRule(a), r = !0), m(e) || (n.modifyCss(e).appendRule(d), r = !0), r && n.apply(new l("Add mobile layout CSS rules"));
16
+ }
17
+ export {
18
+ s as CSS_CLASS_DESKTOP_CONTAINER,
19
+ i as CSS_CLASS_MOBILE_CONTAINER,
20
+ S 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
+ };