@useinsider/guido 2.2.0-beta.8160e1e → 2.2.0-beta.8abc7b6

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 (146) 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/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
  6. package/dist/composables/useBlocksConfig.js +26 -16
  7. package/dist/composables/useHtmlValidator.js +114 -104
  8. package/dist/composables/useRecommendation.js +54 -21
  9. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  10. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  11. package/dist/config/migrator/itemsBlockMigrator.js +101 -97
  12. package/dist/config/migrator/recommendationMigrator.js +2 -2
  13. package/dist/enums/defaults.js +8 -4
  14. package/dist/enums/extensions/recommendationBlock.js +1 -1
  15. package/dist/enums/recommendation.js +16 -15
  16. package/dist/extensions/Blocks/Recommendation/block.js +133 -9
  17. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  18. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  19. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +66 -0
  20. package/dist/extensions/Blocks/Recommendation/constants/layout.js +22 -0
  21. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -0
  22. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  23. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  24. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  25. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  26. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +92 -0
  27. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
  28. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +209 -0
  29. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
  30. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +250 -0
  31. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
  32. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +160 -0
  33. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
  34. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +307 -0
  35. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  36. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  37. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
  38. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  39. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  41. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  44. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  45. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
  47. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  48. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  49. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  50. package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
  51. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  52. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +254 -207
  53. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
  54. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  55. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
  56. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  57. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
  58. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  59. package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
  60. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  61. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  62. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
  63. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  64. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  65. package/dist/extensions/Blocks/controlFactories.js +125 -93
  66. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  67. package/dist/guido.css +1 -1
  68. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +317 -193
  69. package/dist/services/recommendationApi.js +11 -8
  70. package/dist/services/templateLibraryApi.js +16 -13
  71. package/dist/src/@types/config/schemas.d.ts +8 -0
  72. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  73. package/dist/src/composables/useConfig.d.ts +4 -0
  74. package/dist/src/composables/useRecommendation.d.ts +1 -0
  75. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  76. package/dist/src/enums/defaults.d.ts +4 -0
  77. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
  78. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  79. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  80. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  81. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  82. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +41 -0
  83. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +35 -0
  84. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  86. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  87. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  88. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  89. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  90. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  91. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
  92. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  93. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +79 -0
  94. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  95. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
  96. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  97. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +221 -0
  98. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  99. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  100. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
  101. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  102. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  103. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  104. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  105. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  106. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  107. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  108. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  109. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
  110. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  111. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  112. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  113. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -468
  114. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  115. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  116. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  117. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
  118. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  119. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  120. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  121. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
  122. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  123. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +166 -0
  124. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  125. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  126. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  127. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  128. package/dist/src/stores/config.d.ts +36 -0
  129. package/dist/static/styles/customEditorStyle.css.js +35 -11
  130. package/dist/utils/pairProductVariables.js +57 -56
  131. package/dist/utils/templatePreparation.js +15 -14
  132. package/package.json +1 -1
  133. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  134. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  135. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  136. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  137. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  138. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  139. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  140. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  141. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  142. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  143. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  144. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
  145. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  146. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,160 @@
1
+ var _ = Object.defineProperty;
2
+ var c = (i, o, t) => o in i ? _(i, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[o] = t;
3
+ var d = (i, o, t) => c(i, typeof o != "symbol" ? o + "" : o, t);
4
+ import { EditorStatePropertyType as u, PreviewDeviceMode as R } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { MAX_PRODUCT_COUNT as C, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as s } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { ensureMobileCssRulesExist as O } from "../mobileLayout/cssRules.js";
10
+ import { getCurrentLayout as I, regenerateMobileProductRows as g, regenerateProductRowsWithStyles as b } from "./utils.js";
11
+ import { useDebounceFn as N } from "../../../../../node_modules/@vueuse/shared/index.js";
12
+ const P = "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 S extends h {
20
+ constructor() {
21
+ super(...arguments);
22
+ // Store is used for backward compatibility with product fetching and regeneration
23
+ d(this, "store", l());
24
+ d(this, "storeUnsubscription", () => {
25
+ });
26
+ d(this, "_debouncedRegenerateProductRows", N(() => {
27
+ this._regenerateProductRows();
28
+ }, 500));
29
+ }
30
+ getId() {
31
+ return P;
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: C }),
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: m
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 = s.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()[u.previewDeviceMode] === R.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 r = (s.getConfig(this.currentNode).layout || I(this.currentNode)) === "grid", n = this._isMobileMode();
88
+ this.api.setVisibility(e.PRODUCT_IN_ROW, r && !n), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, r && !n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, r && n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, r && n);
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
+ u.previewDeviceMode,
98
+ () => {
99
+ this._updateProductsInRowVisibility();
100
+ }
101
+ );
102
+ }
103
+ _onProductCountChange(t) {
104
+ this.currentNode && (s.updateConfig(
105
+ this.api,
106
+ this.currentNode,
107
+ { size: t },
108
+ `Changed product count to ${t}`
109
+ ), this.store.patchCurrentBlockConfig({ size: t }), this._debouncedRegenerateProductRows());
110
+ }
111
+ _onProductsInRowChange(t) {
112
+ this.currentNode && (s.updateConfig(
113
+ this.api,
114
+ this.currentNode,
115
+ { cardsInRow: t },
116
+ `Changed products per row to ${t}`
117
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }), this._debouncedRegenerateProductRows());
118
+ }
119
+ _onMobileCardsInRowChange(t) {
120
+ this.currentNode && (s.updateConfig(
121
+ this.api,
122
+ this.currentNode,
123
+ { mobileCardsInRow: t },
124
+ `Changed mobile products per row to ${t}`
125
+ ), O(this.api), g({
126
+ currentNode: this.currentNode,
127
+ documentModifier: this.api.getDocumentModifier()
128
+ }));
129
+ }
130
+ _regenerateProductRows() {
131
+ b({
132
+ currentNode: this.currentNode,
133
+ documentModifier: this.api.getDocumentModifier()
134
+ });
135
+ }
136
+ _listenToFormUpdates() {
137
+ this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
138
+ this._onProductCountChange(t.toString());
139
+ }), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
140
+ this._onProductsInRowChange(Number(t));
141
+ }), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
142
+ this._onMobileCardsInRowChange(Number(t));
143
+ });
144
+ }
145
+ /**
146
+ * Subscribe to store changes to update visibility when layout changes
147
+ * This is still needed because layout changes come from LayoutControl
148
+ */
149
+ _listenStateUpdates() {
150
+ let t = this.store.recommendationConfigs.orientation;
151
+ this.storeUnsubscription = this.store.$subscribe(() => {
152
+ const a = this.store.recommendationConfigs.orientation;
153
+ a !== t && (t = a, this._updateProductsInRowVisibility());
154
+ });
155
+ }
156
+ }
157
+ export {
158
+ P as PRODUCT_LAYOUT_CONTROL_ID,
159
+ S as ProductLayoutControl
160
+ };
@@ -0,0 +1,67 @@
1
+ var r = Object.defineProperty;
2
+ var u = (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) => u(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as f } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
+ const h = "recommendation-shuffle-control", s = {
9
+ SHUFFLE_PRODUCTS: "shuffleProducts"
10
+ };
11
+ class g extends f {
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(s.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 = i.getConfig(this.currentNode);
38
+ this.api.updateValues({
39
+ [s.SHUFFLE_PRODUCTS]: e.shuffleProducts
40
+ });
41
+ }
42
+ _initializeToggle() {
43
+ const e = i.getConfig(this.currentNode);
44
+ this.api.setUIEAttribute(
45
+ s.SHUFFLE_PRODUCTS,
46
+ l.SELECTPICKER.items,
47
+ e.shuffleProducts
48
+ );
49
+ }
50
+ _onShuffleChange(e) {
51
+ this.currentNode && (i.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(s.SHUFFLE_PRODUCTS, (e) => {
60
+ this._onShuffleChange(!!e);
61
+ });
62
+ }
63
+ }
64
+ export {
65
+ h as SHUFFLE_CONTROL_ID,
66
+ g as ShuffleControl
67
+ };
@@ -0,0 +1,307 @@
1
+ import { ModificationDescription as S } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RecommendationBlockId as m } from "../../constants/blockIds.js";
3
+ import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as T, DESKTOP_CONTAINER_SELECTOR as w, 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 R } from "../../templates/index.js";
7
+ import { formatPrice as D } from "../../utils/priceFormatter.js";
8
+ import { isTdNode as L } from "../../utils/tagName.js";
9
+ import { sanitizeImageUrl as U, getDefaultProducts as H, DEFAULT_CARD_COMPOSITION as C } from "../../templates/utils.js";
10
+ const q = "ins-recommendation-v3-block-v2";
11
+ function E(o) {
12
+ if (!o)
13
+ return null;
14
+ if ("getAttribute" in o) {
15
+ const e = o.getAttribute("class");
16
+ if (e && e.includes(q))
17
+ return o;
18
+ }
19
+ return "querySelector" in o ? o.querySelector(`.${q}`) : null;
20
+ }
21
+ function P(o) {
22
+ const e = E(o);
23
+ if (!e || !("getAttribute" in e))
24
+ return "grid";
25
+ const t = e.getAttribute("data-layout");
26
+ return t === "list" || t === "horizontal" ? "list" : "grid";
27
+ }
28
+ function N(o) {
29
+ const e = E(o);
30
+ if (!e || !("getAttribute" in e))
31
+ return C;
32
+ const t = e.getAttribute("data-card-composition");
33
+ return t ? t.split(",").filter(Boolean) : C;
34
+ }
35
+ function g(o, e, t) {
36
+ if (!e || !("childNodes" in e))
37
+ return !1;
38
+ const n = e.childNodes().find(
39
+ (i) => "getType" in i && i.getType() === "text"
40
+ );
41
+ return n ? (o.modifyHtml(n).setText(t), !0) : !1;
42
+ }
43
+ function h(o, e) {
44
+ return o && o.length > 0 ? o : e.length > 0 ? e : H();
45
+ }
46
+ function $(o) {
47
+ const { currentNode: e, documentModifier: t, products: r, layout: n } = o;
48
+ if (!e || !("querySelector" in e))
49
+ return;
50
+ const i = e.querySelector(T);
51
+ if (!i)
52
+ return;
53
+ const c = b(), u = k.getConfig(e), l = h(r, c.recommendationProducts), s = N(e), d = n ?? P(e), a = R(l, d, {
54
+ productsPerRow: u.mobileCardsInRow,
55
+ composition: s
56
+ });
57
+ t.modifyHtml(i).setInnerHtml(a).apply(new S("Updated mobile product rows"));
58
+ }
59
+ function x(o) {
60
+ const {
61
+ currentNode: e,
62
+ documentModifier: t,
63
+ afterRegenerate: r,
64
+ products: n,
65
+ layout: i
66
+ } = o;
67
+ if (!e || !("querySelector" in e))
68
+ return;
69
+ const c = e.querySelector(w) ?? e.querySelector(_);
70
+ if (!c)
71
+ return;
72
+ const u = b(), l = h(n, u.recommendationProducts), { cardsInRow: s } = u.recommendationConfigs, d = N(e), a = i ?? P(e), p = R(l, a, {
73
+ productsPerRow: s,
74
+ composition: d
75
+ });
76
+ t.modifyHtml(c).setInnerHtml(p).apply(new S("Updated product")), $(o), r == null || r();
77
+ }
78
+ function B(o, e, t, r) {
79
+ const i = `0 ${Math.floor(t / 2)}px`;
80
+ let c = !1;
81
+ return r === "grid" ? Array.from(
82
+ o.querySelectorAll(".attribute-cell")
83
+ ).forEach((l) => {
84
+ e.modifyHtml(l).setStyle("padding", i), c = !0;
85
+ }) : Array.from(
86
+ o.querySelectorAll(".product-card-wrapper")
87
+ ).forEach((l) => {
88
+ const s = "parentNode" in l ? l.parentNode : null;
89
+ s && L(s) && (e.modifyHtml(s).setStyle("padding", i), c = !0);
90
+ }), c;
91
+ }
92
+ function v(o, e, t) {
93
+ const r = `${t}px`, n = Array.from(o.querySelectorAll(".spacer"));
94
+ let i = !1;
95
+ return n.forEach((c) => {
96
+ e.modifyHtml(c).setStyle("height", r), i = !0;
97
+ }), i;
98
+ }
99
+ function V(o) {
100
+ const { currentNode: e, documentModifier: t } = o;
101
+ if (!e)
102
+ return;
103
+ const r = E(e);
104
+ if (!r || !("getAttribute" in r))
105
+ return;
106
+ const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = P(e);
107
+ let u = !1;
108
+ if (n) {
109
+ const l = parseInt(n);
110
+ Number.isNaN(l) || (u = B(
111
+ e,
112
+ t,
113
+ l,
114
+ c
115
+ ));
116
+ }
117
+ if (i) {
118
+ const l = parseInt(i);
119
+ if (!Number.isNaN(l)) {
120
+ const s = v(e, t, l);
121
+ u = u || s;
122
+ }
123
+ }
124
+ u && t.apply(new S("Reapply spacing after regeneration"));
125
+ }
126
+ function ee(o) {
127
+ const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
128
+ e && x({
129
+ currentNode: e,
130
+ documentModifier: t,
131
+ products: n,
132
+ layout: i,
133
+ afterRegenerate: () => {
134
+ setTimeout(() => {
135
+ V({ currentNode: e, documentModifier: t });
136
+ }, 0), r == null || r();
137
+ }
138
+ });
139
+ }
140
+ function M() {
141
+ const o = b(), { currencySettings: e } = o.recommendationConfigs;
142
+ return {
143
+ code: e.value,
144
+ symbol: e.symbol,
145
+ alignment: e.alignment === "0" ? "before" : "after",
146
+ decimalCount: parseInt(e.decimalCount) || 2,
147
+ decimalSeparator: e.decimalSeparator,
148
+ thousandSeparator: e.thousandSeparator
149
+ };
150
+ }
151
+ function A(o, e = "price") {
152
+ const t = M(), r = o[e], n = (r == null ? void 0 : r[t.code]) ?? Object.values(r ?? {})[0] ?? 0;
153
+ return D({
154
+ price: n,
155
+ currency: t
156
+ });
157
+ }
158
+ function j(o) {
159
+ var i, c;
160
+ const e = M(), t = ((i = o.original_price) == null ? void 0 : i[e.code]) ?? Object.values(o.original_price ?? {})[0] ?? 0, r = ((c = o.price) == null ? void 0 : c[e.code]) ?? Object.values(o.price ?? {})[0] ?? 0, n = t > 0 ? Math.round((t - r) / t * 100) : 0;
161
+ return n > 0 ? `-${n}%` : "0%";
162
+ }
163
+ function I(o) {
164
+ const { documentModifier: e, product: t, priceEl: r, oldPriceEl: n, omnibusPriceEl: i, omnibusDiscountEl: c } = o;
165
+ let u = !1;
166
+ if (r && "querySelector" in r) {
167
+ const l = r.querySelector("strong"), s = A(t, "price");
168
+ g(e, l, s) && (u = !0);
169
+ }
170
+ if (n && "querySelector" in n) {
171
+ const l = n.querySelector("strong"), s = A(t, "original_price");
172
+ g(e, l, s) && (u = !0);
173
+ }
174
+ if (i && "querySelector" in i) {
175
+ const l = i.querySelector(".omnibus-price-value"), s = A(t, "original_price");
176
+ g(e, l, s) && (u = !0);
177
+ }
178
+ if (c && "querySelector" in c) {
179
+ const l = c.querySelector(".omnibus-discount-value"), s = j(t);
180
+ g(e, l, s) && (u = !0);
181
+ }
182
+ return u;
183
+ }
184
+ function W(o) {
185
+ const {
186
+ documentModifier: e,
187
+ product: t,
188
+ imageEl: r,
189
+ nameEl: n,
190
+ priceEl: i,
191
+ oldPriceEl: c,
192
+ omnibusPriceEl: u,
193
+ omnibusDiscountEl: l,
194
+ buttonEl: s
195
+ } = o;
196
+ let d = !1;
197
+ if (r && "querySelector" in r) {
198
+ const a = r.querySelector("img");
199
+ a && (e.modifyHtml(a).setAttribute("src", U(t.image_url)).setAttribute("alt", t.name), d = !0);
200
+ const p = r.querySelector("a");
201
+ p && (e.modifyHtml(p).setAttribute("href", t.url), d = !0);
202
+ }
203
+ if (n && "querySelector" in n) {
204
+ const a = n.querySelector("strong");
205
+ g(e, a, t.name) && (d = !0);
206
+ }
207
+ if (I({
208
+ documentModifier: e,
209
+ product: t,
210
+ priceEl: i,
211
+ oldPriceEl: c,
212
+ omnibusPriceEl: u,
213
+ omnibusDiscountEl: l
214
+ }) && (d = !0), s && "querySelector" in s) {
215
+ const a = s.querySelector("a.es-button") || s.querySelector("a");
216
+ a && (e.modifyHtml(a).setAttribute("href", t.url), d = !0);
217
+ }
218
+ return d;
219
+ }
220
+ function te(o) {
221
+ const { currentNode: e, documentModifier: t, products: r } = o;
222
+ if (!e || !("querySelectorAll" in e))
223
+ return !1;
224
+ const n = e.querySelectorAll(
225
+ `[esd-extension-block-id="${m.IMAGE}"]`
226
+ ), i = e.querySelectorAll(
227
+ `[esd-extension-block-id="${m.NAME}"]`
228
+ ), c = e.querySelectorAll(
229
+ `[esd-extension-block-id="${m.PRICE}"]`
230
+ ), u = e.querySelectorAll(
231
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
232
+ ), l = e.querySelectorAll(
233
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
234
+ ), s = e.querySelectorAll(
235
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
236
+ ), d = e.querySelectorAll(
237
+ `[esd-extension-block-id="${m.BUTTON}"]`
238
+ );
239
+ if (n.length !== r.length)
240
+ return !1;
241
+ let a = !1;
242
+ return r.forEach((p, f) => {
243
+ const O = W({
244
+ documentModifier: t,
245
+ product: p,
246
+ imageEl: n[f] ?? null,
247
+ nameEl: i[f] ?? null,
248
+ priceEl: c[f] ?? null,
249
+ oldPriceEl: u[f] ?? null,
250
+ omnibusPriceEl: l[f] ?? null,
251
+ omnibusDiscountEl: s[f] ?? null,
252
+ buttonEl: d[f] ?? null
253
+ });
254
+ a = a || O;
255
+ }), a && t.apply(new S("Updated product content in-place")), !0;
256
+ }
257
+ function oe(o) {
258
+ const { currentNode: e, documentModifier: t } = o;
259
+ if (!e || !("querySelectorAll" in e))
260
+ return !1;
261
+ const n = b().recommendationProducts;
262
+ if (n.length === 0)
263
+ return !1;
264
+ const i = e.querySelectorAll(
265
+ `[esd-extension-block-id="${m.PRICE}"]`
266
+ ), c = e.querySelectorAll(
267
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
268
+ ), u = e.querySelectorAll(
269
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
270
+ ), l = e.querySelectorAll(
271
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
272
+ );
273
+ let s = !1;
274
+ return n.forEach((d, a) => {
275
+ I({
276
+ documentModifier: t,
277
+ product: d,
278
+ priceEl: i[a] ?? null,
279
+ oldPriceEl: c[a] ?? null,
280
+ omnibusPriceEl: u[a] ?? null,
281
+ omnibusDiscountEl: l[a] ?? null
282
+ }) && (s = !0);
283
+ }), s && t.apply(new S("Updated price formatting in-place")), s;
284
+ }
285
+ function re(o) {
286
+ const { currentNode: e, documentModifier: t, currency: r } = o, n = E(e);
287
+ if (!n)
288
+ return;
289
+ const i = r.alignment === "before" ? "0" : "1", c = (u, l) => {
290
+ t.modifyHtml(n).setAttribute(u, l);
291
+ };
292
+ c(y.CURRENCY, r.code), c(y.SYMBOL, r.symbol), c(y.ALIGNMENT, i), c(y.THOUSAND_SEPARATOR, r.thousandSeparator), c(y.DECIMAL_SEPARATOR, r.decimalSeparator), c(y.DECIMAL_COUNT, r.decimalCount.toString()), t.apply(new S("Update currency attributes"));
293
+ }
294
+ export {
295
+ A as formatProductPrice,
296
+ E as getBlockElement,
297
+ N as getCardComposition,
298
+ P as getCurrentLayout,
299
+ V as reapplySpacing,
300
+ $ as regenerateMobileProductRows,
301
+ x as regenerateProductRows,
302
+ ee as regenerateProductRowsWithStyles,
303
+ re as setCurrencyAttributes,
304
+ oe as updatePricesInPlace,
305
+ te as updateProductContentInPlace,
306
+ W as updateSingleProductContent
307
+ };
@@ -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 N, createTextAlignControl as a } from "../../../controlFactories.js";
2
+ import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
+ import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
+ import { CONTAINER_SELECTOR as r } from "../../constants/selectors.js";
5
+ import { NameTextTrimControl as i } from "./textTrim.js";
6
+ const m = a(
7
+ t.NAME_ALIGN,
8
+ o.NAME,
9
+ r
10
+ ), A = N(
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
+ ), F = {
35
+ align: m,
36
+ color: A,
37
+ size: E,
38
+ style: M,
39
+ fontFamily: s,
40
+ background: d,
41
+ paddings: T,
42
+ textTrim: i
43
+ };
44
+ export {
45
+ F as NameControls
46
+ };