@useinsider/guido 2.0.0-beta.cf2fe38 → 2.0.0-beta.d170da6

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 (103) hide show
  1. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +153 -69
  2. package/dist/extensions/Blocks/Recommendation/constants.js +9 -1
  3. package/dist/extensions/Blocks/Recommendation/control.js +74 -59
  4. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
  5. package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
  6. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
  7. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.js +71 -0
  8. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.js +71 -0
  9. package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.js +71 -0
  10. package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.js +71 -0
  11. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
  12. package/dist/extensions/Blocks/Recommendation/extension.js +16 -42
  13. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +117 -72
  14. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +85 -64
  15. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +54 -17
  16. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +74 -45
  17. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +25 -0
  18. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +47 -52
  19. package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +50 -3
  20. package/dist/src/extensions/Blocks/Recommendation/constants.d.ts +32 -0
  21. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +5 -2
  22. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
  23. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +592 -0
  24. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
  25. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +15 -0
  26. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +15 -0
  27. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +15 -0
  28. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +15 -0
  29. package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +60 -0
  30. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +3 -3
  31. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +15 -7
  32. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +19 -0
  33. package/dist/static/styles/components/wide-panel.css.js +0 -4
  34. package/dist/static/styles/customEditorStyle.css.js +13 -0
  35. package/package.json +1 -1
  36. package/dist/extensions/Blocks/Recommendation/controls/button/align.js +0 -13
  37. package/dist/extensions/Blocks/Recommendation/controls/button/border.js +0 -13
  38. package/dist/extensions/Blocks/Recommendation/controls/button/borderRadius.js +0 -13
  39. package/dist/extensions/Blocks/Recommendation/controls/button/color.js +0 -13
  40. package/dist/extensions/Blocks/Recommendation/controls/button/fitToContent.js +0 -13
  41. package/dist/extensions/Blocks/Recommendation/controls/button/fontFamily.js +0 -13
  42. package/dist/extensions/Blocks/Recommendation/controls/button/margins.js +0 -13
  43. package/dist/extensions/Blocks/Recommendation/controls/button/paddings.js +0 -13
  44. package/dist/extensions/Blocks/Recommendation/controls/button/text.js +0 -13
  45. package/dist/extensions/Blocks/Recommendation/controls/button/textSize.js +0 -13
  46. package/dist/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.js +0 -13
  47. package/dist/extensions/Blocks/Recommendation/controls/image/margins.js +0 -13
  48. package/dist/extensions/Blocks/Recommendation/controls/image/size.js +0 -13
  49. package/dist/extensions/Blocks/Recommendation/controls/name/align.js +0 -13
  50. package/dist/extensions/Blocks/Recommendation/controls/name/background.js +0 -13
  51. package/dist/extensions/Blocks/Recommendation/controls/name/color.js +0 -13
  52. package/dist/extensions/Blocks/Recommendation/controls/name/fontFamily.js +0 -13
  53. package/dist/extensions/Blocks/Recommendation/controls/name/paddings.js +0 -13
  54. package/dist/extensions/Blocks/Recommendation/controls/name/size.js +0 -13
  55. package/dist/extensions/Blocks/Recommendation/controls/name/style.js +0 -13
  56. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/align.js +0 -13
  57. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/background.js +0 -13
  58. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/color.js +0 -13
  59. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.js +0 -13
  60. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/paddings.js +0 -13
  61. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/size.js +0 -13
  62. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/style.js +0 -13
  63. package/dist/extensions/Blocks/Recommendation/controls/price/align.js +0 -13
  64. package/dist/extensions/Blocks/Recommendation/controls/price/background.js +0 -13
  65. package/dist/extensions/Blocks/Recommendation/controls/price/color.js +0 -13
  66. package/dist/extensions/Blocks/Recommendation/controls/price/fontFamily.js +0 -13
  67. package/dist/extensions/Blocks/Recommendation/controls/price/paddings.js +0 -13
  68. package/dist/extensions/Blocks/Recommendation/controls/price/size.js +0 -13
  69. package/dist/extensions/Blocks/Recommendation/controls/price/style.js +0 -13
  70. package/dist/src/extensions/Blocks/Recommendation/controls/button/align.d.ts +0 -5
  71. package/dist/src/extensions/Blocks/Recommendation/controls/button/border.d.ts +0 -5
  72. package/dist/src/extensions/Blocks/Recommendation/controls/button/borderRadius.d.ts +0 -5
  73. package/dist/src/extensions/Blocks/Recommendation/controls/button/color.d.ts +0 -5
  74. package/dist/src/extensions/Blocks/Recommendation/controls/button/fitToContent.d.ts +0 -5
  75. package/dist/src/extensions/Blocks/Recommendation/controls/button/fontFamily.d.ts +0 -5
  76. package/dist/src/extensions/Blocks/Recommendation/controls/button/margins.d.ts +0 -5
  77. package/dist/src/extensions/Blocks/Recommendation/controls/button/paddings.d.ts +0 -5
  78. package/dist/src/extensions/Blocks/Recommendation/controls/button/text.d.ts +0 -5
  79. package/dist/src/extensions/Blocks/Recommendation/controls/button/textSize.d.ts +0 -5
  80. package/dist/src/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.d.ts +0 -5
  81. package/dist/src/extensions/Blocks/Recommendation/controls/image/margins.d.ts +0 -5
  82. package/dist/src/extensions/Blocks/Recommendation/controls/image/size.d.ts +0 -5
  83. package/dist/src/extensions/Blocks/Recommendation/controls/name/align.d.ts +0 -5
  84. package/dist/src/extensions/Blocks/Recommendation/controls/name/background.d.ts +0 -5
  85. package/dist/src/extensions/Blocks/Recommendation/controls/name/color.d.ts +0 -5
  86. package/dist/src/extensions/Blocks/Recommendation/controls/name/fontFamily.d.ts +0 -5
  87. package/dist/src/extensions/Blocks/Recommendation/controls/name/paddings.d.ts +0 -5
  88. package/dist/src/extensions/Blocks/Recommendation/controls/name/size.d.ts +0 -5
  89. package/dist/src/extensions/Blocks/Recommendation/controls/name/style.d.ts +0 -5
  90. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/align.d.ts +0 -5
  91. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/background.d.ts +0 -5
  92. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/color.d.ts +0 -5
  93. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.d.ts +0 -5
  94. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/paddings.d.ts +0 -5
  95. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/size.d.ts +0 -5
  96. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/style.d.ts +0 -5
  97. package/dist/src/extensions/Blocks/Recommendation/controls/price/align.d.ts +0 -5
  98. package/dist/src/extensions/Blocks/Recommendation/controls/price/background.d.ts +0 -5
  99. package/dist/src/extensions/Blocks/Recommendation/controls/price/color.d.ts +0 -5
  100. package/dist/src/extensions/Blocks/Recommendation/controls/price/fontFamily.d.ts +0 -5
  101. package/dist/src/extensions/Blocks/Recommendation/controls/price/paddings.d.ts +0 -5
  102. package/dist/src/extensions/Blocks/Recommendation/controls/price/size.d.ts +0 -5
  103. package/dist/src/extensions/Blocks/Recommendation/controls/price/style.d.ts +0 -5
@@ -1,103 +1,187 @@
1
- var m = Object.defineProperty;
2
- var y = (n, o, i) => o in n ? m(n, o, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[o] = i;
3
- var a = (n, o, i) => y(n, typeof o != "symbol" ? o + "" : o, i);
4
- import { ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as b } from "../common-control.js";
6
- const h = "ui-elements-recommendation-card-composition", s = [
7
- { key: "productImage", label: "Product Image", visible: !0 },
8
- { key: "productName", label: "Product Name", visible: !0 },
9
- { key: "productPrice", label: "Product Price", visible: !0 },
10
- { key: "productOriginalPrice", label: "Product Original Price", visible: !0 },
11
- { key: "productButton", label: "Product Button", visible: !0 }
1
+ import { ModificationDescription as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as _ } from "../common-control.js";
3
+ import { ATTR_PRODUCT_IMAGE as m, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OLD_PRICE as h, ATTR_PRODUCT_OMNIBUS_PRICE as C, ATTR_PRODUCT_OMNIBUS_DISCOUNT as f, ATTR_PRODUCT_BUTTON as g } from "./constants.js";
4
+ const R = "ui-elements-recommendation-card-composition", l = ".recommendation-attribute-row", A = "tr.recommendation-product-row", c = "data-card-composition", a = "data-attribute-type", d = "data-visibility", s = [
5
+ { key: m, label: "Product Image", visible: !0 },
6
+ { key: y, label: "Product Name", visible: !0 },
7
+ { key: T, label: "Product Price", visible: !0 },
8
+ { key: h, label: "Product Original Price", visible: !0 },
9
+ { key: C, label: "Omnibus Price", visible: !1 },
10
+ { key: f, label: "Omnibus Discount", visible: !1 },
11
+ { key: g, label: "Product Button", visible: !0 }
12
12
  ];
13
- class g extends b {
14
- constructor() {
15
- super(...arguments);
16
- a(this, "currentComposition", []);
17
- a(this, "currentVisibility", {});
18
- }
13
+ class N extends _ {
19
14
  getId() {
20
- return h;
15
+ return R;
21
16
  }
22
17
  getTemplate() {
23
- const i = s.map((e) => ({
24
- key: e.key,
25
- label: e.label,
26
- content: `
27
- <div style="display: flex; align-items: center; justify-content: space-between;
28
- padding: 8px; gap: 8px;">
29
- <span style="flex: 1;">${e.label}</span>
30
- ${this._GuToggle(`visibility_${e.key}`)}
31
- </div>
32
- `
18
+ const t = s.map((i) => ({
19
+ key: i.key,
20
+ label: i.label,
21
+ content: this._createItemContent(i.label, i.key)
33
22
  }));
34
23
  return `
35
24
  <div class="container">
36
25
  ${this._GuLabel({ text: "Card Element Order & Visibility" })}
37
- ${this._GuOrderable("cardComposition", i)}
26
+ ${this._GuOrderable("cardComposition", t)}
38
27
  </div>
39
28
  `;
40
29
  }
41
30
  onRender() {
42
- this._initializeComposition(), this.api.onValueChanged("cardComposition", (i) => {
43
- this.currentComposition = i, this._applyCompositionToBlock(i);
44
- }), s.forEach((i) => {
45
- this.api.onValueChanged(`visibility_${i.key}`, (e) => {
46
- this.currentVisibility[i.key] = e, this._applyVisibilityToBlock();
31
+ this._initializeComposition(), this._registerValueChangeListeners();
32
+ }
33
+ onTemplateNodeUpdated(t) {
34
+ super.onTemplateNodeUpdated(t), this._initializeComposition();
35
+ }
36
+ /**
37
+ * Creates the HTML content for an orderable item with label and toggle
38
+ */
39
+ _createItemContent(t, i) {
40
+ return `
41
+ <div style="display: flex; align-items: center; justify-content: space-between;
42
+ padding: 8px; gap: 8px;">
43
+ <span style="flex: 1;">${t}</span>
44
+ ${this._GuToggle(`visibility_${i}`)}
45
+ </div>
46
+ `;
47
+ }
48
+ /**
49
+ * Registers event listeners for composition and visibility changes
50
+ */
51
+ _registerValueChangeListeners() {
52
+ this.api.onValueChanged("cardComposition", (t) => {
53
+ this._applyCompositionToBlock(t);
54
+ }), s.forEach((t) => {
55
+ this.api.onValueChanged(`visibility_${t.key}`, (i) => {
56
+ this._applyVisibilityToBlock(t.key, i);
47
57
  });
48
58
  });
49
59
  }
50
- onTemplateNodeUpdated(i) {
51
- super.onTemplateNodeUpdated(i), this._initializeComposition();
52
- }
53
60
  /**
54
- * Initialize the composition order and visibility from the block or use defaults
61
+ * Initializes composition order and visibility state from the current node
55
62
  */
56
63
  _initializeComposition() {
57
- var p;
58
- const i = (p = this.currentNode) == null ? void 0 : p.querySelector(".ins-recommendation-v3-block-v2");
59
- let e = null, l = null;
60
- if (i && "getAttribute" in i && (e = i.getAttribute("data-card-composition"), l = i.getAttribute("data-card-visibility")), e) {
61
- const t = e.split(",").filter(Boolean), r = s.map((c) => c.key);
62
- t.every((c) => r.includes(c)) && t.length > 0 ? this.currentComposition = t : this.currentComposition = r;
63
- } else
64
- this.currentComposition = s.map((t) => t.key);
65
- if (l)
66
- try {
67
- const t = JSON.parse(l);
68
- this.currentVisibility = t;
69
- } catch {
70
- this.currentVisibility = s.reduce((t, r) => (t[r.key] = r.visible, t), {});
71
- }
72
- else
73
- this.currentVisibility = s.reduce((t, r) => (t[r.key] = r.visible, t), {});
74
- const d = {
75
- cardComposition: this.currentComposition
64
+ const t = this._readCompositionFromNode(), i = this._readVisibilityFromRows(), e = {
65
+ cardComposition: t,
66
+ ...this._buildVisibilityValues(i)
76
67
  };
77
- s.forEach((t) => {
78
- d[`visibility_${t.key}`] = this.currentVisibility[t.key] ?? !0;
79
- }), this.api.updateValues(d);
68
+ this.api.updateValues(e);
69
+ }
70
+ /**
71
+ * Reads composition order from node's data-card-composition attribute
72
+ * Falls back to default order if attribute is not present
73
+ */
74
+ _readCompositionFromNode() {
75
+ if (!this.currentNode || !("getAttribute" in this.currentNode))
76
+ return s.map((i) => i.key);
77
+ const t = this.currentNode.getAttribute(c);
78
+ return t ? t.split(",").filter(Boolean) : s.map((i) => i.key);
79
+ }
80
+ /**
81
+ * Builds visibility values object from the visibility map
82
+ */
83
+ _buildVisibilityValues(t) {
84
+ return s.reduce((i, e) => (i[`visibility_${e.key}`] = t[e.key] ?? !0, i), {});
85
+ }
86
+ /**
87
+ * Read visibility state from individual row elements' data-visibility attributes
88
+ * This ensures toggles reflect the actual DOM state
89
+ */
90
+ _readVisibilityFromRows() {
91
+ if (!this.currentNode)
92
+ return this._getDefaultVisibilities();
93
+ const t = Array.from(this.currentNode.querySelectorAll(l));
94
+ console.debug("_readVisibilityFromRows - found attribute rows:", t.length);
95
+ const i = this._extractVisibilityFromRows(t);
96
+ return this._mergeWithDefaults(i);
97
+ }
98
+ /**
99
+ * Returns default visibility values for all items
100
+ */
101
+ _getDefaultVisibilities() {
102
+ return s.reduce((t, i) => (t[i.key] = i.visible, t), {});
103
+ }
104
+ /**
105
+ * Extracts visibility values from DOM nodes
106
+ */
107
+ _extractVisibilityFromRows(t) {
108
+ const i = {};
109
+ return t.forEach((e) => {
110
+ if (!("getAttribute" in e))
111
+ return;
112
+ const o = e.getAttribute(a), r = e.getAttribute(d);
113
+ o && r !== null && (i[o] = this._parseVisibilityValue(r), console.debug(
114
+ `_readVisibilityFromRows - ${o}: ${i[o]} (raw: ${r})`
115
+ ));
116
+ }), i;
117
+ }
118
+ /**
119
+ * Parses visibility value from string to boolean
120
+ * Accepts "1", "true" as true, everything else as false
121
+ */
122
+ _parseVisibilityValue(t) {
123
+ return t === "1" || t === "true";
124
+ }
125
+ /**
126
+ * Merges extracted visibilities with default values for missing keys
127
+ */
128
+ _mergeWithDefaults(t) {
129
+ return s.forEach((i) => {
130
+ i.key in t || (t[i.key] = i.visible, console.debug(`_readVisibilityFromRows - ${i.key}: using default ${i.visible}`));
131
+ }), t;
80
132
  }
81
133
  /**
82
134
  * Apply the reordered composition to the block's HTML structure
135
+ * Updates the data-card-composition attribute and reorders product attributes
136
+ */
137
+ _applyCompositionToBlock(t) {
138
+ if (console.debug("_applyCompositionToBlock - composition:", t), !this.currentNode) {
139
+ console.debug("_applyCompositionToBlock - no current node");
140
+ return;
141
+ }
142
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(c, t.join(",")).apply(new n("Update card composition")), this._reorderProductAttributes(t);
143
+ }
144
+ /**
145
+ * Reorders attribute rows within each product row based on composition order
83
146
  */
84
- _applyCompositionToBlock(i) {
147
+ _reorderProductAttributes(t) {
85
148
  if (!this.currentNode)
86
149
  return;
87
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
88
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute("data-card-composition", i.join(",")).apply(new u("Stored card composition order"));
150
+ const i = this.currentNode.querySelectorAll(A);
151
+ if (!(i != null && i.length))
152
+ return;
153
+ const e = this.api.getDocumentModifier();
154
+ i.forEach((o) => {
155
+ const r = this._buildCompositionHtml(o, t);
156
+ e.modifyHtml(o).setInnerHtml(r);
157
+ }), e.apply(new n("Reorder product attributes"));
158
+ }
159
+ /**
160
+ * Builds HTML string with attributes ordered according to composition
161
+ */
162
+ _buildCompositionHtml(t, i) {
163
+ return i.reduce((e, o) => {
164
+ const r = t.querySelector(`${l}[${a}="${o}"]`);
165
+ return r && "getOuterHTML" in r ? e + r.getOuterHTML() : e;
166
+ }, "");
89
167
  }
90
168
  /**
91
169
  * Apply visibility changes to the block's HTML structure
170
+ * Updates display style and data-visibility attribute for all matching rows
92
171
  */
93
- _applyVisibilityToBlock() {
94
- if (!this.currentNode)
172
+ _applyVisibilityToBlock(t, i) {
173
+ if (console.debug("_applyVisibilityToBlock", t, i), !this.currentNode)
174
+ return;
175
+ const e = this.currentNode.querySelectorAll(`${l}[${a}="${t}"]`);
176
+ if (!(e != null && e.length))
95
177
  return;
96
- const i = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
97
- i && this.api.getDocumentModifier().modifyHtml(i).setAttribute("data-card-visibility", JSON.stringify(this.currentVisibility)).apply(new u("Stored card visibility settings"));
178
+ const o = i ? "table-row" : "none", r = i ? "1" : "0", p = `Set ${t} visibility to ${i ? "visible" : "hidden"}`, u = this.api.getDocumentModifier();
179
+ e.forEach((b) => {
180
+ u.modifyHtml(b).setStyle("display", o).setAttribute(d, r);
181
+ }), u.apply(new n(p));
98
182
  }
99
183
  }
100
184
  export {
101
- h as COMPOSITION_CONTROL_BLOCK_ID,
102
- g as RecommendationCardCompositionControl
185
+ R as COMPOSITION_CONTROL_BLOCK_ID,
186
+ N as RecommendationCardCompositionControl
103
187
  };
@@ -1,5 +1,13 @@
1
- var o = /* @__PURE__ */ ((c) => (c.BUTTON = "recommendation-block-button", c.NAME = "recommendation-block-name", c.PRICE = "recommendation-block-price", c.OLD_PRICE = "recommendation-block-old-price", c.IMAGE = "recommendation-block-image", c))(o || {}), r = /* @__PURE__ */ ((c) => (c.BUTTON_ALIGN = "recommendation-block-button-align-control", c.BUTTON_BORDER = "recommendation-block-button-border-control", c.BUTTON_BORDER_RADIUS = "recommendation-block-button-border-radius-control", c.BUTTON_COLOR = "recommendation-block-button-color-control", c.BUTTON_FIT_TO_CONTENT = "recommendation-block-button-fit-to-content-control", c.BUTTON_FONT_FAMILY = "recommendation-block-button-font-family-control", c.BUTTON_MARGINS = "recommendation-block-button-margins-control", c.BUTTON_PADDINGS = "recommendation-block-button-paddings-control", c.BUTTON_TEXT = "recommendation-block-button-text-control", c.BUTTON_TEXT_SIZE = "recommendation-block-button-text-size-control", c.BUTTON_TEXT_STYLE_AND_FONT_COLOR = "recommendation-block-button-text-style-and-font-color-control", c.NAME_ALIGN = "recommendation-block-name-align-control", c.NAME_BACKGROUND = "recommendation-block-name-background-control", c.NAME_COLOR = "recommendation-block-name-color-control", c.NAME_FONT_FAMILY = "recommendation-block-name-font-family-control", c.NAME_PADDINGS = "recommendation-block-name-paddings-control", c.NAME_SIZE = "recommendation-block-name-size-control", c.NAME_STYLE = "recommendation-block-name-style-control", c.PRICE_ALIGN = "recommendation-block-price-align-control", c.PRICE_BACKGROUND = "recommendation-block-price-background-control", c.PRICE_COLOR = "recommendation-block-price-color-control", c.PRICE_FONT_FAMILY = "recommendation-block-price-font-family-control", c.PRICE_PADDINGS = "recommendation-block-price-paddings-control", c.PRICE_SIZE = "recommendation-block-price-size-control", c.PRICE_STYLE = "recommendation-block-price-style-control", c.OLD_PRICE_ALIGN = "recommendation-block-old-price-align-control", c.OLD_PRICE_BACKGROUND = "recommendation-block-old-price-background-control", c.OLD_PRICE_COLOR = "recommendation-block-old-price-color-control", c.OLD_PRICE_FONT_FAMILY = "recommendation-block-old-price-font-family-control", c.OLD_PRICE_PADDINGS = "recommendation-block-old-price-paddings-control", c.OLD_PRICE_SIZE = "recommendation-block-old-price-size-control", c.OLD_PRICE_STYLE = "recommendation-block-old-price-style-control", c.IMAGE_SIZE = "recommendation-block-image-size-control", c.IMAGE_MARGINS = "recommendation-block-image-margins-control", c))(r || {});
1
+ const _ = "productImage", b = "productName", n = "productPrice", i = "productOldPrice", O = "productOmnibusPrice", T = "productOmnibusDiscount", t = "productButton";
2
+ var o = /* @__PURE__ */ ((c) => (c.BUTTON = "recommendation-block-button", c.NAME = "recommendation-block-name", c.PRICE = "recommendation-block-price", c.OLD_PRICE = "recommendation-block-old-price", c.OMNIBUS_PRICE = "recommendation-block-omnibus-price", c.OMNIBUS_DISCOUNT = "recommendation-block-omnibus-discount", c.IMAGE = "recommendation-block-image", c))(o || {}), r = /* @__PURE__ */ ((c) => (c.BUTTON_ALIGN = "recommendation-block-button-align-control", c.BUTTON_BORDER = "recommendation-block-button-border-control", c.BUTTON_BORDER_RADIUS = "recommendation-block-button-border-radius-control", c.BUTTON_COLOR = "recommendation-block-button-color-control", c.BUTTON_FIT_TO_CONTENT = "recommendation-block-button-fit-to-content-control", c.BUTTON_FONT_FAMILY = "recommendation-block-button-font-family-control", c.BUTTON_MARGINS = "recommendation-block-button-margins-control", c.BUTTON_PADDINGS = "recommendation-block-button-paddings-control", c.BUTTON_TEXT = "recommendation-block-button-text-control", c.BUTTON_TEXT_SIZE = "recommendation-block-button-text-size-control", c.BUTTON_TEXT_STYLE_AND_FONT_COLOR = "recommendation-block-button-text-style-and-font-color-control", c.NAME_ALIGN = "recommendation-block-name-align-control", c.NAME_BACKGROUND = "recommendation-block-name-background-control", c.NAME_COLOR = "recommendation-block-name-color-control", c.NAME_FONT_FAMILY = "recommendation-block-name-font-family-control", c.NAME_PADDINGS = "recommendation-block-name-paddings-control", c.NAME_SIZE = "recommendation-block-name-size-control", c.NAME_STYLE = "recommendation-block-name-style-control", c.NAME_TEXT_TRIM = "recommendation-block-name-text-trim-control", c.PRICE_ALIGN = "recommendation-block-price-align-control", c.PRICE_BACKGROUND = "recommendation-block-price-background-control", c.PRICE_COLOR = "recommendation-block-price-color-control", c.PRICE_FONT_FAMILY = "recommendation-block-price-font-family-control", c.PRICE_PADDINGS = "recommendation-block-price-paddings-control", c.PRICE_SIZE = "recommendation-block-price-size-control", c.PRICE_STYLE = "recommendation-block-price-style-control", c.OLD_PRICE_ALIGN = "recommendation-block-old-price-align-control", c.OLD_PRICE_BACKGROUND = "recommendation-block-old-price-background-control", c.OLD_PRICE_COLOR = "recommendation-block-old-price-color-control", c.OLD_PRICE_FONT_FAMILY = "recommendation-block-old-price-font-family-control", c.OLD_PRICE_PADDINGS = "recommendation-block-old-price-paddings-control", c.OLD_PRICE_SIZE = "recommendation-block-old-price-size-control", c.OLD_PRICE_STYLE = "recommendation-block-old-price-style-control", c.OMNIBUS_PRICE_ALIGN = "recommendation-block-omnibus-price-align-control", c.OMNIBUS_PRICE_BACKGROUND = "recommendation-block-omnibus-price-background-control", c.OMNIBUS_PRICE_COLOR = "recommendation-block-omnibus-price-color-control", c.OMNIBUS_PRICE_FONT_FAMILY = "recommendation-block-omnibus-price-font-family-control", c.OMNIBUS_PRICE_PADDINGS = "recommendation-block-omnibus-price-paddings-control", c.OMNIBUS_PRICE_SIZE = "recommendation-block-omnibus-price-size-control", c.OMNIBUS_PRICE_STYLE = "recommendation-block-omnibus-price-style-control", c.OMNIBUS_PRICE_TEXT_BEFORE = "recommendation-block-omnibus-price-text-before-control", c.OMNIBUS_PRICE_TEXT_AFTER = "recommendation-block-omnibus-price-text-after-control", c.OMNIBUS_DISCOUNT_ALIGN = "recommendation-block-omnibus-discount-align-control", c.OMNIBUS_DISCOUNT_BACKGROUND = "recommendation-block-omnibus-discount-background-control", c.OMNIBUS_DISCOUNT_COLOR = "recommendation-block-omnibus-discount-color-control", c.OMNIBUS_DISCOUNT_FONT_FAMILY = "recommendation-block-omnibus-discount-font-family-control", c.OMNIBUS_DISCOUNT_PADDINGS = "recommendation-block-omnibus-discount-paddings-control", c.OMNIBUS_DISCOUNT_SIZE = "recommendation-block-omnibus-discount-size-control", c.OMNIBUS_DISCOUNT_STYLE = "recommendation-block-omnibus-discount-style-control", c.OMNIBUS_DISCOUNT_TEXT_BEFORE = "recommendation-block-omnibus-discount-text-before-control", c.OMNIBUS_DISCOUNT_TEXT_AFTER = "recommendation-block-omnibus-discount-text-after-control", c.IMAGE_SIZE = "recommendation-block-image-size-control", c.IMAGE_MARGINS = "recommendation-block-image-margins-control", c))(r || {});
2
3
  export {
4
+ t as ATTR_PRODUCT_BUTTON,
5
+ _ as ATTR_PRODUCT_IMAGE,
6
+ b as ATTR_PRODUCT_NAME,
7
+ i as ATTR_PRODUCT_OLD_PRICE,
8
+ T as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
9
+ O as ATTR_PRODUCT_OMNIBUS_PRICE,
10
+ n as ATTR_PRODUCT_PRICE,
3
11
  o as RecommendationBlockId,
4
12
  r as RecommendationControlId
5
13
  };
@@ -1,14 +1,14 @@
1
- var _ = Object.defineProperty;
2
- var R = (s, n, e) => n in s ? _(s, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[n] = e;
3
- var r = (s, n, e) => R(s, typeof n != "symbol" ? n + "" : n, e);
4
- import { currencyDecimalCounts as l, currencyOperators as c, currencyLocationMaps as h } from "../../../enums/extensions/recommendationBlock.js";
5
- import { UEAttr as m, ModificationDescription as S } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { CommonControl as g } from "../common-control.js";
7
- import { useRecommendationExtensionStore as O } from "./store/recommendation.js";
8
- import { prepareProductRows as p } from "./templates/blockTemplate.js";
9
- import { DEFAULT_CARD_COMPOSITION as C, getDefaultProducts as E } from "./templates/templateUtils.js";
10
- import { useDebounceFn as U } from "../../../node_modules/@vueuse/shared/index.js";
11
- const L = "ui-elements-recommendation-block", t = {
1
+ var p = Object.defineProperty;
2
+ var S = (a, s, e) => s in a ? p(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
+ var u = (a, s, e) => S(a, typeof s != "symbol" ? s + "" : s, e);
4
+ import { currencyDecimalCounts as _, currencyOperators as C, currencyLocationMaps as R } from "../../../enums/extensions/recommendationBlock.js";
5
+ import { UEAttr as O, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as U } from "../common-control.js";
7
+ import { useRecommendationExtensionStore as N } from "./store/recommendation.js";
8
+ import { prepareProductRows as E } from "./templates/blockTemplate.js";
9
+ import { DEFAULT_CARD_COMPOSITION as d, getDefaultProducts as L } from "./templates/templateUtils.js";
10
+ import { useDebounceFn as T } from "../../../node_modules/@vueuse/shared/index.js";
11
+ const f = "ui-elements-recommendation-block", t = {
12
12
  ALGORITHM: "strategy",
13
13
  PRODUCT_IDS: "productIds",
14
14
  LOCALE: "language",
@@ -21,24 +21,23 @@ const L = "ui-elements-recommendation-block", t = {
21
21
  FILTERS: "filterStatus",
22
22
  PRODUCT_COUNT: "size",
23
23
  PRODUCT_IN_ROW: "cardsInRow",
24
- SHUFFLE_PRODUCTS: "shuffleProducts",
25
- RESPONSIVE: "unresponsive"
24
+ SHUFFLE_PRODUCTS: "shuffleProducts"
26
25
  };
27
- class b extends g {
26
+ class Y extends U {
28
27
  constructor() {
29
28
  super(...arguments);
30
- r(this, "store", O());
31
- r(this, "storeUnsubscription", () => {
29
+ u(this, "store", N());
30
+ u(this, "storeUnsubscription", () => {
32
31
  });
33
- r(this, "addFilterListener", () => {
32
+ u(this, "addFilterListener", () => {
34
33
  });
35
- r(this, "addFilterButton", null);
36
- r(this, "_debouncedRegenerateProductRows", U(() => {
34
+ u(this, "addFilterButton", null);
35
+ u(this, "_debouncedRegenerateProductRows", T(() => {
37
36
  this._regenerateProductRows();
38
37
  }, 500));
39
38
  }
40
39
  getId() {
41
- return L;
40
+ return f;
42
41
  }
43
42
  getTemplate() {
44
43
  return `
@@ -49,7 +48,6 @@ class b extends g {
49
48
  ${this._getFilterStatus()}
50
49
  ${this._getProductLayout()}
51
50
  ${this._getShuffleProducts()}
52
- ${this._getResponsive()}
53
51
  </div>
54
52
  `;
55
53
  }
@@ -79,27 +77,25 @@ class b extends g {
79
77
  [t.CURRENCY_DECIMAL_COUNT]: e.currencySettings.decimalCount,
80
78
  [t.PRODUCT_COUNT]: e.size,
81
79
  [t.PRODUCT_IN_ROW]: e.cardsInRow,
82
- [t.SHUFFLE_PRODUCTS]: e.shuffleProducts,
83
- [t.RESPONSIVE]: !e.unresponsive
80
+ [t.SHUFFLE_PRODUCTS]: e.shuffleProducts
84
81
  });
85
82
  }
86
83
  _initializeSelectItems() {
87
- const { store: e } = this, o = e.getActivePredictiveAlgorithms, i = e.getLanguages, a = {
84
+ const { store: e } = this, o = e.getActivePredictiveAlgorithms, i = e.getLanguages, n = {
88
85
  [t.ALGORITHM]: o,
89
86
  [t.LOCALE]: i,
90
87
  [t.CURRENCY]: e.currencyList,
91
- [t.CURRENCY_LOCATION]: h,
88
+ [t.CURRENCY_LOCATION]: R,
92
89
  [t.CURRENCY_SYMBOL]: e.getCurrencySymbolList,
93
- [t.CURRENCY_THOUSAND_SEPARATOR]: c,
94
- [t.CURRENCY_DECIMAL_SEPARATOR]: c,
95
- [t.CURRENCY_DECIMAL_COUNT]: l,
90
+ [t.CURRENCY_THOUSAND_SEPARATOR]: C,
91
+ [t.CURRENCY_DECIMAL_SEPARATOR]: C,
92
+ [t.CURRENCY_DECIMAL_COUNT]: _,
96
93
  [t.PRODUCT_COUNT]: Number(e.recommendationConfigs.size),
97
94
  [t.PRODUCT_IN_ROW]: e.recommendationConfigs.cardsInRow,
98
- [t.SHUFFLE_PRODUCTS]: e.recommendationConfigs.shuffleProducts,
99
- [t.RESPONSIVE]: !e.recommendationConfigs.unresponsive
95
+ [t.SHUFFLE_PRODUCTS]: e.recommendationConfigs.shuffleProducts
100
96
  };
101
- Object.entries(a).forEach(([u, d]) => {
102
- this.api.setUIEAttribute(u, m.SELECTPICKER.items, d);
97
+ Object.entries(n).forEach(([r, l]) => {
98
+ this.api.setUIEAttribute(r, O.SELECTPICKER.items, l);
103
99
  });
104
100
  }
105
101
  _getAlgorithms() {
@@ -145,7 +141,7 @@ class b extends g {
145
141
  this._GuSelect({
146
142
  name: t.CURRENCY_LOCATION,
147
143
  placeholder: "Select Currency Location",
148
- options: h
144
+ options: R
149
145
  }),
150
146
  this._GuLabel({ text: "Currency Symbol" }),
151
147
  this._GuSelect({
@@ -157,19 +153,19 @@ class b extends g {
157
153
  this._GuSelect({
158
154
  name: t.CURRENCY_THOUSAND_SEPARATOR,
159
155
  placeholder: "Select Thousand Separator",
160
- options: c
156
+ options: C
161
157
  }),
162
158
  this._GuLabel({ text: "Decimal Separator" }),
163
159
  this._GuSelect({
164
160
  name: t.CURRENCY_DECIMAL_SEPARATOR,
165
161
  placeholder: "Select Decimal Separator",
166
- options: c
162
+ options: C
167
163
  }),
168
164
  this._GuLabel({ text: "Decimal Count" }),
169
165
  this._GuSelect({
170
166
  name: t.CURRENCY_DECIMAL_COUNT,
171
167
  placeholder: "Select Decimal Count",
172
- options: l
168
+ options: _
173
169
  })
174
170
  ])}
175
171
  `;
@@ -204,20 +200,6 @@ class b extends g {
204
200
  ])}
205
201
  `;
206
202
  }
207
- _getResponsive() {
208
- return `
209
- ${this._GuTwoColumns([
210
- this._GuLabel({ text: "Responsive Block" }),
211
- this._GuToggle(t.RESPONSIVE)
212
- ])}
213
- `;
214
- }
215
- _onFilterChange(e) {
216
- this.currentNode && this.store.$patch({
217
- filterStatus: e,
218
- filterSelectionDrawerStatus: e
219
- });
220
- }
221
203
  _onFilterSelectClick() {
222
204
  this.store.$patch({
223
205
  filterSelectionDrawerStatus: !0
@@ -235,12 +217,12 @@ class b extends g {
235
217
  */
236
218
  _getCardComposition() {
237
219
  if (!this.currentNode)
238
- return C;
220
+ return d;
239
221
  const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
240
222
  if (!e || !("getAttribute" in e))
241
- return C;
223
+ return d;
242
224
  const o = e.getAttribute("data-card-composition");
243
- return o ? o.split(",").filter(Boolean) : C;
225
+ return o ? o.split(",").filter(Boolean) : d;
244
226
  }
245
227
  _regenerateProductRows() {
246
228
  if (!this.currentNode || !("querySelector" in this.currentNode))
@@ -250,8 +232,41 @@ class b extends g {
250
232
  console.error("Could not find container table for product rows");
251
233
  return;
252
234
  }
253
- const o = this.store.recommendationProducts.length > 0 ? this.store.recommendationProducts : E(), { cardsInRow: i } = this.store.recommendationConfigs, a = this._getCardComposition(), u = p(o, i, a);
254
- this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(u).apply(new S("Updated product"));
235
+ const o = this.store.recommendationProducts.length > 0 ? this.store.recommendationProducts : L(), { cardsInRow: i } = this.store.recommendationConfigs, n = this._getCardComposition(), r = E(o, i, n);
236
+ this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(r).apply(new g("Updated product")), this._reapplySpacing();
237
+ }
238
+ /**
239
+ * Reapply spacing values after product regeneration
240
+ * This ensures spacing persists when products are regenerated
241
+ */
242
+ _reapplySpacing() {
243
+ if (!this.currentNode)
244
+ return;
245
+ const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
246
+ if (!e || !("getAttribute" in e))
247
+ return;
248
+ const o = e.getAttribute("data-column-spacing"), i = e.getAttribute("data-row-spacing"), n = this.api.getDocumentModifier();
249
+ if (o) {
250
+ const r = parseInt(o);
251
+ if (!Number.isNaN(r)) {
252
+ const h = `0 ${Math.floor(r / 2)}px`;
253
+ Array.from(
254
+ this.currentNode.querySelectorAll(".product-card-wrapper")
255
+ ).forEach((c) => {
256
+ "parentNode" in c && c.parentNode && typeof c.parentNode == "object" && "tagName" in c.parentNode && c.parentNode.tagName === "TD" && n.modifyHtml(c.parentNode).setStyle("padding", h);
257
+ });
258
+ }
259
+ }
260
+ if (i) {
261
+ const r = parseInt(i);
262
+ if (!Number.isNaN(r)) {
263
+ const l = `${r}px`;
264
+ Array.from(this.currentNode.querySelectorAll(".spacer")).forEach((m) => {
265
+ n.modifyHtml(m).setStyle("height", l);
266
+ });
267
+ }
268
+ }
269
+ (o || i) && n.apply(new g("Reapply spacing after regeneration"));
255
270
  }
256
271
  _onCurrencyConfigChange(e, o) {
257
272
  this.currentNode && this.store.$patch({
@@ -288,8 +303,8 @@ class b extends g {
288
303
  t.CURRENCY_DECIMAL_SEPARATOR,
289
304
  t.CURRENCY_DECIMAL_COUNT
290
305
  ].forEach((i) => {
291
- this.api.onValueChanged(i, (a) => this._onCurrencyConfigChange(i, a));
292
- }), this.api.onValueChanged(t.PRODUCT_COUNT, (i) => this._onDataChange(t.PRODUCT_COUNT, i.toString())), this.api.onValueChanged(t.PRODUCT_IN_ROW, (i) => this._onDataChange(t.PRODUCT_IN_ROW, i)), this.api.onValueChanged(t.SHUFFLE_PRODUCTS, (i) => this._onDataChange(t.SHUFFLE_PRODUCTS, i)), this.api.onValueChanged(t.RESPONSIVE, (i) => this._onDataChange(t.RESPONSIVE, i)), this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (o = this.addFilterButton) == null || o.addEventListener("click", this.addFilterListener);
306
+ this.api.onValueChanged(i, (n) => this._onCurrencyConfigChange(i, n));
307
+ }), this.api.onValueChanged(t.PRODUCT_COUNT, (i) => this._onDataChange(t.PRODUCT_COUNT, i.toString())), this.api.onValueChanged(t.PRODUCT_IN_ROW, (i) => this._onDataChange(t.PRODUCT_IN_ROW, i)), this.api.onValueChanged(t.SHUFFLE_PRODUCTS, (i) => this._onDataChange(t.SHUFFLE_PRODUCTS, i)), this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (o = this.addFilterButton) == null || o.addEventListener("click", this.addFilterListener);
293
308
  }
294
309
  _listenStateUpdates() {
295
310
  this.storeUnsubscription = this.store.$subscribe((e) => {
@@ -301,6 +316,6 @@ class b extends g {
301
316
  }
302
317
  }
303
318
  export {
304
- L as CONTROL_BLOCK_ID,
305
- b as RecommendationBlockControl
319
+ f as CONTROL_BLOCK_ID,
320
+ Y as RecommendationBlockControl
306
321
  };
@@ -0,0 +1,68 @@
1
+ import { ModificationDescription as a } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as d } from "../../common-control.js";
3
+ const c = "recommendation-card-background-color-control", o = {
4
+ CARD_BACKGROUND_COLOR: "cardBackgroundColor"
5
+ };
6
+ class u extends d {
7
+ getId() {
8
+ return c;
9
+ }
10
+ getTemplate() {
11
+ return `
12
+ <div class="card-bg-control-container">
13
+ ${this._GuTwoColumns([
14
+ this._GuLabel({ text: "Card Background Color" }),
15
+ this._GuColorPicker(o.CARD_BACKGROUND_COLOR)
16
+ ])}
17
+ </div>
18
+ `;
19
+ }
20
+ onRender() {
21
+ this._setFormValues(), this._listenToFormUpdates();
22
+ }
23
+ onTemplateNodeUpdated(r) {
24
+ super.onTemplateNodeUpdated(r), this._setFormValues();
25
+ }
26
+ _setFormValues() {
27
+ const r = this._getCurrentCardBackgroundColor();
28
+ this.api.updateValues({
29
+ [o.CARD_BACKGROUND_COLOR]: r
30
+ });
31
+ }
32
+ /**
33
+ * Reads the current background color from the first product card wrapper
34
+ * @returns The background color value or 'transparent' if not found
35
+ */
36
+ _getCurrentCardBackgroundColor() {
37
+ if (!this.currentNode || !("querySelectorAll" in this.currentNode))
38
+ return "transparent";
39
+ const r = this.currentNode.querySelector(".product-card-wrapper");
40
+ return !r || !("getStyle" in r) ? "transparent" : r.getStyle("background-color") || "transparent";
41
+ }
42
+ /**
43
+ * Handles card background color changes
44
+ * Applies the color to all product card wrapper elements
45
+ */
46
+ _onCardBackgroundColorChange(r) {
47
+ if (!this.currentNode || !("querySelectorAll" in this.currentNode))
48
+ return;
49
+ const e = Array.from(
50
+ this.currentNode.querySelectorAll(".product-card-wrapper")
51
+ );
52
+ if (e.length === 0)
53
+ return;
54
+ const t = this.api.getDocumentModifier();
55
+ e.forEach((n) => {
56
+ t.modifyHtml(n).setStyle("background-color", r);
57
+ }), t.apply(new a("Update card background color"));
58
+ }
59
+ _listenToFormUpdates() {
60
+ this.api.onValueChanged(o.CARD_BACKGROUND_COLOR, (r) => {
61
+ this._onCardBackgroundColorChange(r);
62
+ });
63
+ }
64
+ }
65
+ export {
66
+ c as CARD_BACKGROUND_COLOR_CONTROL_ID,
67
+ u as CardBackgroundColorControl
68
+ };