@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,13 +1,11 @@
1
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 { DEFAULT_CARD_COMPOSITION as C, getDefaultProducts as p, prepareProductRows as E } from "./template.js";
9
- import { useDebounceFn as U } from "../../../node_modules/@vueuse/shared/index.js";
10
- const L = "ui-elements-recommendation-block", t = {
2
+ var R = (o, n, e) => n in o ? _(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
3
+ var r = (o, n, e) => R(o, typeof n != "symbol" ? n + "" : n, e);
4
+ import { currencyDecimalCounts as c, currencyOperators as a, currencyLocationMaps as l } from "../../../enums/extensions/recommendationBlock.js";
5
+ import { UEAttr as d } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as m } from "../common-control.js";
7
+ import { useRecommendationExtensionStore as S } from "./store/recommendation.js";
8
+ const g = "ui-elements-recommendation-block", t = {
11
9
  ALGORITHM: "strategy",
12
10
  PRODUCT_IDS: "productIds",
13
11
  LOCALE: "language",
@@ -23,21 +21,18 @@ const L = "ui-elements-recommendation-block", t = {
23
21
  SHUFFLE_PRODUCTS: "shuffleProducts",
24
22
  RESPONSIVE: "unresponsive"
25
23
  };
26
- class y extends g {
24
+ class p extends m {
27
25
  constructor() {
28
26
  super(...arguments);
29
- r(this, "store", O());
27
+ r(this, "store", S());
30
28
  r(this, "storeUnsubscription", () => {
31
29
  });
32
30
  r(this, "addFilterListener", () => {
33
31
  });
34
32
  r(this, "addFilterButton", null);
35
- r(this, "_debouncedRegenerateProductRows", U(() => {
36
- this._regenerateProductRows();
37
- }, 500));
38
33
  }
39
34
  getId() {
40
- return L;
35
+ return g;
41
36
  }
42
37
  getTemplate() {
43
38
  return `
@@ -83,22 +78,22 @@ class y extends g {
83
78
  });
84
79
  }
85
80
  _initializeSelectItems() {
86
- const { store: e } = this, o = e.getActivePredictiveAlgorithms, i = e.getLanguages, a = {
87
- [t.ALGORITHM]: o,
81
+ const { store: e } = this, s = e.getActivePredictiveAlgorithms, i = e.getLanguages, C = {
82
+ [t.ALGORITHM]: s,
88
83
  [t.LOCALE]: i,
89
84
  [t.CURRENCY]: e.currencyList,
90
- [t.CURRENCY_LOCATION]: h,
85
+ [t.CURRENCY_LOCATION]: l,
91
86
  [t.CURRENCY_SYMBOL]: e.getCurrencySymbolList,
92
- [t.CURRENCY_THOUSAND_SEPARATOR]: c,
93
- [t.CURRENCY_DECIMAL_SEPARATOR]: c,
94
- [t.CURRENCY_DECIMAL_COUNT]: l,
87
+ [t.CURRENCY_THOUSAND_SEPARATOR]: a,
88
+ [t.CURRENCY_DECIMAL_SEPARATOR]: a,
89
+ [t.CURRENCY_DECIMAL_COUNT]: c,
95
90
  [t.PRODUCT_COUNT]: Number(e.recommendationConfigs.size),
96
91
  [t.PRODUCT_IN_ROW]: e.recommendationConfigs.cardsInRow,
97
92
  [t.SHUFFLE_PRODUCTS]: e.recommendationConfigs.shuffleProducts,
98
93
  [t.RESPONSIVE]: !e.recommendationConfigs.unresponsive
99
94
  };
100
- Object.entries(a).forEach(([u, d]) => {
101
- this.api.setUIEAttribute(u, m.SELECTPICKER.items, d);
95
+ Object.entries(C).forEach(([u, h]) => {
96
+ this.api.setUIEAttribute(u, d.SELECTPICKER.items, h);
102
97
  });
103
98
  }
104
99
  _getAlgorithms() {
@@ -144,7 +139,7 @@ class y extends g {
144
139
  this._GuSelect({
145
140
  name: t.CURRENCY_LOCATION,
146
141
  placeholder: "Select Currency Location",
147
- options: h
142
+ options: l
148
143
  }),
149
144
  this._GuLabel({ text: "Currency Symbol" }),
150
145
  this._GuSelect({
@@ -156,19 +151,19 @@ class y extends g {
156
151
  this._GuSelect({
157
152
  name: t.CURRENCY_THOUSAND_SEPARATOR,
158
153
  placeholder: "Select Thousand Separator",
159
- options: c
154
+ options: a
160
155
  }),
161
156
  this._GuLabel({ text: "Decimal Separator" }),
162
157
  this._GuSelect({
163
158
  name: t.CURRENCY_DECIMAL_SEPARATOR,
164
159
  placeholder: "Select Decimal Separator",
165
- options: c
160
+ options: a
166
161
  }),
167
162
  this._GuLabel({ text: "Decimal Count" }),
168
163
  this._GuSelect({
169
164
  name: t.CURRENCY_DECIMAL_COUNT,
170
165
  placeholder: "Select Decimal Count",
171
- options: l
166
+ options: c
172
167
  })
173
168
  ])}
174
169
  `;
@@ -222,62 +217,39 @@ class y extends g {
222
217
  filterSelectionDrawerStatus: !0
223
218
  });
224
219
  }
225
- _onDataChange(e, o) {
226
- this.currentNode && (this.store.$patch({
220
+ _onDataChange(e, s) {
221
+ this.currentNode && this.store.$patch({
227
222
  recommendationConfigs: {
228
- [e]: o
223
+ [e]: s
229
224
  }
230
- }), this._debouncedRegenerateProductRows());
231
- }
232
- /**
233
- * Get the current card composition from block data attribute or use default
234
- */
235
- _getCardComposition() {
236
- if (!this.currentNode)
237
- return C;
238
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
239
- if (!e || !("getAttribute" in e))
240
- return C;
241
- const o = e.getAttribute("data-card-composition");
242
- return o ? o.split(",").filter(Boolean) : C;
243
- }
244
- _regenerateProductRows() {
245
- if (!this.currentNode || !("querySelector" in this.currentNode))
246
- return;
247
- const e = this.currentNode.querySelector(".ins-recommendation-product-container");
248
- if (!e) {
249
- console.error("Could not find container table for product rows");
250
- return;
251
- }
252
- const o = this.store.recommendationProducts.length > 0 ? this.store.recommendationProducts : p(), { cardsInRow: i } = this.store.recommendationConfigs, a = this._getCardComposition(), u = E(o, i, a);
253
- this.api.getDocumentModifier().modifyHtml(e).setInnerHtml(u).apply(new S("Updated product"));
225
+ });
254
226
  }
255
- _onCurrencyConfigChange(e, o) {
227
+ _onCurrencyConfigChange(e, s) {
256
228
  this.currentNode && this.store.$patch({
257
229
  recommendationConfigs: {
258
230
  currencySettings: {
259
- [e]: o
231
+ [e]: s
260
232
  }
261
233
  }
262
234
  });
263
235
  }
264
236
  _onCurrencyChange(e) {
265
- const [, o] = e.split(".");
237
+ const [, s] = e.split(".");
266
238
  this.store.$patch({
267
239
  recommendationConfigs: {
268
240
  currencySettings: {
269
- name: o,
270
- value: o
241
+ name: s,
242
+ value: s
271
243
  }
272
244
  }
273
245
  });
274
246
  }
275
247
  _setProductIdsVisibility() {
276
- const { recommendationConfigs: e } = this.store, o = e.strategy === "manualMerchandising";
277
- this.api.setVisibility(t.PRODUCT_IDS, o), this.api.setVisibility(`${t.PRODUCT_IDS}_label`, o);
248
+ const { recommendationConfigs: e } = this.store, s = e.strategy === "manualMerchandising";
249
+ this.api.setVisibility(t.PRODUCT_IDS, s), this.api.setVisibility(`${t.PRODUCT_IDS}_label`, s);
278
250
  }
279
251
  _listenToFormUpdates() {
280
- var o;
252
+ var s;
281
253
  this.api.onValueChanged(t.ALGORITHM, (i) => {
282
254
  this._onDataChange(t.ALGORITHM, i), this._setProductIdsVisibility();
283
255
  }), this.api.onValueChanged(t.PRODUCT_IDS, (i) => this._onDataChange(t.PRODUCT_IDS, i.split(",") || [])), this.api.onValueChanged(t.LOCALE, (i) => this._onDataChange(t.LOCALE, i)), this.api.onValueChanged(t.CURRENCY, (i) => this._onCurrencyChange(i)), [
@@ -287,19 +259,19 @@ class y extends g {
287
259
  t.CURRENCY_DECIMAL_SEPARATOR,
288
260
  t.CURRENCY_DECIMAL_COUNT
289
261
  ].forEach((i) => {
290
- this.api.onValueChanged(i, (a) => this._onCurrencyConfigChange(i, a));
291
- }), 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);
262
+ this.api.onValueChanged(i, (C) => this._onCurrencyConfigChange(i, C));
263
+ }), 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"), (s = this.addFilterButton) == null || s.addEventListener("click", this.addFilterListener);
292
264
  }
293
265
  _listenStateUpdates() {
294
266
  this.storeUnsubscription = this.store.$subscribe((e) => {
295
267
  if ("payload" in e) {
296
- const o = e.payload.recommendationConfigs;
297
- o && (this.api.updateValues(o), this.store.fetchRecommendationProducts());
268
+ const s = e.payload.recommendationConfigs;
269
+ s && (this.api.updateValues(s), this.store.fetchRecommendationProducts());
298
270
  }
299
271
  });
300
272
  }
301
273
  }
302
274
  export {
303
- L as CONTROL_BLOCK_ID,
304
- y as RecommendationBlockControl
275
+ g as CONTROL_BLOCK_ID,
276
+ p as RecommendationBlockControl
305
277
  };
@@ -1,29 +1,10 @@
1
1
  import { ExtensionBuilder as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { RecommendationBlock as t } from "./block.js";
3
- import { RecommendationCardCompositionControl as r } from "./cardCompositionControl.js";
4
- import { RecommendationBlockControl as n } from "./control.js";
5
- import { ButtonAlignControl as m } from "./controls/button/align.js";
6
- import { ButtonBorderControl as d } from "./controls/button/border.js";
7
- import { ButtonBorderRadiusControl as l } from "./controls/button/borderRadius.js";
8
- import { ButtonColorControl as i } from "./controls/button/color.js";
9
- import { ButtonFitToContentControl as a } from "./controls/button/fitToContent.js";
10
- import { ButtonFontFamilyControl as C } from "./controls/button/fontFamily.js";
11
- import { ButtonMarginsControl as e } from "./controls/button/margins.js";
12
- import { ButtonPaddingsControl as p } from "./controls/button/paddings.js";
13
- import { ButtonTextControl as f } from "./controls/button/text.js";
14
- import { ButtonTextSizeControl as s } from "./controls/button/textSize.js";
15
- import { ButtonTextStyleAndFontColorControl as B } from "./controls/button/textStyleAndFontColor.js";
16
- import { NameAlignControl as u } from "./controls/name/align.js";
17
- import { NameBackgroundControl as c } from "./controls/name/background.js";
18
- import { NameColorControl as g } from "./controls/name/color.js";
19
- import { NameFontFamilyControl as y } from "./controls/name/fontFamily.js";
20
- import { NamePaddingsControl as R } from "./controls/name/paddings.js";
21
- import { NameSizeControl as N } from "./controls/name/size.js";
22
- import { NameStyleControl as S } from "./controls/name/style.js";
23
- import { RecommendationIconsRegistry as x } from "./iconsRegistry.js";
24
- import F from "./recommendation.css.js";
25
- import { SettingsPanel as k } from "./settingsPanel.js";
26
- const Y = new o().addBlock(t).withSettingsPanelRegistry(k).addControl(n).addControl(u).addControl(c).addControl(g).addControl(y).addControl(R).addControl(N).addControl(S).addControl(m).addControl(d).addControl(l).addControl(i).addControl(a).addControl(C).addControl(e).addControl(p).addControl(f).addControl(s).addControl(B).addControl(r).addStyles(F).withIconsRegistry(x).build();
3
+ import { RecommendationBlockControl as e } from "./control.js";
4
+ import { RecommendationIconsRegistry as n } from "./iconsRegistry.js";
5
+ import i from "./recommendation.css.js";
6
+ import { SettingsPanel as m } from "./settingsPanel.js";
7
+ const f = new o().addBlock(t).withSettingsPanelRegistry(m).addControl(e).addStyles(i).withIconsRegistry(n).build();
27
8
  export {
28
- Y as default
9
+ f as default
29
10
  };
@@ -1,72 +1,32 @@
1
- import { SettingsPanelRegistry as e, SettingsPanelTab as o, SettingsTab as n, ContainerControls as r, TextControls as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { BLOCK_ID as m } from "./block.js";
3
- import { COMPOSITION_CONTROL_BLOCK_ID as l } from "./cardCompositionControl.js";
1
+ import { SettingsPanelRegistry as o, SettingsPanelTab as t, SettingsTab as e, ContainerControls as r, TextControls as s } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { BLOCK_ID as T } from "./block.js";
4
3
  import { CONTROL_BLOCK_ID as i } from "./control.js";
5
- class T extends e {
6
- registerBlockControls(t) {
7
- t[m] = [
8
- new o(
9
- n.SETTINGS,
4
+ class a extends o {
5
+ registerBlockControls(n) {
6
+ n[T] = [
7
+ new t(
8
+ e.SETTINGS,
10
9
  [
11
10
  i,
12
11
  r.EXTERNAL_INDENTS
13
12
  ]
14
13
  ),
15
- new o(
16
- n.STYLES,
14
+ new t(
15
+ e.STYLES,
17
16
  [
18
- c.TEXT_BLOCK_BACKGROUND_COLOR
19
- ]
20
- ),
21
- new o(
22
- "Card Composition",
23
- [
24
- l
25
- ]
26
- ).withLabel("Card Composition")
27
- ], t["recommendation-block-name"] = [
28
- new o(
29
- n.SETTINGS,
30
- [
31
- "recommendation-block-name-background-control",
32
- "recommendation-block-name-color-control",
33
- "recommendation-block-name-size-control",
34
- "recommendation-block-name-style-control",
35
- "recommendation-block-name-font-family-control"
36
- ]
37
- ),
38
- new o(
39
- n.STYLES,
40
- [
41
- "recommendation-block-name-align-control",
42
- "recommendation-block-name-paddings-control"
43
- ]
44
- )
45
- ], t["recommendation-block-button"] = [
46
- new o(
47
- n.SETTINGS,
48
- [
49
- "recommendation-block-button-text-control",
50
- "recommendation-block-button-align-control",
51
- "recommendation-block-button-margins-control",
52
- "recommendation-block-button-paddings-control"
53
- ]
54
- ),
55
- new o(
56
- n.STYLES,
57
- [
58
- "recommendation-block-button-color-control",
59
- "recommendation-block-button-font-family-control",
60
- "recommendation-block-button-text-size-control",
61
- "recommendation-block-button-text-style-and-font-color-control",
62
- "recommendation-block-button-fit-to-content-control",
63
- "recommendation-block-button-border-radius-control",
64
- "recommendation-block-button-border-control"
17
+ s.TEXT_BLOCK_BACKGROUND_COLOR
65
18
  ]
66
19
  )
20
+ // TODO: It'll be opened after the card composition is implemented by Stripo team.
21
+ // new SettingsPanelTab(
22
+ // 'Card Composition',
23
+ // [
24
+ // COMPOSITION_CONTROL_BLOCK_ID,
25
+ // ]
26
+ // ).withLabel('Card Composition'),
67
27
  ];
68
28
  }
69
29
  }
70
30
  export {
71
- T as SettingsPanel
31
+ a as SettingsPanel
72
32
  };