@useinsider/guido 3.30.0-beta.6054a97 → 3.30.0-beta.60f9fc0

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.
@@ -1,57 +1,51 @@
1
- import { defineComponent as N, defineAsyncComponent as E, ref as p, computed as o, watch as R, nextTick as P } from "vue";
1
+ import { defineComponent as b, defineAsyncComponent as T, ref as w, computed as o, watch as N } from "vue";
2
2
  import "@useinsider/design-system-organisms/style";
3
- import { useToaster as U } from "../../../../composables/useToaster.js";
4
- import { useTranslations as G } from "../../../../composables/useTranslations.js";
5
- import { DOTTED_DATE_LOCALE as M } from "../../../../enums/date.js";
6
- import { URLS as $ } from "../../../../enums/extensions/recommendationBlock.js";
7
- import { ToasterTypeOptions as f } from "../../../../enums/toaster.js";
8
- import { useRecommendationExtensionStore as z } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
9
- import { commitStrategyChange as D } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
10
- import H from "./StrategyInfoBoxContent.vue.js";
11
- import { formatShortDate as F } from "../../../../utils/dateUtil.js";
12
- import { asText as O } from "../../../../utils/genericUtil.js";
13
- import { escapeHtml as K } from "../../../../utils/htmlEscape.js";
14
- import { InSkeleton as I } from "@useinsider/design-system-vue";
15
- const lt = /* @__PURE__ */ N({
3
+ import { useToaster as R } from "../../../../composables/useToaster.js";
4
+ import { useTranslations as P } from "../../../../composables/useTranslations.js";
5
+ import { DOTTED_DATE_LOCALE as U } from "../../../../enums/date.js";
6
+ import { URLS as G } from "../../../../enums/extensions/recommendationBlock.js";
7
+ import { ToasterTypeOptions as u } from "../../../../enums/toaster.js";
8
+ import { useRecommendationExtensionStore as M } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
9
+ import { commitStrategyChange as E } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
10
+ import $ from "./StrategyInfoBoxContent.vue.js";
11
+ import { formatShortDate as z } from "../../../../utils/dateUtil.js";
12
+ import { asText as D } from "../../../../utils/genericUtil.js";
13
+ import { escapeHtml as H } from "../../../../utils/htmlEscape.js";
14
+ import { InSkeleton as O } from "@useinsider/design-system-vue";
15
+ const it = /* @__PURE__ */ b({
16
16
  __name: "AssignStrategyDrawer",
17
- setup(V) {
18
- const g = () => import("@useinsider/design-system-organisms"), S = (t, r) => ({
19
- render: (s) => s(I, { props: { sizing: { width: t, height: r } } })
20
- }), h = E({
17
+ setup(F) {
18
+ const g = () => import("@useinsider/design-system-organisms"), p = (t, r) => ({
19
+ render: (s) => s(O, { props: { sizing: { width: t, height: r } } })
20
+ }), I = T({
21
21
  loader: async () => (await g()).OrgStrategyDetailModal,
22
- loadingComponent: S(480, 240),
22
+ loadingComponent: p(480, 240),
23
23
  delay: 0
24
- }), x = E({
24
+ }), h = T({
25
25
  loader: async () => (await g()).OrgStrategyDropdown
26
- }), i = "guido-edit-strategy-", A = { width: 480, height: 42 }, a = G(), e = z(), { showToaster: c } = U(), n = p(null), d = "legacy", l = p(!1), m = p(!1), C = o(() => e.strategiesLoading || e.legacyConversionLoading), L = o(() => a(
27
- "email-editor.assign-strategy-description",
28
- { url: $.RECOMMENDATION_STRATEGIES_PANEL_PATH }
29
- ));
30
- R(() => e.assignStrategyDrawerStatus, async (t) => {
31
- if (!t) {
32
- await P(), m.value = e.assignStrategyDrawerStatus;
26
+ }), i = "guido-edit-strategy-", x = { width: 480, height: 42 }, a = P(), e = M(), { showToaster: c } = R(), n = w(null), d = "legacy", l = w(!1), A = o(() => e.strategiesLoading || e.legacyConversionLoading), C = o(() => e.assignStrategyDrawerStatus ? a("email-editor.assign-strategy-description", { url: G.RECOMMENDATION_STRATEGIES_PANEL_PATH }) : "");
27
+ N(() => e.assignStrategyDrawerStatus, (t) => {
28
+ if (!t)
33
29
  return;
34
- }
35
- m.value = !0;
36
30
  const { strategyId: r } = e.recommendationConfigs;
37
31
  n.value = r || (e.isLegacyStrategyBlock ? d : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
38
32
  c({
39
- type: f.Error,
33
+ type: u.Error,
40
34
  message: a("discovery-strategy.error-description")
41
35
  });
42
36
  });
43
- }, { immediate: !0 });
44
- const v = (t) => {
45
- const r = O(t.updated_at || t.created_at);
37
+ });
38
+ const f = (t) => {
39
+ const r = D(t.updated_at || t.created_at);
46
40
  if (!r)
47
41
  return "";
48
- const s = F(r, M);
42
+ const s = z(r, U);
49
43
  return a("recommendation-strategy.last-updated-on", { value: s });
50
- }, T = o(() => ({
44
+ }, S = o(() => ({
51
45
  text: a("ds-steps.legacy-strategy"),
52
46
  value: d,
53
47
  hidden: !0
54
- })), u = o(() => e.strategies.map((t) => ({
48
+ })), m = o(() => e.strategies.map((t) => ({
55
49
  text: t.name,
56
50
  value: t.strategy_id,
57
51
  infoBoxProps: {
@@ -60,10 +54,10 @@ const lt = /* @__PURE__ */ N({
60
54
  variant: "information",
61
55
  size: "small",
62
56
  class: "assign-strategy-info-box",
63
- titleText: K(O(t.name)),
57
+ titleText: H(D(t.name)),
64
58
  descriptionStatus: !0,
65
- descriptionText: v(t),
66
- slot: H,
59
+ descriptionText: f(t),
60
+ slot: $,
67
61
  slotProps: { strategy: t },
68
62
  // The info box drops the option's value/text, so the id is the only channel
69
63
  // that can carry the strategy back to the click handler.
@@ -76,17 +70,17 @@ const lt = /* @__PURE__ */ N({
76
70
  icon: "line-open-website"
77
71
  }]
78
72
  }
79
- }))), k = o(() => e.isLegacyStrategyBlock ? [T.value, ...u.value] : u.value), B = (t) => {
80
- var w;
81
- const r = (w = t == null ? void 0 : t.id) != null && w.startsWith(i) ? t.id.slice(i.length) : "";
73
+ }))), L = o(() => e.isLegacyStrategyBlock ? [S.value, ...m.value] : m.value), B = (t) => {
74
+ var _;
75
+ const r = (_ = t == null ? void 0 : t.id) != null && _.startsWith(i) ? t.id.slice(i.length) : "";
82
76
  if (!r)
83
77
  return;
84
78
  const s = e.currentRecommendationId, y = e.recommendationConfigs.strategyId === r;
85
- e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), y && (e.removeStrategy(), s !== null && D(s, "Removed recommendation strategy")));
86
- }, _ = o(() => {
79
+ e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), y && (e.removeStrategy(), s !== null && E(s, "Removed recommendation strategy")));
80
+ }, v = o(() => {
87
81
  const t = e.strategies.find((r) => String(r.strategy_id) === String(n.value ?? ""));
88
82
  return t ? { ...t, fallback_config: null } : null;
89
- }), b = o(() => ({
83
+ }), k = o(() => ({
90
84
  primaryButton: {
91
85
  styling: "solid",
92
86
  type: "primary",
@@ -98,10 +92,10 @@ const lt = /* @__PURE__ */ N({
98
92
  labelText: a("products.cancel")
99
93
  }
100
94
  }));
101
- return { __sfc: !0, loadOrganisms: g, skeleton: S, OrgStrategyDetailModal: h, OrgStrategyDropdown: x, EDIT_BUTTON_ID_PREFIX: i, SELECT_SKELETON_SIZING: A, trans: a, store: e, showToaster: c, selectedStrategyId: n, LEGACY_OPTION_VALUE: d, showSelectionError: l, isRendered: m, strategiesLoading: C, drawerDescription: L, lastUpdatedText: v, legacyStrategyOption: T, remoteStrategyOptions: u, strategyOptions: k, onInfoBoxButtonClick: B, selectedStrategy: _, footerButtonGroupOptions: b, closeDrawer: () => {
95
+ return { __sfc: !0, loadOrganisms: g, skeleton: p, OrgStrategyDetailModal: I, OrgStrategyDropdown: h, EDIT_BUTTON_ID_PREFIX: i, SELECT_SKELETON_SIZING: x, trans: a, store: e, showToaster: c, selectedStrategyId: n, LEGACY_OPTION_VALUE: d, showSelectionError: l, strategiesLoading: A, drawerDescription: C, lastUpdatedText: f, legacyStrategyOption: S, remoteStrategyOptions: m, strategyOptions: L, onInfoBoxButtonClick: B, selectedStrategy: v, footerButtonGroupOptions: k, closeDrawer: () => {
102
96
  e.closeAssignStrategyDrawer();
103
97
  }, assignStrategy: async () => {
104
- const t = _.value;
98
+ const t = v.value;
105
99
  if (!t) {
106
100
  l.value = !0;
107
101
  return;
@@ -114,21 +108,21 @@ const lt = /* @__PURE__ */ N({
114
108
  }
115
109
  if (!r) {
116
110
  c({
117
- type: f.Error,
111
+ type: u.Error,
118
112
  message: a("email-editor.strategy-assign-failed", { strategyName: t.name })
119
113
  });
120
114
  return;
121
115
  }
122
116
  const s = e.currentRecommendationId;
123
117
  e.assignStrategy(t), c({
124
- type: f.Success,
118
+ type: u.Success,
125
119
  message: a("email-editor.strategy-assigned-success", { strategyName: t.name })
126
- }), e.closeAssignStrategyDrawer(), s !== null && await D(s, "Assigned recommendation strategy");
120
+ }), e.closeAssignStrategyDrawer(), s !== null && await E(s, "Assigned recommendation strategy");
127
121
  }, onSelect: (t) => {
128
122
  n.value = t.value, l.value = !1;
129
- }, InSkeleton: I };
123
+ }, InSkeleton: O };
130
124
  }
131
125
  });
132
126
  export {
133
- lt as default
127
+ it as default
134
128
  };
@@ -0,0 +1,105 @@
1
+ import { useDynamicContentStore as f } from "../stores/dynamic-content.js";
2
+ import { useEditorStore as T } from "../stores/editor.js";
3
+ import { getEditorCanvasFrame as g, getCanvasElementPosition as S } from "../utils/editorCanvas.js";
4
+ import { watch as A } from "vue";
5
+ const C = "merge-tag-selector", E = "merge-tag-value", u = "guido-invalid-dynamic-content-style", v = ["", " "], h = (t) => v.flatMap((n) => v.map((e) => ({
6
+ exact: `{{${n}${t}${e}}}`,
7
+ prefix: `{{${n}${t}${e}|`
8
+ }))), D = (t, n) => h(n).some(({ exact: e, prefix: o }) => t === e || t.startsWith(o)), p = (t) => t.replace(/["\\|]/g, "\\$&").replace(/[\n\r\f]/g, (n) => `\\${n.charCodeAt(0).toString(16)} `), _ = (t) => {
9
+ const n = t.flatMap((e) => h(e).flatMap(({ exact: o, prefix: r }) => [`="${p(o)}"`, `^="${p(r)}"`]).map((o) => `${C}[${E}${o}]`).flatMap((o) => [`${o} .esd-merge-tag`, `${o} .esd-x`]));
10
+ return n.length === 0 ? "" : `${n.join(`,
11
+ `)} {
12
+ color: var(--guido-dc-invalid-color) !important;
13
+ border-color: var(--guido-dc-invalid-color) !important;
14
+ }`;
15
+ }, y = (t, n) => {
16
+ const e = t.getAttribute(E) ?? "";
17
+ return n.find((o) => D(e, o.value));
18
+ }, w = (t) => typeof (t == null ? void 0 : t.nodeType) == "number", x = (t) => {
19
+ const n = t;
20
+ return typeof (n == null ? void 0 : n.closest) == "function" ? n.closest(C) : null;
21
+ }, $ = () => {
22
+ var t, n;
23
+ return ((n = (t = g()) == null ? void 0 : t.contentWindow) == null ? void 0 : n.document) ?? null;
24
+ }, L = (t, n) => {
25
+ var a;
26
+ const e = _(n), o = t.getElementById(u);
27
+ if (!e) {
28
+ o == null || o.remove();
29
+ return;
30
+ }
31
+ if (o) {
32
+ o.textContent !== e && (o.textContent = e);
33
+ return;
34
+ }
35
+ const r = t.createElement("style");
36
+ r.id = u, r.textContent = e, (a = t.head ?? t.body) == null || a.appendChild(r);
37
+ }, P = () => {
38
+ const t = $();
39
+ if (t)
40
+ try {
41
+ const n = f().invalidDynamicContentList.map((e) => e.value);
42
+ L(t, n);
43
+ } catch (n) {
44
+ console.error("Failed to apply the invalid dynamic content marking", n);
45
+ }
46
+ }, k = () => {
47
+ const t = f(), n = T();
48
+ let e = null, o = null;
49
+ const r = () => {
50
+ o && (o = null, document.dispatchEvent(new CustomEvent("dynamic-content:invalid-leave")));
51
+ }, a = (i) => {
52
+ const s = x(i.target);
53
+ if (!s || s === o)
54
+ return;
55
+ const l = y(s, t.invalidDynamicContentList), m = g();
56
+ if (!l || !m)
57
+ return;
58
+ o = s;
59
+ const M = {
60
+ entry: { ...l },
61
+ position: S(m, s)
62
+ };
63
+ document.dispatchEvent(new CustomEvent("dynamic-content:invalid-hover", { detail: M }));
64
+ }, d = (i) => {
65
+ !o || w(i.relatedTarget) && o.contains(i.relatedTarget) || r();
66
+ }, c = () => {
67
+ e == null || e.removeEventListener("mouseover", a), e == null || e.removeEventListener("mouseout", d), e == null || e.removeEventListener("scroll", r, !0), e = null, r();
68
+ }, I = () => {
69
+ if (!n.isStripoInitialized) {
70
+ c();
71
+ return;
72
+ }
73
+ const i = $(), s = t.invalidDynamicContentList.map((l) => l.value);
74
+ if (!i) {
75
+ c();
76
+ return;
77
+ }
78
+ if (L(i, s), s.length === 0) {
79
+ c();
80
+ return;
81
+ }
82
+ i !== e && (c(), i.addEventListener("mouseover", a), i.addEventListener("mouseout", d), i.addEventListener("scroll", r, !0), e = i), o && (!o.isConnected || !y(o, t.invalidDynamicContentList)) && r();
83
+ };
84
+ return A(
85
+ [
86
+ () => n.isStripoInitialized,
87
+ () => n.changeSeq,
88
+ () => n.isCodeEditorOpen,
89
+ () => n.isVersionHistoryOpen,
90
+ () => n.isPreviewModeOpen,
91
+ () => t.invalidDynamicContentList
92
+ ],
93
+ () => {
94
+ try {
95
+ I();
96
+ } catch (i) {
97
+ console.error("Failed to track invalid dynamic content", i);
98
+ }
99
+ }
100
+ ), { dispose: c };
101
+ };
102
+ export {
103
+ P as applyInvalidDynamicContentMarking,
104
+ k as useInvalidDynamicContentMarking
105
+ };