@useinsider/guido 1.0.3-beta.d1ff593 → 1.0.3-beta.d6f4719

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 (68) hide show
  1. package/README.md +126 -0
  2. package/dist/components/organisms/header/LeftSlot.vue.js +1 -1
  3. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -15
  4. package/dist/components/organisms/header/RightSlot.vue.js +5 -5
  5. package/dist/components/organisms/header/RightSlot.vue2.js +20 -19
  6. package/dist/composables/useBlocksConfig.js +58 -0
  7. package/dist/composables/usePartner.js +9 -5
  8. package/dist/composables/useStripo.js +39 -50
  9. package/dist/config/migrator/index.js +6 -7
  10. package/dist/enums/defaults.js +10 -5
  11. package/dist/extensions/Blocks/Recommendation/block.js +2 -5
  12. package/dist/extensions/Blocks/Recommendation/control.js +40 -68
  13. package/dist/extensions/Blocks/Recommendation/extension.js +6 -25
  14. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -58
  15. package/dist/extensions/Blocks/Recommendation/template.js +151 -265
  16. package/dist/extensions/Blocks/common-control.js +43 -125
  17. package/dist/guido.css +1 -1
  18. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +104 -289
  19. package/dist/src/@types/generic.d.ts +7 -0
  20. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  21. package/dist/src/composables/useBlocksConfig.d.ts +11 -0
  22. package/dist/src/composables/usePartner.d.ts +1 -0
  23. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  24. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -6
  25. package/dist/src/extensions/Blocks/Recommendation/template.d.ts +1 -38
  26. package/dist/src/extensions/Blocks/common-control.d.ts +0 -21
  27. package/dist/src/stores/config.d.ts +4 -0
  28. package/package.json +2 -2
  29. package/dist/config/migrator/recommendationMigrator.js +0 -203
  30. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -335
  31. package/dist/extensions/Blocks/Recommendation/controls/button/align.js +0 -12
  32. package/dist/extensions/Blocks/Recommendation/controls/button/border.js +0 -12
  33. package/dist/extensions/Blocks/Recommendation/controls/button/borderRadius.js +0 -12
  34. package/dist/extensions/Blocks/Recommendation/controls/button/color.js +0 -12
  35. package/dist/extensions/Blocks/Recommendation/controls/button/fitToContent.js +0 -12
  36. package/dist/extensions/Blocks/Recommendation/controls/button/fontFamily.js +0 -12
  37. package/dist/extensions/Blocks/Recommendation/controls/button/margins.js +0 -12
  38. package/dist/extensions/Blocks/Recommendation/controls/button/paddings.js +0 -12
  39. package/dist/extensions/Blocks/Recommendation/controls/button/text.js +0 -12
  40. package/dist/extensions/Blocks/Recommendation/controls/button/textSize.js +0 -12
  41. package/dist/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.js +0 -12
  42. package/dist/extensions/Blocks/Recommendation/controls/name/align.js +0 -12
  43. package/dist/extensions/Blocks/Recommendation/controls/name/background.js +0 -12
  44. package/dist/extensions/Blocks/Recommendation/controls/name/color.js +0 -12
  45. package/dist/extensions/Blocks/Recommendation/controls/name/fontFamily.js +0 -12
  46. package/dist/extensions/Blocks/Recommendation/controls/name/paddings.js +0 -12
  47. package/dist/extensions/Blocks/Recommendation/controls/name/size.js +0 -12
  48. package/dist/extensions/Blocks/Recommendation/controls/name/style.js +0 -12
  49. package/dist/src/config/migrator/recommendationMigrator.d.ts +0 -1
  50. package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +0 -65
  51. package/dist/src/extensions/Blocks/Recommendation/controls/button/align.d.ts +0 -5
  52. package/dist/src/extensions/Blocks/Recommendation/controls/button/border.d.ts +0 -5
  53. package/dist/src/extensions/Blocks/Recommendation/controls/button/borderRadius.d.ts +0 -5
  54. package/dist/src/extensions/Blocks/Recommendation/controls/button/color.d.ts +0 -5
  55. package/dist/src/extensions/Blocks/Recommendation/controls/button/fitToContent.d.ts +0 -5
  56. package/dist/src/extensions/Blocks/Recommendation/controls/button/fontFamily.d.ts +0 -5
  57. package/dist/src/extensions/Blocks/Recommendation/controls/button/margins.d.ts +0 -5
  58. package/dist/src/extensions/Blocks/Recommendation/controls/button/paddings.d.ts +0 -5
  59. package/dist/src/extensions/Blocks/Recommendation/controls/button/text.d.ts +0 -5
  60. package/dist/src/extensions/Blocks/Recommendation/controls/button/textSize.d.ts +0 -5
  61. package/dist/src/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.d.ts +0 -5
  62. package/dist/src/extensions/Blocks/Recommendation/controls/name/align.d.ts +0 -5
  63. package/dist/src/extensions/Blocks/Recommendation/controls/name/background.d.ts +0 -5
  64. package/dist/src/extensions/Blocks/Recommendation/controls/name/color.d.ts +0 -5
  65. package/dist/src/extensions/Blocks/Recommendation/controls/name/fontFamily.d.ts +0 -5
  66. package/dist/src/extensions/Blocks/Recommendation/controls/name/paddings.d.ts +0 -5
  67. package/dist/src/extensions/Blocks/Recommendation/controls/name/size.d.ts +0 -5
  68. package/dist/src/extensions/Blocks/Recommendation/controls/name/style.d.ts +0 -5
@@ -1,43 +1,6 @@
1
- import type { RecommendationProduct } from '@@/Types/recommendation';
2
- /**
3
- * Migration template for converting old recommendation blocks (v1) to new format (v2)
4
- *
5
- * This template is used by Stripo to migrate existing emails with old recommendation blocks
6
- * to the new block structure. It preserves user content while updating the HTML structure.
7
- *
8
- * Pattern:
9
- * - Detects old blocks with class "ins-recommendation-v3-block-1"
10
- * - Extracts title from ".ext-recommendation-title"
11
- * - Extracts product cards and reconstructs them in new format
12
- * - Preserves all product data variables ({{1_0_name}}, {{1_0_price}}, etc.)
13
- */
14
- declare const migrationTemplate = "\n <td\n align=\"left\"\n esd-extension-block-id=\"recommendation-block\"\n esd-handler-name=\"esd-extension-RecommendationBlock\"\n class=\"ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20\"\n >\n <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tr>\n <td align=\"center\">\n <table\n class=\"container\"\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\"\n border=\"0\">\n <tbody>\n <tr>\n <td>\n <table\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\"\n border=\"0\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n <tr>\n <td class=\"spacer\" style=\"height: 20px;\"></td>\n </tr>\n <tr>\n <td>\n <table\n class=\"ins-recommendation-product-container\"\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\"\n border=\"0\"\n >\n {-{-PRODUCT_ROWS-}-}\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n </table>\n </td>\n";
15
- /**
16
- * Default card composition order
17
- */
18
- export declare const DEFAULT_CARD_COMPOSITION: string[];
19
- /**
20
- * Prepares product rows HTML with customizable composition order
21
- * @param products - Array of products to display
22
- * @param productsPerRow - Number of products per row
23
- * @param composition - Optional array defining order of card elements
24
- * @returns HTML string for product rows
25
- */
26
- export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[]): string;
27
- /**
28
- * @returns The default mock products for initial template
29
- */
30
- export declare function getDefaultProducts(): RecommendationProduct[];
1
+ declare const migrationTemplate = "ADD YOUR MIGRATION HERE";
31
2
  /**
32
3
  * @returns The template for the default checkbox block
33
4
  */
34
5
  export declare function getDefaultTemplate(): string;
35
- /**
36
- * Generates the complete HTML template with dynamic products and layout
37
- * @param products - Array of products to display
38
- * @param productsPerRow - Number of products per row
39
- * @param title - Optional title for the block
40
- * @returns Complete HTML template
41
- */
42
- export declare function generateTemplate(products: RecommendationProduct[], productsPerRow: number, title?: string): string;
43
6
  export default migrationTemplate;
@@ -62,26 +62,5 @@ export declare abstract class CommonControl extends Control {
62
62
  */
63
63
  _GuIconButton({ name, icon, className }: IconButtonProps): string;
64
64
  _GuTwoColumns(children: string[]): string;
65
- /**
66
- * Creates an orderable (sortable) list control
67
- * @param name - The control name for value binding
68
- * @param items - Array of item keys/values
69
- * @param itemLabels - Optional array of objects with key and label properties for display
70
- * @returns HTML string for the orderable control
71
- */
72
- _GuOrderable(name: string, items: {
73
- key: string;
74
- label: string;
75
- content: string;
76
- }[]): string;
77
- _GuNestedControl(id: string, content: string): string;
78
- _GuExpandable(label: string, content: string): string;
79
- _GuColorPicker(name: string): string;
80
- _GuFontFamily(name: string, placeholder?: string): string;
81
- _GuRadioButtons(name: string, buttons: {
82
- text: string;
83
- value: string;
84
- }[]): string;
85
- _GuCheckbox(name: string, caption: string): string;
86
65
  }
87
66
  export {};
@@ -77,6 +77,10 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"config", S
77
77
  saveAsTemplate?: boolean | undefined;
78
78
  versionHistory?: boolean | undefined;
79
79
  } | undefined;
80
+ blocks?: {
81
+ excludeDefaults?: import("@@/Types/generic").GuidoBlockType[] | undefined;
82
+ includeCustoms?: import("@@/Types/generic").GuidoCustomBlockType[] | undefined;
83
+ } | undefined;
80
84
  };
81
85
  templateConfig?: {
82
86
  preselectedDynamicContentList?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.3-beta.d1ff593",
3
+ "version": "1.0.3-beta.d6f4719",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -31,7 +31,7 @@
31
31
  "author": "",
32
32
  "license": "ISC",
33
33
  "dependencies": {
34
- "@stripoinc/ui-editor-extensions": "3.1.0",
34
+ "@stripoinc/ui-editor-extensions": "3.0.0",
35
35
  "@useinsider/design-system-vue": "0.14.20",
36
36
  "@vueuse/core": "11.3.0",
37
37
  "lodash-es": "4.17.21",
@@ -1,203 +0,0 @@
1
- var b = Object.defineProperty;
2
- var y = (i, e, t) => e in i ? b(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var p = (i, e, t) => y(i, typeof e != "symbol" ? e + "" : e, t);
4
- import h, { getDefaultProducts as x, prepareProductRows as C } from "../../extensions/Blocks/Recommendation/template.js";
5
- class w {
6
- constructor() {
7
- p(this, "parser");
8
- this.parser = new DOMParser();
9
- }
10
- migrate(e) {
11
- try {
12
- const t = this.parser.parseFromString(e, "text/html"), r = t.querySelectorAll(
13
- 'td.ins-recommendation-v3-block-1, td.product-block[esd-handler-name*="EmailRecommendationV3"]'
14
- );
15
- return r.length === 0 ? e : (r.forEach((o) => {
16
- const n = o.getAttribute("id"), s = this.extractBgColor(o), c = this.extractTitle(o), a = this.extractProductRows(o), u = h.replace("{-{-TITLE-}-}", c).replace("{-{-PRODUCT_ROWS-}-}", a), l = this.parser.parseFromString(
17
- `<table id="tempDoc"><tbody><tr>${u}</tr></tbody></table>`,
18
- "text/html"
19
- ).querySelector(".ins-recommendation-v3-block-v2");
20
- l && o.parentNode && (n && l.setAttribute("id", n), console.debug("BG Color", s), s && l.setAttribute("bgcolor", s), o.parentNode.replaceChild(l, o));
21
- }), t.documentElement.outerHTML);
22
- } catch (t) {
23
- return console.error("RecommendationMigrator failed:", t), e;
24
- }
25
- }
26
- /**
27
- * Extracts background color from old block
28
- *
29
- * Checks for background color in the following priority order:
30
- * 1. bgcolor attribute: `<td bgcolor="#f9f9f9">`
31
- * 2. style attribute: `<td style="background-color: #f9f9f9;">`
32
- * @example
33
- * // From bgcolor attribute
34
- * <td bgcolor="#ffffff"> → "#ffffff"
35
- *
36
- * // From style attribute
37
- * <td style="background-color: rgb(255, 255, 255);"> → "rgb(255, 255, 255)"
38
- *
39
- * // No background color
40
- * <td> → ""
41
- * @param block - The old recommendation block element
42
- * @returns The background color value (hex, rgb, rgba, named color) or empty string
43
- */
44
- extractBgColor(e) {
45
- const t = e.getAttribute("bgcolor");
46
- if (console.debug("bg block", e), console.debug("bg attr", t), t)
47
- return t.trim();
48
- const r = e.getAttribute("style");
49
- if (console.debug("bg style", r), r) {
50
- const o = r.match(/background-color\s*:\s*([^;]+)/i);
51
- if (o && o[1])
52
- return o[1].trim();
53
- }
54
- return "";
55
- }
56
- /**
57
- * Extracts title from old block
58
- *
59
- * Old structure:
60
- * <td class="ext-recommendation-title" align="right">
61
- * <p style="color: #93c47d; font-weight: bold; font-style: italic; font-size: 28px;">
62
- * This is amazing recommendation
63
- * </p>
64
- * </td>
65
- *
66
- * New structure (output):
67
- * <td class="esd-block-text es-p10t es-p10b es-p20l es-p20r" align="center">
68
- * <p path="1" style="font-size: 28px; color: #333333;">
69
- * <strong path="1,0">Title Text</strong>
70
- * </p>
71
- * </td>
72
- */
73
- extractTitle(e) {
74
- var l, d;
75
- const t = e.querySelector(".ext-recommendation-title");
76
- if (!t)
77
- return this.buildTitleBlock({
78
- text: "You May Also Like!",
79
- isBold: !0,
80
- isItalic: !1,
81
- align: "center",
82
- styles: "font-size: 28px; color: #333333;"
83
- });
84
- const r = t.querySelector("p");
85
- if (!r) {
86
- const m = ((l = t.textContent) == null ? void 0 : l.trim()) || "You May Also Like!", f = t.getAttribute("align") || "center";
87
- return this.buildTitleBlock({
88
- text: m,
89
- isBold: !0,
90
- isItalic: !1,
91
- align: f,
92
- styles: "font-size: 28px; color: #333333;"
93
- });
94
- }
95
- const o = ((d = r.textContent) == null ? void 0 : d.trim()) || "You May Also Like!", n = t.getAttribute("align") || r.getAttribute("align") || "center", s = r.getAttribute("style") || "", c = /font-weight\s*:\s*bold/i.test(s) || !!r.querySelector("b, strong"), a = /font-style\s*:\s*italic/i.test(s) || !!r.querySelector("i, em"), u = this.removeStyleProperties(s, ["font-weight", "font-style"]), g = this.convertInlineToBlock(u);
96
- return this.buildTitleBlock({
97
- text: o,
98
- isBold: c,
99
- isItalic: a,
100
- align: n,
101
- styles: g
102
- });
103
- }
104
- /**
105
- * Extracts product configuration from old block and generates new product rows
106
- *
107
- * Strategy:
108
- * 1. Extract product count and layout configuration from old block
109
- * 2. Use prepareProductRows() to generate new HTML structure with default product data
110
- *
111
- * The migrator uses default/placeholder product data from getDefaultProducts()
112
- * to populate the new block structure.
113
- */
114
- extractProductRows(e) {
115
- const t = this.extractProductConfig(e);
116
- if (!t)
117
- return console.warn("[RecommendationMigrator] No product config found, using defaults"), this.generateProductRows(6, 3);
118
- const { totalCount: r, rowCount: o } = t;
119
- return this.generateProductRows(r, o);
120
- }
121
- /**
122
- * Extracts product configuration from old block
123
- *
124
- * Parses esd-dev-product-config attribute:
125
- * {"rowCount":3,"totalCount":6,"orientation":"vertical",...}
126
- */
127
- extractProductConfig(e) {
128
- const t = e.getAttribute("esd-dev-product-config");
129
- if (!t)
130
- return null;
131
- try {
132
- const r = t.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">"), o = JSON.parse(r);
133
- return {
134
- totalCount: o.totalCount ?? 6,
135
- rowCount: o.rowCount ?? 3
136
- };
137
- } catch (r) {
138
- return console.error("[RecommendationMigrator] Failed to parse product config:", r), null;
139
- }
140
- }
141
- /**
142
- * Generates product rows using prepareProductRows with default product data
143
- *
144
- * Process:
145
- * 1. Get default products from getDefaultProducts()
146
- * 2. Create array of products (repeat defaults if needed to reach totalCount)
147
- * 3. Call prepareProductRows() to generate HTML structure
148
- *
149
- * The generated HTML will contain placeholder/default product data
150
- * which can be replaced with real data at runtime.
151
- * @param totalCount - Total number of products (e.g., 6)
152
- * @param productsPerRow - Products per row (e.g., 3)
153
- */
154
- generateProductRows(e, t) {
155
- const r = x(), o = [];
156
- for (let n = 0; n < e; n++) {
157
- const s = r[n % r.length];
158
- o.push({ ...s });
159
- }
160
- return C(o, t);
161
- }
162
- /**
163
- * Builds title block with proper structure
164
- */
165
- buildTitleBlock(e) {
166
- let t = e.text;
167
- e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
168
- const r = e.align ? ` align="${e.align}"` : "", o = e.styles ? ` style="${e.styles}"` : "";
169
- return `
170
- <td class="esd-block-text es-p10t es-p10b es-p20l es-p20r"${r}>
171
- <p path="1"${o}>
172
- ${t}
173
- </p>
174
- </td>
175
- `;
176
- }
177
- /**
178
- * Removes specified style properties from a style string
179
- * Helper from CheckboxMigrator
180
- */
181
- removeStyleProperties(e, t) {
182
- return e ? t.reduce((o, n) => {
183
- const s = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
184
- return o.replace(s, "");
185
- }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
186
- }
187
- /**
188
- * Converts inline display to block display
189
- * Helper from CheckboxMigrator
190
- */
191
- convertInlineToBlock(e) {
192
- if (!e)
193
- return "";
194
- let t = e.replace(/display\s*:\s*inline/gi, "display: block");
195
- return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
196
- }
197
- }
198
- function P(i) {
199
- return new w().migrate(i);
200
- }
201
- export {
202
- P as migrateRecommendation
203
- };
@@ -1,335 +0,0 @@
1
- var h = Object.defineProperty;
2
- var f = (c, l, t) => l in c ? h(c, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[l] = t;
3
- var u = (c, l, t) => f(c, typeof l != "symbol" ? l + "" : l, t);
4
- import { ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as y } from "../common-control.js";
6
- const m = "ui-elements-recommendation-card-composition", d = [
7
- { key: "productImage", label: "Product Image" },
8
- { key: "productName", label: "Product Name" },
9
- { key: "productPrice", label: "Product Price" },
10
- { key: "productOriginalPrice", label: "Product Original Price" },
11
- { key: "productButton", label: "Product Button" }
12
- ];
13
- class b extends y {
14
- constructor() {
15
- super(...arguments);
16
- u(this, "currentComposition", []);
17
- u(this, "currentStyling", {});
18
- }
19
- getId() {
20
- return m;
21
- }
22
- getTemplate() {
23
- const t = d.map((e) => {
24
- let i = "";
25
- return e.key === "productName" ? i = this._getProductNameStylingControls() : e.key === "productPrice" ? i = this._getProductPriceStylingControls() : e.key === "productOriginalPrice" ? i = this._getProductOriginalPriceStylingControls() : e.key === "productButton" && (i = this._getProductButtonStylingControls()), {
26
- key: e.key,
27
- label: e.label,
28
- content: i ? this._GuExpandable(e.label, i) : ""
29
- };
30
- });
31
- return console.debug("orderable", this._GuOrderable("cardComposition", t)), `
32
- <div class="container">
33
- ${this._GuLabel({ text: "Card Element Order" })}
34
- ${this._GuOrderable("cardComposition", t)}
35
- </div>
36
- `;
37
- }
38
- _getTextColor(t, e) {
39
- return `
40
- ${this._GuTwoColumns([
41
- this._GuLabel({ text: t }),
42
- this._GuColorPicker(e)
43
- ])}
44
- `;
45
- }
46
- _getFontFamily(t, e) {
47
- return `
48
- ${this._GuTwoColumns([
49
- this._GuLabel({ text: t }),
50
- this._GuFontFamily(e, "Select Font")
51
- ])}
52
- `;
53
- }
54
- /**
55
- * Generate styling controls for Product Name element
56
- */
57
- _getProductNameStylingControls() {
58
- return `
59
- ${this._getTextColor("Text Color", "productName.color")}
60
-
61
- <div class="control-group" style="padding: 10px 0;">
62
- ${this._GuLabel({ text: "Text Alignment" })}
63
- ${this._GuRadioButtons("productName.textAlign", [
64
- { text: "Left", value: "left" },
65
- { text: "Center", value: "center" },
66
- { text: "Right", value: "right" },
67
- { text: "Justify", value: "justify" }
68
- ])}
69
- </div>
70
-
71
- ${this._getFontFamily("Font Family", "productName.fontFamily")}
72
-
73
- <div class="control-group" style="padding: 10px 0;">
74
- ${this._GuLabel({ text: "Font Size (px)" })}
75
- ${this._GuCounter({ name: "productName.fontSize", minValue: 8, maxValue: 72, step: 1 })}
76
- </div>
77
-
78
- <div class="control-group" style="padding: 10px 0;">
79
- ${this._GuLabel({ text: "Text Style" })}
80
- <div style="display: flex; flex-direction: column; gap: 8px; margin-top: 8px;">
81
- ${this._GuCheckbox("productName.fontWeight", "Bold")}
82
- ${this._GuCheckbox("productName.fontStyle", "Italic")}
83
- ${this._GuCheckbox("productName.textDecoration", "Underline")}
84
- </div>
85
- </div>
86
- `;
87
- }
88
- /**
89
- * Generate styling controls for Product Price element
90
- */
91
- _getProductPriceStylingControls() {
92
- return `
93
- <div class="control-group" style="padding: 10px 0;">
94
- ${this._GuLabel({ text: "Text Color" })}
95
- ${this._GuColorPicker("productPrice.color")}
96
- </div>
97
-
98
- <div class="control-group" style="padding: 10px 0;">
99
- ${this._GuLabel({ text: "Text Alignment" })}
100
- ${this._GuRadioButtons("productPrice.textAlign", [
101
- { text: "Left", value: "left" },
102
- { text: "Center", value: "center" },
103
- { text: "Right", value: "right" }
104
- ])}
105
- </div>
106
-
107
- <div class="control-group" style="padding: 10px 0;">
108
- ${this._GuLabel({ text: "Font Size (px)" })}
109
- ${this._GuCounter({ name: "productPrice.fontSize", minValue: 8, maxValue: 48, step: 1 })}
110
- </div>
111
-
112
- <div class="control-group" style="padding: 10px 0;">
113
- ${this._GuCheckbox("productPrice.fontWeight", "Bold")}
114
- </div>
115
- `;
116
- }
117
- /**
118
- * Generate styling controls for Product Original Price element
119
- */
120
- _getProductOriginalPriceStylingControls() {
121
- return `
122
- <div class="control-group" style="padding: 10px 0;">
123
- ${this._GuLabel({ text: "Text Color" })}
124
- ${this._GuColorPicker("productOriginalPrice.color")}
125
- </div>
126
-
127
- <div class="control-group" style="padding: 10px 0;">
128
- ${this._GuLabel({ text: "Font Size (px)" })}
129
- ${this._GuCounter({ name: "productOriginalPrice.fontSize", minValue: 8, maxValue: 48, step: 1 })}
130
- </div>
131
- `;
132
- }
133
- /**
134
- * Generate styling controls for Product Button element
135
- */
136
- _getProductButtonStylingControls() {
137
- return `
138
- <div class="control-group" style="padding: 10px 0;">
139
- ${this._GuLabel({ text: "Button Text Color" })}
140
- ${this._GuColorPicker("productButton.color")}
141
- </div>
142
-
143
- <div class="control-group" style="padding: 10px 0;">
144
- ${this._GuLabel({ text: "Font Size (px)" })}
145
- ${this._GuCounter({ name: "productButton.fontSize", minValue: 10, maxValue: 32, step: 1 })}
146
- </div>
147
-
148
- <div class="control-group" style="padding: 10px 0;">
149
- ${this._GuCheckbox("productButton.fontWeight", "Bold")}
150
- </div>
151
- `;
152
- }
153
- onRender() {
154
- this._initializeComposition(), this._initializeStyling(), this.api.onValueChanged("cardComposition", (t) => {
155
- this.currentComposition = t, console.debug("Card composition reordered:", t), this._applyCompositionToBlock(t);
156
- }), this.api.onValueChanged("productName.color", (t) => {
157
- this._updateElementStyling("productName", "color", t), this._applyStylingToElement("productName");
158
- }), this.api.onValueChanged("productName.textAlign", (t) => {
159
- this._updateElementStyling("productName", "textAlign", t), this._applyStylingToElement("productName");
160
- }), this.api.onValueChanged("productName.fontFamily", (t) => {
161
- this._updateElementStyling("productName", "fontFamily", t), this._applyStylingToElement("productName");
162
- }), this.api.onValueChanged("productName.fontSize", (t) => {
163
- this._updateElementStyling("productName", "fontSize", t), this._applyStylingToElement("productName");
164
- }), this.api.onValueChanged("productName.fontWeight", (t) => {
165
- this._updateElementStyling("productName", "fontWeight", t), this._applyStylingToElement("productName");
166
- }), this.api.onValueChanged("productName.fontStyle", (t) => {
167
- this._updateElementStyling("productName", "fontStyle", t), this._applyStylingToElement("productName");
168
- }), this.api.onValueChanged("productName.textDecoration", (t) => {
169
- this._updateElementStyling("productName", "textDecoration", t), this._applyStylingToElement("productName");
170
- }), this.api.onValueChanged("productPrice.color", (t) => {
171
- this._updateElementStyling("productPrice", "color", t), this._applyStylingToElement("productPrice");
172
- }), this.api.onValueChanged("productPrice.textAlign", (t) => {
173
- this._updateElementStyling("productPrice", "textAlign", t), this._applyStylingToElement("productPrice");
174
- }), this.api.onValueChanged("productPrice.fontSize", (t) => {
175
- this._updateElementStyling("productPrice", "fontSize", t), this._applyStylingToElement("productPrice");
176
- }), this.api.onValueChanged("productPrice.fontWeight", (t) => {
177
- this._updateElementStyling("productPrice", "fontWeight", t), this._applyStylingToElement("productPrice");
178
- }), this.api.onValueChanged("productOriginalPrice.color", (t) => {
179
- this._updateElementStyling("productOriginalPrice", "color", t), this._applyStylingToElement("productOriginalPrice");
180
- }), this.api.onValueChanged("productOriginalPrice.fontSize", (t) => {
181
- this._updateElementStyling("productOriginalPrice", "fontSize", t), this._applyStylingToElement("productOriginalPrice");
182
- }), this.api.onValueChanged("productButton.color", (t) => {
183
- this._updateElementStyling("productButton", "color", t), this._applyStylingToElement("productButton");
184
- }), this.api.onValueChanged("productButton.fontSize", (t) => {
185
- this._updateElementStyling("productButton", "fontSize", t), this._applyStylingToElement("productButton");
186
- }), this.api.onValueChanged("productButton.fontWeight", (t) => {
187
- this._updateElementStyling("productButton", "fontWeight", t), this._applyStylingToElement("productButton");
188
- });
189
- }
190
- onTemplateNodeUpdated(t) {
191
- super.onTemplateNodeUpdated(t), this._initializeComposition();
192
- }
193
- /**
194
- * Initialize the composition order from the block or use defaults
195
- */
196
- _initializeComposition() {
197
- var i;
198
- const t = (i = this.currentNode) == null ? void 0 : i.querySelector(".ins-recommendation-v3-block-v2");
199
- let e = null;
200
- if (t && "getAttribute" in t && (e = t.getAttribute("data-card-composition")), e) {
201
- const o = e.split(",").filter(Boolean), s = d.map((n) => n.key);
202
- o.every((n) => s.includes(n)) && o.length > 0 ? this.currentComposition = o : this.currentComposition = s;
203
- } else
204
- this.currentComposition = d.map((o) => o.key);
205
- this.api.updateValues({
206
- cardComposition: this.currentComposition
207
- });
208
- }
209
- /**
210
- * Apply the reordered composition to the block's HTML structure
211
- */
212
- _applyCompositionToBlock(t) {
213
- if (!this.currentNode)
214
- return;
215
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
216
- e && this.api.getDocumentModifier().modifyHtml(e).setAttribute("data-card-composition", t.join(",")).apply(new p("Stored card composition order")), console.debug("Card composition updated:", t);
217
- }
218
- /**
219
- * Initialize styling from stored block attributes
220
- */
221
- _initializeStyling() {
222
- var i;
223
- const t = (i = this.currentNode) == null ? void 0 : i.querySelector(".ins-recommendation-v3-block-v2");
224
- if (!t || !("getAttribute" in t)) {
225
- this._loadDefaultStyling();
226
- return;
227
- }
228
- const e = t.getAttribute("data-card-styling");
229
- if (e)
230
- try {
231
- this.currentStyling = JSON.parse(e), this._populateControlsWithStyling();
232
- } catch (o) {
233
- console.error("Failed to parse stored styling:", o), this._loadDefaultStyling();
234
- }
235
- else
236
- this._loadDefaultStyling();
237
- }
238
- /**
239
- * Load default styling values and populate controls
240
- */
241
- _loadDefaultStyling() {
242
- this.currentStyling = {
243
- productName: {
244
- color: "#333333",
245
- textAlign: "center",
246
- fontSize: 16,
247
- fontWeight: !0
248
- },
249
- productPrice: {
250
- color: "#333333",
251
- textAlign: "center",
252
- fontSize: 16,
253
- fontWeight: !0
254
- },
255
- productOriginalPrice: {
256
- color: "#999999",
257
- fontSize: 14
258
- },
259
- productButton: {
260
- color: "#333333",
261
- fontSize: 16
262
- }
263
- }, this._populateControlsWithStyling();
264
- }
265
- /**
266
- * Populate control values with current styling
267
- */
268
- _populateControlsWithStyling() {
269
- const t = {};
270
- if (this.currentStyling.productName) {
271
- const e = this.currentStyling.productName;
272
- e.color && (t["productName.color"] = e.color), e.textAlign && (t["productName.textAlign"] = e.textAlign), e.fontFamily && (t["productName.fontFamily"] = e.fontFamily), e.fontSize && (t["productName.fontSize"] = e.fontSize), e.fontWeight !== void 0 && (t["productName.fontWeight"] = e.fontWeight), e.fontStyle !== void 0 && (t["productName.fontStyle"] = e.fontStyle), e.textDecoration !== void 0 && (t["productName.textDecoration"] = e.textDecoration);
273
- }
274
- if (this.currentStyling.productPrice) {
275
- const e = this.currentStyling.productPrice;
276
- e.color && (t["productPrice.color"] = e.color), e.textAlign && (t["productPrice.textAlign"] = e.textAlign), e.fontSize && (t["productPrice.fontSize"] = e.fontSize), e.fontWeight !== void 0 && (t["productPrice.fontWeight"] = e.fontWeight);
277
- }
278
- if (this.currentStyling.productOriginalPrice) {
279
- const e = this.currentStyling.productOriginalPrice;
280
- e.color && (t["productOriginalPrice.color"] = e.color), e.fontSize && (t["productOriginalPrice.fontSize"] = e.fontSize);
281
- }
282
- if (this.currentStyling.productButton) {
283
- const e = this.currentStyling.productButton;
284
- e.color && (t["productButton.color"] = e.color), e.fontSize && (t["productButton.fontSize"] = e.fontSize), e.fontWeight !== void 0 && (t["productButton.fontWeight"] = e.fontWeight);
285
- }
286
- this.api.updateValues(t);
287
- }
288
- /**
289
- * Update styling object for a specific element and property
290
- */
291
- _updateElementStyling(t, e, i) {
292
- this.currentStyling[t] || (this.currentStyling[t] = {});
293
- const o = this.currentStyling[t];
294
- o && (e === "color" && typeof i == "string" ? o.color = i : e === "textAlign" && typeof i == "string" ? o.textAlign = i : e === "fontFamily" && typeof i == "string" ? o.fontFamily = i : e === "fontSize" && typeof i == "number" ? o.fontSize = i : e === "fontWeight" && typeof i == "boolean" ? o.fontWeight = i : e === "fontStyle" && typeof i == "boolean" ? o.fontStyle = i : e === "textDecoration" && typeof i == "boolean" && (o.textDecoration = i)), this._persistStyling();
295
- }
296
- /**
297
- * Persist current styling to block attributes
298
- */
299
- _persistStyling() {
300
- if (!this.currentNode)
301
- return;
302
- const t = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
303
- t && this.api.getDocumentModifier().modifyHtml(t).setAttribute("data-card-styling", JSON.stringify(this.currentStyling)).apply(new p("Updated card element styling"));
304
- }
305
- /**
306
- * Apply styling to a specific element in the DOM
307
- */
308
- _applyStylingToElement(t) {
309
- if (!this.currentNode)
310
- return;
311
- const e = this.currentStyling[t];
312
- if (!e)
313
- return;
314
- const o = {
315
- productName: ".product-name-cell",
316
- productPrice: ".price-cell .current-price",
317
- productOriginalPrice: ".price-cell .old-price",
318
- productButton: ".buy-button"
319
- }[t];
320
- if (!o)
321
- return;
322
- this.currentNode.querySelectorAll(o).forEach((a) => {
323
- if (!a || !("style" in a))
324
- return;
325
- const n = [];
326
- e.color && n.push(`color: ${e.color}`), e.textAlign && n.push(`text-align: ${e.textAlign}`), e.fontFamily && n.push(`font-family: ${e.fontFamily}`), e.fontSize && n.push(`font-size: ${e.fontSize}px`), e.fontWeight ? n.push("font-weight: bold") : e.fontWeight === !1 && n.push("font-weight: normal"), e.fontStyle ? n.push("font-style: italic") : e.fontStyle === !1 && n.push("font-style: normal"), e.textDecoration ? n.push("text-decoration: underline") : e.textDecoration === !1 && n.push("text-decoration: none");
327
- const g = [...(("getAttribute" in a ? a.getAttribute("style") : null) || "").split(";").map((r) => r.trim()).filter((r) => r && !r.startsWith("color:") && !r.startsWith("text-align:") && !r.startsWith("font-family:") && !r.startsWith("font-size:") && !r.startsWith("font-weight:") && !r.startsWith("font-style:") && !r.startsWith("text-decoration:")), ...n].join("; ");
328
- this.api.getDocumentModifier().modifyHtml(a).setAttribute("style", g).apply(new p(`Applied ${t} styling`));
329
- });
330
- }
331
- }
332
- export {
333
- m as COMPOSITION_CONTROL_BLOCK_ID,
334
- b as RecommendationCardCompositionControl
335
- };
@@ -1,12 +0,0 @@
1
- import { ButtonAlignBuiltInControl as o } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- class r extends o {
3
- getId() {
4
- return "recommendation-block-button-align-control";
5
- }
6
- getTargetNodes(t) {
7
- return t.closest(".ins-recommendation-product-container").querySelectorAll('[esd-extension-block-id="recommendation-block-button"]');
8
- }
9
- }
10
- export {
11
- r as ButtonAlignControl
12
- };
@@ -1,12 +0,0 @@
1
- import { ButtonBorderBuiltInControl as o } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- class l extends o {
3
- getId() {
4
- return "recommendation-block-button-border-control";
5
- }
6
- getTargetNodes(t) {
7
- return t.closest(".ins-recommendation-product-container").querySelectorAll('[esd-extension-block-id="recommendation-block-button"]');
8
- }
9
- }
10
- export {
11
- l as ButtonBorderControl
12
- };