@useinsider/guido 3.12.1-beta.3214ec4 → 3.13.0

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 (41) hide show
  1. package/README.md +16 -1
  2. package/dist/@types/config/schemas.js +27 -25
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +110 -101
  5. package/dist/composables/useAllowlist.js +50 -0
  6. package/dist/composables/useSave.js +42 -23
  7. package/dist/composables/useStripo.js +72 -69
  8. package/dist/composables/useUserRole.js +12 -0
  9. package/dist/enums/roles.js +4 -0
  10. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  11. package/dist/extensions/Blocks/Recommendation/controls/blockBackground/index.js +10 -0
  12. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +12 -12
  13. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +12 -12
  14. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
  15. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +12 -12
  16. package/dist/extensions/Blocks/Recommendation/extension.js +23 -21
  17. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +41 -40
  18. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +7 -7
  19. package/dist/extensions/Blocks/controlFactories.js +125 -75
  20. package/dist/guido.css +1 -1
  21. package/dist/services/allowlistApi.js +15 -0
  22. package/dist/services/stripoApi.js +18 -18
  23. package/dist/src/@types/config/schemas.d.ts +10 -0
  24. package/dist/src/components/Guido.vue.d.ts +18 -2
  25. package/dist/src/composables/useAllowlist.d.ts +6 -0
  26. package/dist/src/composables/useConfig.d.ts +2 -0
  27. package/dist/src/composables/useStripo.d.ts +3 -2
  28. package/dist/src/composables/useUserRole.d.ts +3 -0
  29. package/dist/src/enums/roles.d.ts +9 -0
  30. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  31. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +14 -0
  32. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  33. package/dist/src/extensions/Blocks/controlFactories.d.ts +36 -0
  34. package/dist/src/services/allowlistApi.d.ts +4 -0
  35. package/dist/src/stores/config.d.ts +21 -1
  36. package/dist/static/styles/components/base-input.css.js +6 -7
  37. package/dist/stores/config.js +21 -19
  38. package/dist/utils/pairProductVariables.js +44 -43
  39. package/dist/{extensions/Blocks/Recommendation/utils → utils}/preserveTextStyles.js +1 -1
  40. package/package.json +1 -1
  41. /package/dist/src/{extensions/Blocks/Recommendation/utils → utils}/preserveTextStyles.d.ts +0 -0
@@ -1,30 +1,31 @@
1
- import { productPairs as q } from "../extensions/Blocks/Items/enums/productEnums.js";
2
- import { DefaultConfigValues as N } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
- function W(M) {
4
- const S = M.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), g = new DOMParser().parseFromString(S, "text/html"), m = q.PAIRS_FOR_EXTENSION;
1
+ import { productPairs as N } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ import { DefaultConfigValues as O } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
+ import { preserveTextStyles as C } from "./preserveTextStyles.js";
4
+ function V(L) {
5
+ const H = L.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), g = new DOMParser().parseFromString(H, "text/html"), m = N.PAIRS_FOR_EXTENSION;
5
6
  Object.entries(m).forEach(([r, f]) => {
6
7
  g.querySelectorAll(".ins-product-td").forEach((c) => {
7
- const A = c.getAttribute("data-number") || "1", C = c.getAttribute("data-type") || "CART_ITEMS";
8
- c.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
8
+ const A = c.getAttribute("data-number") || "1", y = c.getAttribute("data-type") || "CART_ITEMS";
9
+ c.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
9
10
  var F, I, w;
10
- const $ = e.getAttribute("data-type") || C, u = e.getAttribute("data-number") || A, d = f[$];
11
+ const T = t.getAttribute("data-type") || y, u = t.getAttribute("data-number") || A, d = f[T];
11
12
  if (d)
12
13
  switch (r) {
13
14
  case "imageSrc": {
14
- let t = null, i = null;
15
- if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
15
+ let e = null, i = null;
16
+ if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
16
17
  break;
17
18
  const a = d.DEFAULT, s = d.ATTR;
18
- if (a && t.src) {
19
- const o = t.src;
19
+ if (a && e.src) {
20
+ const o = e.src;
20
21
  a.some((h) => {
21
- const l = h.split("/").pop() || "", b = o.split("/").pop() || "";
22
- return o.includes(h) || o.includes(l) || b === l;
23
- }) && (t.src = `{{${s}_${u}}}`);
22
+ const l = h.split("/").pop() || "", $ = o.split("/").pop() || "";
23
+ return o.includes(h) || o.includes(l) || $ === l;
24
+ }) && (e.src = `{{${s}_${u}}}`);
24
25
  }
25
- const n = (I = (F = m.name) == null ? void 0 : F[$]) == null ? void 0 : I.ATTR;
26
- if (n && t.setAttribute("alt", `{{${n}_${u}}}`), i) {
27
- const o = (w = m.itemLink) == null ? void 0 : w[$];
26
+ const n = (I = (F = m.name) == null ? void 0 : F[T]) == null ? void 0 : I.ATTR;
27
+ if (n && e.setAttribute("alt", `{{${n}_${u}}}`), i) {
28
+ const o = (w = m.itemLink) == null ? void 0 : w[T];
28
29
  if (o) {
29
30
  const E = o.HREF, h = o.DEFAULT_HREF || "#!", l = i.href;
30
31
  (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${u}}}`);
@@ -33,9 +34,9 @@ function W(M) {
33
34
  break;
34
35
  }
35
36
  case "name": {
36
- const t = d, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
37
- e.textContent && (e.textContent = `{{${i}_${u}}}`);
38
- const n = e.closest("a") || (e.tagName === "A" ? e : null);
37
+ const e = d, i = e.ATTR, a = e.DEFAULT_HREF || "#!", s = e.HREF;
38
+ t.textContent && (t.innerHTML = C(t, `{{${i}_${u}}}`));
39
+ const n = t.closest("a") || (t.tagName === "A" ? t : null);
39
40
  if (n && s) {
40
41
  const o = n.href, E = `${window.location.href}${a}`;
41
42
  (o === E || o.endsWith(a)) && (n.href = `{{${s}_${u}}}`);
@@ -44,23 +45,23 @@ function W(M) {
44
45
  }
45
46
  case "price":
46
47
  case "originalPrice": {
47
- const t = d, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", o = e.getAttribute("data-curency") || "before";
48
+ const e = d, i = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), s = i === "true", n = a === "true", o = t.getAttribute("data-curency") || "before";
48
49
  let E;
49
- n ? E = s ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : E = s ? t.PRICE_FORMATTED : t.PRICE;
50
- const h = t.CURRENCY;
50
+ n ? E = s ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : E = s ? e.PRICE_FORMATTED : e.PRICE;
51
+ const h = e.CURRENCY;
51
52
  let l = `{{${E}_${u}}}`;
52
- const b = (e.getAttribute("data-currency_symbol") || "").trim(), x = b !== "" && b !== N.productPriceCurrencySymbolControlValue;
53
- let T = "";
54
- x ? T = b : h && (T = `{{${h}_${u}}}`), T && (l = o === "after" ? `${l} ${T}` : `${T} ${l}`), e.textContent = l;
53
+ const $ = (t.getAttribute("data-currency_symbol") || "").trim(), q = $ !== "" && $ !== O.productPriceCurrencySymbolControlValue;
54
+ let b = "";
55
+ q ? b = $ : h && (b = `{{${h}_${u}}}`), b && (l = o === "after" ? `${l} ${b}` : `${b} ${l}`), t.innerHTML = C(t, l);
55
56
  break;
56
57
  }
57
58
  case "quantity": {
58
- const t = d, i = t.ATTR, a = t.DEFAULT;
59
- e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${u}}}`);
59
+ const e = d, i = e.ATTR, a = e.DEFAULT;
60
+ t.textContent && t.textContent.trim() === a && (t.innerHTML = C(t, `{{${i}_${u}}}`));
60
61
  break;
61
62
  }
62
63
  case "button": {
63
- const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
64
+ const e = d, i = e.HREF, a = e.DEFAULT_HREF || "#!", s = t.tagName === "A" ? t : t.querySelector("a");
64
65
  if (s) {
65
66
  const n = s.href || "", o = `${window.location.href}${a}`;
66
67
  (n === "" || n === "#" || n === o || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${u}}}`);
@@ -68,7 +69,7 @@ function W(M) {
68
69
  break;
69
70
  }
70
71
  case "itemLink": {
71
- const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
72
+ const e = d, i = e.HREF, a = e.DEFAULT_HREF || "#!", s = t;
72
73
  if (s.href) {
73
74
  const n = s.href, o = `${window.location.href}${a}`;
74
75
  (n === o || n.endsWith(a)) && (s.href = `{{${i}_${u}}}`);
@@ -77,8 +78,8 @@ function W(M) {
77
78
  }
78
79
  default: {
79
80
  if ("ATTR" in d) {
80
- const t = d.ATTR;
81
- e.textContent && (e.textContent = `{{${t}_${u}}}`);
81
+ const e = d.ATTR;
82
+ t.textContent && (t.innerHTML = C(t, `{{${e}_${u}}}`));
82
83
  }
83
84
  break;
84
85
  }
@@ -86,11 +87,11 @@ function W(M) {
86
87
  });
87
88
  });
88
89
  });
89
- const H = S.match(/<!DOCTYPE[^>]*>/i), P = H ? `${H[0]}
90
- ` : "", D = g.querySelectorAll(".ins-product-td"), k = [];
90
+ const k = H.match(/<!DOCTYPE[^>]*>/i), P = k ? `${k[0]}
91
+ ` : "", D = g.querySelectorAll(".ins-product-td"), M = [];
91
92
  D.forEach((r) => {
92
93
  const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", c = r.getAttribute("data-nodup"), A = r.outerHTML;
93
- k.push({
94
+ M.push({
94
95
  element: r,
95
96
  outerHtml: A,
96
97
  type: f,
@@ -99,7 +100,7 @@ function W(M) {
99
100
  });
100
101
  });
101
102
  let _ = P + g.documentElement.outerHTML;
102
- k.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
103
+ M.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
103
104
  let c = "";
104
105
  switch (f) {
105
106
  case "CART_ITEMS":
@@ -113,21 +114,21 @@ function W(M) {
113
114
  break;
114
115
  }
115
116
  if (c) {
116
- const C = parseInt(p) - 1, $ = `${`{% if ${c} > ${C} %}`}${r}{% endif %}`;
117
- _ = _.replace(r, $);
117
+ const y = parseInt(p) - 1, T = `${`{% if ${c} > ${y} %}`}${r}{% endif %}`;
118
+ _ = _.replace(r, T);
118
119
  }
119
120
  });
120
- const L = g.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), y = [];
121
- return L.forEach((r) => {
121
+ const x = g.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
122
+ return x.forEach((r) => {
122
123
  const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
123
124
  if (!f || p !== "CART_ITEMS")
124
125
  return;
125
126
  const c = r.closest(".product-original-price-class");
126
127
  if (c) {
127
128
  const A = c.outerHTML;
128
- y.some((R) => R.tdOuterHtml === A) || y.push({ tdOuterHtml: A, number: f });
129
+ R.some((S) => S.tdOuterHtml === A) || R.push({ tdOuterHtml: A, number: f });
129
130
  }
130
- }), y.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
131
+ }), R.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
131
132
  const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
132
133
  if (!_.includes(p) && !r.includes("{% if")) {
133
134
  const A = `${p}${r}{% endif %}`;
@@ -136,5 +137,5 @@ function W(M) {
136
137
  }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
137
138
  }
138
139
  export {
139
- W as pairProductVariables
140
+ V as pairProductVariables
140
141
  };
@@ -1,4 +1,4 @@
1
- import { escapeHtml as g } from "../../../../utils/htmlEscape.js";
1
+ import { escapeHtml as g } from "./htmlEscape.js";
2
2
  function u(n) {
3
3
  return "getInnerHTML" in n && typeof n.getInnerHTML == "function" ? n.getInnerHTML().trim() : "innerHTML" in n ? n.innerHTML : "";
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.12.1-beta.3214ec4",
3
+ "version": "3.13.0",
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",