@useinsider/guido 1.0.3-beta.2cf8046 → 1.0.3-beta.2df2106

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 (116) hide show
  1. package/README.md +3 -32
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/organisms/LoadingWrapper.vue.js +1 -1
  4. package/dist/components/organisms/header/RightSlot.vue2.js +13 -13
  5. package/dist/composables/useActionsApi.js +1 -1
  6. package/dist/composables/useHtmlCompiler.js +15 -13
  7. package/dist/composables/useHtmlValidator.js +36 -35
  8. package/dist/composables/useStripo.js +29 -25
  9. package/dist/config/compiler/itemsCompilerRules.js +14 -0
  10. package/dist/enums/unsubscribe.js +27 -26
  11. package/dist/extensions/Blocks/Checkbox/control.js +15 -14
  12. package/dist/extensions/Blocks/Checkbox/template.js +14 -9
  13. package/dist/extensions/Blocks/Items/block.js +26 -26
  14. package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
  15. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +92 -0
  16. package/dist/extensions/Blocks/Items/controls/settingsControl.js +150 -114
  17. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  18. package/dist/extensions/Blocks/Items/enums/productEnums.js +77 -4
  19. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +3 -2
  20. package/dist/extensions/Blocks/Items/extension.js +7 -6
  21. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +57 -56
  22. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +67 -56
  23. package/dist/extensions/Blocks/Items/settingsPanel.js +69 -43
  24. package/dist/extensions/Blocks/Items/store/items-block.js +8 -4
  25. package/dist/extensions/Blocks/Items/template.js +147 -62
  26. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +35 -26
  27. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +29 -27
  28. package/dist/extensions/Blocks/RadioButton/control.js +18 -17
  29. package/dist/extensions/Blocks/RadioButton/template.js +18 -9
  30. package/dist/extensions/Blocks/Unsubscribe/block.js +45 -41
  31. package/dist/guido.css +1 -1
  32. package/dist/node_modules/lodash-es/_DataView.js +6 -0
  33. package/dist/node_modules/lodash-es/_Promise.js +6 -0
  34. package/dist/node_modules/lodash-es/_Set.js +6 -0
  35. package/dist/node_modules/lodash-es/_SetCache.js +13 -0
  36. package/dist/node_modules/lodash-es/_WeakMap.js +6 -0
  37. package/dist/node_modules/lodash-es/_arrayFilter.js +10 -0
  38. package/dist/node_modules/lodash-es/_arrayLikeKeys.js +13 -12
  39. package/dist/node_modules/lodash-es/_arrayMap.js +8 -0
  40. package/dist/node_modules/lodash-es/_arrayPush.js +8 -0
  41. package/dist/node_modules/lodash-es/_arraySome.js +9 -0
  42. package/dist/node_modules/lodash-es/_baseEach.js +6 -0
  43. package/dist/node_modules/lodash-es/_baseFlatten.js +13 -0
  44. package/dist/node_modules/lodash-es/_baseForOwn.js +8 -0
  45. package/dist/node_modules/lodash-es/_baseGet.js +11 -0
  46. package/dist/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  47. package/dist/node_modules/lodash-es/_baseHasIn.js +6 -0
  48. package/dist/node_modules/lodash-es/_baseIsEqual.js +8 -0
  49. package/dist/node_modules/lodash-es/_baseIsEqualDeep.js +32 -0
  50. package/dist/node_modules/lodash-es/_baseIsMatch.js +29 -0
  51. package/dist/node_modules/lodash-es/_baseIteratee.js +11 -0
  52. package/dist/node_modules/lodash-es/_baseKeys.js +14 -0
  53. package/dist/node_modules/lodash-es/_baseMap.js +11 -0
  54. package/dist/node_modules/lodash-es/_baseMatches.js +12 -0
  55. package/dist/node_modules/lodash-es/_baseMatchesProperty.js +17 -0
  56. package/dist/node_modules/lodash-es/_baseProperty.js +8 -0
  57. package/dist/node_modules/lodash-es/_basePropertyDeep.js +9 -0
  58. package/dist/node_modules/lodash-es/_baseRange.js +9 -0
  59. package/dist/node_modules/lodash-es/_baseToString.js +18 -0
  60. package/dist/node_modules/lodash-es/_baseTrim.js +8 -0
  61. package/dist/node_modules/lodash-es/_cacheHas.js +6 -0
  62. package/dist/node_modules/lodash-es/_castPath.js +10 -0
  63. package/dist/node_modules/lodash-es/_createBaseEach.js +15 -0
  64. package/dist/node_modules/lodash-es/_createRange.js +11 -0
  65. package/dist/node_modules/lodash-es/_equalArrays.js +40 -0
  66. package/dist/node_modules/lodash-es/_equalByTag.js +45 -0
  67. package/dist/node_modules/lodash-es/_equalObjects.js +36 -0
  68. package/dist/node_modules/lodash-es/_getAllKeys.js +9 -0
  69. package/dist/node_modules/lodash-es/_getMatchData.js +12 -0
  70. package/dist/node_modules/lodash-es/_getSymbols.js +10 -0
  71. package/dist/node_modules/lodash-es/_getTag.js +28 -0
  72. package/dist/node_modules/lodash-es/_hasPath.js +19 -0
  73. package/dist/node_modules/lodash-es/_isFlattenable.js +10 -0
  74. package/dist/node_modules/lodash-es/_isKey.js +12 -0
  75. package/dist/node_modules/lodash-es/_isStrictComparable.js +7 -0
  76. package/dist/node_modules/lodash-es/_mapToArray.js +9 -0
  77. package/dist/node_modules/lodash-es/_matchesStrictComparable.js +8 -0
  78. package/dist/node_modules/lodash-es/_memoizeCapped.js +11 -0
  79. package/dist/node_modules/lodash-es/_nativeKeys.js +5 -0
  80. package/dist/node_modules/lodash-es/_setCacheAdd.js +7 -0
  81. package/dist/node_modules/lodash-es/_setCacheHas.js +6 -0
  82. package/dist/node_modules/lodash-es/_setToArray.js +9 -0
  83. package/dist/node_modules/lodash-es/_stringToPath.js +10 -0
  84. package/dist/node_modules/lodash-es/_toKey.js +10 -0
  85. package/dist/node_modules/lodash-es/_trimmedEndIndex.js +9 -0
  86. package/dist/node_modules/lodash-es/flatMap.js +8 -0
  87. package/dist/node_modules/lodash-es/get.js +8 -0
  88. package/dist/node_modules/lodash-es/hasIn.js +8 -0
  89. package/dist/node_modules/lodash-es/isSymbol.js +9 -0
  90. package/dist/node_modules/lodash-es/keys.js +9 -0
  91. package/dist/node_modules/lodash-es/keysIn.js +3 -3
  92. package/dist/node_modules/lodash-es/map.js +11 -0
  93. package/dist/node_modules/lodash-es/property.js +10 -0
  94. package/dist/node_modules/lodash-es/range.js +5 -0
  95. package/dist/node_modules/lodash-es/stubArray.js +6 -0
  96. package/dist/node_modules/lodash-es/toFinite.js +14 -0
  97. package/dist/node_modules/lodash-es/toNumber.js +22 -0
  98. package/dist/node_modules/lodash-es/toString.js +7 -0
  99. package/dist/src/config/compiler/itemsCompilerRules.d.ts +2 -0
  100. package/dist/src/extensions/Blocks/Checkbox/template.d.ts +1 -1
  101. package/dist/src/extensions/Blocks/Items/block.d.ts +14 -0
  102. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +15 -0
  103. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +8 -2
  104. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  105. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  106. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
  107. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
  108. package/dist/src/extensions/Blocks/Items/template.d.ts +9 -1
  109. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +6 -0
  110. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  111. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +3 -4
  112. package/dist/src/utils/environmentUtil.d.ts +5 -0
  113. package/dist/src/utils/pairProductVariables.d.ts +7 -0
  114. package/dist/utils/environmentUtil.js +4 -0
  115. package/dist/utils/pairProductVariables.js +136 -0
  116. package/package.json +5 -10
@@ -42,3 +42,9 @@ export declare function syncButtonLinkFromAttributes(currentNode: ImmutableHtmlN
42
42
  * @param currentNode - The current node from the control (usually this.currentNode)
43
43
  */
44
44
  export declare function syncImageLinkFromAttributes(currentNode: ImmutableHtmlNode | undefined): void;
45
+ /**
46
+ * Reads price orientation value from esd-config-block attribute and updates the store.
47
+ * This makes the price orientation value mutable by syncing it from the DOM.
48
+ * @param currentNode - The current node from the control (usually this.currentNode)
49
+ */
50
+ export declare function syncPriceOrientationFromAttributes(currentNode: ImmutableHtmlNode | undefined): void;
@@ -1,4 +1,4 @@
1
- declare const migrationTemplate = "\n <td \n align=\"left\" \n esd-extension-block-id=\"radio-button-block\" \n esd-handler-name=\"esd-extension-RadioButtonBlock\"\n class=\"radio-button-v2 esd-block-ra esd-radio-button-block esd-extension-block es-p10t es-p10b es-p30r es-p30l\"\n >\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td align=\"left\" width=\"70%\" style=\"vertical-align: top;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n <tr>\n {-{-DESCRIPTION-}-}\n </tr>\n </tbody>\n </table>\n </td>\n <td align=\"right\" width=\"30%\" style=\"vertical-align: middle;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioYes\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;>\n </td>\n {-{-YES-}-}\n </tr>\n </table>\n </td>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioNo\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;\">\n </td>\n {-{-NO-}-}\n </tr>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n";
1
+ declare const migrationTemplate = "\n <td\n align=\"left\"\n esd-extension-block-id=\"radio-button-block\"\n esd-handler-name=\"esd-extension-RadioButtonBlock\"\n class=\"\n radio-button\n radio-button-v2\n esd-block-ra\n esd-radio-button-block\n esd-extension-block\n es-p10t\n es-p10b\n es-p30r\n es-p30l\"\n >\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td align=\"left\" width=\"70%\" style=\"vertical-align: top;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n <tr>\n {-{-DESCRIPTION-}-}\n </tr>\n </tbody>\n </table>\n </td>\n <td align=\"right\" width=\"30%\" style=\"vertical-align: middle;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioYes\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;>\n </td>\n {-{-YES-}-}\n </tr>\n </table>\n </td>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioNo\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;\">\n </td>\n {-{-NO-}-}\n </tr>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n";
2
2
  /**
3
3
  * @returns The template for the default checkbox block
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
1
+ import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
2
2
  import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
3
3
  export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
4
4
  export declare class UnsubscribeBlock extends Block {
@@ -12,9 +12,8 @@ export declare class UnsubscribeBlock extends Block {
12
12
  getName(): string;
13
13
  getDescription(): string;
14
14
  getTemplate(): string;
15
- onCreated(node: ImmutableHtmlNode): void;
16
- onSelect(node: ImmutableHtmlNode): undefined;
17
- onDelete(node: ImmutableHtmlNode): undefined;
15
+ onSelect(node: ImmutableHtmlElementNode): void;
16
+ onDelete(node: ImmutableHtmlElementNode): void;
18
17
  onDestroy(): void;
19
18
  private _setupSelectEventListener;
20
19
  private _removeSelectEventListener;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Gets the appropriate environment prefix by parsing from current hostname
3
+ * Extracts environment prefix from domains by splitting hostname
4
+ */
5
+ export declare const getEnvironmentPrefix: () => string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Transforms product-related HTML elements from default/dummy values to template variables.
3
+ * This method is called before saving email templates to ensure product data is properly templated.
4
+ * @param html - The HTML string containing product elements
5
+ * @returns The transformed HTML with template variables
6
+ */
7
+ export declare function pairProductVariables(html: string): string;
@@ -0,0 +1,4 @@
1
+ const n = () => window.location.hostname.split(".")[2];
2
+ export {
3
+ n as getEnvironmentPrefix
4
+ };
@@ -0,0 +1,136 @@
1
+ import { productPairs as w } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ function M(H) {
3
+ const m = H.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), $ = new DOMParser().parseFromString(m, "text/html"), C = w.PAIRS_FOR_EXTENSION;
4
+ Object.entries(C).forEach(([n, d]) => {
5
+ $.querySelectorAll(".ins-product-td").forEach((o) => {
6
+ const h = o.getAttribute("data-number") || "1", _ = o.getAttribute("data-type") || "CART_ITEMS";
7
+ o.querySelectorAll(`[product-attr="${n}"]`).forEach((e) => {
8
+ var y;
9
+ const b = e.getAttribute("data-type") || _, u = e.getAttribute("data-number") || h, p = d[b];
10
+ if (p)
11
+ switch (n) {
12
+ case "imageSrc": {
13
+ let t = null, i = null;
14
+ if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
15
+ break;
16
+ const c = p.DEFAULT, a = p.ATTR;
17
+ if (c && t.src) {
18
+ const r = t.src;
19
+ c.some((l) => {
20
+ const s = l.split("/").pop() || "", F = r.split("/").pop() || "";
21
+ return r.includes(l) || r.includes(s) || F === s;
22
+ }) && (t.src = `{{${a}_${u}}}`);
23
+ }
24
+ if (i) {
25
+ const r = (y = C.itemLink) == null ? void 0 : y[b];
26
+ if (r) {
27
+ const f = r.HREF, l = r.DEFAULT_HREF || "#!", s = i.href;
28
+ (s === "#" || s === "" || s.endsWith("#!") || s.endsWith(l) || s === `${window.location.href}${l}` || !s || s === window.location.href) && (i.href = `{{${f}_${u}}}`);
29
+ }
30
+ }
31
+ break;
32
+ }
33
+ case "name": {
34
+ const t = p, i = t.ATTR, c = t.DEFAULT_HREF || "#!", a = t.HREF;
35
+ e.textContent && (e.textContent = `{{${i}_${u}}}`);
36
+ const r = e.closest("a") || (e.tagName === "A" ? e : null);
37
+ if (r && a) {
38
+ const f = r.href, l = `${window.location.href}${c}`;
39
+ (f === l || f.endsWith(c)) && (r.href = `{{${a}_${u}}}`);
40
+ }
41
+ break;
42
+ }
43
+ case "price":
44
+ case "originalPrice": {
45
+ const t = p, c = e.getAttribute("data-formated") === "true", a = e.getAttribute("data-curency") || "before", r = c ? t.PRICE_FORMATTED : t.PRICE, f = t.CURRENCY;
46
+ let l = `{{${r}_${u}}}`;
47
+ if (f) {
48
+ const s = `{{${f}_${u}}}`;
49
+ l = a === "after" ? `${l} ${s}` : `${s} ${l}`;
50
+ }
51
+ e.textContent = l;
52
+ break;
53
+ }
54
+ case "quantity": {
55
+ const t = p, i = t.ATTR, c = t.DEFAULT;
56
+ e.textContent && e.textContent.trim() === c && (e.textContent = `{{${i}_${u}}}`);
57
+ break;
58
+ }
59
+ case "button": {
60
+ const t = p, i = t.HREF, c = t.DEFAULT_HREF || "#!", a = e.tagName === "A" ? e : e.querySelector("a");
61
+ if (a) {
62
+ const r = a.href || "", f = `${window.location.href}${c}`;
63
+ (r === "" || r === "#" || r === f || r.endsWith(c) || r.endsWith("#!") || r === window.location.href) && (a.href = `{{${i}_${u}}}`);
64
+ }
65
+ break;
66
+ }
67
+ case "itemLink": {
68
+ const t = p, i = t.HREF, c = t.DEFAULT_HREF || "#!", a = e;
69
+ if (a.href) {
70
+ const r = a.href, f = `${window.location.href}${c}`;
71
+ (r === f || r.endsWith(c)) && (a.href = `{{${i}_${u}}}`);
72
+ }
73
+ break;
74
+ }
75
+ default: {
76
+ if ("ATTR" in p) {
77
+ const t = p.ATTR;
78
+ e.textContent && (e.textContent = `{{${t}_${u}}}`);
79
+ }
80
+ break;
81
+ }
82
+ }
83
+ });
84
+ });
85
+ });
86
+ const S = $.querySelectorAll(".ins-product-td"), R = [];
87
+ S.forEach((n) => {
88
+ const d = n.getAttribute("data-type") || "CART_ITEMS", A = n.getAttribute("data-number") || "1", o = n.getAttribute("data-nodup"), h = n.outerHTML;
89
+ R.push({
90
+ element: n,
91
+ outerHtml: h,
92
+ type: d,
93
+ number: A,
94
+ nodup: o || void 0
95
+ });
96
+ });
97
+ let E = $.body.innerHTML;
98
+ R.reverse().forEach(({ outerHtml: n, type: d, number: A }) => {
99
+ let o = "";
100
+ switch (d) {
101
+ case "CART_ITEMS":
102
+ o = "ins_apr_total_product_kind";
103
+ break;
104
+ case "BROWSED_ITEMS":
105
+ o = "browsed_item_total_product_kind";
106
+ break;
107
+ case "PURCHASED_ITEMS":
108
+ o = "purchased_item_total_product_kind";
109
+ break;
110
+ }
111
+ if (o) {
112
+ const _ = parseInt(A) - 1, b = `${`{% if ${o} > ${_} %}`}${n}{% endif %}`;
113
+ E = E.replace(n, b);
114
+ }
115
+ });
116
+ const k = $.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), T = [];
117
+ return k.forEach((n) => {
118
+ const d = n.getAttribute("data-number"), A = n.getAttribute("data-type");
119
+ if (!d || A !== "CART_ITEMS")
120
+ return;
121
+ const o = n.closest(".product-original-price-class");
122
+ if (o) {
123
+ const h = o.outerHTML;
124
+ T.some((g) => g.tdOuterHtml === h) || T.push({ tdOuterHtml: h, number: d });
125
+ }
126
+ }), T.reverse().forEach(({ tdOuterHtml: n, number: d }) => {
127
+ const A = `{% if ins_apr_price_${d} != ins_apr_originalprice_${d} %}`;
128
+ if (!E.includes(A) && !n.includes("{% if")) {
129
+ const h = `${A}${n}{% endif %}`;
130
+ E = E.replace(n, h);
131
+ }
132
+ }), E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
133
+ }
134
+ export {
135
+ M as pairProductVariables
136
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.3-beta.2cf8046",
3
+ "version": "1.0.3-beta.2df2106",
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",
@@ -27,14 +27,7 @@
27
27
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
28
28
  "prepare": "husky"
29
29
  },
30
- "keywords": [
31
- "vue",
32
- "typescript",
33
- "email",
34
- "editor",
35
- "stripo",
36
- "useinsider"
37
- ],
30
+ "keywords": [],
38
31
  "author": "",
39
32
  "license": "ISC",
40
33
  "dependencies": {
@@ -48,10 +41,12 @@
48
41
  "vue": "2.7.14"
49
42
  },
50
43
  "devDependencies": {
44
+ "@commitlint/cli": "20.2.0",
45
+ "@commitlint/config-conventional": "20.2.0",
51
46
  "@cspell/eslint-plugin": "8.17.5",
52
47
  "@eslint/eslintrc": "3.3.0",
53
48
  "@eslint/js": "8.57.1",
54
- "@playwright/test": "1.55.0",
49
+ "@playwright/test": "1.57.0",
55
50
  "@stylistic/eslint-plugin": "3.1.0",
56
51
  "@stylistic/eslint-plugin-migrate": "3.1.0",
57
52
  "@types/eslint": "8.56.12",