@useinsider/guido 3.28.1-beta.c5eeeb7 → 3.28.1-beta.d3309a6

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 (47) hide show
  1. package/README.md +10 -0
  2. package/dist/@types/config/schemas.js +142 -129
  3. package/dist/@types/display-condition.js +45 -21
  4. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +25 -19
  5. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +77 -55
  6. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +1 -1
  7. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +62 -43
  8. package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue.js +18 -0
  9. package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue2.js +25 -0
  10. package/dist/components/organisms/display-conditions/LogicBuilderField.vue.js +28 -0
  11. package/dist/components/organisms/display-conditions/LogicBuilderField.vue2.js +28 -0
  12. package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue.js +30 -0
  13. package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue2.js +32 -0
  14. package/dist/components/organisms/display-conditions/LogicBuilderRow.vue.js +28 -0
  15. package/dist/components/organisms/display-conditions/LogicBuilderRow.vue2.js +60 -0
  16. package/dist/composables/useDisplayConditions.js +83 -68
  17. package/dist/composables/useScrollToInvalid.js +15 -0
  18. package/dist/config/migrator/itemsBlockMigrator.js +187 -186
  19. package/dist/enums/html-validator.js +1 -1
  20. package/dist/extensions/DisplayConditions/constants.js +19 -10
  21. package/dist/extensions/DisplayConditions/control.js +120 -99
  22. package/dist/extensions/DisplayConditions/display-conditions.css.js +58 -6
  23. package/dist/extensions/DisplayConditions/extension.js +18 -14
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/valibot/dist/index.js +118 -102
  26. package/dist/package.json.js +6 -6
  27. package/dist/services/displayConditionApi.js +18 -19
  28. package/dist/src/@types/config/schemas.d.ts +65 -0
  29. package/dist/src/@types/display-condition.d.ts +67 -0
  30. package/dist/src/components/organisms/display-conditions/LogicBuilderConnector.vue.d.ts +19 -0
  31. package/dist/src/components/organisms/display-conditions/LogicBuilderField.vue.d.ts +22 -0
  32. package/dist/src/components/organisms/display-conditions/LogicBuilderGroup.vue.d.ts +24 -0
  33. package/dist/src/components/organisms/display-conditions/LogicBuilderRow.vue.d.ts +25 -0
  34. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  35. package/dist/src/composables/useConfig.d.ts +42 -2
  36. package/dist/src/composables/useDisplayConditions.d.ts +1 -1
  37. package/dist/src/composables/useScrollToInvalid.d.ts +6 -0
  38. package/dist/src/extensions/DisplayConditions/constants.d.ts +2 -0
  39. package/dist/src/extensions/DisplayConditions/control.d.ts +1 -0
  40. package/dist/src/stores/config.d.ts +441 -21
  41. package/dist/src/utils/displayConditionBuilder.d.ts +29 -0
  42. package/dist/src/utils/displayConditionRules.d.ts +12 -0
  43. package/dist/src/utils/displayConditionSummary.d.ts +11 -0
  44. package/dist/utils/displayConditionBuilder.js +50 -0
  45. package/dist/utils/displayConditionRules.js +91 -0
  46. package/dist/utils/displayConditionSummary.js +28 -0
  47. package/package.json +1 -1
@@ -1,34 +1,48 @@
1
- import { useToaster as M } from "./useToaster.js";
2
- import { useTranslations as x } from "./useTranslations.js";
3
- import { ACADEMY_LINKS as L } from "../enums/academy.js";
4
- import { DisplayConditionSourceType as y, DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as I } from "../enums/display-condition.js";
5
- import { ToasterTypeOptions as l } from "../enums/toaster.js";
6
- import { useDisplayConditionApi as O } from "../services/displayConditionApi.js";
1
+ import { useToaster as L } from "./useToaster.js";
2
+ import { useTranslations as M } from "./useTranslations.js";
3
+ import { ACADEMY_LINKS as O } from "../enums/academy.js";
4
+ import { DisplayConditionSourceType as E, DISPLAY_CONDITION_LIMITS as a, DisplayConditionEvent as C } from "../enums/display-condition.js";
5
+ import { ToasterTypeOptions as u } from "../enums/toaster.js";
6
+ import { useDisplayConditionApi as B } from "../services/displayConditionApi.js";
7
7
  import { useConfigStore as q } from "../stores/config.js";
8
- import { useDisplayConditionStore as P } from "../stores/display-condition.js";
9
- import { findInvalidCodeFields as Y, nextConditionId as w } from "../utils/displayCondition.js";
10
- import { escapeHtml as R } from "../utils/htmlEscape.js";
11
- import { computed as b } from "vue";
12
- const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
13
- id: w(),
14
- name: n.name.trim(),
15
- description: n.description.trim(),
16
- beforeScript: n.codeBefore,
17
- afterScript: n.codeAfter,
18
- extraData: JSON.stringify(r === void 0 ? { source: m } : { source: m, savedId: r })
19
- }), v = (n) => ({
20
- name: n.name,
21
- description: n.description,
22
- codeBefore: n.codeBefore,
23
- codeAfter: n.codeAfter
24
- }), ne = () => {
25
- const n = P(), m = q(), r = O(), o = x(), { showToaster: p } = M(), u = b(
26
- () => m.isFeatureEnabled("liquidSyntax") ? "liquid" : "pongo"
27
- ), f = (e) => {
8
+ import { useDisplayConditionStore as R } from "../stores/display-condition.js";
9
+ import { findInvalidCodeFields as P, nextConditionId as Y } from "../utils/displayCondition.js";
10
+ import { parseRuleTree as b, compileRuleTree as k } from "../utils/displayConditionRules.js";
11
+ import { escapeHtml as F } from "../utils/htmlEscape.js";
12
+ import { computed as X } from "vue";
13
+ const w = "email-editor.display-conditions", i = w, K = 409, I = (n) => {
14
+ const l = n.method === "logicBuilder";
15
+ return {
16
+ name: n.name,
17
+ description: n.description,
18
+ method: n.method,
19
+ codeBefore: l ? "" : n.codeBefore,
20
+ codeAfter: l ? "" : n.codeAfter,
21
+ rules: l ? b(n.codeBefore) : null
22
+ };
23
+ }, se = () => {
24
+ const n = R(), l = q(), y = B(), o = M(), { showToaster: p } = L(), d = X(
25
+ () => l.isFeatureEnabled("liquidSyntax") ? "liquid" : "pongo"
26
+ ), h = (e) => {
28
27
  const t = { condition: e };
29
- return document.dispatchEvent(new CustomEvent(I.APPLY, { detail: t })), n.close(), t.applied === !0;
30
- }, D = () => {
31
- n.view !== "none" && (document.dispatchEvent(new CustomEvent(I.CANCEL)), n.close());
28
+ return document.dispatchEvent(new CustomEvent(C.APPLY, { detail: t })), n.close(), t.applied === !0;
29
+ }, D = (e, t, r) => {
30
+ const c = Y(), f = r === void 0 ? { source: t } : { source: t, savedId: r }, s = { id: c, name: e.name.trim(), description: e.description.trim() };
31
+ return e.method !== "logicBuilder" ? {
32
+ ...s,
33
+ beforeScript: e.codeBefore,
34
+ afterScript: e.codeAfter,
35
+ extraData: JSON.stringify(f)
36
+ } : e.rules ? {
37
+ ...s,
38
+ ...k(e.rules, d.value, `dc${c}`),
39
+ extraData: JSON.stringify({ ...f, method: "logicBuilder", rules: e.rules })
40
+ } : null;
41
+ }, A = (e, t, r) => {
42
+ const c = D(e, t, r);
43
+ return c ? h(c) : !1;
44
+ }, g = () => {
45
+ n.view !== "none" && (document.dispatchEvent(new CustomEvent(C.CANCEL)), n.close());
32
46
  }, N = (e) => {
33
47
  if (e.mode === "select") {
34
48
  n.openSelect();
@@ -39,71 +53,72 @@ const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
39
53
  const e = ++n.listRequest;
40
54
  n.listStatus = "loading";
41
55
  try {
42
- const t = await r.list(u.value);
56
+ const t = await y.list(d.value);
43
57
  e === n.listRequest && (n.list = t, n.listStatus = "loaded");
44
58
  } catch (t) {
45
59
  console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
46
60
  }
47
- }, h = (e) => {
48
- const t = {}, d = e.name.trim();
49
- d ? d.length < s.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: s.NAME_MIN }) : d.length > s.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: s.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
50
- const { DESCRIPTION_MAX: C } = s;
51
- e.description.trim().length > C && (t.description = o(`${i}.error-description-max`, { max: C }));
52
- const g = Y(e.codeBefore, e.codeAfter, u.value);
53
- return ["codeBefore", "codeAfter"].forEach((a) => {
54
- e[a].trim() ? g.includes(a) ? t[a] = o(`${i}.error-code-invalid`) : e[a].length > s.CODE_MAX && (t[a] = o(`${i}.error-code-max`, { max: s.CODE_MAX })) : t[a] = o(`${i}.error-code-required`);
61
+ }, T = (e) => {
62
+ const t = {}, r = e.name.trim();
63
+ r ? r.length < a.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: a.NAME_MIN }) : r.length > a.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: a.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
64
+ const { DESCRIPTION_MAX: c } = a;
65
+ if (e.description.trim().length > c && (t.description = o(`${i}.error-description-max`, { max: c })), e.method === "logicBuilder")
66
+ return t;
67
+ const f = P(e.codeBefore, e.codeAfter, d.value);
68
+ return ["codeBefore", "codeAfter"].forEach((s) => {
69
+ e[s].trim() ? f.includes(s) ? t[s] = o(`${i}.error-code-invalid`) : e[s].length > a.CODE_MAX && (t[s] = o(`${i}.error-code-max`, { max: a.CODE_MAX })) : t[s] = o(`${i}.error-code-required`);
55
70
  }), t;
56
- }, A = (e, t) => {
57
- p(e ? { type: l.Success, message: t } : { type: l.Error, message: o("products.something-went-wrong") });
58
- }, T = (e) => o(
71
+ }, S = (e, t) => {
72
+ p(e ? { type: u.Success, message: t } : { type: u.Error, message: o("products.something-went-wrong") });
73
+ }, _ = (e) => o(
59
74
  `${i}.${e}`,
60
75
  {
61
- academyLink: `<a href="${L.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
76
+ academyLink: `<a href="${O.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
62
77
  }
63
- ), _ = () => {
64
- p({ type: l.Error, message: o(`${i}.validation-failed`) });
65
- }, c = (e) => ({ name: R(e) }), E = (e, t) => {
66
- e != null && e.authReported || (console.warn(t, e), p({ type: l.Error, message: t }));
78
+ ), x = () => {
79
+ p({ type: u.Error, message: o(`${i}.validation-failed`) });
80
+ }, m = (e) => ({ name: F(e) }), v = (e, t) => {
81
+ e != null && e.authReported || (console.warn(t, e), p({ type: u.Error, message: t }));
67
82
  };
68
83
  return {
69
- syntax: u,
84
+ syntax: d,
70
85
  handleOpen: N,
71
- cancel: D,
86
+ cancel: g,
72
87
  loadList: $,
73
- validate: h,
74
- notifyInvalid: _,
75
- describeWithAcademyLink: T,
88
+ validate: T,
89
+ notifyInvalid: x,
90
+ describeWithAcademyLink: _,
76
91
  createInline: (e) => {
77
- A(
78
- f(S(e, y.INLINE)),
79
- o(`${i}.created`, c(e.name.trim()))
92
+ S(
93
+ A(e, E.INLINE),
94
+ o(`${i}.created`, m(e.name.trim()))
80
95
  );
81
96
  },
82
97
  createAndSave: async (e) => {
83
98
  try {
84
- const t = await r.create(e, u.value);
85
- return n.list = [t, ...n.list.filter((d) => d.id !== t.id)], A(
86
- f(S(v(t), y.SAVED, t.id)),
87
- o(`${i}.created-and-saved`, c(t.name))
99
+ const t = await y.create(e, d.value);
100
+ return n.list = [t, ...n.list.filter((r) => r.id !== t.id)], S(
101
+ A(I(t), E.SAVED, t.id),
102
+ o(`${i}.created-and-saved`, m(t.name))
88
103
  ), {};
89
104
  } catch (t) {
90
- return (t == null ? void 0 : t.status) === F ? { name: o(`${i}.error-name-exists`) } : (E(t, o(`${i}.save-failed`, c(e.name.trim()))), null);
105
+ return (t == null ? void 0 : t.status) === K ? { name: o(`${i}.error-name-exists`) } : (v(t, o(`${i}.save-failed`, m(e.name.trim()))), null);
91
106
  }
92
107
  },
93
108
  select: (e) => {
94
- A(
95
- f(S(v(e), y.SAVED, e.id)),
96
- o(`${i}.applied`, c(e.name))
109
+ S(
110
+ A(I(e), E.SAVED, e.id),
111
+ o(`${i}.applied`, m(e.name))
97
112
  );
98
113
  },
99
114
  deleteSaved: async (e) => {
100
115
  try {
101
- await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
102
- type: l.Success,
103
- message: o(`${i}.deleted`, c(e.name))
116
+ await y.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
117
+ type: u.Success,
118
+ message: o(`${i}.deleted`, m(e.name))
104
119
  });
105
120
  } catch (t) {
106
- E(t, o(`${i}.delete-failed`));
121
+ v(t, o(`${i}.delete-failed`));
107
122
  } finally {
108
123
  n.pendingDelete = null;
109
124
  }
@@ -111,6 +126,6 @@ const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
111
126
  };
112
127
  };
113
128
  export {
114
- B as DISPLAY_CONDITIONS_TRANS_KEY,
115
- ne as useDisplayConditions
129
+ w as DISPLAY_CONDITIONS_TRANS_KEY,
130
+ se as useDisplayConditions
116
131
  };
@@ -0,0 +1,15 @@
1
+ import { nextTick as i } from "vue";
2
+ const r = "data-guido-invalid", a = (e) => e ? { [r]: "true" } : {}, n = () => {
3
+ var e;
4
+ return ((e = window.matchMedia) == null ? void 0 : e.call(window, "(prefers-reduced-motion: reduce)").matches) ?? !1;
5
+ }, l = (e) => ({ scrollToFirstInvalid: async () => {
6
+ var o;
7
+ await i();
8
+ const t = (o = e.value) == null ? void 0 : o.querySelector(`[${r}]`);
9
+ return t ? (t.scrollIntoView({ behavior: n() ? "auto" : "smooth", block: "center" }), !0) : !1;
10
+ } });
11
+ export {
12
+ r as INVALID_FIELD_ATTR,
13
+ a as invalidFieldAttrs,
14
+ l as useScrollToInvalid
15
+ };