@useinsider/guido 3.2.0-beta.da93bda → 3.2.0-beta.dc55d68

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 (61) hide show
  1. package/dist/@types/config/schemas.js +150 -94
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +88 -87
  4. package/dist/composables/useRecommendation.js +16 -12
  5. package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
  6. package/dist/config/migrator/index.js +9 -9
  7. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  8. package/dist/config/migrator/recommendation/extractors.js +27 -0
  9. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  10. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  11. package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
  12. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  13. package/dist/config/migrator/recommendationMigrator.js +74 -290
  14. package/dist/enums/extensions/recommendationBlock.js +2 -1
  15. package/dist/enums/unsubscribe.js +34 -27
  16. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  17. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  18. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  19. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  20. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +21 -19
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  22. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  23. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
  26. package/dist/node_modules/valibot/dist/index.js +450 -235
  27. package/dist/package.json.js +1 -1
  28. package/dist/src/@types/config/defaults.d.ts +5 -1
  29. package/dist/src/@types/config/index.d.ts +3 -3
  30. package/dist/src/@types/config/schemas.d.ts +213 -0
  31. package/dist/src/@types/config/types.d.ts +9 -1
  32. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  33. package/dist/src/composables/useConfig.d.ts +56 -0
  34. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  35. package/dist/src/config/migrator/index.d.ts +2 -1
  36. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  37. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  38. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  39. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  40. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  41. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  42. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  43. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  44. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  45. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  46. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  47. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  48. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  49. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  50. package/dist/src/enums/unsubscribe.d.ts +5 -0
  51. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  52. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  53. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  54. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  56. package/dist/src/stores/config.d.ts +504 -0
  57. package/dist/src/utils/htmlEscape.d.ts +5 -0
  58. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  59. package/dist/utils/htmlEscape.js +13 -0
  60. package/package.json +7 -3
  61. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
@@ -1,15 +1,15 @@
1
- var k = Object.defineProperty;
2
- var I = (r, n, t) => n in r ? k(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
- var u = (r, n, t) => I(r, typeof n != "symbol" ? n + "" : n, t);
4
- import { BlockId as B } from "../../../enums/block.js";
5
- import { getMigrationBannerHtml as _ } from "../../../utils/migrationBannerHtml.js";
1
+ var I = Object.defineProperty;
2
+ var k = (r, n, t) => n in r ? I(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
+ var u = (r, n, t) => k(r, typeof n != "symbol" ? n + "" : n, t);
4
+ import { BlockId as _ } from "../../../enums/block.js";
5
+ import { getMigrationBannerHtml as B } from "../../../utils/migrationBannerHtml.js";
6
6
  import { Block as b, BlockCompositionType as R, ModificationDescription as y } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
7
  import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
8
8
  import { ensureMobileCssRulesExist as g, setMobileLayoutOptOut as d, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
9
9
  import { RecommendationConfigService as c } from "./services/configService.js";
10
10
  import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
11
11
  import { getDefaultTemplate as E } from "./templates/grid/template.js";
12
- const f = B.Recommendation, a = "recommendation-block-v2", l = "recommendation-id";
12
+ const f = _.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
13
13
  let h = !1;
14
14
  class q extends b {
15
15
  constructor() {
@@ -38,7 +38,7 @@ class q extends b {
38
38
  );
39
39
  }
40
40
  getSettingsPanelTitleHtml() {
41
- return _(
41
+ return B(
42
42
  f,
43
43
  this.api.translate("Recommendation Block"),
44
44
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
@@ -66,15 +66,18 @@ class q extends b {
66
66
  * @param node - The newly created block node
67
67
  */
68
68
  onCreated(t) {
69
- const e = this._pendingBlockId ?? this._generateNextId();
70
- this._pendingBlockId = null, this._assignRecommendationId(t, e);
71
- const o = c.initializeConfig(this.api, t, { recommendationId: e }), i = p();
72
- i.setCurrentBlock(e), g(this.api);
73
- const s = this._getBlockElement(t);
74
- s && (d(this.api, s, !0), C({
69
+ const e = this._getRecommendationId(t);
70
+ if (e !== null && e > 0)
71
+ return;
72
+ const i = this._pendingBlockId ?? this._generateNextId();
73
+ this._pendingBlockId = null, this._assignRecommendationId(t, i);
74
+ const o = c.initializeConfig(this.api, t, { recommendationId: i }), s = p();
75
+ s.setCurrentBlock(i), g(this.api);
76
+ const a = this._getBlockElement(t);
77
+ a && (d(this.api, a, !0), C({
75
78
  currentNode: t,
76
79
  documentModifier: this.api.getDocumentModifier()
77
- })), i.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
80
+ })), s.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
78
81
  }
79
82
  /**
80
83
  * Called when the document changes or template is loaded
@@ -97,10 +100,10 @@ class q extends b {
97
100
  c.needsMigration(t) && this._migrateFromLegacy(t);
98
101
  try {
99
102
  h || (g(this.api), h = !0);
100
- const e = c.getConfig(t), o = this._getBlockElement(t);
101
- if (o) {
102
- const i = !e.mobileLayoutEnabled;
103
- A(o) !== i && d(this.api, o, i);
103
+ const e = c.getConfig(t), i = this._getBlockElement(t);
104
+ if (i) {
105
+ const o = !e.mobileLayoutEnabled;
106
+ A(i) !== o && d(this.api, i, o);
104
107
  }
105
108
  } catch {
106
109
  }
@@ -124,10 +127,10 @@ class q extends b {
124
127
  let t = 0;
125
128
  try {
126
129
  const e = this.api.getDocumentRoot();
127
- e && "querySelectorAll" in e && e.querySelectorAll(`.${a}`).forEach((i) => {
128
- if ("getAttribute" in i) {
129
- const s = i.getAttribute(l), m = s ? parseInt(s) : 0;
130
- m > t && (t = m);
130
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${l}`).forEach((o) => {
131
+ if ("getAttribute" in o) {
132
+ const s = o.getAttribute(m), a = s ? parseInt(s) : 0;
133
+ a > t && (t = a);
131
134
  }
132
135
  });
133
136
  } catch {
@@ -141,11 +144,11 @@ class q extends b {
141
144
  * added classes via setAttribute.
142
145
  */
143
146
  _assignRecommendationId(t, e) {
144
- const o = this._getBlockElement(t);
145
- if (!o)
147
+ const i = this._getBlockElement(t);
148
+ if (!i)
146
149
  return;
147
- const i = this.api.getDocumentModifier();
148
- i.modifyHtml(o).setAttribute(l, e.toString()), i.apply(new y(`Assign recommendation ID ${e}`));
150
+ const o = this.api.getDocumentModifier();
151
+ o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new y(`Assign recommendation ID ${e}`));
149
152
  }
150
153
  /**
151
154
  * Gets the recommendation-id from a block node
@@ -154,11 +157,11 @@ class q extends b {
154
157
  const e = this._getBlockElement(t);
155
158
  if (!e || !("getAttribute" in e))
156
159
  return null;
157
- const o = e.getAttribute(l);
158
- if (!o)
160
+ const i = e.getAttribute(m);
161
+ if (!i)
159
162
  return null;
160
- const i = parseInt(o);
161
- return Number.isNaN(i) ? null : i;
163
+ const o = parseInt(i);
164
+ return Number.isNaN(o) ? null : o;
162
165
  }
163
166
  /**
164
167
  * Gets the block element (the element with BLOCK_CLASS)
@@ -166,10 +169,10 @@ class q extends b {
166
169
  _getBlockElement(t) {
167
170
  if ("getAttribute" in t) {
168
171
  const e = t.getAttribute("class");
169
- if (e && e.includes(a))
172
+ if (e && e.includes(l))
170
173
  return t;
171
174
  }
172
- return "querySelector" in t ? t.querySelector(`.${a}`) ?? null : null;
175
+ return "querySelector" in t ? t.querySelector(`.${l}`) ?? null : null;
173
176
  }
174
177
  /**
175
178
  * Migrate configuration from legacy format
@@ -1,4 +1,4 @@
1
- import { DEFAULT_MOBILE_ROW_SPACING as R, DEFAULT_MOBILE_COLUMN_SPACING as U, DEFAULT_ROW_SPACING as i, DEFAULT_COLUMN_SPACING as s, DEFAULT_MOBILE_CARDS_IN_ROW as o, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
1
+ import { DEFAULT_COLUMN_SPACING as R, DEFAULT_ROW_SPACING as U, DEFAULT_MOBILE_ROW_SPACING as i, DEFAULT_MOBILE_COLUMN_SPACING as s, DEFAULT_MOBILE_CARDS_IN_ROW as o, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
2
2
  import { ATTR_PRODUCT_IMAGE as _, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as t, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as r, ATTR_PRODUCT_OMNIBUS_DISCOUNT as I, ATTR_PRODUCT_BUTTON as n } from "./selectors.js";
3
3
  const O = {
4
4
  code: "USD",
@@ -44,10 +44,10 @@ const O = {
44
44
  mobileCardsInRow: o,
45
45
  mobileLayoutEnabled: !1,
46
46
  previousMobileCardsInRow: o,
47
- columnSpacing: s,
48
- rowSpacing: i,
49
- mobileColumnSpacing: U,
50
- mobileRowSpacing: R,
47
+ columnSpacing: R,
48
+ rowSpacing: U,
49
+ mobileColumnSpacing: s,
50
+ mobileRowSpacing: i,
51
51
  // Composition
52
52
  composition: a,
53
53
  visibility: E,