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

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 (80) hide show
  1. package/README.md +0 -32
  2. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +18 -20
  3. package/dist/composables/useBlocksConfig.js +2 -1
  4. package/dist/composables/useStripo.js +9 -9
  5. package/dist/enums/extensions/recommendationBlock.js +2 -2
  6. package/dist/enums/onboarding.js +3 -7
  7. package/dist/enums/unsubscribe.js +27 -26
  8. package/dist/extensions/Blocks/Checkbox/block.js +2 -5
  9. package/dist/extensions/Blocks/RadioButton/block.js +2 -5
  10. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +43 -43
  11. package/dist/extensions/Blocks/common-control.js +110 -174
  12. package/dist/guido.css +1 -1
  13. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +168 -213
  14. package/dist/package.json.js +1 -1
  15. package/dist/services/recommendationApi.js +19 -13
  16. package/dist/src/enums/onboarding.d.ts +0 -4
  17. package/dist/src/extensions/Blocks/Checkbox/block.d.ts +0 -1
  18. package/dist/src/extensions/Blocks/RadioButton/block.d.ts +0 -1
  19. package/dist/src/extensions/Blocks/common-control.d.ts +7 -44
  20. package/dist/src/stores/onboarding.d.ts +0 -334
  21. package/dist/src/utils/environmentUtil.d.ts +5 -0
  22. package/dist/static/styles/customEditorStyle.css.js +1 -1
  23. package/dist/stores/onboarding.js +12 -20
  24. package/dist/utils/environmentUtil.js +4 -0
  25. package/dist/utils/genericUtil.js +17 -16
  26. package/package.json +5 -12
  27. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +0 -21
  28. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +0 -99
  29. package/dist/extensions/Blocks/Items/block.js +0 -67
  30. package/dist/extensions/Blocks/Items/controls/button/link.js +0 -68
  31. package/dist/extensions/Blocks/Items/controls/cardComposition.js +0 -193
  32. package/dist/extensions/Blocks/Items/controls/image/link.js +0 -68
  33. package/dist/extensions/Blocks/Items/controls/index.js +0 -217
  34. package/dist/extensions/Blocks/Items/controls/name/trimming.js +0 -70
  35. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +0 -107
  36. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +0 -123
  37. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +0 -76
  38. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +0 -61
  39. package/dist/extensions/Blocks/Items/controls/settingsControl.js +0 -280
  40. package/dist/extensions/Blocks/Items/enums/controlEnums.js +0 -5
  41. package/dist/extensions/Blocks/Items/enums/productEnums.js +0 -201
  42. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -76
  43. package/dist/extensions/Blocks/Items/extension.js +0 -19
  44. package/dist/extensions/Blocks/Items/iconsRegistry.js +0 -32
  45. package/dist/extensions/Blocks/Items/items.css.js +0 -23
  46. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +0 -61
  47. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +0 -61
  48. package/dist/extensions/Blocks/Items/settingsPanel.js +0 -106
  49. package/dist/extensions/Blocks/Items/store/items-block.js +0 -71
  50. package/dist/extensions/Blocks/Items/template.js +0 -110
  51. package/dist/extensions/Blocks/Items/utils/configBlockUtils.js +0 -17
  52. package/dist/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.js +0 -28
  53. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +0 -67
  54. package/dist/extensions/Blocks/Items/utils/updateAttributes.js +0 -44
  55. package/dist/extensions/Blocks/controlFactories.js +0 -223
  56. package/dist/src/components/organisms/onboarding/ItemsOnboarding.vue.d.ts +0 -2
  57. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -13
  58. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -14
  59. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -33
  60. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -14
  61. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +0 -501
  62. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -14
  63. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -19
  64. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -21
  65. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -14
  66. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -13
  67. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -42
  68. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +0 -61
  69. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -160
  70. package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +0 -49
  71. package/dist/src/extensions/Blocks/Items/extension.d.ts +0 -2
  72. package/dist/src/extensions/Blocks/Items/iconsRegistry.d.ts +0 -4
  73. package/dist/src/extensions/Blocks/Items/settingsPanel.d.ts +0 -4
  74. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -41
  75. package/dist/src/extensions/Blocks/Items/template.d.ts +0 -16
  76. package/dist/src/extensions/Blocks/Items/utils/configBlockUtils.d.ts +0 -23
  77. package/dist/src/extensions/Blocks/Items/utils/syncAttributeFromConfigBlock.d.ts +0 -32
  78. package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +0 -44
  79. package/dist/src/extensions/Blocks/Items/utils/updateAttributes.d.ts +0 -8
  80. package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -312
@@ -1,21 +1,20 @@
1
- import { useOnboardingApi as r } from "../services/onboardingApi.js";
2
- import { defineStore as e } from "pinia";
3
- const t = () => ({
1
+ import { useOnboardingApi as t } from "../services/onboardingApi.js";
2
+ import { defineStore as s } from "pinia";
3
+ const e = () => ({
4
4
  cardIndex: 0,
5
5
  isActive: !1,
6
6
  config: []
7
7
  }), a = () => ({
8
8
  onboardings: {
9
- newVersionPopup: t(),
10
- genericOnboarding: t(),
11
- textBlockOnboarding: t(),
12
- versionHistoryOnboarding: t(),
13
- ampOnboarding: t(),
14
- itemsOnboarding: t()
9
+ newVersionPopup: e(),
10
+ genericOnboarding: e(),
11
+ textBlockOnboarding: e(),
12
+ versionHistoryOnboarding: e(),
13
+ ampOnboarding: e()
15
14
  },
16
15
  userModalState: {},
17
16
  isFetched: !1
18
- }), c = e("guidoOnboarding", {
17
+ }), c = s("guidoOnboarding", {
19
18
  state: () => a(),
20
19
  getters: {
21
20
  getOnboarding: (n) => (i) => n.onboardings[i],
@@ -40,10 +39,6 @@ const t = () => ({
40
39
  const { ampOnboarding: i } = n.onboardings;
41
40
  return i.config[i.cardIndex];
42
41
  },
43
- getItemsCurrentCard: (n) => {
44
- const { itemsOnboarding: i } = n.onboardings;
45
- return i.config[i.cardIndex];
46
- },
47
42
  shouldShowOnboarding: (n) => (i) => {
48
43
  const o = n.userModalState.Guido;
49
44
  return i === "newVersionPopup" && (o != null && o.genericOnboarding) ? !1 : o ? !o[i] : !0;
@@ -59,9 +54,6 @@ const t = () => ({
59
54
  start(n) {
60
55
  this.closeOtherOnboardings(n), this.onboardings[n].cardIndex = 0, this.onboardings[n].isActive = !0;
61
56
  },
62
- startOnboarding(n) {
63
- this.shouldShowOnboarding(n) && !this.isActive(n) && this.start(n);
64
- },
65
57
  async close(n) {
66
58
  await this.setUserModalState(n, "true", "Guido"), this.onboardings[n].isActive = !1, this.onboardings[n].cardIndex = 0, this.onboardings[n].config = [];
67
59
  },
@@ -89,12 +81,12 @@ const t = () => ({
89
81
  async fetchUserModalState() {
90
82
  if (this.isFetched)
91
83
  return;
92
- const { fetchUserModalState: n } = r(), i = await n();
84
+ const { fetchUserModalState: n } = t(), i = await n();
93
85
  this.userModalState = i, this.isFetched = !0;
94
86
  },
95
87
  async setUserModalState(n, i, o) {
96
- const { setUserModalState: s } = r();
97
- await s(n, i, o), this.isFetched = !1, await this.fetchUserModalState();
88
+ const { setUserModalState: r } = t();
89
+ await r(n, i, o), this.isFetched = !1, await this.fetchUserModalState();
98
90
  }
99
91
  }
100
92
  });
@@ -0,0 +1,4 @@
1
+ const n = () => window.location.hostname.split(".")[2];
2
+ export {
3
+ n as getEnvironmentPrefix
4
+ };
@@ -1,25 +1,26 @@
1
- const f = (t) => {
2
- const n = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((l) => l.trim()), [r] = n, e = {
3
- text: t.label,
1
+ const s = (e) => {
2
+ const n = e.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [r] = n, l = {
3
+ text: e.label,
4
4
  value: r || ""
5
5
  };
6
6
  if (n.length >= 2) {
7
- const [, l, o] = n, c = l.includes("=") ? { key: l.split("=")[0].trim(), value: l.split("=")[1].trim() } : null;
8
- c ? e.format = c : o || (e.fallback = l), o && (e.fallback = o);
7
+ const [, a, c] = n, o = a.includes("=") ? { key: a.split("=")[0].trim(), value: a.split("=")[1].trim() } : null;
8
+ o ? l.format = o : c || (l.fallback = a), c && (l.fallback = c);
9
9
  }
10
- return e;
11
- }, s = (t) => t.map((a) => a.format ? {
12
- label: `${a.text} | ${a.format.key}=${a.format.value}`,
13
- value: `{{${a.value}|${a.format.key}=${a.format.value}}}`
10
+ return l;
11
+ }, f = (e) => e.map((t) => t.format ? {
12
+ label: `${t.text} | ${t.format.key}=${t.format.value}`,
13
+ value: `{{${t.value}|${t.format.key}=${t.format.value}}}`
14
14
  } : {
15
- label: a.fallback ? `${a.text} | ${a.fallback}` : a.text,
16
- value: a.fallback ? `{{${a.value}|${a.fallback}}}` : `{{${a.value}}}`
15
+ label: t.fallback ? `${t.text} | ${t.fallback}` : t.text,
16
+ value: t.fallback ? `{{${t.value}|${t.fallback}}}` : `{{${t.value}}}`
17
17
  }), u = () => {
18
- var t;
19
- return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
20
- };
18
+ var e;
19
+ return ((e = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : e.getAttribute("content")) ?? "";
20
+ }, $ = (e = "", t = {}, n = !1) => Object.entries(t).reduce((r, [l, a]) => n && (a === "" || a === null || a === void 0) ? r.replace(`&${l}={${l}}`, "") : r.replace(`{${l}}`, String(a)), e);
21
21
  export {
22
- s as dynamicContentToMergeTags,
22
+ f as dynamicContentToMergeTags,
23
23
  u as getCsrfToken,
24
- f as mergeTagToDynamicContent
24
+ s as mergeTagToDynamicContent,
25
+ $ as replaceString
25
26
  };
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.2dd7b80",
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,18 +27,11 @@
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": {
41
- "@stripoinc/ui-editor-extensions": "3.3.0",
34
+ "@stripoinc/ui-editor-extensions": "3.1.0",
42
35
  "@useinsider/design-system-vue": "0.14.20",
43
36
  "@vueuse/core": "11.3.0",
44
37
  "lodash-es": "4.17.21",
@@ -51,7 +44,7 @@
51
44
  "@cspell/eslint-plugin": "8.17.5",
52
45
  "@eslint/eslintrc": "3.3.0",
53
46
  "@eslint/js": "8.57.1",
54
- "@playwright/test": "1.55.0",
47
+ "@playwright/test": "1.57.0",
55
48
  "@stylistic/eslint-plugin": "3.1.0",
56
49
  "@stylistic/eslint-plugin-migrate": "3.1.0",
57
50
  "@types/eslint": "8.56.12",
@@ -90,7 +83,7 @@
90
83
  },
91
84
  "guido": {
92
85
  "stripo": {
93
- "version": "2.47.0"
86
+ "version": "2.46.0"
94
87
  }
95
88
  }
96
89
  }
@@ -1,21 +0,0 @@
1
- import g from "./ItemsOnboarding.vue2.js";
2
- /* empty css */
3
- import m from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var l = function() {
5
- var e, n, r, i, s, a;
6
- var o = this, d = o._self._c, t = o._self._setupProxy;
7
- return t.isVisible ? d(t.InOnboard, { key: "guido__items-onboard", staticClass: "w-21-s p-a z-11", class: (e = t.onboardingStore.getItemsCurrentCard) == null ? void 0 : e.classes, attrs: { id: "guido__items-onboard", "is-multiple-page": "", visible: "", "image-source": "", title: "", "bottom-position": (n = t.onboardingStore.getItemsCurrentCard) == null ? void 0 : n.bottom, "left-position": (r = t.onboardingStore.getItemsCurrentCard) == null ? void 0 : r.left, "pages-config": t.onboardingStore.onboardings.itemsOnboarding.config, "pointer-position": (i = t.onboardingStore.getItemsCurrentCard) == null ? void 0 : i.position, "right-position": (s = t.onboardingStore.getItemsCurrentCard) == null ? void 0 : s.right, "top-position": (a = t.onboardingStore.getItemsCurrentCard) == null ? void 0 : a.top }, on: { backButtonClick: t.handleBack, close: function(b) {
8
- return t.onboardingStore.close("itemsOnboarding");
9
- }, nextButtonClick: t.handleNext } }) : o._e();
10
- }, c = [], p = /* @__PURE__ */ m(
11
- g,
12
- l,
13
- c,
14
- !1,
15
- null,
16
- "dd1a237a"
17
- );
18
- const I = p.exports;
19
- export {
20
- I as default
21
- };
@@ -1,99 +0,0 @@
1
- import { defineComponent as l, computed as a, watch as u } from "vue";
2
- import { useTranslations as x } from "../../../composables/useTranslations.js";
3
- import { RIBBON_SELECTOR as T, UI_EDITOR_SELECTOR as O, CARD_COMPOSITION_TAB_SELECTOR as B, SETTINGS_TAB_SELECTOR as f } from "../../../enums/onboarding.js";
4
- import { useOnboardingStore as C } from "../../../stores/onboarding.js";
5
- import { InOnboard as k } from "@useinsider/design-system-vue";
6
- const E = /* @__PURE__ */ l({
7
- __name: "ItemsOnboarding",
8
- setup(_) {
9
- const e = x(), o = C(), c = a(() => {
10
- const t = document.querySelector(T);
11
- return (t == null ? void 0 : t.offsetHeight) ?? 0;
12
- }), n = (t) => `${t + c.value}px`, r = (t) => {
13
- const i = document.querySelector(O);
14
- if (!(i != null && i.shadowRoot))
15
- return;
16
- const { shadowRoot: s } = i, m = s.querySelector(t);
17
- m && m.click();
18
- }, d = a(() => [
19
- {
20
- classes: "guido-items-onboarding-card-1",
21
- right: "426px",
22
- top: n(90),
23
- position: "Right Top",
24
- title: e("email-editor.onboarding-items-title"),
25
- description: e("email-editor.onboarding-items-description"),
26
- imageSource: "",
27
- backButtonClick: () => {
28
- },
29
- nextButtonType: "text",
30
- nextButtonText: e("products.next"),
31
- nextButtonClick: () => {
32
- o.next("itemsOnboarding");
33
- }
34
- },
35
- {
36
- classes: "guido-items-onboarding-card-2",
37
- right: "426px",
38
- top: n(218),
39
- position: "Right Top",
40
- title: e("email-editor.onboarding-items-item-type-title"),
41
- description: e("email-editor.onboarding-items-item-type-description"),
42
- imageSource: "",
43
- backButtonType: "text",
44
- backButtonText: e("ds-steps.back"),
45
- backButtonClick: () => {
46
- o.previous("itemsOnboarding");
47
- },
48
- nextButtonType: "text",
49
- nextButtonText: e("products.next"),
50
- nextButtonClick: () => {
51
- o.next("itemsOnboarding");
52
- }
53
- },
54
- {
55
- classes: "guido-items-onboarding-card-3",
56
- right: "426px",
57
- top: n(140),
58
- position: "Right Top",
59
- title: e("email-editor.onboarding-items-composition-title"),
60
- description: e("email-editor.onboarding-items-composition-description"),
61
- imageSource: "",
62
- backButtonType: "text",
63
- backButtonText: e("ds-steps.back"),
64
- backButtonClick: () => {
65
- o.previous("itemsOnboarding");
66
- },
67
- nextButtonType: "text",
68
- nextButtonText: e("action-builder.ok"),
69
- nextButtonClick: () => {
70
- o.close("itemsOnboarding");
71
- }
72
- }
73
- ]), g = a(() => o.onboardings.itemsOnboarding.config.length > 0 && o.onboardings.itemsOnboarding.isActive), p = () => {
74
- var t, i;
75
- (i = (t = o.getItemsCurrentCard) == null ? void 0 : t.nextButtonClick) == null || i.call(t);
76
- }, b = () => {
77
- var t, i;
78
- (i = (t = o.getItemsCurrentCard) == null ? void 0 : t.backButtonClick) == null || i.call(t);
79
- };
80
- return u(
81
- () => o.isActive("itemsOnboarding"),
82
- (t) => {
83
- t && o.setConfig("itemsOnboarding", d.value);
84
- },
85
- { immediate: !0 }
86
- ), u(
87
- () => o.onboardings.itemsOnboarding.cardIndex,
88
- (t, i) => {
89
- if (!o.isActive("itemsOnboarding"))
90
- return;
91
- const s = `${i}-${t}`;
92
- s === "1-2" && r(B), s === "2-1" && r(f);
93
- }
94
- ), { __sfc: !0, trans: e, onboardingStore: o, ribbonOffset: c, getTopPosition: n, switchTab: r, onboardingCardsConfig: d, isVisible: g, handleNext: p, handleBack: b, InOnboard: k };
95
- }
96
- });
97
- export {
98
- E as default
99
- };
@@ -1,67 +0,0 @@
1
- import { useOnboardingStore as L } from "../../../stores/onboarding.js";
2
- import { Block as S, BlockCompositionType as y, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- import { configAttributes as t } from "./enums/productEnums.js";
4
- import { DefaultConfigValues as e, SETTINGS_ENUMS as l } from "./enums/settingsEnums.js";
5
- import { useItemsBlockStore as I } from "./store/items-block.js";
6
- import { getDefaultTemplate as V } from "./template.js";
7
- const B = "items-block";
8
- class z extends S {
9
- getId() {
10
- return B;
11
- }
12
- getIcon() {
13
- return "items-icon";
14
- }
15
- getBlockCompositionType() {
16
- return y.CONTAINER;
17
- }
18
- getName() {
19
- return this.api.translate("Items");
20
- }
21
- getDescription() {
22
- return this.api.translate("Items lets you display personalized products based on user behavior.");
23
- }
24
- getTemplate() {
25
- const i = I();
26
- return V({
27
- orientation: l.ORIENTATION.HORIZONTAL,
28
- itemsType: l.ITEMS_TYPE.CART_ITEMS,
29
- itemId: "{{Abandoned Cart Item (1) Url}}",
30
- currencySymbol: i.currencySymbol,
31
- currencyLocation: i.currencyLocation,
32
- formattedPrice: i.formattedPrice
33
- });
34
- }
35
- allowInnerBlocksDND() {
36
- return !1;
37
- }
38
- onCreated(i) {
39
- const n = i.querySelector("esd-config-block");
40
- if (!n)
41
- return;
42
- const o = n, s = o.getAttribute("data-initialized") || "0", a = o.getAttribute(t.BLOCK_INSTANCE_ID), c = () => String(Date.now() + Math.floor(Math.random() * 1e3));
43
- if (Number(s)) {
44
- if (!a) {
45
- const r = c();
46
- this.api.getDocumentModifier().modifyHtml(o).setAttribute(t.BLOCK_INSTANCE_ID, r).apply(new u("Assign block instance ID to legacy block"));
47
- }
48
- } else {
49
- const r = e.itemsType, d = e.cartItemsSelectControlValue, m = e.cardOrientationControlValue, T = e.productNameTrimmingControlValue, C = e.productPriceHideDiscountControlValue, b = e.productPriceFormattedControlValue, E = e.productPriceCurrencySymbolControlValue, O = e.productPriceCurrencyLocationControlValue, A = e.productButtonLinkControlValue, _ = e.productImageLinkControlValue, N = e.productImageVisible, p = e.productNameVisible, f = e.productQuantityVisible, g = e.productPriceVisible, D = e.productOriginalPriceVisible, R = e.productButtonVisible, P = c();
50
- this.api.getDocumentModifier().modifyHtml(o).setAttribute("data-source", r).setAttribute(t.TYPE, r).setAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE, d).setAttribute(t.ORIENTATION, m).setAttribute(t.PRODUCT_NAME_TRIMMING, T).setAttribute(t.PRODUCT_PRICE_HIDE_DISCOUNT, C).setAttribute(t.PRODUCT_PRICE_FORMATTED, b).setAttribute(t.PRODUCT_PRICE_CURRENCY_SYMBOL, E).setAttribute(t.PRODUCT_PRICE_CURRENCY_LOCATION, O).setAttribute(t.PRODUCT_BUTTON_LINK, A).setAttribute(t.PRODUCT_IMAGE_LINK, _).setAttribute(t.BLOCK_INSTANCE_ID, P).setAttribute("data-initialized", "1").setAttribute(t.NAME_CONTROL_ENABLED, e.productNameControlEnabled).setAttribute(
51
- t.QUANTITY_CONTROL_ENABLED,
52
- e.productQuantityControlEnabled
53
- ).setAttribute(t.PRICE_CONTROL_OPENED, e.productPriceControlOpened).setAttribute(t.PRODUCT_IMAGE_VISIBLE, N).setAttribute(t.PRODUCT_NAME_VISIBLE, p).setAttribute(t.PRODUCT_QUANTITY_VISIBLE, f).setAttribute(t.PRODUCT_PRICE_VISIBLE, g).setAttribute(t.PRODUCT_ORIGINAL_PRICE_VISIBLE, D).setAttribute(t.PRODUCT_BUTTON_VISIBLE, R).apply(new u("Initialize config block attributes with defaults")), L().startOnboarding("itemsOnboarding");
54
- }
55
- }
56
- onSelect(i) {
57
- const n = i.querySelector("esd-config-block"), o = I();
58
- if (!n)
59
- return;
60
- const s = n, a = s.getAttribute(t.TYPE) || e.itemsType, c = s.getAttribute(t.ITEMS_INDEX_SELECT_CONTROL_VALUE) || e.cartItemsSelectControlValue, r = s.getAttribute(t.ORIENTATION) || e.cardOrientationControlValue;
61
- o.setItemsType(a), o.setItemIds(c), o.setOrientation(r);
62
- }
63
- }
64
- export {
65
- B as BLOCK_ID,
66
- z as ItemsBlock
67
- };
@@ -1,68 +0,0 @@
1
- var r = Object.defineProperty;
2
- var a = (o, e, t) => e in o ? r(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var s = (o, e, t) => a(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommonControl as u } from "../../../common-control.js";
5
- import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
6
- import { useItemsBlockStore as l } from "../../store/items-block.js";
7
- import { syncButtonLinkFromAttributes as h } from "../../utils/syncAttributesFromConfigBlock.js";
8
- import { updateConfigBlockAttributes as m } from "../../utils/updateAttributes.js";
9
- const i = d.BUTTON_LINK, n = {
10
- LINK: "link"
11
- };
12
- class C extends u {
13
- constructor() {
14
- super(...arguments);
15
- s(this, "store", l());
16
- }
17
- getId() {
18
- return i;
19
- }
20
- getTemplate() {
21
- return `
22
- <div class="${i}">
23
- ${this._getLink()}
24
- </div>
25
- `;
26
- }
27
- onRender() {
28
- this.api.updateValues({
29
- [n.LINK]: this.store.buttonLink
30
- }), this._listenToFormUpdates();
31
- }
32
- onTemplateNodeUpdated(t) {
33
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
34
- () => h(this.currentNode),
35
- () => {
36
- this.api.updateValues({
37
- [n.LINK]: this.store.buttonLink
38
- });
39
- }
40
- );
41
- }
42
- _listenToFormUpdates() {
43
- this.api.onValueChanged(
44
- n.LINK,
45
- (t) => this._onLinkChange(t)
46
- );
47
- }
48
- _onLinkChange(t) {
49
- console.debug("Button link changed to: ", t), this.store.setButtonLink(t), m(this.currentNode, this.api);
50
- }
51
- _getLink() {
52
- return `
53
- ${this._GuOneColumn([
54
- this._GuLabel({ text: "Link" }),
55
- this._GuTextInput({
56
- name: n.LINK,
57
- placeholder: "Enter Link",
58
- className: "es-100",
59
- disabled: !0
60
- })
61
- ])}
62
- `;
63
- }
64
- }
65
- export {
66
- C as ButtonLinkControl,
67
- i as CONTROL_BLOCK_ID
68
- };
@@ -1,193 +0,0 @@
1
- var c = Object.defineProperty;
2
- var I = (a, n, t) => n in a ? c(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
- var _ = (a, n, t) => I(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { ModificationDescription as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as R } from "../../common-control.js";
6
- import { ItemsBlockId as s } from "../enums/controlEnums.js";
7
- import { configAttributes as C } from "../enums/productEnums.js";
8
- import { SETTINGS_ENUMS as u } from "../enums/settingsEnums.js";
9
- import { useItemsBlockStore as O } from "../store/items-block.js";
10
- import { getConfigBlock as P, attributeToBoolean as U } from "../utils/configBlockUtils.js";
11
- const h = "ui-elements-items-card-composition-block", i = {
12
- PRODUCT_IMAGE: "image",
13
- PRODUCT_NAME: "name",
14
- PRODUCT_QUANTITY: "quantity",
15
- PRODUCT_PRICE: "price",
16
- PRODUCT_ORIGINAL_PRICE: "originalPrice",
17
- PRODUCT_BUTTON: "button"
18
- };
19
- class g extends R {
20
- constructor() {
21
- super(...arguments);
22
- _(this, "store", O());
23
- _(this, "visibilityState", {
24
- [i.PRODUCT_IMAGE]: !0,
25
- [i.PRODUCT_NAME]: !0,
26
- [i.PRODUCT_QUANTITY]: !0,
27
- [i.PRODUCT_PRICE]: !0,
28
- [i.PRODUCT_ORIGINAL_PRICE]: !0,
29
- [i.PRODUCT_BUTTON]: !0
30
- });
31
- }
32
- getId() {
33
- return h;
34
- }
35
- getTemplate() {
36
- return `
37
- <div class="items-controls-container">
38
- ${[
39
- { name: i.PRODUCT_IMAGE, label: "Product Image" },
40
- { name: i.PRODUCT_NAME, label: "Product Name" },
41
- { name: i.PRODUCT_QUANTITY, label: "Product Quantity" },
42
- { name: i.PRODUCT_PRICE, label: "Product Price" },
43
- { name: i.PRODUCT_ORIGINAL_PRICE, label: "Product Original Price" },
44
- { name: i.PRODUCT_BUTTON, label: "Product Button" }
45
- ].map((e) => this._getToggleContainer(e)).join("")}
46
- </div>
47
- `;
48
- }
49
- onRender() {
50
- this._syncVisibilityFromAttributes(), this._handleBrowsedItemsQuantity(), this._initializeToggles(), this._listenToFormUpdates();
51
- }
52
- onTemplateNodeUpdated(t) {
53
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(
54
- () => {
55
- this._syncVisibilityFromAttributes(), this._handleBrowsedItemsQuantity(), this._applyVisibilityStyles();
56
- },
57
- () => {
58
- this._updateTogglesFromState();
59
- }
60
- );
61
- }
62
- _getToggleContainer({ name: t, label: e }) {
63
- return `
64
- <div class="container" name="${t}Container">
65
- <div class="display-flex align-items-center justify-content-between">
66
- ${this._GuLabel({ text: e, name: `${t}Label` })}
67
- ${this._GuToggle(t)}
68
- </div>
69
- </div>
70
- `;
71
- }
72
- _initializeToggles() {
73
- this._updateTogglesFromState();
74
- }
75
- _updateTogglesFromState() {
76
- this.api.updateValues({
77
- [i.PRODUCT_IMAGE]: this.visibilityState[i.PRODUCT_IMAGE],
78
- [i.PRODUCT_NAME]: this.visibilityState[i.PRODUCT_NAME],
79
- [i.PRODUCT_QUANTITY]: this.visibilityState[i.PRODUCT_QUANTITY],
80
- [i.PRODUCT_PRICE]: this.visibilityState[i.PRODUCT_PRICE],
81
- [i.PRODUCT_ORIGINAL_PRICE]: this.visibilityState[i.PRODUCT_ORIGINAL_PRICE],
82
- [i.PRODUCT_BUTTON]: this.visibilityState[i.PRODUCT_BUTTON]
83
- });
84
- }
85
- _syncVisibilityFromAttributes() {
86
- const t = P(this.currentNode);
87
- if (!t)
88
- return;
89
- const e = {
90
- [i.PRODUCT_IMAGE]: "PRODUCT_IMAGE_VISIBLE",
91
- [i.PRODUCT_NAME]: "PRODUCT_NAME_VISIBLE",
92
- [i.PRODUCT_QUANTITY]: "PRODUCT_QUANTITY_VISIBLE",
93
- [i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
94
- [i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
95
- [i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
96
- };
97
- Object.entries(e).forEach(([o, r]) => {
98
- const T = t.getAttribute(C[r]);
99
- this.visibilityState[o] = U(T, !0);
100
- });
101
- }
102
- /**
103
- * If itemsType is not BROWSED_ITEMS, show quantity
104
- * If itemsType is BROWSED_ITEMS, hide quantity
105
- * and mark it as '0'
106
- */
107
- _handleBrowsedItemsQuantity() {
108
- var r;
109
- const t = this.store.itemsType !== u.ITEMS_TYPE.BROWSED_ITEMS, e = (r = this.currentNode) == null ? void 0 : r.querySelector("esd-config-block");
110
- if (!e)
111
- return;
112
- const o = e.getAttribute(C.PRODUCT_QUANTITY_VISIBLE) === "1";
113
- this.visibilityState[i.PRODUCT_QUANTITY] = t && o, this.api.setVisibility(`${i.PRODUCT_QUANTITY}Container`, t), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t && o);
114
- }
115
- _applyVisibilityStyles() {
116
- const t = {
117
- [i.PRODUCT_IMAGE]: s.IMAGE,
118
- [i.PRODUCT_NAME]: s.NAME,
119
- [i.PRODUCT_QUANTITY]: s.QUANTITY,
120
- [i.PRODUCT_PRICE]: s.PRICE,
121
- [i.PRODUCT_ORIGINAL_PRICE]: s.ORIGINAL_PRICE,
122
- [i.PRODUCT_BUTTON]: s.BUTTON
123
- };
124
- Object.entries(t).forEach(([e, o]) => {
125
- var d;
126
- const r = (d = this.currentNode) == null ? void 0 : d.querySelector(`[esd-extension-block-id="${o}"]`);
127
- if (!r)
128
- return;
129
- const T = this.visibilityState[e];
130
- this.api.getDocumentModifier().modifyHtml(r).setStyle("display", T ? "table-cell" : "none").apply(new l(`Applied ${e} visibility from attributes`));
131
- });
132
- }
133
- _updateVisibilityAttribute(t, e) {
134
- const o = P(this.currentNode);
135
- if (!o)
136
- return;
137
- const T = {
138
- [i.PRODUCT_IMAGE]: "PRODUCT_IMAGE_VISIBLE",
139
- [i.PRODUCT_NAME]: "PRODUCT_NAME_VISIBLE",
140
- [i.PRODUCT_QUANTITY]: "PRODUCT_QUANTITY_VISIBLE",
141
- [i.PRODUCT_PRICE]: "PRODUCT_PRICE_VISIBLE",
142
- [i.PRODUCT_ORIGINAL_PRICE]: "PRODUCT_ORIGINAL_PRICE_VISIBLE",
143
- [i.PRODUCT_BUTTON]: "PRODUCT_BUTTON_VISIBLE"
144
- }[t];
145
- T && this.api.getDocumentModifier().modifyHtml(o).setAttribute(C[T], e ? "1" : "0").apply(new l(`Updated ${t} visibility attribute`));
146
- }
147
- _listenToFormUpdates() {
148
- this.api.onValueChanged(i.PRODUCT_IMAGE, (t) => this._onProductImageChange(t)), this.api.onValueChanged(i.PRODUCT_NAME, (t) => this._onProductNameChange(t)), this.api.onValueChanged(i.PRODUCT_QUANTITY, (t) => this._onProductQuantityChange(t)), this.api.onValueChanged(i.PRODUCT_PRICE, (t) => this._onProductPriceChange(t)), this.api.onValueChanged(
149
- i.PRODUCT_ORIGINAL_PRICE,
150
- (t) => this._onProductOriginalPriceChange(t)
151
- ), this.api.onValueChanged(i.PRODUCT_BUTTON, (t) => this._onProductButtonChange(t));
152
- }
153
- _onProductImageChange(t) {
154
- var o;
155
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.IMAGE}"]`);
156
- e && (this.visibilityState[i.PRODUCT_IMAGE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product image visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_IMAGE, t));
157
- }
158
- _onProductNameChange(t) {
159
- var o;
160
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.NAME}"]`);
161
- e && (this.visibilityState[i.PRODUCT_NAME] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product name visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_NAME, t));
162
- }
163
- _onProductQuantityChange(t) {
164
- var o;
165
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.QUANTITY}"]`);
166
- e && (this.visibilityState[i.PRODUCT_QUANTITY] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
167
- `Product quantity visibility changed to ${t ? "visible" : "hidden"}`
168
- )), this._updateVisibilityAttribute(i.PRODUCT_QUANTITY, t));
169
- }
170
- _onProductPriceChange(t) {
171
- var o;
172
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.PRICE}"]`);
173
- e && (this.visibilityState[i.PRODUCT_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product price visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_PRICE, t));
174
- }
175
- _onProductOriginalPriceChange(t) {
176
- var o;
177
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(
178
- `[esd-extension-block-id="${s.ORIGINAL_PRICE}"]`
179
- );
180
- e && (this.visibilityState[i.PRODUCT_ORIGINAL_PRICE] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(
181
- `Product original price visibility changed to ${t ? "visible" : "hidden"}`
182
- )), this._updateVisibilityAttribute(i.PRODUCT_ORIGINAL_PRICE, t));
183
- }
184
- _onProductButtonChange(t) {
185
- var o;
186
- const e = (o = this.currentNode) == null ? void 0 : o.querySelector(`[esd-extension-block-id="${s.BUTTON}"]`);
187
- e && (this.visibilityState[i.PRODUCT_BUTTON] = t, this.api.getDocumentModifier().modifyHtml(e).setStyle("display", t ? "table-cell" : "none").apply(new l(`Product button visibility changed to ${t ? "visible" : "hidden"}`)), this._updateVisibilityAttribute(i.PRODUCT_BUTTON, t));
188
- }
189
- }
190
- export {
191
- h as COMPOSITION_CONTROL_BLOCK_ID,
192
- g as ItemsBlockCardCompositionControl
193
- };